mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-13 16:05:00 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
065b0efa85 | ||
|
|
83e5bfbc17 |
@@ -7,7 +7,8 @@
|
||||
setInputCat as computeInputCat,
|
||||
debounce,
|
||||
emptyString,
|
||||
getSchemaFromProperties
|
||||
getSchemaFromProperties,
|
||||
clone
|
||||
} from '$lib/utils'
|
||||
import { DollarSign, Pipette, Plus, X, Check, Loader2 } from 'lucide-svelte'
|
||||
import { createEventDispatcher, onDestroy, onMount, tick, untrack } from 'svelte'
|
||||
@@ -244,7 +245,7 @@
|
||||
nvalue = undefined
|
||||
}
|
||||
if ((value == undefined || value == null) && !ignoreValueUndefined) {
|
||||
nvalue = structuredClone($state.snapshot(defaultValue))
|
||||
nvalue = clone(defaultValue)
|
||||
if (defaultValue === undefined || defaultValue === null) {
|
||||
if (inputCat === 'string') {
|
||||
nvalue = nullable ? null : ''
|
||||
@@ -296,7 +297,7 @@
|
||||
lastValue = value
|
||||
}
|
||||
|
||||
let oldDefaultValue = structuredClone($state.snapshot(defaultValue))
|
||||
let oldDefaultValue = clone(defaultValue)
|
||||
function handleDefaultValueChange() {
|
||||
if (
|
||||
deepEqual(value, oldDefaultValue) &&
|
||||
@@ -305,7 +306,7 @@
|
||||
) {
|
||||
value = defaultValue
|
||||
}
|
||||
oldDefaultValue = structuredClone($state.snapshot(defaultValue))
|
||||
oldDefaultValue = clone(defaultValue)
|
||||
}
|
||||
|
||||
function isObjectCat(inputCat?: string) {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
orderedJsonStringify,
|
||||
orderedYamlStringify,
|
||||
replaceFalseWithUndefined,
|
||||
type Value
|
||||
type Value,
|
||||
clone
|
||||
} from '$lib/utils'
|
||||
import type { Script } from '$lib/gen'
|
||||
|
||||
@@ -68,7 +69,7 @@
|
||||
}
|
||||
|
||||
function prepareDiff(data: Value) {
|
||||
const metadata = structuredClone(cleanValueProperties(replaceFalseWithUndefined(data)))
|
||||
const metadata = clone(cleanValueProperties(replaceFalseWithUndefined(data)))
|
||||
const content = metadata['content']
|
||||
if (metadata['content'] !== undefined) {
|
||||
metadata['content'] = 'check content diff'
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
import Tooltip from './Tooltip.svelte'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
import { untrack } from 'svelte'
|
||||
import { readFieldsRecursively } from '$lib/utils'
|
||||
import { readFieldsRecursively, clone} from '$lib/utils'
|
||||
|
||||
interface Props {
|
||||
value?: any
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
let { value = $bindable(), helperScript, entrypoint, args: _args, name }: Props = $props()
|
||||
|
||||
let args = $state(structuredClone($state.snapshot(_args)))
|
||||
let args = $state(clone(_args))
|
||||
$effect(() => {
|
||||
readFieldsRecursively(_args, { excludeField: [name] })
|
||||
untrack(() => !deepEqual(args, _args) && (args = $state.snapshot(_args)))
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
import Label from './Label.svelte'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import Toggle from './Toggle.svelte'
|
||||
import { emptyString } from '$lib/utils'
|
||||
import { emptyString, clone} from '$lib/utils'
|
||||
import Popover from './meltComponents/Popover.svelte'
|
||||
import SchemaFormDnd from './schema/SchemaFormDND.svelte'
|
||||
import { deepEqual } from 'fast-equals'
|
||||
@@ -114,7 +114,7 @@
|
||||
Object.keys(schema?.properties ?? {}).forEach((key) => {
|
||||
if (schema?.properties[key].default != undefined && args?.[key] == undefined) {
|
||||
let value = schema?.properties[key].default
|
||||
nargs[key] = value === 'object' ? structuredClone($state.snapshot(value)) : value
|
||||
nargs[key] = value === 'object' ? clone(value) : value
|
||||
}
|
||||
})
|
||||
args = nargs
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
readFieldsRecursively,
|
||||
replaceFalseWithUndefined,
|
||||
type StateStore,
|
||||
type Value
|
||||
type Value,
|
||||
clone
|
||||
} from '$lib/utils'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { Drawer } from '$lib/components/common'
|
||||
@@ -185,7 +186,7 @@
|
||||
savedValue: savedFlow,
|
||||
modifiedValue: {
|
||||
...flowStore.val,
|
||||
draft_triggers: structuredClone(triggersState.getDraftTriggersSnapshot())
|
||||
draft_triggers: clone(triggersState.getDraftTriggersSnapshot())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,7 +251,7 @@
|
||||
|
||||
if (savedFlow) {
|
||||
const draftOrDeployed = cleanValueProperties(savedFlow.draft || savedFlow)
|
||||
const currentDraftTriggers = structuredClone(triggersState.getDraftTriggersSnapshot())
|
||||
const currentDraftTriggers = clone(triggersState.getDraftTriggersSnapshot())
|
||||
const current = cleanValueProperties(
|
||||
$state.snapshot({
|
||||
...flowStore.val,
|
||||
@@ -329,15 +330,15 @@
|
||||
savedFlow = {
|
||||
...(newFlow || savedFlow?.draft_only
|
||||
? {
|
||||
...structuredClone($state.snapshot(flowStore.val)),
|
||||
...clone(flowStore.val),
|
||||
path: $pathStore,
|
||||
draft_only: true
|
||||
}
|
||||
: savedFlow),
|
||||
draft: {
|
||||
...structuredClone($state.snapshot(flowStore.val)),
|
||||
...clone(flowStore.val),
|
||||
path: $pathStore,
|
||||
draft_triggers: structuredClone(triggersState.getDraftTriggersSnapshot())
|
||||
draft_triggers: clone(triggersState.getDraftTriggersSnapshot())
|
||||
}
|
||||
} as FlowWithDraftAndDraftTriggers
|
||||
|
||||
@@ -519,7 +520,7 @@
|
||||
draft_triggers: Trigger[]
|
||||
}
|
||||
savedFlow = {
|
||||
...structuredClone($state.snapshot(newSavedFlow)),
|
||||
...clone(newSavedFlow),
|
||||
path: $pathStore
|
||||
} as Flow
|
||||
setDraftTriggers([])
|
||||
@@ -1042,7 +1043,7 @@
|
||||
|
||||
await syncWithDeployed()
|
||||
|
||||
const currentDraftTriggers = structuredClone(
|
||||
const currentDraftTriggers = clone(
|
||||
triggersState.getDraftTriggersSnapshot()
|
||||
)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { clone } from '$lib/utils'
|
||||
import { type RunnableType, type Job } from '$lib/gen/index.js'
|
||||
import { sendUserToast } from '$lib/utils.js'
|
||||
import RunningJobSchemaPicker from '$lib/components/schema/RunningJobSchemaPicker.svelte'
|
||||
@@ -48,7 +49,7 @@
|
||||
dispatch('select', { args: fullPayload, jobId: data.id })
|
||||
} else {
|
||||
dispatch('select', {
|
||||
args: structuredClone($state.snapshot(data.payloadData)),
|
||||
args: clone(data.payloadData),
|
||||
jobId: data.id
|
||||
})
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
import type ItemPicker from './ItemPicker.svelte'
|
||||
import type { InputTransform } from '$lib/gen'
|
||||
import TemplateEditor from './TemplateEditor.svelte'
|
||||
import { setInputCat as computeInputCat, isCodeInjection } from '$lib/utils'
|
||||
import { setInputCat as computeInputCat, isCodeInjection, clone} from '$lib/utils'
|
||||
import { FunctionSquare, InfoIcon } from 'lucide-svelte'
|
||||
import { getResourceTypes } from './resourceTypesStore'
|
||||
import type { FlowCopilotContext } from './copilot/flow'
|
||||
@@ -280,7 +280,7 @@
|
||||
function onArgChange() {
|
||||
const newArg = { arg, propertyType, inputCat }
|
||||
if (!deepEqual(newArg, prevArg)) {
|
||||
prevArg = structuredClone($state.snapshot(newArg))
|
||||
prevArg = clone(newArg)
|
||||
updateStaticInput(inputCat, propertyType, arg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { clone } from '$lib/utils'
|
||||
import { Button } from '$lib/components/common'
|
||||
import { InputService, type Input, type RunnableType } from '$lib/gen/index.js'
|
||||
import { userStore, workspaceStore } from '$lib/stores.js'
|
||||
@@ -137,7 +138,7 @@
|
||||
const fullPayload = await input.getFullPayload?.()
|
||||
dispatch('select', fullPayload)
|
||||
} else {
|
||||
selectedArgs = structuredClone($state.snapshot(input.payloadData) ?? {})
|
||||
selectedArgs = clone($state.snapshot(input.payloadData) ?? {})
|
||||
dispatch('select', selectedArgs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { clone } from '$lib/utils'
|
||||
import SavedInputsPicker from '$lib/components/SavedInputsPicker.svelte'
|
||||
import { createEventDispatcher, tick } from 'svelte'
|
||||
import HistoricInputs from '$lib/components/HistoricInputs.svelte'
|
||||
@@ -162,7 +163,7 @@
|
||||
{/if}
|
||||
<Button
|
||||
on:click={async () => {
|
||||
appliedSearchArgs = structuredClone($state.snapshot(searchArgs))
|
||||
appliedSearchArgs = clone(searchArgs)
|
||||
await tick()
|
||||
historicInputs?.refresh(true)
|
||||
}}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import type { Schema } from '$lib/common'
|
||||
import { VariableService, type Script } from '$lib/gen'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { allTrue, computeShow } from '$lib/utils'
|
||||
import { allTrue, computeShow, clone } from '$lib/utils'
|
||||
import { Button } from './common'
|
||||
import ItemPicker from './ItemPicker.svelte'
|
||||
import VariableEditor from './VariableEditor.svelte'
|
||||
@@ -119,12 +119,12 @@
|
||||
let inputCheck: { [id: string]: boolean } = $state({})
|
||||
|
||||
export function setDefaults() {
|
||||
const nargs = structuredClone($state.snapshot(defaultValues))
|
||||
const nargs = clone(defaultValues)
|
||||
|
||||
Object.keys(schema?.properties ?? {}).forEach((key) => {
|
||||
if (schema?.properties[key].default != undefined && args && args[key] == undefined) {
|
||||
let value = schema?.properties[key].default
|
||||
nargs[key] = value === 'object' ? structuredClone($state.snapshot(value)) : value
|
||||
nargs[key] = value === 'object' ? clone(value) : value
|
||||
}
|
||||
})
|
||||
args = nargs
|
||||
@@ -294,7 +294,7 @@
|
||||
pattern={formerProperty?.pattern}
|
||||
valid={inputCheck[argName]}
|
||||
defaultValue={defaultValues?.[argName] ??
|
||||
structuredClone($state.snapshot(formerProperty?.default))}
|
||||
clone(formerProperty?.default)}
|
||||
enum_={dynamicEnums?.[argName] ?? formerProperty?.enum}
|
||||
format={formerProperty?.format}
|
||||
contentEncoding={formerProperty?.contentEncoding}
|
||||
@@ -365,7 +365,7 @@
|
||||
pattern={schema.properties[argName].pattern}
|
||||
bind:valid={inputCheck[argName]}
|
||||
defaultValue={defaultValues?.[argName] ??
|
||||
structuredClone($state.snapshot(schema.properties[argName].default))}
|
||||
clone(schema.properties[argName].default)}
|
||||
enum_={dynamicEnums?.[argName] ?? schema.properties[argName].enum}
|
||||
format={schema.properties[argName].format}
|
||||
contentEncoding={schema.properties[argName].contentEncoding}
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
generateRandomString,
|
||||
orderedJsonStringify,
|
||||
replaceFalseWithUndefined,
|
||||
type Value
|
||||
type Value,
|
||||
clone
|
||||
} from '$lib/utils'
|
||||
import Path from './Path.svelte'
|
||||
import ScriptEditor from './ScriptEditor.svelte'
|
||||
@@ -143,7 +144,7 @@
|
||||
savedValue: savedScript,
|
||||
modifiedValue: {
|
||||
...script,
|
||||
draft_triggers: structuredClone(triggersState.getDraftTriggersSnapshot())
|
||||
draft_triggers: clone(triggersState.getDraftTriggersSnapshot())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,7 +337,7 @@
|
||||
'#' +
|
||||
encodeState({
|
||||
...script,
|
||||
draft_triggers: structuredClone(triggersState.getDraftTriggersSnapshot())
|
||||
draft_triggers: clone(triggersState.getDraftTriggersSnapshot())
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -562,8 +563,8 @@
|
||||
)
|
||||
}
|
||||
|
||||
const { draft_triggers: _, ...newScript } = structuredClone($state.snapshot(script))
|
||||
savedScript = structuredClone($state.snapshot(newScript)) as NewScriptWithDraft
|
||||
const { draft_triggers: _, ...newScript } = clone(script)
|
||||
savedScript = clone(newScript) as NewScriptWithDraft
|
||||
setDraftTriggers([])
|
||||
|
||||
if (!disableHistoryChange) {
|
||||
@@ -589,7 +590,7 @@
|
||||
|
||||
if (savedScript) {
|
||||
const draftOrDeployed = cleanValueProperties(savedScript.draft || savedScript)
|
||||
const currentTriggers = structuredClone(triggersState.getDraftTriggersSnapshot())
|
||||
const currentTriggers = clone(triggersState.getDraftTriggersSnapshot())
|
||||
const current = cleanValueProperties({ ...script, draft_triggers: currentTriggers })
|
||||
if (!forceSave && orderedJsonStringify(draftOrDeployed) === orderedJsonStringify(current)) {
|
||||
sendUserToast('No changes detected, ignoring', false, [
|
||||
@@ -694,7 +695,7 @@
|
||||
}
|
||||
})
|
||||
|
||||
const clonedScript = structuredClone($state.snapshot(script))
|
||||
const clonedScript = clone(script)
|
||||
savedScript = {
|
||||
...(initialPath == '' || savedScript?.draft_only
|
||||
? { ...clonedScript, draft_only: true }
|
||||
@@ -754,7 +755,7 @@
|
||||
}
|
||||
await syncWithDeployed()
|
||||
|
||||
const currentDraftTriggers = structuredClone(
|
||||
const currentDraftTriggers = clone(
|
||||
triggersState.getDraftTriggersSnapshot()
|
||||
)
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
import ResolveStyle from '../helpers/ResolveStyle.svelte'
|
||||
import { deepEqual } from 'fast-equals'
|
||||
import { computeWorkspaceS3FileInputPolicy } from '../../editor/appUtilsS3'
|
||||
import { defaultIfEmptyString } from '$lib/utils'
|
||||
import { defaultIfEmptyString, clone} from '$lib/utils'
|
||||
import { userStore } from '$lib/stores'
|
||||
import SchemaForm from '$lib/components/SchemaForm.svelte'
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
let previousDefault = $state(resolvedConfig.defaultValues)
|
||||
|
||||
function onDefaultChange() {
|
||||
previousDefault = structuredClone($state.snapshot(resolvedConfig.defaultValues))
|
||||
previousDefault = clone(resolvedConfig.defaultValues)
|
||||
args = previousDefault ?? {}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { GridApi, createGrid, type IDatasource } from 'ag-grid-community'
|
||||
import { sendUserToast } from '$lib/utils'
|
||||
import { sendUserToast, clone} from '$lib/utils'
|
||||
import { createEventDispatcher, getContext, mount, unmount } from 'svelte'
|
||||
import type { AppViewerContext, ComponentCustomCSS, ContextPanelContext } from '../../../types'
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
|
||||
function refreshActions(actions: TableAction[]) {
|
||||
if (!deepEqual(actions, lastActions)) {
|
||||
lastActions = structuredClone(stateSnapshot(actions))
|
||||
lastActions = clone(actions)
|
||||
updateOptions()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { GridApi, createGrid } from 'ag-grid-community'
|
||||
import { isObject, sendUserToast } from '$lib/utils'
|
||||
import { isObject, sendUserToast, clone} from '$lib/utils'
|
||||
import { getContext, mount, onDestroy, unmount } from 'svelte'
|
||||
import type { AppInput } from '../../../inputType'
|
||||
import type {
|
||||
@@ -206,7 +206,7 @@
|
||||
|
||||
function refreshActions(actions: TableAction[]) {
|
||||
if (!deepEqual(actions, lastActions)) {
|
||||
lastActions = structuredClone(stateSnapshot(actions))
|
||||
lastActions = clone(actions)
|
||||
updateOptions()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { clone } from '$lib/utils'
|
||||
import { createBubbler, stopPropagation } from 'svelte/legacy'
|
||||
|
||||
const bubble = createBubbler()
|
||||
@@ -133,7 +134,7 @@
|
||||
tabs
|
||||
)
|
||||
) {
|
||||
lastTabs = structuredClone($state.snapshot(tabs))
|
||||
lastTabs = clone(tabs)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
cleanValueProperties,
|
||||
orderedJsonStringify,
|
||||
type Value,
|
||||
replaceFalseWithUndefined
|
||||
replaceFalseWithUndefined,
|
||||
clone
|
||||
} from '../../../utils'
|
||||
import type { AppInput, Runnable } from '../inputType'
|
||||
import type { App, AppEditorContext, AppViewerContext } from '../types'
|
||||
@@ -392,7 +393,7 @@
|
||||
})
|
||||
savedApp = {
|
||||
summary: $summary,
|
||||
value: structuredClone($state.snapshot($app)),
|
||||
value: clone($app),
|
||||
path: path,
|
||||
policy: policy,
|
||||
custom_path: customPath
|
||||
@@ -488,7 +489,7 @@
|
||||
})
|
||||
savedApp = {
|
||||
summary: $summary,
|
||||
value: structuredClone($state.snapshot($app)),
|
||||
value: clone($app),
|
||||
path: npath,
|
||||
policy,
|
||||
custom_path: customPath
|
||||
@@ -572,13 +573,13 @@
|
||||
})
|
||||
savedApp = {
|
||||
summary: $summary,
|
||||
value: structuredClone($state.snapshot($app)),
|
||||
value: clone($app),
|
||||
path: newEditedPath,
|
||||
policy,
|
||||
draft_only: true,
|
||||
draft: {
|
||||
summary: $summary,
|
||||
value: structuredClone($state.snapshot($app)),
|
||||
value: clone($app),
|
||||
path: newEditedPath,
|
||||
policy,
|
||||
custom_path: customPath
|
||||
@@ -660,7 +661,7 @@
|
||||
...(savedApp?.draft_only
|
||||
? {
|
||||
summary: $summary,
|
||||
value: structuredClone($state.snapshot($app)),
|
||||
value: clone($app),
|
||||
path: savedApp.draft_only ? newEditedPath || path : path,
|
||||
policy,
|
||||
draft_only: true,
|
||||
@@ -669,7 +670,7 @@
|
||||
: savedApp),
|
||||
draft: {
|
||||
summary: $summary,
|
||||
value: structuredClone($state.snapshot($app)),
|
||||
value: clone($app),
|
||||
path: newEditedPath || path,
|
||||
policy,
|
||||
custom_path: customPath
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
} from '$lib/gen'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { base } from '$lib/base'
|
||||
import { emptyString, formatCron, sendUserToast, tryEvery } from '$lib/utils'
|
||||
import { emptyString, formatCron, sendUserToast, tryEvery, clone} from '$lib/utils'
|
||||
import SchemaForm from '$lib/components/SchemaForm.svelte'
|
||||
import Button from '$lib/components/common/button/Button.svelte'
|
||||
import Toggle from '$lib/components/Toggle.svelte'
|
||||
@@ -127,7 +127,7 @@
|
||||
)
|
||||
: {}
|
||||
setTimeout(() => {
|
||||
args = structuredClone($state.snapshot(nargs))
|
||||
args = clone(nargs)
|
||||
})
|
||||
|
||||
customPath =
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { clone } from '$lib/utils'
|
||||
import { Code, Copy, MoveLeft, MoveRight, Paintbrush2 } from 'lucide-svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { slide } from 'svelte/transition'
|
||||
@@ -53,10 +54,10 @@
|
||||
const dispatch = createEventDispatcher()
|
||||
let isQuickMenuOpen = $state(false)
|
||||
|
||||
let prevValue = structuredClone($state.snapshot(value))
|
||||
let prevValue = clone(value)
|
||||
$effect(() => {
|
||||
if (deepEqual(prevValue, value)) return
|
||||
prevValue = structuredClone($state.snapshot(value))
|
||||
prevValue = clone(value)
|
||||
dispatch('change', value)
|
||||
})
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
} from '$lib/components/schema/schemaUtils.svelte'
|
||||
import SideBarTab from '$lib/components/meltComponents/SideBarTab.svelte'
|
||||
import CaptureTable from '$lib/components/triggers/CaptureTable.svelte'
|
||||
import { isObjectTooBig } from '$lib/utils'
|
||||
import { isObjectTooBig, clone } from '$lib/utils'
|
||||
import { refreshStateStore } from '$lib/svelte5Utils.svelte'
|
||||
|
||||
interface Props {
|
||||
@@ -170,7 +170,7 @@
|
||||
}
|
||||
|
||||
function schemaFromPayload(payloadData: any) {
|
||||
const payload = structuredClone($state.snapshot(payloadData))
|
||||
const payload = clone(payloadData)
|
||||
const parsed = JSON.parse(JSON.stringify(payload))
|
||||
|
||||
if (!parsed) {
|
||||
@@ -204,7 +204,7 @@
|
||||
|
||||
function runPreview() {
|
||||
if (previewArguments) {
|
||||
previewArgs.val = structuredClone($state.snapshot(previewArguments))
|
||||
previewArgs.val = clone(previewArguments)
|
||||
}
|
||||
onRunPreview?.()
|
||||
}
|
||||
@@ -221,7 +221,7 @@
|
||||
updatePreviewSchema(undefined)
|
||||
return
|
||||
}
|
||||
payloadData = structuredClone($state.snapshot(payload))
|
||||
payloadData = clone(payload)
|
||||
selectedSchema = schemaFromPayload(payloadData)
|
||||
updatePreviewSchema(selectedSchema)
|
||||
updatePreviewArguments(payloadData)
|
||||
@@ -247,7 +247,7 @@
|
||||
async function applySchemaAndArgs() {
|
||||
flowStore.val.schema = applyDiff(flowStore.val.schema, diff)
|
||||
if (previewArguments) {
|
||||
savedPreviewArgs = structuredClone($state.snapshot(previewArguments))
|
||||
savedPreviewArgs = clone(previewArguments)
|
||||
}
|
||||
updatePreviewSchemaAndArgs(undefined)
|
||||
if ($flowInputEditorState) {
|
||||
@@ -260,8 +260,8 @@
|
||||
previewArguments = savedPreviewArgs
|
||||
return
|
||||
}
|
||||
savedPreviewArgs = structuredClone($state.snapshot(previewArguments))
|
||||
previewArguments = structuredClone($state.snapshot(payloadData))
|
||||
savedPreviewArgs = clone(previewArguments)
|
||||
previewArguments = clone(payloadData)
|
||||
}
|
||||
|
||||
let tabButtonWidth = 0
|
||||
@@ -398,7 +398,7 @@
|
||||
on:change={() => {
|
||||
previewArguments = previewArguments
|
||||
if (!previewSchema) {
|
||||
savedPreviewArgs = structuredClone($state.snapshot(previewArguments))
|
||||
savedPreviewArgs = clone(previewArguments)
|
||||
}
|
||||
refreshStateStore(flowStore)
|
||||
}}
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
cleanValueProperties,
|
||||
emptySchema,
|
||||
orderedJsonStringify,
|
||||
sendUserToast
|
||||
sendUserToast,
|
||||
clone
|
||||
} from '$lib/utils'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { fade } from 'svelte/transition'
|
||||
@@ -28,7 +29,7 @@
|
||||
workspace: $workspaceStore!,
|
||||
hash
|
||||
})
|
||||
savedScript = structuredClone($state.snapshot(script))
|
||||
savedScript = clone(script)
|
||||
callback = cb
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@
|
||||
lock: undefined
|
||||
}
|
||||
})
|
||||
savedScript = structuredClone($state.snapshot(script))
|
||||
savedScript = clone(script)
|
||||
callback?.()
|
||||
} catch (error) {
|
||||
sendUserToast(`Impossible to save the script: ${error.body}`, true)
|
||||
@@ -246,7 +247,7 @@
|
||||
button: {
|
||||
text: 'Restore to saved',
|
||||
onClick: () => {
|
||||
script = structuredClone($state.snapshot(savedScript))
|
||||
script = clone(savedScript)
|
||||
diffDrawer?.closeDrawer()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function copyFirstStepSchema(
|
||||
const firstModuleId = flowStore.val.value.modules[0]?.id
|
||||
|
||||
if (flowState[firstModuleId] && firstModuleId) {
|
||||
flowStore.val.schema = structuredClone($state.snapshot(flowState[firstModuleId].schema))
|
||||
flowStore.val.schema = clone(flowState[firstModuleId].schema)
|
||||
const v = flowStore.val.value.modules[0].value
|
||||
if (v.type == 'rawscript' || v.type == 'script') {
|
||||
Object.keys(v.input_transforms ?? {}).forEach((key) => {
|
||||
@@ -47,7 +47,7 @@ export async function getFirstStepSchema(flowState: FlowState, flow: OpenFlow) {
|
||||
throw new Error('no first step found')
|
||||
}
|
||||
|
||||
const schema = structuredClone(flowState[firstModuleId].schema)
|
||||
const schema = clone(flowState[firstModuleId].schema)
|
||||
const v = flow.value.modules[0].value
|
||||
|
||||
if (v.type !== 'rawscript' && v.type !== 'script') {
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function copyFirstStepSchema(flowState: FlowState, flowStore: Writa
|
||||
const firstModuleId = flow.value.modules[0]?.id
|
||||
|
||||
if (flowState[firstModuleId] && firstModuleId) {
|
||||
flow.schema = structuredClone(stateSnapshot(flowState[firstModuleId].schema))
|
||||
flow.schema = clone(flowState[firstModuleId].schema)
|
||||
const v = flow.value.modules[0].value
|
||||
if (v.type == 'rawscript' || v.type == 'script') {
|
||||
Object.keys(v.input_transforms ?? {}).forEach((key) => {
|
||||
@@ -50,7 +50,7 @@ export async function getFirstStepSchema(flowState: FlowState, flowStore: StateS
|
||||
throw new Error('no first step found')
|
||||
}
|
||||
|
||||
const schema = structuredClone(stateSnapshot(flowState[firstModuleId].schema))
|
||||
const schema = clone(flowState[firstModuleId].schema)
|
||||
const v = flow.value.modules[0].value
|
||||
|
||||
if (v.type !== 'rawscript' && v.type !== 'script') {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { clone } from '$lib/utils'
|
||||
import Button from '$lib/components/common/button/Button.svelte'
|
||||
import { Pin, History, Pen, Check, X, Loader2, Pencil } from 'lucide-svelte'
|
||||
import ObjectViewer from '$lib/components/propertyPicker/ObjectViewer.svelte'
|
||||
@@ -195,7 +196,7 @@
|
||||
})
|
||||
} else if (selectedJob && 'result' in selectedJob) {
|
||||
// Pin the job
|
||||
let mockValue: any = structuredClone($state.snapshot(selectedJob.result))
|
||||
let mockValue: any = clone(selectedJob.result)
|
||||
if (selectedJob.result === 'never tested this far') {
|
||||
mockValue = { example: 'value' }
|
||||
}
|
||||
@@ -615,7 +616,7 @@
|
||||
if (mock?.enabled) {
|
||||
const newMock = {
|
||||
enabled: true,
|
||||
return_value: structuredClone($state.snapshot(detail))
|
||||
return_value: clone(detail)
|
||||
}
|
||||
tmpMock = newMock
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ import type { ScheduleTrigger } from '../triggers'
|
||||
import type { Writable } from 'svelte/store'
|
||||
import { writable } from 'svelte/store'
|
||||
import { get } from 'svelte/store'
|
||||
import { sendUserToast } from '$lib/utils'
|
||||
import { stateSnapshot } from '$lib/svelte5Utils.svelte'
|
||||
import { sendUserToast, clone} from '$lib/utils'
|
||||
|
||||
// Load the schedule of a flow given its path and the workspace
|
||||
export async function loadSchedule(path: string, workspace: string): Promise<ScheduleTrigger> {
|
||||
@@ -46,7 +45,7 @@ export async function loadSchedules(
|
||||
if (!path || path == '') {
|
||||
schedules.set([])
|
||||
primarySchedule.update((ps) => (ps === undefined ? false : ps))
|
||||
initialPrimarySchedule.set(structuredClone(stateSnapshot(get(primarySchedule))))
|
||||
initialPrimarySchedule.set(clone(get(primarySchedule)))
|
||||
return
|
||||
}
|
||||
try {
|
||||
@@ -74,7 +73,7 @@ export async function loadSchedules(
|
||||
: false
|
||||
}
|
||||
primarySchedule.update((ps) => (ps === undefined || forceRefresh ? remotePrimarySchedule : ps))
|
||||
initialPrimarySchedule.set(structuredClone(stateSnapshot(remotePrimarySchedule)))
|
||||
initialPrimarySchedule.set(clone(remotePrimarySchedule))
|
||||
|
||||
triggersCount.update((tc) => {
|
||||
const primary = get(primarySchedule)
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
type PickableProperties
|
||||
} from './previousResults'
|
||||
import { evalValue, type ModuleArgs } from './utils'
|
||||
import { clone } from '$lib/utils'
|
||||
|
||||
export class TestSteps {
|
||||
#stepsEvaluated = $state<Record<string, ModuleArgs>>({})
|
||||
@@ -102,7 +103,7 @@ export class TestSteps {
|
||||
|
||||
const argSnapshot = $state.snapshot(evalValue(argName, modules[0], pickableProperties, false))
|
||||
this.#stepsEvaluated[moduleId].value[argName] = argSnapshot
|
||||
this.#steps[moduleId].value[argName] = structuredClone(argSnapshot)
|
||||
this.#steps[moduleId].value[argName] = clone(argSnapshot)
|
||||
}
|
||||
|
||||
initializeFromSchema(
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
import { Expand } from 'lucide-svelte'
|
||||
import Toggle from '../Toggle.svelte'
|
||||
import DataflowEdge from './renderers/edges/DataflowEdge.svelte'
|
||||
import { encodeState } from '$lib/utils'
|
||||
import { encodeState, clone} from '$lib/utils'
|
||||
import BranchOneStart from './renderers/nodes/BranchOneStart.svelte'
|
||||
import NoBranchNode from './renderers/nodes/NoBranchNode.svelte'
|
||||
import HiddenBaseEdge from './renderers/edges/HiddenBaseEdge.svelte'
|
||||
@@ -310,12 +310,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
let lastModules = structuredClone($state.snapshot(modules))
|
||||
let lastModules = clone(modules)
|
||||
let moduleCounter = $state(0)
|
||||
function onModulesChange2(modules) {
|
||||
if (!deepEqual(modules, lastModules)) {
|
||||
console.log('modules changed', modules)
|
||||
lastModules = structuredClone($state.snapshot(modules))
|
||||
lastModules = clone(modules)
|
||||
moduleCounter++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { clone } from '$lib/utils'
|
||||
import { Alert, Badge, Drawer, DrawerContent } from '$lib/components/common'
|
||||
import Button from '$lib/components/common/button/Button.svelte'
|
||||
|
||||
@@ -48,7 +49,6 @@
|
||||
import { collectStaticFields, hash, type TriggerableV2 } from '../apps/editor/commonAppUtils'
|
||||
import type { SavedAndModifiedValue } from '../common/confirmationModal/unsavedTypes'
|
||||
import DropdownV2 from '../DropdownV2.svelte'
|
||||
import { stateSnapshot } from '$lib/svelte5Utils.svelte'
|
||||
|
||||
// async function hash(message) {
|
||||
// try {
|
||||
@@ -205,7 +205,7 @@
|
||||
})
|
||||
savedApp = {
|
||||
summary: summary,
|
||||
value: structuredClone(stateSnapshot(app)),
|
||||
value: clone(app),
|
||||
path: path,
|
||||
policy: policy,
|
||||
custom_path: customPath
|
||||
@@ -310,7 +310,7 @@
|
||||
})
|
||||
savedApp = {
|
||||
summary: summary,
|
||||
value: structuredClone(stateSnapshot(app)),
|
||||
value: clone(app),
|
||||
path: npath,
|
||||
policy,
|
||||
custom_path: customPath
|
||||
@@ -402,13 +402,13 @@
|
||||
})
|
||||
savedApp = {
|
||||
summary: summary,
|
||||
value: structuredClone(stateSnapshot(app)),
|
||||
value: clone(app),
|
||||
path: newEditedPath,
|
||||
policy,
|
||||
draft_only: true,
|
||||
draft: {
|
||||
summary: summary,
|
||||
value: structuredClone(stateSnapshot(app)),
|
||||
value: clone(app),
|
||||
path: newEditedPath,
|
||||
policy,
|
||||
custom_path: customPath
|
||||
@@ -500,7 +500,7 @@
|
||||
...(savedApp?.draft_only
|
||||
? {
|
||||
summary: summary,
|
||||
value: structuredClone(stateSnapshot(app)),
|
||||
value: clone(app),
|
||||
path: savedApp.draft_only ? newEditedPath || path : path,
|
||||
policy,
|
||||
draft_only: true,
|
||||
@@ -509,7 +509,7 @@
|
||||
: savedApp),
|
||||
draft: {
|
||||
summary: summary,
|
||||
value: structuredClone(stateSnapshot(app)),
|
||||
value: clone(app),
|
||||
path: newEditedPath || path,
|
||||
policy,
|
||||
custom_path: customPath
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import AddProperty from './AddProperty.svelte'
|
||||
import { dragHandle, dragHandleZone } from '@windmill-labs/svelte-dnd-action'
|
||||
import { flip } from 'svelte/animate'
|
||||
import { emptyString } from '$lib/utils'
|
||||
import { emptyString, clone} from '$lib/utils'
|
||||
import Button from '$lib/components/common/button/Button.svelte'
|
||||
import { createEventDispatcher, tick } from 'svelte'
|
||||
import Label from '../Label.svelte'
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
let { schema = $bindable(), parentId = undefined, jsonView = $bindable(false) }: Props = $props()
|
||||
|
||||
// let schema = $state(structuredClone($state.snapshot(schema)))
|
||||
// let schema = $state(clone(schema))
|
||||
|
||||
let schemaString: string = $state(JSON.stringify(schema, null, '\t'))
|
||||
let editor: SimpleEditor | undefined = $state(undefined)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import autosize from '$lib/autosize'
|
||||
import { shouldDisplayPlaceholder } from '$lib/utils'
|
||||
import { shouldDisplayPlaceholder, clone} from '$lib/utils'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import ArrayTypeNarrowing from '../ArrayTypeNarrowing.svelte'
|
||||
import Label from '../Label.svelte'
|
||||
@@ -118,7 +118,7 @@
|
||||
order
|
||||
})
|
||||
|
||||
let initialExtra: any = structuredClone({
|
||||
let initialExtra: any = clone({
|
||||
order: undefined,
|
||||
properties: undefined,
|
||||
...$state.snapshot(extra)
|
||||
@@ -138,7 +138,7 @@
|
||||
return
|
||||
}
|
||||
if (!deepEqual(extra, initialExtra)) {
|
||||
initialExtra = structuredClone($state.snapshot(extra))
|
||||
initialExtra = clone(extra)
|
||||
console.debug('property content updated')
|
||||
dispatchIfMounted('change')
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { clone } from '$lib/utils'
|
||||
export type SchemaDiff = {
|
||||
diff: 'same' | 'added' | 'removed' | 'modified' | Record<string, SchemaDiff>
|
||||
fullSchema: { [key: string]: any } | undefined
|
||||
@@ -133,7 +134,7 @@ export function schemaFromDiff(
|
||||
if (!schema) {
|
||||
return undefined
|
||||
}
|
||||
const newSchema = structuredClone($state.snapshot(schema))
|
||||
const newSchema = clone(schema)
|
||||
Object.keys(diff).forEach((key) => {
|
||||
const diffValue = diff[key].diff
|
||||
if (diffValue === 'added' || diffValue === 'modified') {
|
||||
@@ -179,7 +180,7 @@ export function setNestedProperty(
|
||||
return curr[field][key]
|
||||
}, obj)
|
||||
if (lastKey && value) {
|
||||
const newValue = structuredClone($state.snapshot(value))
|
||||
const newValue = clone(value)
|
||||
target[field][lastKey] = newValue
|
||||
return
|
||||
} else if (lastKey && !value) {
|
||||
@@ -199,7 +200,7 @@ export function applyDiff(
|
||||
return
|
||||
}
|
||||
|
||||
let newSchema = structuredClone($state.snapshot(schema))
|
||||
let newSchema = clone(schema)
|
||||
|
||||
Object.keys(diff).forEach((key) => {
|
||||
const diffValue = diff[key].diff
|
||||
|
||||
@@ -27,9 +27,8 @@
|
||||
import { Popover } from '$lib/components/meltComponents'
|
||||
import { CaptureService } from '$lib/gen'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { isObject, sendUserToast } from '$lib/utils'
|
||||
import { isObject, sendUserToast, clone, formatDateShort } from '$lib/utils'
|
||||
import { triggerIconMap } from './utils'
|
||||
import { formatDateShort } from '$lib/utils'
|
||||
import DisplayResult from '$lib/components/DisplayResult.svelte'
|
||||
import DisplayResultControlBar from '$lib/components/DisplayResultControlBar.svelte'
|
||||
import { base } from '$lib/base'
|
||||
@@ -432,7 +431,7 @@
|
||||
|
||||
dispatch('applyArgs', {
|
||||
kind: testKind,
|
||||
args: { ...structuredClone($state.snapshot(payloadData)), ...trigger_extra }
|
||||
args: { ...clone(payloadData), ...trigger_extra }
|
||||
})
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import { type CaptureTriggerKind } from '$lib/gen'
|
||||
import CaptureButton from '$lib/components/triggers/CaptureButton.svelte'
|
||||
import InfiniteList from '../InfiniteList.svelte'
|
||||
import { isObject, sendUserToast } from '$lib/utils'
|
||||
import { isObject, sendUserToast, clone} from '$lib/utils'
|
||||
import SchemaPickerRow from '$lib/components/schema/SchemaPickerRow.svelte'
|
||||
import type { Capture } from '$lib/gen'
|
||||
import { AwsIcon, MqttIcon } from '../icons'
|
||||
@@ -161,7 +161,7 @@
|
||||
} else {
|
||||
const payloadData = await getPayload(capture)
|
||||
selected = capture.id
|
||||
dispatch('select', structuredClone($state.snapshot(payloadData)))
|
||||
dispatch('select', clone(payloadData))
|
||||
dispatch('selectCapture', capture)
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@
|
||||
testKind === 'preprocessor' ? fullCapture.preprocessor_args : fullCapture.main_args
|
||||
}
|
||||
} else {
|
||||
payloadData = structuredClone($state.snapshot(capture.payloadData))
|
||||
payloadData = clone(capture.payloadData)
|
||||
}
|
||||
return payloadData
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import DrawerContent from '$lib/components/common/drawer/DrawerContent.svelte'
|
||||
import Path from '$lib/components/Path.svelte'
|
||||
import { usedTriggerKinds, userStore, workspaceStore } from '$lib/stores'
|
||||
import { canWrite, emptyString, sendUserToast } from '$lib/utils'
|
||||
import { canWrite, emptyString, sendUserToast, clone} from '$lib/utils'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
import {
|
||||
@@ -106,7 +106,7 @@
|
||||
} finally {
|
||||
drawerLoading = false
|
||||
if (!defaultValues) {
|
||||
initialConfig = structuredClone($state.snapshot(getGcpConfig()))
|
||||
initialConfig = clone(getGcpConfig())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import ScriptPicker from '$lib/components/ScriptPicker.svelte'
|
||||
import { HttpTriggerService, VariableService, type AuthenticationMethod } from '$lib/gen'
|
||||
import { usedTriggerKinds, userStore, workspaceStore } from '$lib/stores'
|
||||
import { canWrite, emptyString, sendUserToast } from '$lib/utils'
|
||||
import { canWrite, emptyString, sendUserToast, clone} from '$lib/utils'
|
||||
import Section from '$lib/components/Section.svelte'
|
||||
import { Loader2, Pipette, Plus } from 'lucide-svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
@@ -183,7 +183,7 @@
|
||||
} finally {
|
||||
if (!defaultConfig) {
|
||||
// If the route is loaded from the backend, we to set the initial config
|
||||
initialConfig = structuredClone($state.snapshot(getRouteConfig()))
|
||||
initialConfig = clone(getRouteConfig())
|
||||
}
|
||||
clearTimeout(loader)
|
||||
drawerLoading = false
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import ScriptPicker from '$lib/components/ScriptPicker.svelte'
|
||||
import { KafkaTriggerService } from '$lib/gen'
|
||||
import { usedTriggerKinds, userStore, workspaceStore } from '$lib/stores'
|
||||
import { canWrite, emptyString, sendUserToast } from '$lib/utils'
|
||||
import { canWrite, emptyString, sendUserToast, clone} from '$lib/utils'
|
||||
import Section from '$lib/components/Section.svelte'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
@@ -119,7 +119,7 @@
|
||||
sendUserToast(`Could not load Kafka trigger: ${err}`, true)
|
||||
} finally {
|
||||
if (!defaultConfig) {
|
||||
initialConfig = structuredClone($state.snapshot(getSaveCfg()))
|
||||
initialConfig = clone(getSaveCfg())
|
||||
}
|
||||
clearTimeout(loadingTimeout)
|
||||
drawerLoading = false
|
||||
@@ -221,7 +221,7 @@
|
||||
return {
|
||||
kafka_resource_path: kafkaResourcePath,
|
||||
group_id: kafkaCfg.group_id,
|
||||
topics: structuredClone($state.snapshot(kafkaCfg.topics)),
|
||||
topics: clone(kafkaCfg.topics),
|
||||
path
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import Required from '$lib/components/Required.svelte'
|
||||
import ScriptPicker from '$lib/components/ScriptPicker.svelte'
|
||||
import { usedTriggerKinds, userStore, workspaceStore } from '$lib/stores'
|
||||
import { canWrite, emptyString, sendUserToast } from '$lib/utils'
|
||||
import { canWrite, emptyString, sendUserToast, clone} from '$lib/utils'
|
||||
import Section from '$lib/components/Section.svelte'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
@@ -114,7 +114,7 @@
|
||||
sendUserToast(`Could not load mqtt trigger: ${err.body}`, true)
|
||||
} finally {
|
||||
if (!defaultConfig) {
|
||||
initialConfig = structuredClone($state.snapshot(getSaveCfg()))
|
||||
initialConfig = clone(getSaveCfg())
|
||||
}
|
||||
clearTimeout(loadingTimeout)
|
||||
drawerLoading = false
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import ScriptPicker from '$lib/components/ScriptPicker.svelte'
|
||||
import { NatsTriggerService } from '$lib/gen'
|
||||
import { usedTriggerKinds, userStore, workspaceStore } from '$lib/stores'
|
||||
import { canWrite, emptyString, sendUserToast } from '$lib/utils'
|
||||
import { canWrite, emptyString, sendUserToast, clone} from '$lib/utils'
|
||||
import Section from '$lib/components/Section.svelte'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
@@ -112,7 +112,7 @@
|
||||
drawerLoading = false
|
||||
showLoading = false
|
||||
if (!defaultConfig) {
|
||||
initialConfig = structuredClone($state.snapshot(getSaveCfg()))
|
||||
initialConfig = clone(getSaveCfg())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import ScriptPicker from '$lib/components/ScriptPicker.svelte'
|
||||
import { PostgresTriggerService, type Language, type Relations } from '$lib/gen'
|
||||
import { usedTriggerKinds, userStore, workspaceStore } from '$lib/stores'
|
||||
import { canWrite, emptyString, emptyStringTrimmed, sendUserToast } from '$lib/utils'
|
||||
import { canWrite, emptyString, emptyStringTrimmed, sendUserToast, clone} from '$lib/utils'
|
||||
import Section from '$lib/components/Section.svelte'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
@@ -210,7 +210,7 @@
|
||||
sendUserToast(`Could not load postgres trigger: ${err.body}`, true)
|
||||
} finally {
|
||||
if (!defaultConfig) {
|
||||
initialConfig = structuredClone($state.snapshot(getSaveCfg()))
|
||||
initialConfig = clone(getSaveCfg())
|
||||
}
|
||||
clearTimeout(loadingTimeout)
|
||||
drawerLoading = false
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
type Schedule
|
||||
} from '$lib/gen'
|
||||
import { enterpriseLicense, userStore, workspaceStore } from '$lib/stores'
|
||||
import { canWrite, emptyString, formatCron, sendUserToast, cronV1toV2 } from '$lib/utils'
|
||||
import { canWrite, emptyString, formatCron, sendUserToast, cronV1toV2, clone } from '$lib/utils'
|
||||
import { base } from '$lib/base'
|
||||
import Section from '$lib/components/Section.svelte'
|
||||
import { List, Loader2, Save, AlertTriangle } from 'lucide-svelte'
|
||||
@@ -132,7 +132,7 @@
|
||||
edit = true
|
||||
} finally {
|
||||
if (!defaultCfg) {
|
||||
initialConfig = structuredClone($state.snapshot(getScheduleCfg()))
|
||||
initialConfig = clone(getScheduleCfg())
|
||||
}
|
||||
clearTimeout(loadingTimeout)
|
||||
drawerLoading = false
|
||||
@@ -608,21 +608,21 @@
|
||||
}
|
||||
|
||||
function getScheduleCfg(): Record<string, any> {
|
||||
let errorHadlerExtraArgsDerived = structuredClone($state.snapshot(errorHandlerExtraArgs))
|
||||
let errorHadlerExtraArgsDerived = clone(errorHandlerExtraArgs)
|
||||
if (errorHandlerPath !== undefined && isSlackHandler('error', errorHandlerPath)) {
|
||||
errorHadlerExtraArgsDerived['slack'] = '$res:f/slack_bot/bot_token'
|
||||
} else {
|
||||
errorHadlerExtraArgsDerived['slack'] = undefined
|
||||
}
|
||||
|
||||
let recoveryHandlerExtraArgsDerived = structuredClone($state.snapshot(recoveryHandlerExtraArgs))
|
||||
let recoveryHandlerExtraArgsDerived = clone(recoveryHandlerExtraArgs)
|
||||
if (recoveryHandlerPath !== undefined && isSlackHandler('recovery', recoveryHandlerPath)) {
|
||||
recoveryHandlerExtraArgsDerived['slack'] = '$res:f/slack_bot/bot_token'
|
||||
} else {
|
||||
recoveryHandlerExtraArgsDerived['slack'] = undefined
|
||||
}
|
||||
|
||||
let successHandlerExtraArgsDerived = structuredClone($state.snapshot(successHandlerExtraArgs))
|
||||
let successHandlerExtraArgsDerived = clone(successHandlerExtraArgs)
|
||||
if (successHandlerPath !== undefined && isSlackHandler('success', successHandlerPath)) {
|
||||
successHandlerExtraArgsDerived['slack'] = '$res:f/slack_bot/bot_token'
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import DrawerContent from '$lib/components/common/drawer/DrawerContent.svelte'
|
||||
import Path from '$lib/components/Path.svelte'
|
||||
import { usedTriggerKinds, userStore, workspaceStore } from '$lib/stores'
|
||||
import { canWrite, emptyString, sendUserToast } from '$lib/utils'
|
||||
import { canWrite, emptyString, sendUserToast, clone} from '$lib/utils'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
import { SqsTriggerService, type AwsAuthResourceType } from '$lib/gen'
|
||||
@@ -136,7 +136,7 @@
|
||||
dirtyPath = false
|
||||
enabled = defaultValues?.enabled ?? false
|
||||
} finally {
|
||||
initialConfig = structuredClone($state.snapshot(getSaveCfg()))
|
||||
initialConfig = clone(getSaveCfg())
|
||||
clearTimeout(loadingTimeout)
|
||||
drawerLoading = false
|
||||
showLoading = false
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
type WebsocketTriggerInitialMessage
|
||||
} from '$lib/gen'
|
||||
import { usedTriggerKinds, userStore, workspaceStore } from '$lib/stores'
|
||||
import { canWrite, emptySchema, emptyString, sendUserToast } from '$lib/utils'
|
||||
import { canWrite, emptySchema, emptyString, sendUserToast, clone} from '$lib/utils'
|
||||
import Section from '$lib/components/Section.svelte'
|
||||
import { Loader2, X, Plus } from 'lucide-svelte'
|
||||
import Label from '$lib/components/Label.svelte'
|
||||
@@ -139,7 +139,7 @@
|
||||
sendUserToast(`Could not load websocket trigger: ${err}`, true)
|
||||
} finally {
|
||||
if (!defaultConfig) {
|
||||
initialConfig = structuredClone($state.snapshot(getSaveCfg()))
|
||||
initialConfig = clone(getSaveCfg())
|
||||
}
|
||||
clearTimeout(loadingTimeout)
|
||||
drawerLoading = false
|
||||
|
||||
@@ -1023,7 +1023,7 @@ export type Value = {
|
||||
}
|
||||
|
||||
export function replaceFalseWithUndefined(obj: any) {
|
||||
return replaceFalseWithUndefinedRec(structuredClone(stateSnapshot(obj)))
|
||||
return replaceFalseWithUndefinedRec(clone(obj))
|
||||
}
|
||||
|
||||
function replaceFalseWithUndefinedRec(obj: any) {
|
||||
@@ -1052,7 +1052,7 @@ export function cleanValueProperties(obj: Value) {
|
||||
let newObj: any = {}
|
||||
for (const key of Object.keys(obj)) {
|
||||
if (key !== 'parent_hash' && key !== 'draft' && key !== 'draft_only') {
|
||||
newObj[key] = structuredClone(stateSnapshot(obj[key]))
|
||||
newObj[key] = clone(obj[key])
|
||||
}
|
||||
}
|
||||
return newObj
|
||||
@@ -1432,4 +1432,10 @@ export function scroll_into_view_if_needed_polyfill(elem: Element, centerIfNeede
|
||||
return observer // return for testing
|
||||
}
|
||||
|
||||
export function clone<T>(t: T): T {
|
||||
if (typeof t === 'function') throw new Error('Cannot clone a function')
|
||||
if (typeof t === 'object') return stateSnapshot(t) as T
|
||||
return t
|
||||
}
|
||||
|
||||
export const editorPositionMap: Record<string, IPosition> = {}
|
||||
|
||||
@@ -8,14 +8,13 @@
|
||||
} from '$lib/gen'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { page } from '$app/stores'
|
||||
import { cleanValueProperties, decodeState, type Value } from '$lib/utils'
|
||||
import { cleanValueProperties, decodeState, type Value, clone} from '$lib/utils'
|
||||
import { afterNavigate, replaceState } from '$app/navigation'
|
||||
import { goto } from '$lib/navigation'
|
||||
import { sendUserToast, type ToastAction } from '$lib/toast'
|
||||
import DiffDrawer from '$lib/components/DiffDrawer.svelte'
|
||||
import type { App } from '$lib/components/apps/types'
|
||||
import UnsavedConfirmationModal from '$lib/components/common/confirmationModal/UnsavedConfirmationModal.svelte'
|
||||
import { stateSnapshot } from '$lib/svelte5Utils.svelte'
|
||||
import { untrack } from 'svelte'
|
||||
|
||||
let app = $state(
|
||||
@@ -53,7 +52,7 @@
|
||||
path,
|
||||
workspace: $workspaceStore!
|
||||
})
|
||||
const app_w_draft_: AppWithLastVersionWDraft = structuredClone(stateSnapshot(app_w_draft))
|
||||
const app_w_draft_: AppWithLastVersionWDraft = clone(app_w_draft)
|
||||
savedApp = {
|
||||
summary: app_w_draft_.summary,
|
||||
value: app_w_draft_.value as App,
|
||||
@@ -201,7 +200,7 @@
|
||||
function onRestore(ev: any) {
|
||||
sendUserToast('App restored from previous deployment')
|
||||
app = ev.detail
|
||||
const app_ = structuredClone(stateSnapshot(app!))
|
||||
const app_ = clone(app!)
|
||||
savedApp = {
|
||||
summary: app_.summary,
|
||||
value: app_.value as App,
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
import { AppService, DraftService } from '$lib/gen'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { page } from '$app/stores'
|
||||
import { cleanValueProperties, decodeState, type Value } from '$lib/utils'
|
||||
import { cleanValueProperties, decodeState, type Value, clone} from '$lib/utils'
|
||||
import { afterNavigate, replaceState } from '$app/navigation'
|
||||
import { goto } from '$lib/navigation'
|
||||
import { sendUserToast, type ToastAction } from '$lib/toast'
|
||||
import DiffDrawer from '$lib/components/DiffDrawer.svelte'
|
||||
import type { HiddenRunnable } from '$lib/components/apps/types'
|
||||
import RawAppEditor from '$lib/components/raw_apps/RawAppEditor.svelte'
|
||||
import { stateSnapshot } from '$lib/svelte5Utils.svelte'
|
||||
|
||||
let files: Record<string, string> | undefined = undefined
|
||||
let runnables = {}
|
||||
@@ -63,7 +62,7 @@
|
||||
path,
|
||||
workspace: $workspaceStore!
|
||||
})
|
||||
const app_w_draft_ = structuredClone(stateSnapshot(app_w_draft))
|
||||
const app_w_draft_ = clone(app_w_draft)
|
||||
savedApp = {
|
||||
summary: app_w_draft_.summary,
|
||||
value: app_w_draft_.value as any,
|
||||
@@ -191,9 +190,9 @@
|
||||
extractRawApp(prev)
|
||||
savedApp = {
|
||||
summary: prev.summary,
|
||||
value: structuredClone(stateSnapshot(prev.value)),
|
||||
value: clone(prev.value),
|
||||
path: prev.path,
|
||||
policy: structuredClone(stateSnapshot(policy)),
|
||||
policy: clone(policy),
|
||||
custom_path: prev.custom_path
|
||||
}
|
||||
redraw++
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
decodeState,
|
||||
emptySchema,
|
||||
orderedJsonStringify,
|
||||
type StateStore
|
||||
type StateStore,
|
||||
clone
|
||||
} from '$lib/utils'
|
||||
import { initFlow } from '$lib/components/flows/flowStore.svelte'
|
||||
import { goto } from '$lib/navigation'
|
||||
@@ -158,10 +159,10 @@
|
||||
path: $page.params.path
|
||||
})
|
||||
savedFlow = {
|
||||
...structuredClone($state.snapshot(flowWithDraft)),
|
||||
...clone(flowWithDraft),
|
||||
draft: flowWithDraft.draft
|
||||
? {
|
||||
...structuredClone($state.snapshot(flowWithDraft.draft)),
|
||||
...clone(flowWithDraft.draft),
|
||||
path: flowWithDraft.draft.path ?? flowWithDraft.path // backward compatibility for old drafts missing path
|
||||
}
|
||||
: undefined
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { page } from '$app/stores'
|
||||
import { initialArgsStore, workspaceStore } from '$lib/stores'
|
||||
import ScriptBuilder from '$lib/components/ScriptBuilder.svelte'
|
||||
import { decodeState, cleanValueProperties, orderedJsonStringify } from '$lib/utils'
|
||||
import { decodeState, cleanValueProperties, orderedJsonStringify, clone} from '$lib/utils'
|
||||
import { goto } from '$lib/navigation'
|
||||
import { replaceState } from '$app/navigation'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
@@ -87,14 +87,14 @@
|
||||
workspace: $workspaceStore!,
|
||||
hash
|
||||
})
|
||||
savedScript = structuredClone($state.snapshot(scriptByHash)) as NewScriptWithDraft
|
||||
savedScript = clone(scriptByHash) as NewScriptWithDraft
|
||||
script = { ...scriptByHash, parent_hash: hash, lock: undefined }
|
||||
} else {
|
||||
const scriptWithDraft = await ScriptService.getScriptByPathWithDraft({
|
||||
workspace: $workspaceStore!,
|
||||
path: $page.params.path
|
||||
})
|
||||
savedScript = structuredClone($state.snapshot(scriptWithDraft))
|
||||
savedScript = clone(scriptWithDraft)
|
||||
if (scriptWithDraft.draft != undefined) {
|
||||
script = scriptWithDraft.draft
|
||||
scriptBuilder?.setDraftTriggers(script.draft_triggers)
|
||||
|
||||
Reference in New Issue
Block a user