diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f664e6685..36dda53ec5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## [1.457.1](https://github.com/windmill-labs/windmill/compare/v1.457.0...v1.457.1) (2025-02-05) + + +### Bug Fixes + +* fix autoscaling inc increase by customized parameter ([a457c01](https://github.com/windmill-labs/windmill/commit/a457c0137cd60901619817cc2a3906def64667ac)) +* preprocessor args python ([#5210](https://github.com/windmill-labs/windmill/issues/5210)) ([8a446a6](https://github.com/windmill-labs/windmill/commit/8a446a658a1b8e82fd8c3a051dd7274df8c54c71)) + +## [1.457.0](https://github.com/windmill-labs/windmill/compare/v1.456.0...v1.457.0) (2025-02-04) + + +### Features + +* more AI models ([#5207](https://github.com/windmill-labs/windmill/issues/5207)) ([245c871](https://github.com/windmill-labs/windmill/commit/245c8719fc4bf9779be6c653f057d9ffb2724886)) +* **python:** make S3 cache arch specific ([#5196](https://github.com/windmill-labs/windmill/issues/5196)) ([0e80775](https://github.com/windmill-labs/windmill/commit/0e80775d6d2bd1931fed6d5a1d63fc2e70980d55)) + + +### Bug Fixes + +* hide values of WHITELIST_ENVS ([62bfec0](https://github.com/windmill-labs/windmill/commit/62bfec029c00fd067b9906f546b3c9597a54c319)) +* **python:** clear env before installing/finding python ([#5209](https://github.com/windmill-labs/windmill/issues/5209)) ([97c1134](https://github.com/windmill-labs/windmill/commit/97c11340c3175ba946ac6fc77481899fed508af5)) +* support specialization of list of strings to list of enums ([76afbc3](https://github.com/windmill-labs/windmill/commit/76afbc3df33ec87aff47b0db8c57e64209f8f613)) +* timeout on list_user_usage after 300s ([fd0cd58](https://github.com/windmill-labs/windmill/commit/fd0cd587bbe8f453893ae600ae553ee74eb1ba04)) + ## [1.456.0](https://github.com/windmill-labs/windmill/compare/v1.455.2...v1.456.0) (2025-02-01) diff --git a/backend/.sqlx/query-00b6340396f5121aff49323d12a7e3244ebb2cb864828637e7ff7476a4a4939b.json b/backend/.sqlx/query-00b6340396f5121aff49323d12a7e3244ebb2cb864828637e7ff7476a4a4939b.json new file mode 100644 index 0000000000..389390524e --- /dev/null +++ b/backend/.sqlx/query-00b6340396f5121aff49323d12a7e3244ebb2cb864828637e7ff7476a4a4939b.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT runnable_path FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "runnable_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "00b6340396f5121aff49323d12a7e3244ebb2cb864828637e7ff7476a4a4939b" +} diff --git a/backend/.sqlx/query-00e63eab76d26e148b77e932848de74e8b0943d30481465da453942e299a128f.json b/backend/.sqlx/query-00e63eab76d26e148b77e932848de74e8b0943d30481465da453942e299a128f.json new file mode 100644 index 0000000000..9c1f8d00a7 --- /dev/null +++ b/backend/.sqlx/query-00e63eab76d26e148b77e932848de74e8b0943d30481465da453942e299a128f.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO metrics (id, value)\n VALUES ($1, to_jsonb((\n SELECT EXTRACT(EPOCH FROM now() - scheduled_for)\n FROM v2_job_queue\n WHERE tag = $2 AND running = false AND scheduled_for <= now() - ('3 seconds')::interval\n ORDER BY priority DESC NULLS LAST, scheduled_for LIMIT 1\n )))", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text" + ] + }, + "nullable": [] + }, + "hash": "00e63eab76d26e148b77e932848de74e8b0943d30481465da453942e299a128f" +} diff --git a/backend/.sqlx/query-016bf078cdea0aae4a05ae7e004fad573d5c7cbdca975edc34f36890c824c44b.json b/backend/.sqlx/query-016bf078cdea0aae4a05ae7e004fad573d5c7cbdca975edc34f36890c824c44b.json new file mode 100644 index 0000000000..28a9e33022 --- /dev/null +++ b/backend/.sqlx/query-016bf078cdea0aae4a05ae7e004fad573d5c7cbdca975edc34f36890c824c44b.json @@ -0,0 +1,71 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n email AS \"email!\",\n created_by AS \"created_by!\",\n parent_job, permissioned_as AS \"permissioned_as!\",\n script_path, schedule_path, flow_step_id, root_job,\n scheduled_for AS \"scheduled_for!: chrono::DateTime\"\n FROM queue WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "email!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "parent_job", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "permissioned_as!", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "schedule_path", + "type_info": "Varchar" + }, + { + "ordinal": 6, + "name": "flow_step_id", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "root_job", + "type_info": "Uuid" + }, + { + "ordinal": 8, + "name": "scheduled_for!: chrono::DateTime", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true, + true, + true, + true, + true + ] + }, + "hash": "016bf078cdea0aae4a05ae7e004fad573d5c7cbdca975edc34f36890c824c44b" +} diff --git a/backend/.sqlx/query-036c84bb9ce72748956bc9c18fbe276444fab025a281dc4784596b0e31c1cb9d.json b/backend/.sqlx/query-036c84bb9ce72748956bc9c18fbe276444fab025a281dc4784596b0e31c1cb9d.json new file mode 100644 index 0000000000..dedd3fd272 --- /dev/null +++ b/backend/.sqlx/query-036c84bb9ce72748956bc9c18fbe276444fab025a281dc4784596b0e31c1cb9d.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "create index concurrently if not exists ix_job_workspace_id_created_at_new_9 ON v2_job (workspace_id, created_at DESC) where kind in ('dependencies', 'flowdependencies', 'appdependencies') AND parent_job IS NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "036c84bb9ce72748956bc9c18fbe276444fab025a281dc4784596b0e31c1cb9d" +} diff --git a/backend/.sqlx/query-05d6405b2cc6aabf564a10f05402878e9f2a13e0ce0dad42723f95ac7fb15d4b.json b/backend/.sqlx/query-05d6405b2cc6aabf564a10f05402878e9f2a13e0ce0dad42723f95ac7fb15d4b.json new file mode 100644 index 0000000000..195c9bfe92 --- /dev/null +++ b/backend/.sqlx/query-05d6405b2cc6aabf564a10f05402878e9f2a13e0ce0dad42723f95ac7fb15d4b.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT success AS \"success!\"\n FROM v2_as_completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "05d6405b2cc6aabf564a10f05402878e9f2a13e0ce0dad42723f95ac7fb15d4b" +} diff --git a/backend/.sqlx/query-06731936fb073169b3a1a8a9817f1e669b60edccd260625a95094b7244f5fb83.json b/backend/.sqlx/query-06731936fb073169b3a1a8a9817f1e669b60edccd260625a95094b7244f5fb83.json new file mode 100644 index 0000000000..c509986552 --- /dev/null +++ b/backend/.sqlx/query-06731936fb073169b3a1a8a9817f1e669b60edccd260625a95094b7244f5fb83.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['retry'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "06731936fb073169b3a1a8a9817f1e669b60edccd260625a95094b7244f5fb83" +} diff --git a/backend/.sqlx/query-07a7f1da7ee77324a73eb5b3743e4a801e0c446c55fc9fd8bc75e36d58073bee.json b/backend/.sqlx/query-07a7f1da7ee77324a73eb5b3743e4a801e0c446c55fc9fd8bc75e36d58073bee.json new file mode 100644 index 0000000000..15f9729ee1 --- /dev/null +++ b/backend/.sqlx/query-07a7f1da7ee77324a73eb5b3743e4a801e0c446c55fc9fd8bc75e36d58073bee.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n substr(concat(coalesce(completed_job.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs,\n mem_peak,\n CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\",\n job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset,\n created_by AS \"created_by!\"\n FROM completed_job\n LEFT JOIN job_logs ON job_logs.job_id = completed_job.id \n WHERE completed_job.workspace_id = $2 AND completed_job.id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 1, + "name": "mem_peak", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 4, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Int4", + "Text", + "Uuid" + ] + }, + "nullable": [ + null, + true, + null, + null, + true + ] + }, + "hash": "07a7f1da7ee77324a73eb5b3743e4a801e0c446c55fc9fd8bc75e36d58073bee" +} diff --git a/backend/.sqlx/query-099894523449a70eb301ecd1d744210d39f405016ffec374e4b15a2528baccb5.json b/backend/.sqlx/query-099894523449a70eb301ecd1d744210d39f405016ffec374e4b15a2528baccb5.json new file mode 100644 index 0000000000..8a4a9b9c20 --- /dev/null +++ b/backend/.sqlx/query-099894523449a70eb301ecd1d744210d39f405016ffec374e4b15a2528baccb5.json @@ -0,0 +1,198 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT schedule.*, t.jobs FROM schedule, LATERAL ( SELECT ARRAY (SELECT json_build_object('id', id, 'success', success, 'duration_ms', duration_ms) FROM v2_as_completed_job WHERE\n v2_as_completed_job.schedule_path = schedule.path AND v2_as_completed_job.workspace_id = $1 AND parent_job IS NULL AND is_skipped = False ORDER BY started_at DESC LIMIT 20) AS jobs ) t\n WHERE schedule.workspace_id = $1 ORDER BY schedule.edited_at desc LIMIT $2 OFFSET $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "workspace_id", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "path", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "edited_by", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "edited_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 4, + "name": "schedule", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "enabled", + "type_info": "Bool" + }, + { + "ordinal": 6, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "args", + "type_info": "Jsonb" + }, + { + "ordinal": 8, + "name": "extra_perms", + "type_info": "Jsonb" + }, + { + "ordinal": 9, + "name": "is_flow", + "type_info": "Bool" + }, + { + "ordinal": 10, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 11, + "name": "error", + "type_info": "Text" + }, + { + "ordinal": 12, + "name": "timezone", + "type_info": "Varchar" + }, + { + "ordinal": 13, + "name": "on_failure", + "type_info": "Varchar" + }, + { + "ordinal": 14, + "name": "on_recovery", + "type_info": "Varchar" + }, + { + "ordinal": 15, + "name": "on_failure_times", + "type_info": "Int4" + }, + { + "ordinal": 16, + "name": "on_failure_exact", + "type_info": "Bool" + }, + { + "ordinal": 17, + "name": "on_failure_extra_args", + "type_info": "Json" + }, + { + "ordinal": 18, + "name": "on_recovery_times", + "type_info": "Int4" + }, + { + "ordinal": 19, + "name": "on_recovery_extra_args", + "type_info": "Json" + }, + { + "ordinal": 20, + "name": "ws_error_handler_muted", + "type_info": "Bool" + }, + { + "ordinal": 21, + "name": "retry", + "type_info": "Jsonb" + }, + { + "ordinal": 22, + "name": "summary", + "type_info": "Varchar" + }, + { + "ordinal": 23, + "name": "no_flow_overlap", + "type_info": "Bool" + }, + { + "ordinal": 24, + "name": "tag", + "type_info": "Varchar" + }, + { + "ordinal": 25, + "name": "paused_until", + "type_info": "Timestamptz" + }, + { + "ordinal": 26, + "name": "on_success", + "type_info": "Varchar" + }, + { + "ordinal": 27, + "name": "on_success_extra_args", + "type_info": "Json" + }, + { + "ordinal": 28, + "name": "cron_version", + "type_info": "Text" + }, + { + "ordinal": 29, + "name": "jobs", + "type_info": "JsonArray" + } + ], + "parameters": { + "Left": [ + "Text", + "Int8", + "Int8" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + false, + true, + false, + false, + false, + true, + false, + true, + true, + true, + true, + true, + true, + true, + false, + true, + true, + false, + true, + true, + true, + true, + true, + null + ] + }, + "hash": "099894523449a70eb301ecd1d744210d39f405016ffec374e4b15a2528baccb5" +} diff --git a/backend/.sqlx/query-0a7fb25aa9404c2e6eabfd5d912ed0c1018f249c7ec2a5564787175aa667a456.json b/backend/.sqlx/query-0a7fb25aa9404c2e6eabfd5d912ed0c1018f249c7ec2a5564787175aa667a456.json new file mode 100644 index 0000000000..d340c0e2bc --- /dev/null +++ b/backend/.sqlx/query-0a7fb25aa9404c2e6eabfd5d912ed0c1018f249c7ec2a5564787175aa667a456.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET labels = (\n SELECT array_agg(DISTINCT all_labels)\n FROM unnest(coalesce(labels, ARRAY[]::TEXT[]) || $2) all_labels\n ) WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "TextArray" + ] + }, + "nullable": [] + }, + "hash": "0a7fb25aa9404c2e6eabfd5d912ed0c1018f249c7ec2a5564787175aa667a456" +} diff --git a/backend/.sqlx/query-286fa00c088df146c08c1934556f06a4243c66787ab8759a8045e60effd2fb77.json b/backend/.sqlx/query-0a9dd1addaf48eeb46eed59abb6daf9819d07b08cf7ca442ea7ec78a9b2b63b2.json similarity index 59% rename from backend/.sqlx/query-286fa00c088df146c08c1934556f06a4243c66787ab8759a8045e60effd2fb77.json rename to backend/.sqlx/query-0a9dd1addaf48eeb46eed59abb6daf9819d07b08cf7ca442ea7ec78a9b2b63b2.json index 790948f378..a0f52168b9 100644 --- a/backend/.sqlx/query-286fa00c088df146c08c1934556f06a4243c66787ab8759a8045e60effd2fb77.json +++ b/backend/.sqlx/query-0a9dd1addaf48eeb46eed59abb6daf9819d07b08cf7ca442ea7ec78a9b2b63b2.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT value\n FROM resource\n WHERE path = $1 AND workspace_id = $2", + "query": "SELECT value\n FROM resource\n WHERE path = $1 AND workspace_id = $2", "describe": { "columns": [ { @@ -19,5 +19,5 @@ true ] }, - "hash": "286fa00c088df146c08c1934556f06a4243c66787ab8759a8045e60effd2fb77" + "hash": "0a9dd1addaf48eeb46eed59abb6daf9819d07b08cf7ca442ea7ec78a9b2b63b2" } diff --git a/backend/.sqlx/query-0bc1c617786bb2fdc71b85442b1d52dbd4c922436edacced18b9620c70e0cc8b.json b/backend/.sqlx/query-0bc1c617786bb2fdc71b85442b1d52dbd4c922436edacced18b9620c70e0cc8b.json new file mode 100644 index 0000000000..104cedde3b --- /dev/null +++ b/backend/.sqlx/query-0bc1c617786bb2fdc71b85442b1d52dbd4c922436edacced18b9620c70e0cc8b.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result #> $3 AS \"result: Json>\"\n FROM v2_job_completed WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + null + ] + }, + "hash": "0bc1c617786bb2fdc71b85442b1d52dbd4c922436edacced18b9620c70e0cc8b" +} diff --git a/backend/.sqlx/query-0c9b5b01f7599ad2590a2be01e35da5f5e318582d0bb8ebca6bff5a87c587111.json b/backend/.sqlx/query-0c9b5b01f7599ad2590a2be01e35da5f5e318582d0bb8ebca6bff5a87c587111.json new file mode 100644 index 0000000000..c87479e8ab --- /dev/null +++ b/backend/.sqlx/query-0c9b5b01f7599ad2590a2be01e35da5f5e318582d0bb8ebca6bff5a87c587111.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT (flow_status->'step')::integer as step, jsonb_array_length(flow_status->'modules') as len\n FROM v2_job_status WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "step", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "len", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "0c9b5b01f7599ad2590a2be01e35da5f5e318582d0bb8ebca6bff5a87c587111" +} diff --git a/backend/.sqlx/query-0d86a31d7d53e52d24df76fa745d968cda48e036139cdaecf4e87d948f8c365e.json b/backend/.sqlx/query-0d86a31d7d53e52d24df76fa745d968cda48e036139cdaecf4e87d948f8c365e.json new file mode 100644 index 0000000000..67c10a27dc --- /dev/null +++ b/backend/.sqlx/query-0d86a31d7d53e52d24df76fa745d968cda48e036139cdaecf4e87d948f8c365e.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE v2_job_status f SET flow_status = JSONB_SET(flow_status, ARRAY['user_states'], JSONB_SET(COALESCE(flow_status->'user_states', '{}'::jsonb), ARRAY[$1], $2))\n FROM v2_job j\n WHERE f.id = $3 AND f.id = j.id AND j.workspace_id = $4 AND kind IN ('flow', 'flowpreview', 'flownode') RETURNING 1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "0d86a31d7d53e52d24df76fa745d968cda48e036139cdaecf4e87d948f8c365e" +} diff --git a/backend/.sqlx/query-0dd236e9bfc27ce6cc3ae5a4995003407d523eb0835f59fa2060b7da88ccf601.json b/backend/.sqlx/query-0dd236e9bfc27ce6cc3ae5a4995003407d523eb0835f59fa2060b7da88ccf601.json new file mode 100644 index 0000000000..88f28ca27b --- /dev/null +++ b/backend/.sqlx/query-0dd236e9bfc27ce6cc3ae5a4995003407d523eb0835f59fa2060b7da88ccf601.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT flow_status->'failure_module'->>'parent_module' FROM v2_job_status WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "0dd236e9bfc27ce6cc3ae5a4995003407d523eb0835f59fa2060b7da88ccf601" +} diff --git a/backend/.sqlx/query-0df84fc35f2780ceb7c473b0165ebab93a4bc1bcab166aae68244ab1f3d4df9f.json b/backend/.sqlx/query-0df84fc35f2780ceb7c473b0165ebab93a4bc1bcab166aae68244ab1f3d4df9f.json new file mode 100644 index 0000000000..d34383496a --- /dev/null +++ b/backend/.sqlx/query-0df84fc35f2780ceb7c473b0165ebab93a4bc1bcab166aae68244ab1f3d4df9f.json @@ -0,0 +1,104 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO completed_job AS cj\n ( workspace_id\n , id\n , parent_job\n , created_by\n , created_at\n , started_at\n , duration_ms\n , success\n , script_hash\n , script_path\n , args\n , result\n , raw_code\n , raw_lock\n , canceled\n , canceled_by\n , canceled_reason\n , job_kind\n , schedule_path\n , permissioned_as\n , flow_status\n , raw_flow\n , is_flow_step\n , is_skipped\n , language\n , email\n , visible_to_owner\n , mem_peak\n , tag\n , priority\n )\n VALUES ($1, $2, $3, $4, $5, COALESCE($6, now()), COALESCE($30::bigint, (EXTRACT('epoch' FROM (now())) - EXTRACT('epoch' FROM (COALESCE($6, now()))))*1000), $7, $8, $9,$10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29)\n ON CONFLICT (id) DO UPDATE SET success = $7, result = $11 RETURNING duration_ms AS \"duration_ms!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "duration_ms!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Uuid", + "Uuid", + "Varchar", + "Timestamptz", + "Timestamptz", + "Bool", + "Int8", + "Varchar", + "Jsonb", + "Jsonb", + "Text", + "Text", + "Bool", + "Varchar", + "Text", + { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + }, + "Varchar", + "Varchar", + "Jsonb", + "Jsonb", + "Bool", + "Bool", + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Varchar", + "Bool", + "Int4", + "Varchar", + "Int2", + "Int8" + ] + }, + "nullable": [ + true + ] + }, + "hash": "0df84fc35f2780ceb7c473b0165ebab93a4bc1bcab166aae68244ab1f3d4df9f" +} diff --git a/backend/.sqlx/query-0ea5ba568ec0f62b808fe938a41174646b6bdd658b8461db1bb90a871d076718.json b/backend/.sqlx/query-0ea5ba568ec0f62b808fe938a41174646b6bdd658b8461db1bb90a871d076718.json new file mode 100644 index 0000000000..19fe394067 --- /dev/null +++ b/backend/.sqlx/query-0ea5ba568ec0f62b808fe938a41174646b6bdd658b8461db1bb90a871d076718.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET workspace_id = $1 WHERE workspace_id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text" + ] + }, + "nullable": [] + }, + "hash": "0ea5ba568ec0f62b808fe938a41174646b6bdd658b8461db1bb90a871d076718" +} diff --git a/backend/.sqlx/query-0ef638eb62cb8b285cb20855679486b78eae82901a0128b9c9c837c9e9e91212.json b/backend/.sqlx/query-0ef638eb62cb8b285cb20855679486b78eae82901a0128b9c9c837c9e9e91212.json new file mode 100644 index 0000000000..85523ee5c3 --- /dev/null +++ b/backend/.sqlx/query-0ef638eb62cb8b285cb20855679486b78eae82901a0128b9c9c837c9e9e91212.json @@ -0,0 +1,38 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n success AS \"success!\",\n result AS \"result: Json>\",\n started_at AS \"started_at!\"FROM completed_job WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4\n ORDER BY created_at DESC\n LIMIT $5", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "result: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "started_at!", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Text", + "Uuid", + "Int8" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "0ef638eb62cb8b285cb20855679486b78eae82901a0128b9c9c837c9e9e91212" +} diff --git a/backend/.sqlx/query-0f23535bdfe222eee5a27d52fe4fdce4ad1a487afcd62735ef25386586cfc036.json b/backend/.sqlx/query-0f23535bdfe222eee5a27d52fe4fdce4ad1a487afcd62735ef25386586cfc036.json new file mode 100644 index 0000000000..c30c505a7b --- /dev/null +++ b/backend/.sqlx/query-0f23535bdfe222eee5a27d52fe4fdce4ad1a487afcd62735ef25386586cfc036.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job_queue WHERE id = any($1) AND workspace_id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray", + "Text" + ] + }, + "nullable": [] + }, + "hash": "0f23535bdfe222eee5a27d52fe4fdce4ad1a487afcd62735ef25386586cfc036" +} diff --git a/backend/.sqlx/query-0f9c4c2fda3beeafc940e14a6c2c44d61782aaae68ffa413f37b13dc6cf4d83d.json b/backend/.sqlx/query-0f9c4c2fda3beeafc940e14a6c2c44d61782aaae68ffa413f37b13dc6cf4d83d.json new file mode 100644 index 0000000000..fc68dc313a --- /dev/null +++ b/backend/.sqlx/query-0f9c4c2fda3beeafc940e14a6c2c44d61782aaae68ffa413f37b13dc6cf4d83d.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = jsonb_set(\n jsonb_set(\n COALESCE(flow_status, '{}'::jsonb),\n array[$1],\n COALESCE(flow_status->$1, '{}'::jsonb)\n ),\n array[$1, 'started_at'],\n to_jsonb(now()::text)\n )\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "0f9c4c2fda3beeafc940e14a6c2c44d61782aaae68ffa413f37b13dc6cf4d83d" +} diff --git a/backend/.sqlx/query-0230bd64d2b6719c3536a106e18a68c7b43b3a9a9efa92b5517132e9c0d8a25b.json b/backend/.sqlx/query-103ef3cf5cf4d25d780e4aefd5b290d810a5e8ea6458d9f9fd484ced549ea82e.json similarity index 50% rename from backend/.sqlx/query-0230bd64d2b6719c3536a106e18a68c7b43b3a9a9efa92b5517132e9c0d8a25b.json rename to backend/.sqlx/query-103ef3cf5cf4d25d780e4aefd5b290d810a5e8ea6458d9f9fd484ced549ea82e.json index e38ddcb726..15d772ab16 100644 --- a/backend/.sqlx/query-0230bd64d2b6719c3536a106e18a68c7b43b3a9a9efa92b5517132e9c0d8a25b.json +++ b/backend/.sqlx/query-103ef3cf5cf4d25d780e4aefd5b290d810a5e8ea6458d9f9fd484ced549ea82e.json @@ -1,21 +1,22 @@ { "db_name": "PostgreSQL", - "query": "SELECT ai_resource, code_completion_enabled FROM workspace_settings WHERE workspace_id = $1", + "query": "SELECT value, resource_type FROM resource WHERE path = $1 AND workspace_id = $2", "describe": { "columns": [ { "ordinal": 0, - "name": "ai_resource", + "name": "value", "type_info": "Jsonb" }, { "ordinal": 1, - "name": "code_completion_enabled", - "type_info": "Bool" + "name": "resource_type", + "type_info": "Varchar" } ], "parameters": { "Left": [ + "Text", "Text" ] }, @@ -24,5 +25,5 @@ false ] }, - "hash": "0230bd64d2b6719c3536a106e18a68c7b43b3a9a9efa92b5517132e9c0d8a25b" + "hash": "103ef3cf5cf4d25d780e4aefd5b290d810a5e8ea6458d9f9fd484ced549ea82e" } diff --git a/backend/.sqlx/query-119469ebfe8572c78ed3ee5ab5b1a6a1cb1b0f31e357b5370f9bb7eab1e20a7b.json b/backend/.sqlx/query-119469ebfe8572c78ed3ee5ab5b1a6a1cb1b0f31e357b5370f9bb7eab1e20a7b.json new file mode 100644 index 0000000000..bb701df30d --- /dev/null +++ b/backend/.sqlx/query-119469ebfe8572c78ed3ee5ab5b1a6a1cb1b0f31e357b5370f9bb7eab1e20a7b.json @@ -0,0 +1,27 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH uuid_table as (\n select gen_random_uuid() as uuid from generate_series(1, $6)\n )\n INSERT INTO job\n (id, workspace_id, raw_code, raw_lock, raw_flow, tag)\n (SELECT uuid, $1, $2, $3, $4, $5 FROM uuid_table)\n RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Text", + "Jsonb", + "Varchar", + "Int4" + ] + }, + "nullable": [ + true + ] + }, + "hash": "119469ebfe8572c78ed3ee5ab5b1a6a1cb1b0f31e357b5370f9bb7eab1e20a7b" +} diff --git a/backend/.sqlx/query-11d59fb24aeb40f82e6fd11b697f26e14a0ae955fabeecc4a936b95937bf04d1.json b/backend/.sqlx/query-11d59fb24aeb40f82e6fd11b697f26e14a0ae955fabeecc4a936b95937bf04d1.json new file mode 100644 index 0000000000..3375abd07a --- /dev/null +++ b/backend/.sqlx/query-11d59fb24aeb40f82e6fd11b697f26e14a0ae955fabeecc4a936b95937bf04d1.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = jsonb_set(\n jsonb_set(flow_status, ARRAY['modules', $4::INTEGER::TEXT, 'job'], to_jsonb($1::UUID::TEXT)),\n ARRAY['modules', $4::INTEGER::TEXT, 'type'],\n to_jsonb('InProgress'::text)\n )\n WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "11d59fb24aeb40f82e6fd11b697f26e14a0ae955fabeecc4a936b95937bf04d1" +} diff --git a/backend/.sqlx/query-11db65c493990f6935103033b2fbb0c08ae6d91b05b2f3f7c89a990d1d5a5f8a.json b/backend/.sqlx/query-11db65c493990f6935103033b2fbb0c08ae6d91b05b2f3f7c89a990d1d5a5f8a.json new file mode 100644 index 0000000000..1afb036030 --- /dev/null +++ b/backend/.sqlx/query-11db65c493990f6935103033b2fbb0c08ae6d91b05b2f3f7c89a990d1d5a5f8a.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(id) FROM v2_as_queue WHERE running = true AND email = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "11db65c493990f6935103033b2fbb0c08ae6d91b05b2f3f7c89a990d1d5a5f8a" +} diff --git a/backend/.sqlx/query-1252ef3a652ffb99529c2ce84928197fa15efb9c78d68e3a191c01a04efe153f.json b/backend/.sqlx/query-1252ef3a652ffb99529c2ce84928197fa15efb9c78d68e3a191c01a04efe153f.json new file mode 100644 index 0000000000..d3d6dd84cf --- /dev/null +++ b/backend/.sqlx/query-1252ef3a652ffb99529c2ce84928197fa15efb9c78d68e3a191c01a04efe153f.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4),\n ARRAY['modules', $1::TEXT, 'iterator', 'index'],\n ((flow_status->'modules'->$1::int->'iterator'->>'index')::int + 1)::text::jsonb\n )\n WHERE id = $2\n RETURNING (flow_status->'modules'->$1::int->'iterator'->>'index')::int", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "int4", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [ + null + ] + }, + "hash": "1252ef3a652ffb99529c2ce84928197fa15efb9c78d68e3a191c01a04efe153f" +} diff --git a/backend/.sqlx/query-12828c9b2964f2b484a68de1e01b65cdcd277257192ee0a6d18a00f41bce49d4.json b/backend/.sqlx/query-12828c9b2964f2b484a68de1e01b65cdcd277257192ee0a6d18a00f41bce49d4.json new file mode 100644 index 0000000000..84c0804c95 --- /dev/null +++ b/backend/.sqlx/query-12828c9b2964f2b484a68de1e01b65cdcd277257192ee0a6d18a00f41bce49d4.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT suspend > 0 AS \"r!\" FROM v2_job_queue WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "r!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "12828c9b2964f2b484a68de1e01b65cdcd277257192ee0a6d18a00f41bce49d4" +} diff --git a/backend/.sqlx/query-14540eef4594d9282cee3df4f92a7ed2e67243e5c1522850045b2da42fa914bc.json b/backend/.sqlx/query-14540eef4594d9282cee3df4f92a7ed2e67243e5c1522850045b2da42fa914bc.json new file mode 100644 index 0000000000..b10496550f --- /dev/null +++ b/backend/.sqlx/query-14540eef4594d9282cee3df4f92a7ed2e67243e5c1522850045b2da42fa914bc.json @@ -0,0 +1,91 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n queue.job_kind AS \"job_kind!: JobKind\",\n queue.script_hash AS \"script_hash: ScriptHash\",\n queue.raw_flow AS \"raw_flow: sqlx::types::Json>\",\n completed_job.parent_job AS \"parent_job: Uuid\",\n completed_job.created_at AS \"created_at!: chrono::NaiveDateTime\",\n completed_job.created_by AS \"created_by!\",\n queue.script_path,\n queue.args AS \"args: sqlx::types::Json>\"\n FROM queue\n JOIN completed_job ON completed_job.parent_job = queue.id\n WHERE completed_job.id = $1 AND completed_job.workspace_id = $2\n LIMIT 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "job_kind!: JobKind", + "type_info": { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + } + }, + { + "ordinal": 1, + "name": "script_hash: ScriptHash", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "raw_flow: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "parent_job: Uuid", + "type_info": "Uuid" + }, + { + "ordinal": 4, + "name": "created_at!: chrono::NaiveDateTime", + "type_info": "Timestamptz" + }, + { + "ordinal": 5, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 6, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "args: sqlx::types::Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true, + true, + true, + true + ] + }, + "hash": "14540eef4594d9282cee3df4f92a7ed2e67243e5c1522850045b2da42fa914bc" +} diff --git a/backend/.sqlx/query-15557c0acea71cee03f42516553fb4f5709e0e1a02a0187e88fa5d9e94ffb91a.json b/backend/.sqlx/query-15557c0acea71cee03f42516553fb4f5709e0e1a02a0187e88fa5d9e94ffb91a.json new file mode 100644 index 0000000000..dc8718bda6 --- /dev/null +++ b/backend/.sqlx/query-15557c0acea71cee03f42516553fb4f5709e0e1a02a0187e88fa5d9e94ffb91a.json @@ -0,0 +1,104 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO queue\n (workspace_id, id, running, parent_job, created_by, permissioned_as, scheduled_for, \n script_hash, script_path, raw_code, raw_lock, args, job_kind, schedule_path, raw_flow, flow_status, is_flow_step, language, started_at, same_worker, pre_run_error, email, visible_to_owner, root_job, tag, concurrent_limit, concurrency_time_window_s, timeout, flow_step_id, cache_ttl, priority, last_ping)\n VALUES ($1, $2, $3, $4, $5, $6, COALESCE($7, now()), $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, CASE WHEN $3 THEN now() END, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, NULL) RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Uuid", + "Bool", + "Uuid", + "Varchar", + "Varchar", + "Timestamptz", + "Int8", + "Varchar", + "Text", + "Text", + "Jsonb", + { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + }, + "Varchar", + "Jsonb", + "Jsonb", + "Bool", + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Bool", + "Text", + "Varchar", + "Bool", + "Uuid", + "Varchar", + "Int4", + "Int4", + "Int4", + "Varchar", + "Int4", + "Int2" + ] + }, + "nullable": [ + true + ] + }, + "hash": "15557c0acea71cee03f42516553fb4f5709e0e1a02a0187e88fa5d9e94ffb91a" +} diff --git a/backend/.sqlx/query-15697f3b63f88b9cfa33ab0aa64b441961aad80bf9fd0125bcf55a729e556d1e.json b/backend/.sqlx/query-15697f3b63f88b9cfa33ab0aa64b441961aad80bf9fd0125bcf55a729e556d1e.json new file mode 100644 index 0000000000..4199d677a7 --- /dev/null +++ b/backend/.sqlx/query-15697f3b63f88b9cfa33ab0aa64b441961aad80bf9fd0125bcf55a729e556d1e.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n DELETE\n FROM parallel_monitor_lock\n WHERE last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval \n RETURNING parent_flow_id, job_id, last_ping, (SELECT workspace_id FROM queue q\n WHERE q.id = parent_flow_id AND q.running = true AND q.canceled = false) AS workspace_id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "parent_flow_id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "job_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "last_ping", + "type_info": "Timestamptz" + }, + { + "ordinal": 3, + "name": "workspace_id", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + true, + null + ] + }, + "hash": "15697f3b63f88b9cfa33ab0aa64b441961aad80bf9fd0125bcf55a729e556d1e" +} diff --git a/backend/.sqlx/query-1730f39fd1793d45fbb41b21389c61296a3ff7489ae12f52a19f9543173ac597.json b/backend/.sqlx/query-1730f39fd1793d45fbb41b21389c61296a3ff7489ae12f52a19f9543173ac597.json index b6fee2c5ff..03da2cee85 100644 --- a/backend/.sqlx/query-1730f39fd1793d45fbb41b21389c61296a3ff7489ae12f52a19f9543173ac597.json +++ b/backend/.sqlx/query-1730f39fd1793d45fbb41b21389c61296a3ff7489ae12f52a19f9543173ac597.json @@ -70,68 +70,73 @@ }, { "ordinal": 13, - "name": "code_completion_enabled", - "type_info": "Bool" - }, - { - "ordinal": 14, "name": "error_handler_extra_args", "type_info": "Json" }, { - "ordinal": 15, + "ordinal": 14, "name": "error_handler_muted_on_cancel", "type_info": "Bool" }, { - "ordinal": 16, + "ordinal": 15, "name": "large_file_storage", "type_info": "Jsonb" }, { - "ordinal": 17, + "ordinal": 16, "name": "git_sync", "type_info": "Jsonb" }, { - "ordinal": 18, + "ordinal": 17, "name": "default_app", "type_info": "Varchar" }, { - "ordinal": 19, + "ordinal": 18, "name": "auto_add", "type_info": "Bool" }, { - "ordinal": 20, + "ordinal": 19, "name": "automatic_billing", "type_info": "Bool" }, { - "ordinal": 21, + "ordinal": 20, "name": "default_scripts", "type_info": "Jsonb" }, { - "ordinal": 22, + "ordinal": 21, "name": "deploy_ui", "type_info": "Jsonb" }, { - "ordinal": 23, + "ordinal": 22, "name": "mute_critical_alerts", "type_info": "Bool" }, { - "ordinal": 24, + "ordinal": 23, "name": "color", "type_info": "Varchar" }, { - "ordinal": 25, + "ordinal": 24, "name": "operator_settings", "type_info": "Jsonb" + }, + { + "ordinal": 25, + "name": "ai_models", + "type_info": "VarcharArray" + }, + { + "ordinal": 26, + "name": "code_completion_model", + "type_info": "Varchar" } ], "parameters": { @@ -153,7 +158,6 @@ true, true, true, - false, true, false, true, @@ -165,6 +169,8 @@ true, true, true, + true, + false, true ] }, diff --git a/backend/.sqlx/query-173fbfd3ca2344fd08f73af75524c917d27fdb6273a35a563292b1f0701dc6ed.json b/backend/.sqlx/query-173fbfd3ca2344fd08f73af75524c917d27fdb6273a35a563292b1f0701dc6ed.json new file mode 100644 index 0000000000..214bf50c6e --- /dev/null +++ b/backend/.sqlx/query-173fbfd3ca2344fd08f73af75524c917d27fdb6273a35a563292b1f0701dc6ed.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['failure_module'], $1),\n ARRAY['step'],\n $2\n )\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "173fbfd3ca2344fd08f73af75524c917d27fdb6273a35a563292b1f0701dc6ed" +} diff --git a/backend/.sqlx/query-17851a0710b80ffd6bebe42012a354665dff01554549ea7bbbb9953c68231296.json b/backend/.sqlx/query-17851a0710b80ffd6bebe42012a354665dff01554549ea7bbbb9953c68231296.json new file mode 100644 index 0000000000..eefc009b5e --- /dev/null +++ b/backend/.sqlx/query-17851a0710b80ffd6bebe42012a354665dff01554549ea7bbbb9953c68231296.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = JSONB_SET(\n flow_status,\n ARRAY['modules', $1::TEXT, 'iterator', 'index'],\n ((flow_status->'modules'->$1::int->'iterator'->>'index')::int + 1)::text::jsonb\n )\n WHERE id = $2\n RETURNING (flow_status->'modules'->$1::int->'iterator'->>'index')::int", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "int4", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "17851a0710b80ffd6bebe42012a354665dff01554549ea7bbbb9953c68231296" +} diff --git a/backend/.sqlx/query-17f04341c5c52173a776b71672f9e4d932d2f072b6c08ce419e4b95a2fd83e96.json b/backend/.sqlx/query-17f04341c5c52173a776b71672f9e4d932d2f072b6c08ce419e4b95a2fd83e96.json new file mode 100644 index 0000000000..65ae96f587 --- /dev/null +++ b/backend/.sqlx/query-17f04341c5c52173a776b71672f9e4d932d2f072b6c08ce419e4b95a2fd83e96.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH zombie_jobs AS (\n UPDATE queue SET running = false, started_at = null\n WHERE last_ping < now() - ($1 || ' seconds')::interval\n AND running = true AND job_kind NOT IN ('flow', 'flowpreview', 'flownode', 'singlescriptflow') AND same_worker = false\n RETURNING id, workspace_id, last_ping\n ),\n update_concurrency AS (\n UPDATE concurrency_counter cc\n SET job_uuids = job_uuids - zj.id::text\n FROM zombie_jobs zj\n INNER JOIN concurrency_key ck ON ck.job_id = zj.id\n WHERE cc.concurrency_id = ck.key\n )\n SELECT id AS \"id!\", workspace_id AS \"workspace_id!\", last_ping FROM zombie_jobs", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "workspace_id!", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "last_ping", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "17f04341c5c52173a776b71672f9e4d932d2f072b6c08ce419e4b95a2fd83e96" +} diff --git a/backend/.sqlx/query-1850552883e67da181d68ff5c4e1babaa2fe072900b57e78e461590a6dafb682.json b/backend/.sqlx/query-1850552883e67da181d68ff5c4e1babaa2fe072900b57e78e461590a6dafb682.json new file mode 100644 index 0000000000..037e63ae49 --- /dev/null +++ b/backend/.sqlx/query-1850552883e67da181d68ff5c4e1babaa2fe072900b57e78e461590a6dafb682.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['preprocessor_module'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "1850552883e67da181d68ff5c4e1babaa2fe072900b57e78e461590a6dafb682" +} diff --git a/backend/.sqlx/query-19cc8499f682ec34d54bc4f694cb281a9bd7f5431c646c6268513751fff95395.json b/backend/.sqlx/query-19cc8499f682ec34d54bc4f694cb281a9bd7f5431c646c6268513751fff95395.json new file mode 100644 index 0000000000..0c379a7bdb --- /dev/null +++ b/backend/.sqlx/query-19cc8499f682ec34d54bc4f694cb281a9bd7f5431c646c6268513751fff95395.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT coalesce(COUNT(*) FILTER(WHERE suspend = 0 AND running = false), 0) as \"database_length!\", coalesce(COUNT(*) FILTER(WHERE suspend > 0), 0) as \"suspended!\" FROM v2_as_queue WHERE (workspace_id = $1 OR $2) AND scheduled_for <= now()", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "database_length!", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "suspended!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "19cc8499f682ec34d54bc4f694cb281a9bd7f5431c646c6268513751fff95395" +} diff --git a/backend/.sqlx/query-1a85ca0a6d0ba5ab3462907e35037136fd123f80389abe6ebbcf12084da45868.json b/backend/.sqlx/query-1a85ca0a6d0ba5ab3462907e35037136fd123f80389abe6ebbcf12084da45868.json new file mode 100644 index 0000000000..1d83c36fd8 --- /dev/null +++ b/backend/.sqlx/query-1a85ca0a6d0ba5ab3462907e35037136fd123f80389abe6ebbcf12084da45868.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job_queue WHERE workspace_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "1a85ca0a6d0ba5ab3462907e35037136fd123f80389abe6ebbcf12084da45868" +} diff --git a/backend/.sqlx/query-1a9984fa378634f7f12356407831807b5e3415c28aacbf09cf7bac58bb1d8470.json b/backend/.sqlx/query-1a9984fa378634f7f12356407831807b5e3415c28aacbf09cf7bac58bb1d8470.json new file mode 100644 index 0000000000..3f9c7a61a4 --- /dev/null +++ b/backend/.sqlx/query-1a9984fa378634f7f12356407831807b5e3415c28aacbf09cf7bac58bb1d8470.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(id) FROM v2_job_queue WHERE running = true AND workspace_id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "1a9984fa378634f7f12356407831807b5e3415c28aacbf09cf7bac58bb1d8470" +} diff --git a/backend/.sqlx/query-1b58b90c184ca21d777ea4e264c79aecc2361134a4817c2b9580f2680425352d.json b/backend/.sqlx/query-1b58b90c184ca21d777ea4e264c79aecc2361134a4817c2b9580f2680425352d.json new file mode 100644 index 0000000000..d0b582d17b --- /dev/null +++ b/backend/.sqlx/query-1b58b90c184ca21d777ea4e264c79aecc2361134a4817c2b9580f2680425352d.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT args AS \"args: Json>>\"\n FROM v2_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args: Json>>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "1b58b90c184ca21d777ea4e264c79aecc2361134a4817c2b9580f2680425352d" +} diff --git a/backend/.sqlx/query-6940ddc5ee8d2a1048213d46f52d964b199604ba66dedbe9f89cea727d726a2d.json b/backend/.sqlx/query-1bbef6baa5b8e2522d685df2979bb1e4b9022f5e841afd9eeb08a81688f6c0c8.json similarity index 57% rename from backend/.sqlx/query-6940ddc5ee8d2a1048213d46f52d964b199604ba66dedbe9f89cea727d726a2d.json rename to backend/.sqlx/query-1bbef6baa5b8e2522d685df2979bb1e4b9022f5e841afd9eeb08a81688f6c0c8.json index 4891854d48..4fcd1f0969 100644 --- a/backend/.sqlx/query-6940ddc5ee8d2a1048213d46f52d964b199604ba66dedbe9f89cea727d726a2d.json +++ b/backend/.sqlx/query-1bbef6baa5b8e2522d685df2979bb1e4b9022f5e841afd9eeb08a81688f6c0c8.json @@ -1,15 +1,15 @@ { "db_name": "PostgreSQL", - "query": "UPDATE workspace_settings SET ai_resource = NULL, code_completion_enabled = $1 WHERE workspace_id = $2", + "query": "UPDATE workspace_settings SET ai_resource = NULL, code_completion_model = $1, ai_models = '{}' WHERE workspace_id = $2", "describe": { "columns": [], "parameters": { "Left": [ - "Bool", + "Varchar", "Text" ] }, "nullable": [] }, - "hash": "6940ddc5ee8d2a1048213d46f52d964b199604ba66dedbe9f89cea727d726a2d" + "hash": "1bbef6baa5b8e2522d685df2979bb1e4b9022f5e841afd9eeb08a81688f6c0c8" } diff --git a/backend/.sqlx/query-1d1098cc9367502faa1483627bf534472a6cae70d7964ba019aa2121c3929234.json b/backend/.sqlx/query-1d1098cc9367502faa1483627bf534472a6cae70d7964ba019aa2121c3929234.json new file mode 100644 index 0000000000..abbd8b2a6d --- /dev/null +++ b/backend/.sqlx/query-1d1098cc9367502faa1483627bf534472a6cae70d7964ba019aa2121c3929234.json @@ -0,0 +1,68 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result AS \"result: sqlx::types::Json>\",\n language AS \"language: ScriptLang\",\n flow_status AS \"flow_status: sqlx::types::Json>\",\n success AS \"success!\"\n FROM completed_job\n WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "language: ScriptLang", + "type_info": { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + } + }, + { + "ordinal": 2, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "1d1098cc9367502faa1483627bf534472a6cae70d7964ba019aa2121c3929234" +} diff --git a/backend/.sqlx/query-1d819b829cd92995c39d29540df8cffbcc3334bada244a331a0bd8db06029d42.json b/backend/.sqlx/query-1d819b829cd92995c39d29540df8cffbcc3334bada244a331a0bd8db06029d42.json new file mode 100644 index 0000000000..9f40c5293d --- /dev/null +++ b/backend/.sqlx/query-1d819b829cd92995c39d29540df8cffbcc3334bada244a331a0bd8db06029d42.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job_completed c\n USING v2_job j\n WHERE\n created_at <= now() - ($1::bigint::text || ' s')::interval\n AND completed_at + ($1::bigint::text || ' s')::interval <= now()\n AND c.id = j.id\n RETURNING c.id", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + false + ] + }, + "hash": "1d819b829cd92995c39d29540df8cffbcc3334bada244a331a0bd8db06029d42" +} diff --git a/backend/.sqlx/query-1d842b4c940d788372ed377465e24faa490a4649f74c37bcd0b47ebffc81a2a9.json b/backend/.sqlx/query-1d842b4c940d788372ed377465e24faa490a4649f74c37bcd0b47ebffc81a2a9.json new file mode 100644 index 0000000000..0d5b76374d --- /dev/null +++ b/backend/.sqlx/query-1d842b4c940d788372ed377465e24faa490a4649f74c37bcd0b47ebffc81a2a9.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = jsonb_set(\n jsonb_set(\n COALESCE(flow_status, '{}'::jsonb),\n array[$1],\n COALESCE(flow_status->$1, '{}'::jsonb)\n ),\n array[$1, 'duration_ms'],\n to_jsonb($2::bigint)\n )\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Int8", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "1d842b4c940d788372ed377465e24faa490a4649f74c37bcd0b47ebffc81a2a9" +} diff --git a/backend/.sqlx/query-1d87f41fd1abb9361d795a899120e6b77e24bf5a9044fdc5284d0d7f1e14eafa.json b/backend/.sqlx/query-1d87f41fd1abb9361d795a899120e6b77e24bf5a9044fdc5284d0d7f1e14eafa.json new file mode 100644 index 0000000000..6a79013c0b --- /dev/null +++ b/backend/.sqlx/query-1d87f41fd1abb9361d795a899120e6b77e24bf5a9044fdc5284d0d7f1e14eafa.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO usage (id, is_workspace, month_, usage) \n VALUES ($1, TRUE, EXTRACT(YEAR FROM current_date) * 12 + EXTRACT(MONTH FROM current_date), $2) \n ON CONFLICT (id, is_workspace, month_) DO UPDATE SET usage = usage.usage + $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "1d87f41fd1abb9361d795a899120e6b77e24bf5a9044fdc5284d0d7f1e14eafa" +} diff --git a/backend/.sqlx/query-202e580eacc7907bb34b6464a66fe96ff91951fc8486d1f0f5733b8e63f043bc.json b/backend/.sqlx/query-202e580eacc7907bb34b6464a66fe96ff91951fc8486d1f0f5733b8e63f043bc.json new file mode 100644 index 0000000000..23d9bb4cc4 --- /dev/null +++ b/backend/.sqlx/query-202e580eacc7907bb34b6464a66fe96ff91951fc8486d1f0f5733b8e63f043bc.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_runtime SET ping = null WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "202e580eacc7907bb34b6464a66fe96ff91951fc8486d1f0f5733b8e63f043bc" +} diff --git a/backend/.sqlx/query-205e4faf72177cae685c7f0727659d0e223b98f3ca84fdff21b1bc57c2ca3512.json b/backend/.sqlx/query-205e4faf72177cae685c7f0727659d0e223b98f3ca84fdff21b1bc57c2ca3512.json new file mode 100644 index 0000000000..980cc6787b --- /dev/null +++ b/backend/.sqlx/query-205e4faf72177cae685c7f0727659d0e223b98f3ca84fdff21b1bc57c2ca3512.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE job_logs SET logs = '##DELETED##' WHERE job_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "205e4faf72177cae685c7f0727659d0e223b98f3ca84fdff21b1bc57c2ca3512" +} diff --git a/backend/.sqlx/query-20d9a1b3a6631f97836e7b8d96cdec706ba1cc2d5d432e397633a1f79e67589a.json b/backend/.sqlx/query-20d9a1b3a6631f97836e7b8d96cdec706ba1cc2d5d432e397633a1f79e67589a.json new file mode 100644 index 0000000000..7a1fe7377e --- /dev/null +++ b/backend/.sqlx/query-20d9a1b3a6631f97836e7b8d96cdec706ba1cc2d5d432e397633a1f79e67589a.json @@ -0,0 +1,69 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result AS \"result: sqlx::types::Json>\",\n flow_status AS \"flow_status: sqlx::types::Json>\",\n language AS \"language: ScriptLang\",\n created_by AS \"created_by!\"\n FROM completed_job\n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "language: ScriptLang", + "type_info": { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "20d9a1b3a6631f97836e7b8d96cdec706ba1cc2d5d432e397633a1f79e67589a" +} diff --git a/backend/.sqlx/query-241270e20c751806dece12fbc2de360e389da8c7f653ef8e6bc0d30c823aea51.json b/backend/.sqlx/query-241270e20c751806dece12fbc2de360e389da8c7f653ef8e6bc0d30c823aea51.json new file mode 100644 index 0000000000..eefc3dd8e8 --- /dev/null +++ b/backend/.sqlx/query-241270e20c751806dece12fbc2de360e389da8c7f653ef8e6bc0d30c823aea51.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT \n flow_status->>'step' = '0' \n AND (\n jsonb_array_length(flow_status->'modules') = 0 \n OR flow_status->'modules'->0->>'type' = 'WaitingForPriorSteps' \n OR (\n flow_status->'modules'->0->>'type' = 'Failure' \n AND flow_status->'modules'->0->>'job' = $1\n )\n )\n FROM v2_job_completed WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "241270e20c751806dece12fbc2de360e389da8c7f653ef8e6bc0d30c823aea51" +} diff --git a/backend/.sqlx/query-2456fc71fc7a0758a4c1fbe77d72fbac2fead0e1bff4e909fd7fb1a41bc35d8f.json b/backend/.sqlx/query-2456fc71fc7a0758a4c1fbe77d72fbac2fead0e1bff4e909fd7fb1a41bc35d8f.json new file mode 100644 index 0000000000..07ae8f17c5 --- /dev/null +++ b/backend/.sqlx/query-2456fc71fc7a0758a4c1fbe77d72fbac2fead0e1bff4e909fd7fb1a41bc35d8f.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n script_path, args AS \"args: sqlx::types::Json>>\",\n tag AS \"tag!\", priority\n FROM v2_as_completed_job\n WHERE id = $1 and workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "args: sqlx::types::Json>>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "tag!", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "priority", + "type_info": "Int2" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "2456fc71fc7a0758a4c1fbe77d72fbac2fead0e1bff4e909fd7fb1a41bc35d8f" +} diff --git a/backend/.sqlx/query-25d05a1e10d1aaa3f7c3c3bea5f6b2fe3f690da7bc8dfd36b47ec619c4e31995.json b/backend/.sqlx/query-25d05a1e10d1aaa3f7c3c3bea5f6b2fe3f690da7bc8dfd36b47ec619c4e31995.json new file mode 100644 index 0000000000..eb652ef49d --- /dev/null +++ b/backend/.sqlx/query-25d05a1e10d1aaa3f7c3c3bea5f6b2fe3f690da7bc8dfd36b47ec619c4e31995.json @@ -0,0 +1,54 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n running AS \"running!\",\n substr(concat(coalesce(v2_as_queue.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs,\n mem_peak,\n CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\",\n job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset,\n created_by AS \"created_by!\"\n FROM v2_as_queue\n LEFT JOIN job_logs ON job_logs.job_id = v2_as_queue.id \n WHERE v2_as_queue.workspace_id = $2 AND v2_as_queue.id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "running!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "mem_peak", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 5, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Int4", + "Text", + "Uuid" + ] + }, + "nullable": [ + true, + null, + true, + null, + null, + true + ] + }, + "hash": "25d05a1e10d1aaa3f7c3c3bea5f6b2fe3f690da7bc8dfd36b47ec619c4e31995" +} diff --git a/backend/.sqlx/query-280a361076d1c6317610765960f543252891c53351bdc98da66cc30ffc895866.json b/backend/.sqlx/query-280a361076d1c6317610765960f543252891c53351bdc98da66cc30ffc895866.json new file mode 100644 index 0000000000..e9705c23a6 --- /dev/null +++ b/backend/.sqlx/query-280a361076d1c6317610765960f543252891c53351bdc98da66cc30ffc895866.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT script_path FROM v2_as_completed_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "280a361076d1c6317610765960f543252891c53351bdc98da66cc30ffc895866" +} diff --git a/backend/.sqlx/query-282afbff89d3186d47ef5dbd0b65026ad37fb31b485fc44b6ec257dd77825428.json b/backend/.sqlx/query-282afbff89d3186d47ef5dbd0b65026ad37fb31b485fc44b6ec257dd77825428.json new file mode 100644 index 0000000000..200bd3155d --- /dev/null +++ b/backend/.sqlx/query-282afbff89d3186d47ef5dbd0b65026ad37fb31b485fc44b6ec257dd77825428.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by, coalesce(job_logs.logs, '') as logs, job_logs.log_offset, job_logs.log_file_index\n FROM v2_as_completed_job\n LEFT JOIN job_logs ON job_logs.job_id = v2_as_completed_job.id\n WHERE v2_as_completed_job.id = $1 AND v2_as_completed_job.workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "log_file_index", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + null, + false, + true + ] + }, + "hash": "282afbff89d3186d47ef5dbd0b65026ad37fb31b485fc44b6ec257dd77825428" +} diff --git a/backend/.sqlx/query-28b42ab9c3ce0c2f05cf385e81f3b72fa7c4b3c458d52a5891a61f9c53a49c6d.json b/backend/.sqlx/query-28b42ab9c3ce0c2f05cf385e81f3b72fa7c4b3c458d52a5891a61f9c53a49c6d.json new file mode 100644 index 0000000000..817b993d8f --- /dev/null +++ b/backend/.sqlx/query-28b42ab9c3ce0c2f05cf385e81f3b72fa7c4b3c458d52a5891a61f9c53a49c6d.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = JSONB_SET(\n flow_status,\n ARRAY['modules', $1::TEXT, 'branchall', 'branch'],\n ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb\n )\n WHERE id = $2\n RETURNING (flow_status->'modules'->$1::int->'branchall'->>'branch')::int", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "int4", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "28b42ab9c3ce0c2f05cf385e81f3b72fa7c4b3c458d52a5891a61f9c53a49c6d" +} diff --git a/backend/.sqlx/query-28c40cfbe796c6fb942cc9f72e00f9d3de633cdc4f9e23c6d9bd27eba07b0cb2.json b/backend/.sqlx/query-28c40cfbe796c6fb942cc9f72e00f9d3de633cdc4f9e23c6d9bd27eba07b0cb2.json new file mode 100644 index 0000000000..b39b9ef58a --- /dev/null +++ b/backend/.sqlx/query-28c40cfbe796c6fb942cc9f72e00f9d3de633cdc4f9e23c6d9bd27eba07b0cb2.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT null FROM v2_job_queue WHERE id = $1 FOR UPDATE", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "28c40cfbe796c6fb942cc9f72e00f9d3de633cdc4f9e23c6d9bd27eba07b0cb2" +} diff --git a/backend/.sqlx/query-29624682d687790dd199c4af759132d79fdb2982de111cb5fd43e3d9ecd0f15e.json b/backend/.sqlx/query-29624682d687790dd199c4af759132d79fdb2982de111cb5fd43e3d9ecd0f15e.json new file mode 100644 index 0000000000..7623243f07 --- /dev/null +++ b/backend/.sqlx/query-29624682d687790dd199c4af759132d79fdb2982de111cb5fd43e3d9ecd0f15e.json @@ -0,0 +1,93 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job (id, workspace_id, raw_code, raw_lock, raw_flow, tag, parent_job,\n created_by, permissioned_as, runnable_id, runnable_path, args, kind, trigger,\n script_lang, same_worker, pre_run_error, permissioned_as_email, visible_to_owner,\n flow_innermost_root_job, concurrent_limit, concurrency_time_window_s, timeout, flow_step_id,\n cache_ttl, priority, trigger_kind, script_entrypoint_override, preprocessed)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18,\n $19, $20, $21, $22, $23, $24, $25, $26,\n CASE WHEN $14::VARCHAR IS NOT NULL THEN 'schedule'::job_trigger_kind END,\n ($12::JSONB)->>'_ENTRYPOINT_OVERRIDE', $27)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Text", + "Text", + "Jsonb", + "Varchar", + "Uuid", + "Varchar", + "Varchar", + "Int8", + "Varchar", + "Jsonb", + { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + }, + "Varchar", + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Bool", + "Text", + "Varchar", + "Bool", + "Uuid", + "Int4", + "Int4", + "Int4", + "Varchar", + "Int4", + "Int2", + "Bool" + ] + }, + "nullable": [] + }, + "hash": "29624682d687790dd199c4af759132d79fdb2982de111cb5fd43e3d9ecd0f15e" +} diff --git a/backend/.sqlx/query-2a0b59e2770b27a1f2a8baddc67dba29216a1aad733171c25cc4aae5b3c84d54.json b/backend/.sqlx/query-2a0b59e2770b27a1f2a8baddc67dba29216a1aad733171c25cc4aae5b3c84d54.json new file mode 100644 index 0000000000..8ff5e29db1 --- /dev/null +++ b/backend/.sqlx/query-2a0b59e2770b27a1f2a8baddc67dba29216a1aad733171c25cc4aae5b3c84d54.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue SET\n flow_status = JSONB_SET(flow_status, ARRAY['modules', flow_status->>'step'::text], $1),\n suspend = $2,\n suspend_until = now() + $3\n WHERE id = $4", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Int4", + "Interval", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "2a0b59e2770b27a1f2a8baddc67dba29216a1aad733171c25cc4aae5b3c84d54" +} diff --git a/backend/.sqlx/query-2c5a1b1ebd872ce8a03a1b7e5246c876750c85075cfda816c025c805d4c3cd4c.json b/backend/.sqlx/query-2c5a1b1ebd872ce8a03a1b7e5246c876750c85075cfda816c025c805d4c3cd4c.json new file mode 100644 index 0000000000..6d916281eb --- /dev/null +++ b/backend/.sqlx/query-2c5a1b1ebd872ce8a03a1b7e5246c876750c85075cfda816c025c805d4c3cd4c.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", CONCAT(coalesce(v2_as_completed_job.logs, ''), coalesce(job_logs.logs, '')) as logs, job_logs.log_offset, job_logs.log_file_index\n FROM v2_as_completed_job \n LEFT JOIN job_logs ON job_logs.job_id = v2_as_completed_job.id \n WHERE v2_as_completed_job.id = $1 AND v2_as_completed_job.workspace_id = $2 AND ($3::text[] IS NULL OR v2_as_completed_job.tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "log_file_index", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + null, + false, + true + ] + }, + "hash": "2c5a1b1ebd872ce8a03a1b7e5246c876750c85075cfda816c025c805d4c3cd4c" +} diff --git a/backend/.sqlx/query-2cef109784efc04999e4537e0d1d3fb3221e04f3a7c1abe91dd763f366d06618.json b/backend/.sqlx/query-2cef109784efc04999e4537e0d1d3fb3221e04f3a7c1abe91dd763f366d06618.json new file mode 100644 index 0000000000..3b7793dd05 --- /dev/null +++ b/backend/.sqlx/query-2cef109784efc04999e4537e0d1d3fb3221e04f3a7c1abe91dd763f366d06618.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT success AS \"success!\" FROM completed_job WHERE id = ANY($1)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [ + true + ] + }, + "hash": "2cef109784efc04999e4537e0d1d3fb3221e04f3a7c1abe91dd763f366d06618" +} diff --git a/backend/.sqlx/query-2f27fd4d7aed67c987d9f0cca0a2426f3fbd22c1f0759be943625ad5c921f91b.json b/backend/.sqlx/query-2f27fd4d7aed67c987d9f0cca0a2426f3fbd22c1f0759be943625ad5c921f91b.json new file mode 100644 index 0000000000..eef5b530e7 --- /dev/null +++ b/backend/.sqlx/query-2f27fd4d7aed67c987d9f0cca0a2426f3fbd22c1f0759be943625ad5c921f91b.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result AS \"result: sqlx::types::Json>\",\n result_columns,\n status = 'success' AS \"success!\",\n created_by AS \"created_by!\"\n FROM v2_job_completed c\n JOIN v2_job j USING (id)\n WHERE c.id = $1 AND c.workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "result_columns", + "type_info": "TextArray" + }, + { + "ordinal": 2, + "name": "success!", + "type_info": "Bool" + }, + { + "ordinal": 3, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true, + null, + false + ] + }, + "hash": "2f27fd4d7aed67c987d9f0cca0a2426f3fbd22c1f0759be943625ad5c921f91b" +} diff --git a/backend/.sqlx/query-2f2ef9b1ccff527c48fa01cf1b78cd0e58c8d534ac22ec0356d82a854b31d087.json b/backend/.sqlx/query-2f2ef9b1ccff527c48fa01cf1b78cd0e58c8d534ac22ec0356d82a854b31d087.json new file mode 100644 index 0000000000..77e16162bd --- /dev/null +++ b/backend/.sqlx/query-2f2ef9b1ccff527c48fa01cf1b78cd0e58c8d534ac22ec0356d82a854b31d087.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_runtime SET ping = NULL\n WHERE id = $1 AND ping = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "2f2ef9b1ccff527c48fa01cf1b78cd0e58c8d534ac22ec0356d82a854b31d087" +} diff --git a/backend/.sqlx/query-31df83e9eb6078e93ec5fe4168306caccb849db9e0f71d86da655b01c6a3e8d0.json b/backend/.sqlx/query-31df83e9eb6078e93ec5fe4168306caccb849db9e0f71d86da655b01c6a3e8d0.json new file mode 100644 index 0000000000..b96c05d674 --- /dev/null +++ b/backend/.sqlx/query-31df83e9eb6078e93ec5fe4168306caccb849db9e0f71d86da655b01c6a3e8d0.json @@ -0,0 +1,27 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_queue\n (workspace_id, id, running, scheduled_for, started_at, tag, priority)\n VALUES ($1, $2, $3, COALESCE($4, now()), CASE WHEN $3 THEN now() END, $5, $6) RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Uuid", + "Bool", + "Timestamptz", + "Varchar", + "Int2" + ] + }, + "nullable": [ + false + ] + }, + "hash": "31df83e9eb6078e93ec5fe4168306caccb849db9e0f71d86da655b01c6a3e8d0" +} diff --git a/backend/.sqlx/query-31f6f0712f1f53362628a487e8cd35d6d711b05d6eefffdc8e6a1b9c9bc7085d.json b/backend/.sqlx/query-31f6f0712f1f53362628a487e8cd35d6d711b05d6eefffdc8e6a1b9c9bc7085d.json new file mode 100644 index 0000000000..cff7935a88 --- /dev/null +++ b/backend/.sqlx/query-31f6f0712f1f53362628a487e8cd35d6d711b05d6eefffdc8e6a1b9c9bc7085d.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT raw_code, raw_lock, raw_flow AS \"raw_flow: Json>\" FROM v2_job WHERE id = $1 LIMIT 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "raw_code", + "type_info": "Text" + }, + { + "ordinal": 1, + "name": "raw_lock", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "raw_flow: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "31f6f0712f1f53362628a487e8cd35d6d711b05d6eefffdc8e6a1b9c9bc7085d" +} diff --git a/backend/.sqlx/query-32fdc66931dcf34f6ef5cdf3fd335d9f990eaa3dbb396290477159012e86af14.json b/backend/.sqlx/query-32fdc66931dcf34f6ef5cdf3fd335d9f990eaa3dbb396290477159012e86af14.json new file mode 100644 index 0000000000..4767ba9a23 --- /dev/null +++ b/backend/.sqlx/query-32fdc66931dcf34f6ef5cdf3fd335d9f990eaa3dbb396290477159012e86af14.json @@ -0,0 +1,58 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id AS \"id!\", workspace_id AS \"workspace_id!\", parent_job, is_flow_step,\n flow_status AS \"flow_status: Box\", last_ping, same_worker\n FROM queue\n WHERE running = true AND suspend = 0 AND suspend_until IS null AND scheduled_for <= now()\n AND (job_kind = 'flow' OR job_kind = 'flowpreview' OR job_kind = 'flownode')\n AND last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval\n AND canceled = false\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "workspace_id!", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "parent_job", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "is_flow_step", + "type_info": "Bool" + }, + { + "ordinal": 4, + "name": "flow_status: Box", + "type_info": "Jsonb" + }, + { + "ordinal": 5, + "name": "last_ping", + "type_info": "Timestamptz" + }, + { + "ordinal": 6, + "name": "same_worker", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true, + true, + true + ] + }, + "hash": "32fdc66931dcf34f6ef5cdf3fd335d9f990eaa3dbb396290477159012e86af14" +} diff --git a/backend/.sqlx/query-33351de09c72ccc0a39eb977d26f867595813bfa1ae0b26bc4181780801294bf.json b/backend/.sqlx/query-33351de09c72ccc0a39eb977d26f867595813bfa1ae0b26bc4181780801294bf.json new file mode 100644 index 0000000000..a3d39e0b59 --- /dev/null +++ b/backend/.sqlx/query-33351de09c72ccc0a39eb977d26f867595813bfa1ae0b26bc4181780801294bf.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT success AS \"success!\" FROM v2_as_completed_job WHERE id = ANY($1)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [ + true + ] + }, + "hash": "33351de09c72ccc0a39eb977d26f867595813bfa1ae0b26bc4181780801294bf" +} diff --git a/backend/.sqlx/query-36b26b3a6458d8a0b4f770d52c1bb09370b905d610b9ceb3cfac11365586320d.json b/backend/.sqlx/query-36b26b3a6458d8a0b4f770d52c1bb09370b905d610b9ceb3cfac11365586320d.json new file mode 100644 index 0000000000..3b3fa11ffb --- /dev/null +++ b/backend/.sqlx/query-36b26b3a6458d8a0b4f770d52c1bb09370b905d610b9ceb3cfac11365586320d.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT running AS \"running!\" FROM queue WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "running!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "36b26b3a6458d8a0b4f770d52c1bb09370b905d610b9ceb3cfac11365586320d" +} diff --git a/backend/.sqlx/query-3a5edf3dd884b5a8862bb112f6520967ed4a218782192c6c6fc1498f45d753a6.json b/backend/.sqlx/query-3a5edf3dd884b5a8862bb112f6520967ed4a218782192c6c6fc1498f45d753a6.json new file mode 100644 index 0000000000..26d0b63b5c --- /dev/null +++ b/backend/.sqlx/query-3a5edf3dd884b5a8862bb112f6520967ed4a218782192c6c6fc1498f45d753a6.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "create index concurrently if not exists ix_job_created_at ON v2_job (created_at DESC)", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "3a5edf3dd884b5a8862bb112f6520967ed4a218782192c6c6fc1498f45d753a6" +} diff --git a/backend/.sqlx/query-3bacf9cd9aa63f4bec5f983f4a0c3030216b5a4ed669f77962509d1c2c6cb780.json b/backend/.sqlx/query-3bacf9cd9aa63f4bec5f983f4a0c3030216b5a4ed669f77962509d1c2c6cb780.json new file mode 100644 index 0000000000..200a5bf47f --- /dev/null +++ b/backend/.sqlx/query-3bacf9cd9aa63f4bec5f983f4a0c3030216b5a4ed669f77962509d1c2c6cb780.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "create index concurrently if not exists root_job_index_by_path_2 ON v2_job (workspace_id, runnable_path, created_at desc) WHERE parent_job IS NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "3bacf9cd9aa63f4bec5f983f4a0c3030216b5a4ed669f77962509d1c2c6cb780" +} diff --git a/backend/.sqlx/query-3bc1919515120116705d7c250a34f2b9bf7c4bcaedb87c28f974e46c9c42200c.json b/backend/.sqlx/query-3bc1919515120116705d7c250a34f2b9bf7c4bcaedb87c28f974e46c9c42200c.json new file mode 100644 index 0000000000..125c9593b6 --- /dev/null +++ b/backend/.sqlx/query-3bc1919515120116705d7c250a34f2b9bf7c4bcaedb87c28f974e46c9c42200c.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM queue WHERE id = ANY($1) AND schedule_path IS NULL AND ($2::text[] IS NULL OR tag = ANY($2))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "TextArray" + ] + }, + "nullable": [ + true + ] + }, + "hash": "3bc1919515120116705d7c250a34f2b9bf7c4bcaedb87c28f974e46c9c42200c" +} diff --git a/backend/.sqlx/query-3c0b2a840102b12864c5d721b8e0142602ab37f3e1a95d39b3c7cbd7ff34d0b2.json b/backend/.sqlx/query-3c0b2a840102b12864c5d721b8e0142602ab37f3e1a95d39b3c7cbd7ff34d0b2.json new file mode 100644 index 0000000000..dbb99a4ec1 --- /dev/null +++ b/backend/.sqlx/query-3c0b2a840102b12864c5d721b8e0142602ab37f3e1a95d39b3c7cbd7ff34d0b2.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n id As \"id!\",\n flow_status->'restarted_from'->'flow_job_id' AS \"restarted_from: Json\"\n FROM v2_as_queue\n WHERE COALESCE((SELECT flow_innermost_root_job FROM v2_job WHERE id = $1), $1) = id AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "restarted_from: Json", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + null + ] + }, + "hash": "3c0b2a840102b12864c5d721b8e0142602ab37f3e1a95d39b3c7cbd7ff34d0b2" +} diff --git a/backend/.sqlx/query-3c423bcb10668bdd131f7b6a9b0fcc8f9b1909f255cdfce0fb83496aac0fc021.json b/backend/.sqlx/query-3c423bcb10668bdd131f7b6a9b0fcc8f9b1909f255cdfce0fb83496aac0fc021.json new file mode 100644 index 0000000000..090efe4964 --- /dev/null +++ b/backend/.sqlx/query-3c423bcb10668bdd131f7b6a9b0fcc8f9b1909f255cdfce0fb83496aac0fc021.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\", flow_status AS \"flow_status!: Json\"\n FROM completed_job\n WHERE parent_job = $1 AND workspace_id = $2 AND flow_status IS NOT NULL", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status!: Json", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "3c423bcb10668bdd131f7b6a9b0fcc8f9b1909f255cdfce0fb83496aac0fc021" +} diff --git a/backend/.sqlx/query-3d58b5861c62f0b092b6b95c17ba1dac2cbcf00db116624bd2fe27a4d0dfb436.json b/backend/.sqlx/query-3d58b5861c62f0b092b6b95c17ba1dac2cbcf00db116624bd2fe27a4d0dfb436.json new file mode 100644 index 0000000000..4f1fe255f9 --- /dev/null +++ b/backend/.sqlx/query-3d58b5861c62f0b092b6b95c17ba1dac2cbcf00db116624bd2fe27a4d0dfb436.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['approval_conditions'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "3d58b5861c62f0b092b6b95c17ba1dac2cbcf00db116624bd2fe27a4d0dfb436" +} diff --git a/backend/.sqlx/query-3de870d80a3617e7b31209d922164bf957b8bac3b5c04626ec750b18f705cbfd.json b/backend/.sqlx/query-3de870d80a3617e7b31209d922164bf957b8bac3b5c04626ec750b18f705cbfd.json new file mode 100644 index 0000000000..7b0eb81646 --- /dev/null +++ b/backend/.sqlx/query-3de870d80a3617e7b31209d922164bf957b8bac3b5c04626ec750b18f705cbfd.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "CREATE INDEX CONCURRENTLY ix_v2_job_labels ON v2_job\n USING GIN (labels)\n WHERE labels IS NOT NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "3de870d80a3617e7b31209d922164bf957b8bac3b5c04626ec750b18f705cbfd" +} diff --git a/backend/.sqlx/query-3e0cdd500dffc3bd1d8374ca3cc8fd60ce778c2fece27637d9985d4650778653.json b/backend/.sqlx/query-3e0cdd500dffc3bd1d8374ca3cc8fd60ce778c2fece27637d9985d4650778653.json new file mode 100644 index 0000000000..9f5cb1d19d --- /dev/null +++ b/backend/.sqlx/query-3e0cdd500dffc3bd1d8374ca3cc8fd60ce778c2fece27637d9985d4650778653.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['cleanup_module', 'flow_jobs_to_clean'], COALESCE(flow_status->'cleanup_module'->'flow_jobs_to_clean', '[]'::jsonb) || $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "3e0cdd500dffc3bd1d8374ca3cc8fd60ce778c2fece27637d9985d4650778653" +} diff --git a/backend/.sqlx/query-3e55d027327bd3c76810fbe22d3ccb1bbbf83c8cff69d8f5907d1417a2522e69.json b/backend/.sqlx/query-3e55d027327bd3c76810fbe22d3ccb1bbbf83c8cff69d8f5907d1417a2522e69.json new file mode 100644 index 0000000000..2603a95877 --- /dev/null +++ b/backend/.sqlx/query-3e55d027327bd3c76810fbe22d3ccb1bbbf83c8cff69d8f5907d1417a2522e69.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET running = false, started_at = null\n WHERE id = $1 AND canceled_by IS NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "3e55d027327bd3c76810fbe22d3ccb1bbbf83c8cff69d8f5907d1417a2522e69" +} diff --git a/backend/.sqlx/query-402fd5bff6e8420c9b3477f05df625cae355fda673b9e85284e0fcd7d9232eb7.json b/backend/.sqlx/query-402fd5bff6e8420c9b3477f05df625cae355fda673b9e85284e0fcd7d9232eb7.json new file mode 100644 index 0000000000..83d1b15744 --- /dev/null +++ b/backend/.sqlx/query-402fd5bff6e8420c9b3477f05df625cae355fda673b9e85284e0fcd7d9232eb7.json @@ -0,0 +1,73 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n script_path, script_hash AS \"script_hash: ScriptHash\",\n job_kind AS \"job_kind!: JobKind\",\n flow_status AS \"flow_status: Json>\",\n raw_flow AS \"raw_flow: Json>\"\n FROM completed_job WHERE id = $1 and workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "script_hash: ScriptHash", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "job_kind!: JobKind", + "type_info": { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "flow_status: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "raw_flow: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true + ] + }, + "hash": "402fd5bff6e8420c9b3477f05df625cae355fda673b9e85284e0fcd7d9232eb7" +} diff --git a/backend/.sqlx/query-404d54032aa7814370a8cecb7795246e9f289e647351adb24ced507ff8a4d835.json b/backend/.sqlx/query-404d54032aa7814370a8cecb7795246e9f289e647351adb24ced507ff8a4d835.json new file mode 100644 index 0000000000..bd082c24f3 --- /dev/null +++ b/backend/.sqlx/query-404d54032aa7814370a8cecb7795246e9f289e647351adb24ced507ff8a4d835.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = jsonb_set(\n jsonb_set(flow_status, ARRAY['failure_module', 'job'], to_jsonb($1::UUID::TEXT)),\n ARRAY['failure_module', 'type'],\n to_jsonb('InProgress'::text)\n )\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "404d54032aa7814370a8cecb7795246e9f289e647351adb24ced507ff8a4d835" +} diff --git a/backend/.sqlx/query-4244640e62fffb0f6978f8f7d78291b3294a6a7d1549d752f14acf5972552ba5.json b/backend/.sqlx/query-4244640e62fffb0f6978f8f7d78291b3294a6a7d1549d752f14acf5972552ba5.json new file mode 100644 index 0000000000..841d549e20 --- /dev/null +++ b/backend/.sqlx/query-4244640e62fffb0f6978f8f7d78291b3294a6a7d1549d752f14acf5972552ba5.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET workspace_id = $1 WHERE workspace_id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text" + ] + }, + "nullable": [] + }, + "hash": "4244640e62fffb0f6978f8f7d78291b3294a6a7d1549d752f14acf5972552ba5" +} diff --git a/backend/.sqlx/query-429aef2c320a152b16fe20c1ab84aab41142897db108dc8cbc2c51abb2e30c7c.json b/backend/.sqlx/query-429aef2c320a152b16fe20c1ab84aab41142897db108dc8cbc2c51abb2e30c7c.json new file mode 100644 index 0000000000..c40a18e4c9 --- /dev/null +++ b/backend/.sqlx/query-429aef2c320a152b16fe20c1ab84aab41142897db108dc8cbc2c51abb2e30c7c.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "429aef2c320a152b16fe20c1ab84aab41142897db108dc8cbc2c51abb2e30c7c" +} diff --git a/backend/.sqlx/query-43aa468aac174529a74e6108af55a383f8a20e98b8c502929f4dc5041a55e72f.json b/backend/.sqlx/query-43aa468aac174529a74e6108af55a383f8a20e98b8c502929f4dc5041a55e72f.json new file mode 100644 index 0000000000..e33b0dc0b8 --- /dev/null +++ b/backend/.sqlx/query-43aa468aac174529a74e6108af55a383f8a20e98b8c502929f4dc5041a55e72f.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT EXISTS (\n SELECT 1 FROM v2_as_completed_job \n WHERE workspace_id = $2 \n AND (job_kind = 'appscript' OR job_kind = 'preview')\n AND created_by = 'anonymous' \n AND started_at > now() - interval '3 hours'\n AND script_path LIKE $3 || '/%' \n AND result @> ('{\"s3\":\"' || $1 || '\"}')::jsonb \n )", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "exists", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "43aa468aac174529a74e6108af55a383f8a20e98b8c502929f4dc5041a55e72f" +} diff --git a/backend/.sqlx/query-44a317f7647e2b515f90dc9c04f7ac75c2c87c7c3036acd96ba72fb2a21700db.json b/backend/.sqlx/query-44a317f7647e2b515f90dc9c04f7ac75c2c87c7c3036acd96ba72fb2a21700db.json new file mode 100644 index 0000000000..8885d178e2 --- /dev/null +++ b/backend/.sqlx/query-44a317f7647e2b515f90dc9c04f7ac75c2c87c7c3036acd96ba72fb2a21700db.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM completed_job WHERE created_at <= now() - ($1::bigint::text || ' s')::interval AND started_at + ((duration_ms/1000 + $1::bigint) || ' s')::interval <= now() RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + true + ] + }, + "hash": "44a317f7647e2b515f90dc9c04f7ac75c2c87c7c3036acd96ba72fb2a21700db" +} diff --git a/backend/.sqlx/query-4504f3a5d3cffd56d51bd263e6759404a3a5889dd7c61cb077e17b877b027eff.json b/backend/.sqlx/query-4504f3a5d3cffd56d51bd263e6759404a3a5889dd7c61cb077e17b877b027eff.json new file mode 100644 index 0000000000..76e4896aaa --- /dev/null +++ b/backend/.sqlx/query-4504f3a5d3cffd56d51bd263e6759404a3a5889dd7c61cb077e17b877b027eff.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE queue\n SET canceled = true\n , canceled_by = 'timeout'\n , canceled_reason = $1\n WHERE id = $2\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "4504f3a5d3cffd56d51bd263e6759404a3a5889dd7c61cb077e17b877b027eff" +} diff --git a/backend/.sqlx/query-4535c8effd1bae49894d13293a37e1ee949cf9108239032cb3addbf350fb33de.json b/backend/.sqlx/query-4535c8effd1bae49894d13293a37e1ee949cf9108239032cb3addbf350fb33de.json new file mode 100644 index 0000000000..a500b04785 --- /dev/null +++ b/backend/.sqlx/query-4535c8effd1bae49894d13293a37e1ee949cf9108239032cb3addbf350fb33de.json @@ -0,0 +1,67 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n job_kind AS \"job_kind!: JobKind\",\n script_hash AS \"script_hash: ScriptHash\",\n flow_status AS \"flow_status!: Json>\",\n raw_flow AS \"raw_flow: Json>\"\n FROM v2_as_queue WHERE id = $1 AND workspace_id = $2 LIMIT 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "job_kind!: JobKind", + "type_info": { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + } + }, + { + "ordinal": 1, + "name": "script_hash: ScriptHash", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "flow_status!: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "raw_flow: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "4535c8effd1bae49894d13293a37e1ee949cf9108239032cb3addbf350fb33de" +} diff --git a/backend/.sqlx/query-46046b1435d1f01e6f7cafe054367d88ddbdfe81237b72d5efbc630278e44bb5.json b/backend/.sqlx/query-46046b1435d1f01e6f7cafe054367d88ddbdfe81237b72d5efbc630278e44bb5.json new file mode 100644 index 0000000000..d56b85cd62 --- /dev/null +++ b/backend/.sqlx/query-46046b1435d1f01e6f7cafe054367d88ddbdfe81237b72d5efbc630278e44bb5.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_runtime r SET\n memory_peak = $1,\n ping = now()\n FROM v2_job_queue q\n WHERE r.id = $2 AND q.id = r.id\n RETURNING canceled_by IS NOT NULL AS \"canceled!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "canceled!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "46046b1435d1f01e6f7cafe054367d88ddbdfe81237b72d5efbc630278e44bb5" +} diff --git a/backend/.sqlx/query-464c51a8ea8c06232d33c45b8e59008b382c445476117a2311030734bc6d6d53.json b/backend/.sqlx/query-464c51a8ea8c06232d33c45b8e59008b382c445476117a2311030734bc6d6d53.json new file mode 100644 index 0000000000..df664b5b8b --- /dev/null +++ b/backend/.sqlx/query-464c51a8ea8c06232d33c45b8e59008b382c445476117a2311030734bc6d6d53.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_runtime SET ping = now() WHERE id = $1 AND ping < now()", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "464c51a8ea8c06232d33c45b8e59008b382c445476117a2311030734bc6d6d53" +} diff --git a/backend/.sqlx/query-4671f1727d0563490534c426375738478f3d93f6bb42aaf021794392328c8875.json b/backend/.sqlx/query-4671f1727d0563490534c426375738478f3d93f6bb42aaf021794392328c8875.json new file mode 100644 index 0000000000..e497d7f59e --- /dev/null +++ b/backend/.sqlx/query-4671f1727d0563490534c426375738478f3d93f6bb42aaf021794392328c8875.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\"\n FROM completed_job \n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "args: sqlx::types::Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "4671f1727d0563490534c426375738478f3d93f6bb42aaf021794392328c8875" +} diff --git a/backend/.sqlx/query-47455b0ebaf999ab58b2cba3d74cb4bdd64075939a4aa2c117e18372511ea7e0.json b/backend/.sqlx/query-47455b0ebaf999ab58b2cba3d74cb4bdd64075939a4aa2c117e18372511ea7e0.json new file mode 100644 index 0000000000..6ccaeece1c --- /dev/null +++ b/backend/.sqlx/query-47455b0ebaf999ab58b2cba3d74cb4bdd64075939a4aa2c117e18372511ea7e0.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "VACUUM (skip_locked) v2_job_queue, v2_job_runtime, v2_job_status", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "47455b0ebaf999ab58b2cba3d74cb4bdd64075939a4aa2c117e18372511ea7e0" +} diff --git a/backend/.sqlx/query-47e6b25cc092ec8718a6581c76aca10b275653e10ea4aa17a8ef5091ca09294a.json b/backend/.sqlx/query-47e6b25cc092ec8718a6581c76aca10b275653e10ea4aa17a8ef5091ca09294a.json new file mode 100644 index 0000000000..3206f22bc5 --- /dev/null +++ b/backend/.sqlx/query-47e6b25cc092ec8718a6581c76aca10b275653e10ea4aa17a8ef5091ca09294a.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result, id\n FROM v2_job_completed\n WHERE id = ANY($1) AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Text" + ] + }, + "nullable": [ + true, + false + ] + }, + "hash": "47e6b25cc092ec8718a6581c76aca10b275653e10ea4aa17a8ef5091ca09294a" +} diff --git a/backend/.sqlx/query-47fb4bceddd36fa60ccbe84f6341436fb133f0b3c97abb1267a9c12326dd1a33.json b/backend/.sqlx/query-47fb4bceddd36fa60ccbe84f6341436fb133f0b3c97abb1267a9c12326dd1a33.json new file mode 100644 index 0000000000..9e1d80c2f6 --- /dev/null +++ b/backend/.sqlx/query-47fb4bceddd36fa60ccbe84f6341436fb133f0b3c97abb1267a9c12326dd1a33.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\"\n FROM v2_as_completed_job \n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "args: sqlx::types::Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "47fb4bceddd36fa60ccbe84f6341436fb133f0b3c97abb1267a9c12326dd1a33" +} diff --git a/backend/.sqlx/query-488dd591096b2b47787afdc3a1d73917ed13269f2ee20b86df79fca2c8efe672.json b/backend/.sqlx/query-488dd591096b2b47787afdc3a1d73917ed13269f2ee20b86df79fca2c8efe672.json new file mode 100644 index 0000000000..8622eb9125 --- /dev/null +++ b/backend/.sqlx/query-488dd591096b2b47787afdc3a1d73917ed13269f2ee20b86df79fca2c8efe672.json @@ -0,0 +1,90 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH uuid_table as (\n select gen_random_uuid() as uuid from generate_series(1, $16)\n )\n INSERT INTO v2_job\n (id, workspace_id, raw_code, raw_lock, raw_flow, tag, runnable_id, runnable_path, kind,\n script_lang, created_by, permissioned_as, permissioned_as_email, concurrent_limit,\n concurrency_time_window_s, timeout, args)\n (SELECT uuid, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,\n ('{ \"uuid\": \"' || uuid || '\" }')::jsonb FROM uuid_table)\n RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Text", + "Jsonb", + "Varchar", + "Int8", + "Varchar", + { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + }, + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Varchar", + "Varchar", + "Varchar", + "Int4", + "Int4", + "Int4", + "Int4" + ] + }, + "nullable": [ + false + ] + }, + "hash": "488dd591096b2b47787afdc3a1d73917ed13269f2ee20b86df79fca2c8efe672" +} diff --git a/backend/.sqlx/query-4914b74a7956ab41e1a1c812460cc84bbd5e4045acc529f61de892a4e3aceef9.json b/backend/.sqlx/query-4914b74a7956ab41e1a1c812460cc84bbd5e4045acc529f61de892a4e3aceef9.json new file mode 100644 index 0000000000..26af54b1fa --- /dev/null +++ b/backend/.sqlx/query-4914b74a7956ab41e1a1c812460cc84bbd5e4045acc529f61de892a4e3aceef9.json @@ -0,0 +1,35 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT username, is_admin, operator FROM usr WHERE\n email = $1 AND workspace_id = $2 AND disabled = false", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "is_admin", + "type_info": "Bool" + }, + { + "ordinal": 2, + "name": "operator", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "4914b74a7956ab41e1a1c812460cc84bbd5e4045acc529f61de892a4e3aceef9" +} diff --git a/backend/.sqlx/query-4a1cb9f3ad7f2a692dadb9f75cdc99135af62ccaae5ca122d88356fe7da6eedc.json b/backend/.sqlx/query-4a1cb9f3ad7f2a692dadb9f75cdc99135af62ccaae5ca122d88356fe7da6eedc.json new file mode 100644 index 0000000000..be6e8f22e7 --- /dev/null +++ b/backend/.sqlx/query-4a1cb9f3ad7f2a692dadb9f75cdc99135af62ccaae5ca122d88356fe7da6eedc.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT script_entrypoint_override FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_entrypoint_override", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "4a1cb9f3ad7f2a692dadb9f75cdc99135af62ccaae5ca122d88356fe7da6eedc" +} diff --git a/backend/.sqlx/query-4c5502cdf49a59ce6d8bdce90e1cba3a2bc575dc69f6aa01fc6df1b5d095ab41.json b/backend/.sqlx/query-4c5502cdf49a59ce6d8bdce90e1cba3a2bc575dc69f6aa01fc6df1b5d095ab41.json new file mode 100644 index 0000000000..6651f3d2d9 --- /dev/null +++ b/backend/.sqlx/query-4c5502cdf49a59ce6d8bdce90e1cba3a2bc575dc69f6aa01fc6df1b5d095ab41.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_completed SET result = '{}'::jsonb WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "4c5502cdf49a59ce6d8bdce90e1cba3a2bc575dc69f6aa01fc6df1b5d095ab41" +} diff --git a/backend/.sqlx/query-4c9cf8c3176abc2b8b9a1c3f671949e16830671a458d5a73762cd8545d26172d.json b/backend/.sqlx/query-4c9cf8c3176abc2b8b9a1c3f671949e16830671a458d5a73762cd8545d26172d.json new file mode 100644 index 0000000000..0d108538dc --- /dev/null +++ b/backend/.sqlx/query-4c9cf8c3176abc2b8b9a1c3f671949e16830671a458d5a73762cd8545d26172d.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2),\n ARRAY['step'],\n $3\n )\n WHERE id = $4", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "4c9cf8c3176abc2b8b9a1c3f671949e16830671a458d5a73762cd8545d26172d" +} diff --git a/backend/.sqlx/query-4d3ef32120623584bf5c13d86ea6ad7b3aa41d9b581738d16fbfff4cc5b72a7a.json b/backend/.sqlx/query-4d3ef32120623584bf5c13d86ea6ad7b3aa41d9b581738d16fbfff4cc5b72a7a.json new file mode 100644 index 0000000000..9fad8009ec --- /dev/null +++ b/backend/.sqlx/query-4d3ef32120623584bf5c13d86ea6ad7b3aa41d9b581738d16fbfff4cc5b72a7a.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT canceled AS \"canceled!\" FROM queue WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "canceled!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "4d3ef32120623584bf5c13d86ea6ad7b3aa41d9b581738d16fbfff4cc5b72a7a" +} diff --git a/backend/.sqlx/query-4d4cc1ed4857edb473dc9397ca90de3797d671a7c0395d16eec8a2f84c1fe3d1.json b/backend/.sqlx/query-4d4cc1ed4857edb473dc9397ca90de3797d671a7c0395d16eec8a2f84c1fe3d1.json new file mode 100644 index 0000000000..1b237fbb7b --- /dev/null +++ b/backend/.sqlx/query-4d4cc1ed4857edb473dc9397ca90de3797d671a7c0395d16eec8a2f84c1fe3d1.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET args = '{}'::jsonb WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "4d4cc1ed4857edb473dc9397ca90de3797d671a7c0395d16eec8a2f84c1fe3d1" +} diff --git a/backend/.sqlx/query-4eb44e8ea9313646749bb73dfa6237081246a2985eec1d0d933dfedf634a7191.json b/backend/.sqlx/query-4eb44e8ea9313646749bb73dfa6237081246a2985eec1d0d933dfedf634a7191.json new file mode 100644 index 0000000000..ffb6d3eee2 --- /dev/null +++ b/backend/.sqlx/query-4eb44e8ea9313646749bb73dfa6237081246a2985eec1d0d933dfedf634a7191.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT coalesce(COUNT(*), 0) as \"database_length!\", null::bigint as suspended FROM v2_job_completed WHERE workspace_id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "database_length!", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "suspended", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "4eb44e8ea9313646749bb73dfa6237081246a2985eec1d0d933dfedf634a7191" +} diff --git a/backend/.sqlx/query-1610c79b8d238e3a35d795f34a2a0100b933b7f199d41cc2f554d57c811d55f3.json b/backend/.sqlx/query-4edf05cbf35325d444de0e74ee070aafd27ef61c940daba186e7e66f668c31ed.json similarity index 56% rename from backend/.sqlx/query-1610c79b8d238e3a35d795f34a2a0100b933b7f199d41cc2f554d57c811d55f3.json rename to backend/.sqlx/query-4edf05cbf35325d444de0e74ee070aafd27ef61c940daba186e7e66f668c31ed.json index 9b94af8432..4eae8c22fb 100644 --- a/backend/.sqlx/query-1610c79b8d238e3a35d795f34a2a0100b933b7f199d41cc2f554d57c811d55f3.json +++ b/backend/.sqlx/query-4edf05cbf35325d444de0e74ee070aafd27ef61c940daba186e7e66f668c31ed.json @@ -1,16 +1,17 @@ { "db_name": "PostgreSQL", - "query": "UPDATE workspace_settings SET ai_resource = $1, code_completion_enabled = $2 WHERE workspace_id = $3", + "query": "UPDATE workspace_settings SET ai_resource = $1, code_completion_model = $2, ai_models = $3 WHERE workspace_id = $4", "describe": { "columns": [], "parameters": { "Left": [ "Jsonb", - "Bool", + "Varchar", + "VarcharArray", "Text" ] }, "nullable": [] }, - "hash": "1610c79b8d238e3a35d795f34a2a0100b933b7f199d41cc2f554d57c811d55f3" + "hash": "4edf05cbf35325d444de0e74ee070aafd27ef61c940daba186e7e66f668c31ed" } diff --git a/backend/.sqlx/query-0331a81262e2d3c1bcfaeb64617b11eb68ab4599d64e5e5af639a9ac5d791fd0.json b/backend/.sqlx/query-51648e377d47815d0b15694572d5c9cc0a303d70980346e1f3c4096a8922d7d5.json similarity index 76% rename from backend/.sqlx/query-0331a81262e2d3c1bcfaeb64617b11eb68ab4599d64e5e5af639a9ac5d791fd0.json rename to backend/.sqlx/query-51648e377d47815d0b15694572d5c9cc0a303d70980346e1f3c4096a8922d7d5.json index 5d0a70183e..813981bae2 100644 --- a/backend/.sqlx/query-0331a81262e2d3c1bcfaeb64617b11eb68ab4599d64e5e5af639a9ac5d791fd0.json +++ b/backend/.sqlx/query-51648e377d47815d0b15694572d5c9cc0a303d70980346e1f3c4096a8922d7d5.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT\n -- slack_team_id, \n -- slack_name, \n -- slack_command_script, \n -- CASE WHEN slack_email = 'missing@email.xyz' THEN NULL ELSE slack_email END AS slack_email,\n auto_invite_domain IS NOT NULL AS \"auto_invite_enabled!\",\n CASE WHEN auto_invite_operator IS TRUE THEN 'operator' ELSE 'developer' END AS \"auto_invite_as!\", \n CASE WHEN auto_add IS TRUE THEN 'add' ELSE 'invite' END AS \"auto_invite_mode!\", \n webhook, \n deploy_to, \n error_handler, \n ai_resource, \n code_completion_enabled, \n error_handler_extra_args, \n error_handler_muted_on_cancel, \n large_file_storage, \n git_sync,\n default_app,\n default_scripts,\n workspace.name\n FROM workspace_settings\n LEFT JOIN workspace ON workspace.id = workspace_settings.workspace_id\n WHERE workspace_id = $1", + "query": "SELECT\n -- slack_team_id, \n -- slack_name, \n -- slack_command_script, \n -- CASE WHEN slack_email = 'missing@email.xyz' THEN NULL ELSE slack_email END AS slack_email,\n auto_invite_domain IS NOT NULL AS \"auto_invite_enabled!\",\n CASE WHEN auto_invite_operator IS TRUE THEN 'operator' ELSE 'developer' END AS \"auto_invite_as!\", \n CASE WHEN auto_add IS TRUE THEN 'add' ELSE 'invite' END AS \"auto_invite_mode!\", \n webhook, \n deploy_to, \n error_handler, \n ai_resource, \n ai_models,\n code_completion_model,\n error_handler_extra_args, \n error_handler_muted_on_cancel, \n large_file_storage, \n git_sync,\n default_app,\n default_scripts,\n workspace.name\n FROM workspace_settings\n LEFT JOIN workspace ON workspace.id = workspace_settings.workspace_id\n WHERE workspace_id = $1", "describe": { "columns": [ { @@ -40,41 +40,46 @@ }, { "ordinal": 7, - "name": "code_completion_enabled", - "type_info": "Bool" + "name": "ai_models", + "type_info": "VarcharArray" }, { "ordinal": 8, + "name": "code_completion_model", + "type_info": "Varchar" + }, + { + "ordinal": 9, "name": "error_handler_extra_args", "type_info": "Json" }, { - "ordinal": 9, + "ordinal": 10, "name": "error_handler_muted_on_cancel", "type_info": "Bool" }, { - "ordinal": 10, + "ordinal": 11, "name": "large_file_storage", "type_info": "Jsonb" }, { - "ordinal": 11, + "ordinal": 12, "name": "git_sync", "type_info": "Jsonb" }, { - "ordinal": 12, + "ordinal": 13, "name": "default_app", "type_info": "Varchar" }, { - "ordinal": 13, + "ordinal": 14, "name": "default_scripts", "type_info": "Jsonb" }, { - "ordinal": 14, + "ordinal": 15, "name": "name", "type_info": "Varchar" } @@ -94,6 +99,7 @@ true, false, true, + true, false, true, true, @@ -102,5 +108,5 @@ false ] }, - "hash": "0331a81262e2d3c1bcfaeb64617b11eb68ab4599d64e5e5af639a9ac5d791fd0" + "hash": "51648e377d47815d0b15694572d5c9cc0a303d70980346e1f3c4096a8922d7d5" } diff --git a/backend/.sqlx/query-519f4f76649947f036a2129c11e92ef0ad30e39eec59c27bae8cb0622062c8fb.json b/backend/.sqlx/query-519f4f76649947f036a2129c11e92ef0ad30e39eec59c27bae8cb0622062c8fb.json new file mode 100644 index 0000000000..b2c0b4702c --- /dev/null +++ b/backend/.sqlx/query-519f4f76649947f036a2129c11e92ef0ad30e39eec59c27bae8cb0622062c8fb.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM v2_as_queue WHERE canceled = false AND (scheduled_for <= now()\n OR (suspend_until IS NOT NULL\n AND ( suspend <= 0\n OR suspend_until <= now())))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "519f4f76649947f036a2129c11e92ef0ad30e39eec59c27bae8cb0622062c8fb" +} diff --git a/backend/.sqlx/query-51a19a7d611807c8b0957babf821e58e9aa1ce345f1cd5965298fda6f9e158a9.json b/backend/.sqlx/query-51a19a7d611807c8b0957babf821e58e9aa1ce345f1cd5965298fda6f9e158a9.json new file mode 100644 index 0000000000..c50b3531b0 --- /dev/null +++ b/backend/.sqlx/query-51a19a7d611807c8b0957babf821e58e9aa1ce345f1cd5965298fda6f9e158a9.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_completed AS cj\n ( workspace_id\n , id\n , duration_ms\n , result\n , canceled_by\n , canceled_reason\n , flow_status\n , status\n , worker\n )\n SELECT q.workspace_id\n , q.id\n , 0\n , $4\n , $1\n , 'cancel all'\n , (SELECT flow_status FROM v2_job_status WHERE id = q.id)\n , 'canceled'::job_status\n , worker\n FROM v2_job_queue q\n JOIN v2_job USING (id)\n WHERE q.id = any($2) AND running = false AND parent_job IS NULL AND q.workspace_id = $3 AND trigger IS NULL\n FOR UPDATE SKIP LOCKED\n ON CONFLICT (id) DO NOTHING RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "UuidArray", + "Text", + "Jsonb" + ] + }, + "nullable": [ + false + ] + }, + "hash": "51a19a7d611807c8b0957babf821e58e9aa1ce345f1cd5965298fda6f9e158a9" +} diff --git a/backend/.sqlx/query-51ddbfec67af268d9bbee12b2730d6109d2a6633e62ce708bad8af1a9f8c3925.json b/backend/.sqlx/query-51ddbfec67af268d9bbee12b2730d6109d2a6633e62ce708bad8af1a9f8c3925.json new file mode 100644 index 0000000000..e664011467 --- /dev/null +++ b/backend/.sqlx/query-51ddbfec67af268d9bbee12b2730d6109d2a6633e62ce708bad8af1a9f8c3925.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH ping AS (UPDATE v2_job_runtime SET ping = NULL WHERE id = $2 RETURNING id)\n UPDATE v2_job_queue SET\n running = false,\n started_at = null,\n scheduled_for = $1\n WHERE id = (SELECT id FROM ping)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamptz", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "51ddbfec67af268d9bbee12b2730d6109d2a6633e62ce708bad8af1a9f8c3925" +} diff --git a/backend/.sqlx/query-52bd8efeaec0d0c2aa77d777a0b6559a1aa4ca9ebd4f9b535014cbcb113f9b92.json b/backend/.sqlx/query-52bd8efeaec0d0c2aa77d777a0b6559a1aa4ca9ebd4f9b535014cbcb113f9b92.json new file mode 100644 index 0000000000..b4576d8682 --- /dev/null +++ b/backend/.sqlx/query-52bd8efeaec0d0c2aa77d777a0b6559a1aa4ca9ebd4f9b535014cbcb113f9b92.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\"\n FROM queue\n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "args: sqlx::types::Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "52bd8efeaec0d0c2aa77d777a0b6559a1aa4ca9ebd4f9b535014cbcb113f9b92" +} diff --git a/backend/.sqlx/query-5401c521b5e63b7d9e7bc51c19d116599f6bcedbe70f3bf346b482fe79501958.json b/backend/.sqlx/query-5401c521b5e63b7d9e7bc51c19d116599f6bcedbe70f3bf346b482fe79501958.json new file mode 100644 index 0000000000..9a1b65ff52 --- /dev/null +++ b/backend/.sqlx/query-5401c521b5e63b7d9e7bc51c19d116599f6bcedbe70f3bf346b482fe79501958.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "create index concurrently if not exists ix_job_workspace_id_created_at_new_8 ON v2_job (workspace_id, created_at DESC) where kind in ('deploymentcallback') AND parent_job IS NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "5401c521b5e63b7d9e7bc51c19d116599f6bcedbe70f3bf346b482fe79501958" +} diff --git a/backend/.sqlx/query-55002cccf17e32af5b077a17707122cfeeeebf5a9392c6798a486274d8d233d5.json b/backend/.sqlx/query-55002cccf17e32af5b077a17707122cfeeeebf5a9392c6798a486274d8d233d5.json new file mode 100644 index 0000000000..f9d007d4c1 --- /dev/null +++ b/backend/.sqlx/query-55002cccf17e32af5b077a17707122cfeeeebf5a9392c6798a486274d8d233d5.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM v2_job WHERE id = $1 AND workspace_id = $2\n UNION ALL\n SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM input WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + null + ] + }, + "hash": "55002cccf17e32af5b077a17707122cfeeeebf5a9392c6798a486274d8d233d5" +} diff --git a/backend/.sqlx/query-55cb03040bc2a8c53dd7fbb42bbdcc40f463cbc52d94ed9315cf9a547d4c89f2.json b/backend/.sqlx/query-55cb03040bc2a8c53dd7fbb42bbdcc40f463cbc52d94ed9315cf9a547d4c89f2.json index baf7cb42f5..920176991b 100644 --- a/backend/.sqlx/query-55cb03040bc2a8c53dd7fbb42bbdcc40f463cbc52d94ed9315cf9a547d4c89f2.json +++ b/backend/.sqlx/query-55cb03040bc2a8c53dd7fbb42bbdcc40f463cbc52d94ed9315cf9a547d4c89f2.json @@ -70,68 +70,73 @@ }, { "ordinal": 13, - "name": "code_completion_enabled", - "type_info": "Bool" - }, - { - "ordinal": 14, "name": "error_handler_extra_args", "type_info": "Json" }, { - "ordinal": 15, + "ordinal": 14, "name": "error_handler_muted_on_cancel", "type_info": "Bool" }, { - "ordinal": 16, + "ordinal": 15, "name": "large_file_storage", "type_info": "Jsonb" }, { - "ordinal": 17, + "ordinal": 16, "name": "git_sync", "type_info": "Jsonb" }, { - "ordinal": 18, + "ordinal": 17, "name": "default_app", "type_info": "Varchar" }, { - "ordinal": 19, + "ordinal": 18, "name": "auto_add", "type_info": "Bool" }, { - "ordinal": 20, + "ordinal": 19, "name": "automatic_billing", "type_info": "Bool" }, { - "ordinal": 21, + "ordinal": 20, "name": "default_scripts", "type_info": "Jsonb" }, { - "ordinal": 22, + "ordinal": 21, "name": "deploy_ui", "type_info": "Jsonb" }, { - "ordinal": 23, + "ordinal": 22, "name": "mute_critical_alerts", "type_info": "Bool" }, { - "ordinal": 24, + "ordinal": 23, "name": "color", "type_info": "Varchar" }, { - "ordinal": 25, + "ordinal": 24, "name": "operator_settings", "type_info": "Jsonb" + }, + { + "ordinal": 25, + "name": "ai_models", + "type_info": "VarcharArray" + }, + { + "ordinal": 26, + "name": "code_completion_model", + "type_info": "Varchar" } ], "parameters": { @@ -153,7 +158,6 @@ true, true, true, - false, true, false, true, @@ -165,6 +169,8 @@ true, true, true, + true, + false, true ] }, diff --git a/backend/.sqlx/query-572492b357bc4e2576d77ed135682f4623c74e61759dda257bd1f633f1a2b725.json b/backend/.sqlx/query-572492b357bc4e2576d77ed135682f4623c74e61759dda257bd1f633f1a2b725.json new file mode 100644 index 0000000000..d825f28c4d --- /dev/null +++ b/backend/.sqlx/query-572492b357bc4e2576d77ed135682f4623c74e61759dda257bd1f633f1a2b725.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT EXISTS(SELECT 1 FROM v2_job_completed WHERE id = $1 AND workspace_id = $2)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "exists", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "572492b357bc4e2576d77ed135682f4623c74e61759dda257bd1f633f1a2b725" +} diff --git a/backend/.sqlx/query-58c0eb36b630d5eba9d12edca672ebd56e13193395701e26328a243055bee6b8.json b/backend/.sqlx/query-58c0eb36b630d5eba9d12edca672ebd56e13193395701e26328a243055bee6b8.json new file mode 100644 index 0000000000..b3a4714404 --- /dev/null +++ b/backend/.sqlx/query-58c0eb36b630d5eba9d12edca672ebd56e13193395701e26328a243055bee6b8.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT usage.usage + 1 FROM usage \n WHERE is_workspace IS TRUE AND\n month_ = EXTRACT(YEAR FROM current_date) * 12 + EXTRACT(MONTH FROM current_date)\n AND id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "58c0eb36b630d5eba9d12edca672ebd56e13193395701e26328a243055bee6b8" +} diff --git a/backend/.sqlx/query-597b148ff09a1e0f369bb04781ee4e429ebce64a4d5c16b0f136142ad213cdb1.json b/backend/.sqlx/query-597b148ff09a1e0f369bb04781ee4e429ebce64a4d5c16b0f136142ad213cdb1.json new file mode 100644 index 0000000000..4a704e58d8 --- /dev/null +++ b/backend/.sqlx/query-597b148ff09a1e0f369bb04781ee4e429ebce64a4d5c16b0f136142ad213cdb1.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n args AS \"args: Json>>\"\n FROM v2_job\n WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args: Json>>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "597b148ff09a1e0f369bb04781ee4e429ebce64a4d5c16b0f136142ad213cdb1" +} diff --git a/backend/.sqlx/query-5bce731932a35dbecc38c7b9665ef1117a15acf7d0d41b93de165e788b55d93f.json b/backend/.sqlx/query-5bce731932a35dbecc38c7b9665ef1117a15acf7d0d41b93de165e788b55d93f.json new file mode 100644 index 0000000000..f3ff1e599d --- /dev/null +++ b/backend/.sqlx/query-5bce731932a35dbecc38c7b9665ef1117a15acf7d0d41b93de165e788b55d93f.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", CONCAT(coalesce(completed_job.logs, ''), coalesce(job_logs.logs, '')) as logs, job_logs.log_offset, job_logs.log_file_index\n FROM completed_job \n LEFT JOIN job_logs ON job_logs.job_id = completed_job.id \n WHERE completed_job.id = $1 AND completed_job.workspace_id = $2 AND ($3::text[] IS NULL OR completed_job.tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "log_file_index", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + null, + false, + true + ] + }, + "hash": "5bce731932a35dbecc38c7b9665ef1117a15acf7d0d41b93de165e788b55d93f" +} diff --git a/backend/.sqlx/query-5c141db5cd6806cc27696a38b7f56a190dbea3ff59e2961658dd1677365e0fdf.json b/backend/.sqlx/query-5c141db5cd6806cc27696a38b7f56a190dbea3ff59e2961658dd1677365e0fdf.json new file mode 100644 index 0000000000..3d61a47eb1 --- /dev/null +++ b/backend/.sqlx/query-5c141db5cd6806cc27696a38b7f56a190dbea3ff59e2961658dd1677365e0fdf.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = jsonb_set(\n jsonb_set(flow_status, ARRAY['modules', $3::INTEGER::TEXT, 'job'], to_jsonb($1::UUID::TEXT)),\n ARRAY['modules', $3::INTEGER::TEXT, 'type'],\n to_jsonb('InProgress'::text)\n )\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "5c141db5cd6806cc27696a38b7f56a190dbea3ff59e2961658dd1677365e0fdf" +} diff --git a/backend/.sqlx/query-639dbfa0c98d8b91006823f4c645a1105d6c1cc58990937c9bcf693a8812920c.json b/backend/.sqlx/query-639dbfa0c98d8b91006823f4c645a1105d6c1cc58990937c9bcf693a8812920c.json new file mode 100644 index 0000000000..739be2be53 --- /dev/null +++ b/backend/.sqlx/query-639dbfa0c98d8b91006823f4c645a1105d6c1cc58990937c9bcf693a8812920c.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result #> $3 AS \"result: Json>\"\n FROM completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + null + ] + }, + "hash": "639dbfa0c98d8b91006823f4c645a1105d6c1cc58990937c9bcf693a8812920c" +} diff --git a/backend/.sqlx/query-641087f3166faee8baad063fd569b61aa4d21a15a9bc06e0c2fd15b47eb7beb0.json b/backend/.sqlx/query-641087f3166faee8baad063fd569b61aa4d21a15a9bc06e0c2fd15b47eb7beb0.json new file mode 100644 index 0000000000..b070f8eb7f --- /dev/null +++ b/backend/.sqlx/query-641087f3166faee8baad063fd569b61aa4d21a15a9bc06e0c2fd15b47eb7beb0.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n id As \"id!\",\n flow_status->'restarted_from'->'flow_job_id' AS \"restarted_from: Json\"\n FROM queue\n WHERE COALESCE((SELECT root_job FROM queue WHERE id = $1), $1) = id AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "restarted_from: Json", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + null + ] + }, + "hash": "641087f3166faee8baad063fd569b61aa4d21a15a9bc06e0c2fd15b47eb7beb0" +} diff --git a/backend/.sqlx/query-653574b381a31548d82c1f6f3f44ec826597c42310ab78f9aacd7d9448206c6a.json b/backend/.sqlx/query-653574b381a31548d82c1f6f3f44ec826597c42310ab78f9aacd7d9448206c6a.json new file mode 100644 index 0000000000..3d3309cb5c --- /dev/null +++ b/backend/.sqlx/query-653574b381a31548d82c1f6f3f44ec826597c42310ab78f9aacd7d9448206c6a.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH zombie_jobs AS (\n UPDATE v2_job_queue q SET running = false, started_at = null\n FROM v2_job j, v2_job_runtime r\n WHERE j.id = q.id AND j.id = r.id\n AND ping < now() - ($1 || ' seconds')::interval\n AND running = true\n AND kind NOT IN ('flow', 'flowpreview', 'flownode', 'singlescriptflow')\n AND same_worker = false\n RETURNING q.id, q.workspace_id, ping\n ),\n update_concurrency AS (\n UPDATE concurrency_counter cc\n SET job_uuids = job_uuids - zj.id::text\n FROM zombie_jobs zj\n INNER JOIN concurrency_key ck ON ck.job_id = zj.id\n WHERE cc.concurrency_id = ck.key\n )\n SELECT id, workspace_id, ping FROM zombie_jobs", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "workspace_id", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "ping", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + true + ] + }, + "hash": "653574b381a31548d82c1f6f3f44ec826597c42310ab78f9aacd7d9448206c6a" +} diff --git a/backend/.sqlx/query-6664be80f0d72ea7b8b184c5348063db3bbfea67f4a056d6e3be1fc4255cfc06.json b/backend/.sqlx/query-6664be80f0d72ea7b8b184c5348063db3bbfea67f4a056d6e3be1fc4255cfc06.json new file mode 100644 index 0000000000..0e7ae566fd --- /dev/null +++ b/backend/.sqlx/query-6664be80f0d72ea7b8b184c5348063db3bbfea67f4a056d6e3be1fc4255cfc06.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_leaf_jobs = JSONB_SET(coalesce(flow_leaf_jobs, '{}'::jsonb), ARRAY[$1::TEXT], $2)\n WHERE COALESCE((SELECT flow_innermost_root_job FROM v2_job WHERE id = $3), $3) = id", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "6664be80f0d72ea7b8b184c5348063db3bbfea67f4a056d6e3be1fc4255cfc06" +} diff --git a/backend/.sqlx/query-66bf488f2eeaf5b4c4cb8c579d7a15eb87516c319c1fcbb3e46032bb9fdf718e.json b/backend/.sqlx/query-66bf488f2eeaf5b4c4cb8c579d7a15eb87516c319c1fcbb3e46032bb9fdf718e.json new file mode 100644 index 0000000000..faf1201af1 --- /dev/null +++ b/backend/.sqlx/query-66bf488f2eeaf5b4c4cb8c579d7a15eb87516c319c1fcbb3e46032bb9fdf718e.json @@ -0,0 +1,38 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n success AS \"success!\",\n result AS \"result: Json>\",\n started_at AS \"started_at!\"\n FROM completed_job\n WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4\n ORDER BY created_at DESC\n LIMIT $5", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "result: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "started_at!", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Text", + "Uuid", + "Int8" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "66bf488f2eeaf5b4c4cb8c579d7a15eb87516c319c1fcbb3e46032bb9fdf718e" +} diff --git a/backend/.sqlx/query-672363560895871e4ab19e0dd0dc36afdbc58470664b6cefa8cec25515a42f13.json b/backend/.sqlx/query-672363560895871e4ab19e0dd0dc36afdbc58470664b6cefa8cec25515a42f13.json new file mode 100644 index 0000000000..53ed43a6e0 --- /dev/null +++ b/backend/.sqlx/query-672363560895871e4ab19e0dd0dc36afdbc58470664b6cefa8cec25515a42f13.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result #> $3 AS \"result: Json>\"\n FROM completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + null + ] + }, + "hash": "672363560895871e4ab19e0dd0dc36afdbc58470664b6cefa8cec25515a42f13" +} diff --git a/backend/.sqlx/query-67afe352fc26dda9107c90e50e954642d877178ce2c0e73b72c3824135ef86f4.json b/backend/.sqlx/query-67afe352fc26dda9107c90e50e954642d877178ce2c0e73b72c3824135ef86f4.json new file mode 100644 index 0000000000..a09be9741e --- /dev/null +++ b/backend/.sqlx/query-67afe352fc26dda9107c90e50e954642d877178ce2c0e73b72c3824135ef86f4.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO job_logs (job_id, logs)\n VALUES ($1, 'Restarted job after not receiving job''s ping for too long the ' || now() || '\n\n')\n ON CONFLICT (job_id) DO UPDATE SET logs = job_logs.logs || '\n' || EXCLUDED.logs\n WHERE job_logs.job_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "67afe352fc26dda9107c90e50e954642d877178ce2c0e73b72c3824135ef86f4" +} diff --git a/backend/.sqlx/query-689b9b39c2e51440b428b521a60eca212d91bb79365a117d754f1d47d8f1ba23.json b/backend/.sqlx/query-689b9b39c2e51440b428b521a60eca212d91bb79365a117d754f1d47d8f1ba23.json new file mode 100644 index 0000000000..c64d090bd1 --- /dev/null +++ b/backend/.sqlx/query-689b9b39c2e51440b428b521a60eca212d91bb79365a117d754f1d47d8f1ba23.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_completed SET result = '{}'::jsonb WHERE id = ANY($1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [] + }, + "hash": "689b9b39c2e51440b428b521a60eca212d91bb79365a117d754f1d47d8f1ba23" +} diff --git a/backend/.sqlx/query-695a02db2ee43d18fdf139b52eb546cffa44845cd634f188d6619cf39462ca93.json b/backend/.sqlx/query-695a02db2ee43d18fdf139b52eb546cffa44845cd634f188d6619cf39462ca93.json new file mode 100644 index 0000000000..546f3e8026 --- /dev/null +++ b/backend/.sqlx/query-695a02db2ee43d18fdf139b52eb546cffa44845cd634f188d6619cf39462ca93.json @@ -0,0 +1,37 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result #> $3 AS \"result: sqlx::types::Json>\",\n result_columns,\n created_by AS \"created_by!\"\n FROM v2_job_completed c\n JOIN v2_job USING (id)\n WHERE c.id = $1 AND c.workspace_id = $2 AND ($4::text[] IS NULL OR tag = ANY($4))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "result_columns", + "type_info": "TextArray" + }, + { + "ordinal": 2, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray", + "TextArray" + ] + }, + "nullable": [ + null, + true, + false + ] + }, + "hash": "695a02db2ee43d18fdf139b52eb546cffa44845cd634f188d6619cf39462ca93" +} diff --git a/backend/.sqlx/query-69ff806066a24c60188d7547a7776c160ee65eaa01b259c996f3f96ed44fcaaf.json b/backend/.sqlx/query-69ff806066a24c60188d7547a7776c160ee65eaa01b259c996f3f96ed44fcaaf.json new file mode 100644 index 0000000000..75ef2996a0 --- /dev/null +++ b/backend/.sqlx/query-69ff806066a24c60188d7547a7776c160ee65eaa01b259c996f3f96ed44fcaaf.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['step'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "69ff806066a24c60188d7547a7776c160ee65eaa01b259c996f3f96ed44fcaaf" +} diff --git a/backend/.sqlx/query-6ab112fa42a9ae332bfa30427b70fa742351c5c180ac3de106df54f7badb494c.json b/backend/.sqlx/query-6ab112fa42a9ae332bfa30427b70fa742351c5c180ac3de106df54f7badb494c.json new file mode 100644 index 0000000000..ef26a8453e --- /dev/null +++ b/backend/.sqlx/query-6ab112fa42a9ae332bfa30427b70fa742351c5c180ac3de106df54f7badb494c.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(id) FROM v2_as_queue WHERE email = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "6ab112fa42a9ae332bfa30427b70fa742351c5c180ac3de106df54f7badb494c" +} diff --git a/backend/.sqlx/query-6b0115e40d4361b3ca72dbd071b0a8c0319c5ae0b92f289ec1e74d2478c9e740.json b/backend/.sqlx/query-6b0115e40d4361b3ca72dbd071b0a8c0319c5ae0b92f289ec1e74d2478c9e740.json new file mode 100644 index 0000000000..265ededd17 --- /dev/null +++ b/backend/.sqlx/query-6b0115e40d4361b3ca72dbd071b0a8c0319c5ae0b92f289ec1e74d2478c9e740.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", CONCAT(coalesce(queue.logs, ''), coalesce(job_logs.logs, '')) as logs, coalesce(job_logs.log_offset, 0) as log_offset, job_logs.log_file_index\n FROM queue \n LEFT JOIN job_logs ON job_logs.job_id = queue.id \n WHERE queue.id = $1 AND queue.workspace_id = $2 AND ($3::text[] IS NULL OR queue.tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "log_file_index", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + null, + null, + true + ] + }, + "hash": "6b0115e40d4361b3ca72dbd071b0a8c0319c5ae0b92f289ec1e74d2478c9e740" +} diff --git a/backend/.sqlx/query-6bdb3fcfe16fc40222dc7010a11026d4d4e0d381b31fe02da7d2667c0cdc1a85.json b/backend/.sqlx/query-6bdb3fcfe16fc40222dc7010a11026d4d4e0d381b31fe02da7d2667c0cdc1a85.json new file mode 100644 index 0000000000..c498b1790a --- /dev/null +++ b/backend/.sqlx/query-6bdb3fcfe16fc40222dc7010a11026d4d4e0d381b31fe02da7d2667c0cdc1a85.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_completed SET workspace_id = $1 WHERE workspace_id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text" + ] + }, + "nullable": [] + }, + "hash": "6bdb3fcfe16fc40222dc7010a11026d4d4e0d381b31fe02da7d2667c0cdc1a85" +} diff --git a/backend/.sqlx/query-6cb2c77bb90679a36189007b1f70406fe28923f51fc465ae0f45d7f317077bf5.json b/backend/.sqlx/query-6cb2c77bb90679a36189007b1f70406fe28923f51fc465ae0f45d7f317077bf5.json new file mode 100644 index 0000000000..e41413a7bf --- /dev/null +++ b/backend/.sqlx/query-6cb2c77bb90679a36189007b1f70406fe28923f51fc465ae0f45d7f317077bf5.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['cleanup_module', 'flow_jobs_to_clean'], COALESCE(flow_status->'cleanup_module'->'flow_jobs_to_clean', '[]'::jsonb) || $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "6cb2c77bb90679a36189007b1f70406fe28923f51fc465ae0f45d7f317077bf5" +} diff --git a/backend/.sqlx/query-6daf2aca3e272a1efd7b26b4c80d6b490628f502ed9f9de75cc78d0fe196f260.json b/backend/.sqlx/query-6daf2aca3e272a1efd7b26b4c80d6b490628f502ed9f9de75cc78d0fe196f260.json new file mode 100644 index 0000000000..d94865aafa --- /dev/null +++ b/backend/.sqlx/query-6daf2aca3e272a1efd7b26b4c80d6b490628f502ed9f9de75cc78d0fe196f260.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT running AS \"running!\" FROM v2_job_queue WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "running!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "6daf2aca3e272a1efd7b26b4c80d6b490628f502ed9f9de75cc78d0fe196f260" +} diff --git a/backend/.sqlx/query-6ff7a025f529c077c1b6c9632a367aa29e2f0fdac3f1984550484d5a06a6ea21.json b/backend/.sqlx/query-6ff7a025f529c077c1b6c9632a367aa29e2f0fdac3f1984550484d5a06a6ea21.json new file mode 100644 index 0000000000..b045ed2b07 --- /dev/null +++ b/backend/.sqlx/query-6ff7a025f529c077c1b6c9632a367aa29e2f0fdac3f1984550484d5a06a6ea21.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_runtime r SET\n memory_peak = $1,\n ping = now()\n FROM v2_job_queue q\n WHERE r.id = $2 AND q.id = r.id\n RETURNING canceled_by, canceled_reason", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "canceled_by", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "canceled_reason", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "6ff7a025f529c077c1b6c9632a367aa29e2f0fdac3f1984550484d5a06a6ea21" +} diff --git a/backend/.sqlx/query-70e740465e648d84d32a506916ed437d1e32d4b5bdc7f7fae22e804428660836.json b/backend/.sqlx/query-70e740465e648d84d32a506916ed437d1e32d4b5bdc7f7fae22e804428660836.json new file mode 100644 index 0000000000..9278984d51 --- /dev/null +++ b/backend/.sqlx/query-70e740465e648d84d32a506916ed437d1e32d4b5bdc7f7fae22e804428660836.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH uuid_table as (\n select unnest($4::uuid[]) as uuid\n )\n INSERT INTO v2_job_queue\n (id, workspace_id, scheduled_for, tag)\n (SELECT uuid, $1, $2, $3 FROM uuid_table) \n RETURNING id", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Timestamptz", + "Varchar", + "UuidArray" + ] + }, + "nullable": [ + false + ] + }, + "hash": "70e740465e648d84d32a506916ed437d1e32d4b5bdc7f7fae22e804428660836" +} diff --git a/backend/.sqlx/query-729c5c6430431f044148aeeec18ad3056ee4fdf8691ba5503937424d75f3815e.json b/backend/.sqlx/query-729c5c6430431f044148aeeec18ad3056ee4fdf8691ba5503937424d75f3815e.json new file mode 100644 index 0000000000..b31bd17bd3 --- /dev/null +++ b/backend/.sqlx/query-729c5c6430431f044148aeeec18ad3056ee4fdf8691ba5503937424d75f3815e.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id FROM v2_job_queue", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false + ] + }, + "hash": "729c5c6430431f044148aeeec18ad3056ee4fdf8691ba5503937424d75f3815e" +} diff --git a/backend/.sqlx/query-7463c1eb3f690239c9277b62d935af4f372c07263c6f86bc89b0d25cb573fa80.json b/backend/.sqlx/query-7463c1eb3f690239c9277b62d935af4f372c07263c6f86bc89b0d25cb573fa80.json new file mode 100644 index 0000000000..77ab2c28bd --- /dev/null +++ b/backend/.sqlx/query-7463c1eb3f690239c9277b62d935af4f372c07263c6f86bc89b0d25cb573fa80.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job WHERE workspace_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "7463c1eb3f690239c9277b62d935af4f372c07263c6f86bc89b0d25cb573fa80" +} diff --git a/backend/.sqlx/query-74a2a90d12ca0179c8a80f9bf574066db4e8735c0f717d91391a28bf832c0e71.json b/backend/.sqlx/query-74a2a90d12ca0179c8a80f9bf574066db4e8735c0f717d91391a28bf832c0e71.json new file mode 100644 index 0000000000..fc80d816cf --- /dev/null +++ b/backend/.sqlx/query-74a2a90d12ca0179c8a80f9bf574066db4e8735c0f717d91391a28bf832c0e71.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue SET canceled = true, canceled_by = $1, canceled_reason = $2, scheduled_for = now(), suspend = 0 WHERE id = $3 AND workspace_id = $4 AND (canceled = false OR canceled_reason != $2) RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "74a2a90d12ca0179c8a80f9bf574066db4e8735c0f717d91391a28bf832c0e71" +} diff --git a/backend/.sqlx/query-74dbd5a09255c30991078492ba3850e02ffbef25fbfd29cbedc041b0e439e580.json b/backend/.sqlx/query-74dbd5a09255c30991078492ba3850e02ffbef25fbfd29cbedc041b0e439e580.json new file mode 100644 index 0000000000..77515a838f --- /dev/null +++ b/backend/.sqlx/query-74dbd5a09255c30991078492ba3850e02ffbef25fbfd29cbedc041b0e439e580.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\", flow_status AS \"flow_status!: Json\"\n FROM v2_as_completed_job\n WHERE parent_job = $1 AND workspace_id = $2 AND flow_status IS NOT NULL", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status!: Json", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "74dbd5a09255c30991078492ba3850e02ffbef25fbfd29cbedc041b0e439e580" +} diff --git a/backend/.sqlx/query-76690ea29969da28840c90016ec78e5ea7f326df9f19e9d2f0445e662c921fea.json b/backend/.sqlx/query-76690ea29969da28840c90016ec78e5ea7f326df9f19e9d2f0445e662c921fea.json new file mode 100644 index 0000000000..67ad1da697 --- /dev/null +++ b/backend/.sqlx/query-76690ea29969da28840c90016ec78e5ea7f326df9f19e9d2f0445e662c921fea.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT q.id, f.flow_status, q.suspend, j.runnable_path AS script_path\n FROM v2_job_queue q\n JOIN v2_job j USING (id)\n JOIN v2_job_status f USING (id)\n WHERE id = ( SELECT parent_job FROM v2_job WHERE id = $1 )\n FOR UPDATE\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "suspend", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + true, + false, + true + ] + }, + "hash": "76690ea29969da28840c90016ec78e5ea7f326df9f19e9d2f0445e662c921fea" +} diff --git a/backend/.sqlx/query-798a6bdc8f2fb9421808e084fbddf7de61fa9953998e3dc66af0e5f7491a65f4.json b/backend/.sqlx/query-798a6bdc8f2fb9421808e084fbddf7de61fa9953998e3dc66af0e5f7491a65f4.json new file mode 100644 index 0000000000..15d39aa539 --- /dev/null +++ b/backend/.sqlx/query-798a6bdc8f2fb9421808e084fbddf7de61fa9953998e3dc66af0e5f7491a65f4.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET suspend = 0 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "798a6bdc8f2fb9421808e084fbddf7de61fa9953998e3dc66af0e5f7491a65f4" +} diff --git a/backend/.sqlx/query-7af1cf089022fc1c3597b270b69aa669a153ab0c0bb2807cd4f7fd405afa6f69.json b/backend/.sqlx/query-7af1cf089022fc1c3597b270b69aa669a153ab0c0bb2807cd4f7fd405afa6f69.json new file mode 100644 index 0000000000..d2e54f45c8 --- /dev/null +++ b/backend/.sqlx/query-7af1cf089022fc1c3597b270b69aa669a153ab0c0bb2807cd4f7fd405afa6f69.json @@ -0,0 +1,73 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n script_path, script_hash AS \"script_hash: ScriptHash\",\n job_kind AS \"job_kind!: JobKind\",\n flow_status AS \"flow_status: Json>\",\n raw_flow AS \"raw_flow: Json>\"\n FROM v2_as_completed_job WHERE id = $1 and workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "script_hash: ScriptHash", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "job_kind!: JobKind", + "type_info": { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "flow_status: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "raw_flow: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true + ] + }, + "hash": "7af1cf089022fc1c3597b270b69aa669a153ab0c0bb2807cd4f7fd405afa6f69" +} diff --git a/backend/.sqlx/query-7b084617bf2de5ed9a657d2bd2cbc9de1246427bf0302c032f8bd26ff93313f7.json b/backend/.sqlx/query-7b084617bf2de5ed9a657d2bd2cbc9de1246427bf0302c032f8bd26ff93313f7.json new file mode 100644 index 0000000000..3f72b7b760 --- /dev/null +++ b/backend/.sqlx/query-7b084617bf2de5ed9a657d2bd2cbc9de1246427bf0302c032f8bd26ff93313f7.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['failure_module'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "7b084617bf2de5ed9a657d2bd2cbc9de1246427bf0302c032f8bd26ff93313f7" +} diff --git a/backend/.sqlx/query-7b1e6b67a20ae1128118d5f5cc0db4007fb9dc6fd20582a46ebb951fca3a7abd.json b/backend/.sqlx/query-7b1e6b67a20ae1128118d5f5cc0db4007fb9dc6fd20582a46ebb951fca3a7abd.json new file mode 100644 index 0000000000..a094b8580f --- /dev/null +++ b/backend/.sqlx/query-7b1e6b67a20ae1128118d5f5cc0db4007fb9dc6fd20582a46ebb951fca3a7abd.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT CAST(ROUND(AVG(duration_ms), 0) AS BIGINT) AS avg_duration_s FROM\n (SELECT duration_ms FROM concurrency_key LEFT JOIN v2_as_completed_job ON v2_as_completed_job.id = concurrency_key.job_id WHERE key = $1 AND ended_at IS NOT NULL\n ORDER BY ended_at\n DESC LIMIT 10) AS t", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "avg_duration_s", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "7b1e6b67a20ae1128118d5f5cc0db4007fb9dc6fd20582a46ebb951fca3a7abd" +} diff --git a/backend/.sqlx/query-7bd7505b008954aae6152554c1f9bb0611d0ec451b48aa1a4de309dadeb53315.json b/backend/.sqlx/query-7bd7505b008954aae6152554c1f9bb0611d0ec451b48aa1a4de309dadeb53315.json new file mode 100644 index 0000000000..c7f3146594 --- /dev/null +++ b/backend/.sqlx/query-7bd7505b008954aae6152554c1f9bb0611d0ec451b48aa1a4de309dadeb53315.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = flow_status - 'approval_conditions'\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "7bd7505b008954aae6152554c1f9bb0611d0ec451b48aa1a4de309dadeb53315" +} diff --git a/backend/.sqlx/query-7c31a680436fd91db30c089e694cc5d8c7fb768a6ddc7cf337469a140fa37106.json b/backend/.sqlx/query-7c31a680436fd91db30c089e694cc5d8c7fb768a6ddc7cf337469a140fa37106.json new file mode 100644 index 0000000000..b3483a00ab --- /dev/null +++ b/backend/.sqlx/query-7c31a680436fd91db30c089e694cc5d8c7fb768a6ddc7cf337469a140fa37106.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET args = $1 WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "7c31a680436fd91db30c089e694cc5d8c7fb768a6ddc7cf337469a140fa37106" +} diff --git a/backend/.sqlx/query-7c7234d8234fbaff4d42eb47d1e1ea1747ffe28986055c01a4661628e47c0e51.json b/backend/.sqlx/query-7c7234d8234fbaff4d42eb47d1e1ea1747ffe28986055c01a4661628e47c0e51.json new file mode 100644 index 0000000000..b1ace4f315 --- /dev/null +++ b/backend/.sqlx/query-7c7234d8234fbaff4d42eb47d1e1ea1747ffe28986055c01a4661628e47c0e51.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_completed SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "7c7234d8234fbaff4d42eb47d1e1ea1747ffe28986055c01a4661628e47c0e51" +} diff --git a/backend/.sqlx/query-7cb0b49f5898b1adbf6579922aa02be4b9550b043240b2076e105976fedb789c.json b/backend/.sqlx/query-7cb0b49f5898b1adbf6579922aa02be4b9550b043240b2076e105976fedb789c.json new file mode 100644 index 0000000000..3e507fe815 --- /dev/null +++ b/backend/.sqlx/query-7cb0b49f5898b1adbf6579922aa02be4b9550b043240b2076e105976fedb789c.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET canceled_by = $1, canceled_reason = $2, scheduled_for = now(), suspend = 0 WHERE id = $3 AND workspace_id = $4 AND (canceled_by IS NULL OR canceled_reason != $2) RETURNING id", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "7cb0b49f5898b1adbf6579922aa02be4b9550b043240b2076e105976fedb789c" +} diff --git a/backend/.sqlx/query-7cf5a1c434c8d84eb2400cd394c8fed2e35cb1943d63692dfbf1b997e1263da0.json b/backend/.sqlx/query-7cf5a1c434c8d84eb2400cd394c8fed2e35cb1943d63692dfbf1b997e1263da0.json new file mode 100644 index 0000000000..c171169e32 --- /dev/null +++ b/backend/.sqlx/query-7cf5a1c434c8d84eb2400cd394c8fed2e35cb1943d63692dfbf1b997e1263da0.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET\n args = (SELECT result FROM v2_job_completed WHERE id = $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "7cf5a1c434c8d84eb2400cd394c8fed2e35cb1943d63692dfbf1b997e1263da0" +} diff --git a/backend/.sqlx/query-7d07a717533bfcaf581f6655bc387095542490fbb4aae30ec7fa75c2dae98ec8.json b/backend/.sqlx/query-7d07a717533bfcaf581f6655bc387095542490fbb4aae30ec7fa75c2dae98ec8.json new file mode 100644 index 0000000000..4e90a2a0ec --- /dev/null +++ b/backend/.sqlx/query-7d07a717533bfcaf581f6655bc387095542490fbb4aae30ec7fa75c2dae98ec8.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_runtime r SET\n ping = now()\n FROM v2_job_queue q\n WHERE r.id = $1 AND q.id = r.id\n AND q.workspace_id = $2\n AND canceled_by IS NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "7d07a717533bfcaf581f6655bc387095542490fbb4aae30ec7fa75c2dae98ec8" +} diff --git a/backend/.sqlx/query-7dc7bc4e22942792938d273655962a95486f6da82cdc08f79dd6cef508256474.json b/backend/.sqlx/query-7dc7bc4e22942792938d273655962a95486f6da82cdc08f79dd6cef508256474.json new file mode 100644 index 0000000000..94ad208788 --- /dev/null +++ b/backend/.sqlx/query-7dc7bc4e22942792938d273655962a95486f6da82cdc08f79dd6cef508256474.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO completed_job AS cj\n ( workspace_id\n , id\n , parent_job\n , created_by\n , created_at\n , started_at\n , duration_ms\n , success\n , script_hash\n , script_path\n , args\n , result\n , raw_code\n , raw_lock\n , canceled\n , canceled_by\n , canceled_reason\n , job_kind\n , schedule_path\n , permissioned_as\n , flow_status\n , raw_flow\n , is_flow_step\n , is_skipped\n , language\n , email\n , visible_to_owner\n , mem_peak\n , tag\n , priority\n )\n SELECT workspace_id\n , id\n , parent_job\n , created_by\n , created_at\n , now()\n , 0\n , false\n , script_hash\n , script_path\n , args\n , $4\n , raw_code\n , raw_lock\n , true\n , $1\n , canceled_reason\n , job_kind\n , schedule_path\n , permissioned_as\n , flow_status\n , raw_flow\n , is_flow_step\n , false\n , language\n , email\n , visible_to_owner\n , mem_peak\n , tag\n , priority FROM queue \n WHERE id = any($2) AND running = false AND parent_job IS NULL AND workspace_id = $3 AND schedule_path IS NULL FOR UPDATE SKIP LOCKED\n ON CONFLICT (id) DO NOTHING RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Varchar", + "UuidArray", + "Text", + "Jsonb" + ] + }, + "nullable": [ + true + ] + }, + "hash": "7dc7bc4e22942792938d273655962a95486f6da82cdc08f79dd6cef508256474" +} diff --git a/backend/.sqlx/query-8123ba05f6e7b9bd395175ee4ec0c36c3726b2da9ff3592589ac7e83df1c537c.json b/backend/.sqlx/query-8123ba05f6e7b9bd395175ee4ec0c36c3726b2da9ff3592589ac7e83df1c537c.json new file mode 100644 index 0000000000..1126431b46 --- /dev/null +++ b/backend/.sqlx/query-8123ba05f6e7b9bd395175ee4ec0c36c3726b2da9ff3592589ac7e83df1c537c.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id, flow_status AS \"flow_status!: Json\"\n FROM v2_job_completed WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status!: Json", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + false, + true + ] + }, + "hash": "8123ba05f6e7b9bd395175ee4ec0c36c3726b2da9ff3592589ac7e83df1c537c" +} diff --git a/backend/.sqlx/query-830297547ea33969f96a5c4c2b82a540f1d147948e1b1a7523b21151ffa22305.json b/backend/.sqlx/query-830297547ea33969f96a5c4c2b82a540f1d147948e1b1a7523b21151ffa22305.json new file mode 100644 index 0000000000..2e67b21966 --- /dev/null +++ b/backend/.sqlx/query-830297547ea33969f96a5c4c2b82a540f1d147948e1b1a7523b21151ffa22305.json @@ -0,0 +1,38 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n success AS \"success!\",\n result AS \"result: Json>\",\n started_at AS \"started_at!\"FROM v2_as_completed_job WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4\n ORDER BY created_at DESC\n LIMIT $5", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "result: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "started_at!", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Text", + "Uuid", + "Int8" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "830297547ea33969f96a5c4c2b82a540f1d147948e1b1a7523b21151ffa22305" +} diff --git a/backend/.sqlx/query-8381cee8bec06f8eff847b22d25574fc2cbcb32fef9f44632a8bc4c5c487fc4f.json b/backend/.sqlx/query-8381cee8bec06f8eff847b22d25574fc2cbcb32fef9f44632a8bc4c5c487fc4f.json new file mode 100644 index 0000000000..0a5c7ae2c8 --- /dev/null +++ b/backend/.sqlx/query-8381cee8bec06f8eff847b22d25574fc2cbcb32fef9f44632a8bc4c5c487fc4f.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM v2_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + null + ] + }, + "hash": "8381cee8bec06f8eff847b22d25574fc2cbcb32fef9f44632a8bc4c5c487fc4f" +} diff --git a/backend/.sqlx/query-8440081df15fa7874dded86b8af572d971d5892b7dd4c8e824b953113bd6c4a9.json b/backend/.sqlx/query-8440081df15fa7874dded86b8af572d971d5892b7dd4c8e824b953113bd6c4a9.json new file mode 100644 index 0000000000..4a7ebbc0f7 --- /dev/null +++ b/backend/.sqlx/query-8440081df15fa7874dded86b8af572d971d5892b7dd4c8e824b953113bd6c4a9.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT parent_job\n FROM v2_job\n WHERE id = $1 AND workspace_id = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "parent_job", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "8440081df15fa7874dded86b8af572d971d5892b7dd4c8e824b953113bd6c4a9" +} diff --git a/backend/.sqlx/query-84ad6f24aa9ccdc6f6e705b7de1bb707637a9bb1475711f9f9f3f2a6e28cb169.json b/backend/.sqlx/query-84ad6f24aa9ccdc6f6e705b7de1bb707637a9bb1475711f9f9f3f2a6e28cb169.json new file mode 100644 index 0000000000..510e47e50c --- /dev/null +++ b/backend/.sqlx/query-84ad6f24aa9ccdc6f6e705b7de1bb707637a9bb1475711f9f9f3f2a6e28cb169.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET suspend = $1 WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "84ad6f24aa9ccdc6f6e705b7de1bb707637a9bb1475711f9f9f3f2a6e28cb169" +} diff --git a/backend/.sqlx/query-8512298656d6872a2123c2801d842119537374a815c1292fac4c5b75bdd58898.json b/backend/.sqlx/query-8512298656d6872a2123c2801d842119537374a815c1292fac4c5b75bdd58898.json new file mode 100644 index 0000000000..8390708116 --- /dev/null +++ b/backend/.sqlx/query-8512298656d6872a2123c2801d842119537374a815c1292fac4c5b75bdd58898.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET runnable_path = REGEXP_REPLACE(runnable_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\\1') WHERE runnable_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "8512298656d6872a2123c2801d842119537374a815c1292fac4c5b75bdd58898" +} diff --git a/backend/.sqlx/query-85705fc3d7f8ba5f1b12d5fb222c38fc64deb1226aab9dc3bc4465324fce37d1.json b/backend/.sqlx/query-85705fc3d7f8ba5f1b12d5fb222c38fc64deb1226aab9dc3bc4465324fce37d1.json new file mode 100644 index 0000000000..bce7324fb6 --- /dev/null +++ b/backend/.sqlx/query-85705fc3d7f8ba5f1b12d5fb222c38fc64deb1226aab9dc3bc4465324fce37d1.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_queue (id, workspace_id, scheduled_for, tag) SELECT unnest($1::uuid[]), $2, now(), $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray", + "Varchar", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "85705fc3d7f8ba5f1b12d5fb222c38fc64deb1226aab9dc3bc4465324fce37d1" +} diff --git a/backend/.sqlx/query-858db2a501abcfffbcce19d60cc241060c93354de19f0fa80b8f45290e8b992d.json b/backend/.sqlx/query-858db2a501abcfffbcce19d60cc241060c93354de19f0fa80b8f45290e8b992d.json new file mode 100644 index 0000000000..f3d1c484fe --- /dev/null +++ b/backend/.sqlx/query-858db2a501abcfffbcce19d60cc241060c93354de19f0fa80b8f45290e8b992d.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "858db2a501abcfffbcce19d60cc241060c93354de19f0fa80b8f45290e8b992d" +} diff --git a/backend/.sqlx/query-85bbf1244848682702be93527cad26e44e6ce1308505d1fbc9c28eaabcbe463e.json b/backend/.sqlx/query-85bbf1244848682702be93527cad26e44e6ce1308505d1fbc9c28eaabcbe463e.json new file mode 100644 index 0000000000..de49a218fe --- /dev/null +++ b/backend/.sqlx/query-85bbf1244848682702be93527cad26e44e6ce1308505d1fbc9c28eaabcbe463e.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET flow_status = jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], jsonb_set(jsonb_set('{}'::jsonb, '{scheduled_for}', to_jsonb(now()::text)), '{name}', to_jsonb($3::text))) WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "85bbf1244848682702be93527cad26e44e6ce1308505d1fbc9c28eaabcbe463e" +} diff --git a/backend/.sqlx/query-866c1b86d63466df84877e81655ce999284f3d2d854a00fefcaf7c044dcf71ca.json b/backend/.sqlx/query-866c1b86d63466df84877e81655ce999284f3d2d854a00fefcaf7c044dcf71ca.json new file mode 100644 index 0000000000..c4905590b6 --- /dev/null +++ b/backend/.sqlx/query-866c1b86d63466df84877e81655ce999284f3d2d854a00fefcaf7c044dcf71ca.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = jsonb_set(\n jsonb_set(flow_status, ARRAY['failure_module', 'job'], to_jsonb($1::UUID::TEXT)),\n ARRAY['failure_module', 'type'],\n to_jsonb('InProgress'::text)\n )\n WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "866c1b86d63466df84877e81655ce999284f3d2d854a00fefcaf7c044dcf71ca" +} diff --git a/backend/.sqlx/query-86cc1e3c18e936a700d8842a51a6f8377ec190669e2e22f8d511871d6fbe07b8.json b/backend/.sqlx/query-86cc1e3c18e936a700d8842a51a6f8377ec190669e2e22f8d511871d6fbe07b8.json new file mode 100644 index 0000000000..47b30f2895 --- /dev/null +++ b/backend/.sqlx/query-86cc1e3c18e936a700d8842a51a6f8377ec190669e2e22f8d511871d6fbe07b8.json @@ -0,0 +1,38 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n success AS \"success!\",\n result AS \"result: Json>\",\n started_at AS \"started_at!\"\n FROM v2_as_completed_job\n WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4\n ORDER BY created_at DESC\n LIMIT $5", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "result: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "started_at!", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Text", + "Uuid", + "Int8" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "86cc1e3c18e936a700d8842a51a6f8377ec190669e2e22f8d511871d6fbe07b8" +} diff --git a/backend/.sqlx/query-87cd382066f3d8a89da5deaa592c1d1bb1978ff51c3e061674fe6db32b45eaf1.json b/backend/.sqlx/query-87cd382066f3d8a89da5deaa592c1d1bb1978ff51c3e061674fe6db32b45eaf1.json new file mode 100644 index 0000000000..7af7170f7e --- /dev/null +++ b/backend/.sqlx/query-87cd382066f3d8a89da5deaa592c1d1bb1978ff51c3e061674fe6db32b45eaf1.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_status (id, flow_status) VALUES ($1, $2)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "87cd382066f3d8a89da5deaa592c1d1bb1978ff51c3e061674fe6db32b45eaf1" +} diff --git a/backend/.sqlx/query-8a1c9119f6f4763f64597684dc7b312404e637212de1897e97999755a2e492fd.json b/backend/.sqlx/query-8a1c9119f6f4763f64597684dc7b312404e637212de1897e97999755a2e492fd.json new file mode 100644 index 0000000000..8a92be2af8 --- /dev/null +++ b/backend/.sqlx/query-8a1c9119f6f4763f64597684dc7b312404e637212de1897e97999755a2e492fd.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET\n args = (SELECT result FROM v2_job_completed WHERE id = $1),\n preprocessed = TRUE\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "8a1c9119f6f4763f64597684dc7b312404e637212de1897e97999755a2e492fd" +} diff --git a/backend/.sqlx/query-8be1ddb20ffd8c375b7d1ecb14bdb3a7c2f0c8f9308946b9262e14b8c584dd99.json b/backend/.sqlx/query-8be1ddb20ffd8c375b7d1ecb14bdb3a7c2f0c8f9308946b9262e14b8c584dd99.json new file mode 100644 index 0000000000..60ca066b36 --- /dev/null +++ b/backend/.sqlx/query-8be1ddb20ffd8c375b7d1ecb14bdb3a7c2f0c8f9308946b9262e14b8c584dd99.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = flow_status - 'retry'\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "8be1ddb20ffd8c375b7d1ecb14bdb3a7c2f0c8f9308946b9262e14b8c584dd99" +} diff --git a/backend/.sqlx/query-8be277b89102a26dda506202a3ef7eb05342cfb3aa9b4f5d80c70fbc50d437ba.json b/backend/.sqlx/query-8be277b89102a26dda506202a3ef7eb05342cfb3aa9b4f5d80c70fbc50d437ba.json new file mode 100644 index 0000000000..e5819f5c6a --- /dev/null +++ b/backend/.sqlx/query-8be277b89102a26dda506202a3ef7eb05342cfb3aa9b4f5d80c70fbc50d437ba.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "create index concurrently if not exists ix_job_workspace_id_created_at_new_6 ON v2_job (workspace_id, created_at DESC) where kind in ('script', 'flow') AND parent_job IS NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "8be277b89102a26dda506202a3ef7eb05342cfb3aa9b4f5d80c70fbc50d437ba" +} diff --git a/backend/.sqlx/query-8cb755510f2cfb23bdd0d1cf66b69949549a44855529f77a530f681a6e714646.json b/backend/.sqlx/query-8cb755510f2cfb23bdd0d1cf66b69949549a44855529f77a530f681a6e714646.json new file mode 100644 index 0000000000..82b70ebe92 --- /dev/null +++ b/backend/.sqlx/query-8cb755510f2cfb23bdd0d1cf66b69949549a44855529f77a530f681a6e714646.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = JSONB_SET(\n flow_status,\n ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT],\n $4\n )\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "8cb755510f2cfb23bdd0d1cf66b69949549a44855529f77a530f681a6e714646" +} diff --git a/backend/.sqlx/query-8dd93be44f66c0744ddaff12a9664d9ad745a4a2bb4c0fa36d3caf77fa60e035.json b/backend/.sqlx/query-8dd93be44f66c0744ddaff12a9664d9ad745a4a2bb4c0fa36d3caf77fa60e035.json new file mode 100644 index 0000000000..dead4b0a55 --- /dev/null +++ b/backend/.sqlx/query-8dd93be44f66c0744ddaff12a9664d9ad745a4a2bb4c0fa36d3caf77fa60e035.json @@ -0,0 +1,54 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n running AS \"running!\",\n substr(concat(coalesce(queue.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs,\n mem_peak,\n CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\",\n job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset,\n created_by AS \"created_by!\"\n FROM queue\n LEFT JOIN job_logs ON job_logs.job_id = queue.id \n WHERE queue.workspace_id = $2 AND queue.id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "running!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "mem_peak", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 5, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Int4", + "Text", + "Uuid" + ] + }, + "nullable": [ + true, + null, + true, + null, + null, + true + ] + }, + "hash": "8dd93be44f66c0744ddaff12a9664d9ad745a4a2bb4c0fa36d3caf77fa60e035" +} diff --git a/backend/.sqlx/query-8f3ed45a0290cd9989f40f34775de5e8c3762597e6f55f8b9575a54ccc31e085.json b/backend/.sqlx/query-8f3ed45a0290cd9989f40f34775de5e8c3762597e6f55f8b9575a54ccc31e085.json new file mode 100644 index 0000000000..4fd9cd8a4f --- /dev/null +++ b/backend/.sqlx/query-8f3ed45a0290cd9989f40f34775de5e8c3762597e6f55f8b9575a54ccc31e085.json @@ -0,0 +1,25 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4),\n ARRAY['modules', $1::TEXT, 'branchall', 'branch'],\n ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb\n )\n WHERE id = $2\n RETURNING (flow_status->'modules'->$1::int->'branchall'->>'branch')::int", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "int4", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [ + null + ] + }, + "hash": "8f3ed45a0290cd9989f40f34775de5e8c3762597e6f55f8b9575a54ccc31e085" +} diff --git a/backend/.sqlx/query-902a16d9e7ac34e7f1a0ad633bae754a0d64bc934a2b6434b9cb67f28d3ef950.json b/backend/.sqlx/query-902a16d9e7ac34e7f1a0ad633bae754a0d64bc934a2b6434b9cb67f28d3ef950.json new file mode 100644 index 0000000000..7a6d47ba81 --- /dev/null +++ b/backend/.sqlx/query-902a16d9e7ac34e7f1a0ad633bae754a0d64bc934a2b6434b9cb67f28d3ef950.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "902a16d9e7ac34e7f1a0ad633bae754a0d64bc934a2b6434b9cb67f28d3ef950" +} diff --git a/backend/.sqlx/query-90635149190c59396ca557bf1670554a1e40d0ce9cc686ad09adca0904324cd8.json b/backend/.sqlx/query-90635149190c59396ca557bf1670554a1e40d0ce9cc686ad09adca0904324cd8.json new file mode 100644 index 0000000000..9dce5f08b4 --- /dev/null +++ b/backend/.sqlx/query-90635149190c59396ca557bf1670554a1e40d0ce9cc686ad09adca0904324cd8.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue q SET suspend = 0\n FROM v2_job j, v2_job_status f\n WHERE parent_job = $1\n AND f.id = j.id AND q.id = j.id\n AND suspend = $2 AND (f.flow_status->'step')::int = 0", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "90635149190c59396ca557bf1670554a1e40d0ce9cc686ad09adca0904324cd8" +} diff --git a/backend/.sqlx/query-90fbb9430ab03ce3aadd95cc263e5a3d1a91ea02de7608676575e1c03023ed71.json b/backend/.sqlx/query-90fbb9430ab03ce3aadd95cc263e5a3d1a91ea02de7608676575e1c03023ed71.json new file mode 100644 index 0000000000..61598c0b2d --- /dev/null +++ b/backend/.sqlx/query-90fbb9430ab03ce3aadd95cc263e5a3d1a91ea02de7608676575e1c03023ed71.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT tag as \"tag!\", COUNT(*) as \"count!\"\n FROM v2_as_completed_job\n WHERE started_at > NOW() - make_interval(secs => $1) AND ($2::text IS NULL OR workspace_id = $2)\n GROUP BY tag\n ORDER BY \"count!\" DESC\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "tag!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "count!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Float8", + "Text" + ] + }, + "nullable": [ + true, + null + ] + }, + "hash": "90fbb9430ab03ce3aadd95cc263e5a3d1a91ea02de7608676575e1c03023ed71" +} diff --git a/backend/.sqlx/query-9250b087485e51af83aef1f412c85edc114add7a6b6c1e3845ffda344effa03c.json b/backend/.sqlx/query-9250b087485e51af83aef1f412c85edc114add7a6b6c1e3845ffda344effa03c.json new file mode 100644 index 0000000000..b46a8f1a22 --- /dev/null +++ b/backend/.sqlx/query-9250b087485e51af83aef1f412c85edc114add7a6b6c1e3845ffda344effa03c.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = flow_status - 'approval_conditions'\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "9250b087485e51af83aef1f412c85edc114add7a6b6c1e3845ffda344effa03c" +} diff --git a/backend/.sqlx/query-92b80a77d292ec734b097b815261ce0cd51d7f699ff296314c9801e115c52228.json b/backend/.sqlx/query-92b80a77d292ec734b097b815261ce0cd51d7f699ff296314c9801e115c52228.json new file mode 100644 index 0000000000..1975b59d5a --- /dev/null +++ b/backend/.sqlx/query-92b80a77d292ec734b097b815261ce0cd51d7f699ff296314c9801e115c52228.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = JSONB_SET(JSONB_SET(flow_status, ARRAY['retry'], $1), ARRAY['modules', $3::TEXT, 'failed_retries'], $4)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "92b80a77d292ec734b097b815261ce0cd51d7f699ff296314c9801e115c52228" +} diff --git a/backend/.sqlx/query-931703a98d2ee5fb58d3380896baaee032e731db1e6bd49d991a54f49ab8fa46.json b/backend/.sqlx/query-931703a98d2ee5fb58d3380896baaee032e731db1e6bd49d991a54f49ab8fa46.json new file mode 100644 index 0000000000..5f86a45011 --- /dev/null +++ b/backend/.sqlx/query-931703a98d2ee5fb58d3380896baaee032e731db1e6bd49d991a54f49ab8fa46.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "create index concurrently if not exists ix_completed_job_workspace_id_started_at_new_2 ON v2_job_completed (workspace_id, started_at DESC)", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "931703a98d2ee5fb58d3380896baaee032e731db1e6bd49d991a54f49ab8fa46" +} diff --git a/backend/.sqlx/query-94831baa639d7546f98f24847c0f93697ee1edcee0acf4a0684a28ff66ef735a.json b/backend/.sqlx/query-94831baa639d7546f98f24847c0f93697ee1edcee0acf4a0684a28ff66ef735a.json new file mode 100644 index 0000000000..01a61edd5f --- /dev/null +++ b/backend/.sqlx/query-94831baa639d7546f98f24847c0f93697ee1edcee0acf4a0684a28ff66ef735a.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n substr(concat(coalesce(v2_as_completed_job.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs,\n mem_peak,\n CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\",\n job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset,\n created_by AS \"created_by!\"\n FROM v2_as_completed_job\n LEFT JOIN job_logs ON job_logs.job_id = v2_as_completed_job.id \n WHERE v2_as_completed_job.workspace_id = $2 AND v2_as_completed_job.id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 1, + "name": "mem_peak", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 4, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Int4", + "Text", + "Uuid" + ] + }, + "nullable": [ + null, + true, + null, + null, + true + ] + }, + "hash": "94831baa639d7546f98f24847c0f93697ee1edcee0acf4a0684a28ff66ef735a" +} diff --git a/backend/.sqlx/query-95ae90094ec0e2c22660cc2e3788b22231dab9c558723cc54894597ce4cd3d5a.json b/backend/.sqlx/query-95ae90094ec0e2c22660cc2e3788b22231dab9c558723cc54894597ce4cd3d5a.json new file mode 100644 index 0000000000..d451727f46 --- /dev/null +++ b/backend/.sqlx/query-95ae90094ec0e2c22660cc2e3788b22231dab9c558723cc54894597ce4cd3d5a.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", CONCAT(coalesce(v2_as_queue.logs, ''), coalesce(job_logs.logs, '')) as logs, coalesce(job_logs.log_offset, 0) as log_offset, job_logs.log_file_index\n FROM v2_as_queue \n LEFT JOIN job_logs ON job_logs.job_id = v2_as_queue.id \n WHERE v2_as_queue.id = $1 AND v2_as_queue.workspace_id = $2 AND ($3::text[] IS NULL OR v2_as_queue.tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "logs", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "log_offset", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "log_file_index", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + null, + null, + true + ] + }, + "hash": "95ae90094ec0e2c22660cc2e3788b22231dab9c558723cc54894597ce4cd3d5a" +} diff --git a/backend/.sqlx/query-96a9357888af26e5ec1e314bb565af05de561a8f9899e4ddca958982fdb67803.json b/backend/.sqlx/query-96a9357888af26e5ec1e314bb565af05de561a8f9899e4ddca958982fdb67803.json new file mode 100644 index 0000000000..5fbab5bf20 --- /dev/null +++ b/backend/.sqlx/query-96a9357888af26e5ec1e314bb565af05de561a8f9899e4ddca958982fdb67803.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM queue WHERE schedule_path = $1 AND workspace_id = $2 AND id != $3 AND running = true", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "96a9357888af26e5ec1e314bb565af05de561a8f9899e4ddca958982fdb67803" +} diff --git a/backend/.sqlx/query-9b2c42327378963b16eec5037537b8d9ae95c194b201bd1ce1d8f90925d7dba8.json b/backend/.sqlx/query-9b2c42327378963b16eec5037537b8d9ae95c194b201bd1ce1d8f90925d7dba8.json new file mode 100644 index 0000000000..e73b49d4b0 --- /dev/null +++ b/backend/.sqlx/query-9b2c42327378963b16eec5037537b8d9ae95c194b201bd1ce1d8f90925d7dba8.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET permissioned_as = ('u/' || $1) WHERE permissioned_as = ('u/' || $2) AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "9b2c42327378963b16eec5037537b8d9ae95c194b201bd1ce1d8f90925d7dba8" +} diff --git a/backend/.sqlx/query-9bdad9fbe8990588d8d769d4a38e2397ee789f6732199a5259f5f4ee2c5a166d.json b/backend/.sqlx/query-9bdad9fbe8990588d8d769d4a38e2397ee789f6732199a5259f5f4ee2c5a166d.json new file mode 100644 index 0000000000..b49d76d6cf --- /dev/null +++ b/backend/.sqlx/query-9bdad9fbe8990588d8d769d4a38e2397ee789f6732199a5259f5f4ee2c5a166d.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\", result AS \"result: Json>\"\n FROM completed_job WHERE id = ANY($1) AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "result: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Text" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "9bdad9fbe8990588d8d769d4a38e2397ee789f6732199a5259f5f4ee2c5a166d" +} diff --git a/backend/.sqlx/query-9c19ad9ab14325587d662539c04e18e8dfbdb0bf1dd4c0dc07a55f4eeb4eb5f8.json b/backend/.sqlx/query-9c19ad9ab14325587d662539c04e18e8dfbdb0bf1dd4c0dc07a55f4eeb4eb5f8.json new file mode 100644 index 0000000000..89368ea0c8 --- /dev/null +++ b/backend/.sqlx/query-9c19ad9ab14325587d662539c04e18e8dfbdb0bf1dd4c0dc07a55f4eeb4eb5f8.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM v2_as_queue LEFT JOIN concurrency_key ON concurrency_key.job_id = v2_as_queue.id\n WHERE key = $1 AND running = false AND canceled = false AND scheduled_for >= $2 AND scheduled_for < $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text", + "Timestamptz", + "Timestamptz" + ] + }, + "nullable": [ + null + ] + }, + "hash": "9c19ad9ab14325587d662539c04e18e8dfbdb0bf1dd4c0dc07a55f4eeb4eb5f8" +} diff --git a/backend/.sqlx/query-9c34c717b218c09e3784a5413f7972e5e805dae837a075da4e503494624b518a.json b/backend/.sqlx/query-9c34c717b218c09e3784a5413f7972e5e805dae837a075da4e503494624b518a.json new file mode 100644 index 0000000000..d22420d6e4 --- /dev/null +++ b/backend/.sqlx/query-9c34c717b218c09e3784a5413f7972e5e805dae837a075da4e503494624b518a.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = jsonb_set(\n jsonb_set(flow_status, ARRAY['preprocessor_module', 'job'], to_jsonb($1::UUID::TEXT)),\n ARRAY['preprocessor_module', 'type'],\n to_jsonb('InProgress'::text)\n )\n WHERE id = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "9c34c717b218c09e3784a5413f7972e5e805dae837a075da4e503494624b518a" +} diff --git a/backend/.sqlx/query-9c7b2d9708a65764d91bf7f8a2cb9e59aba53d8e17f1d8a887128b7863c3924d.json b/backend/.sqlx/query-9c7b2d9708a65764d91bf7f8a2cb9e59aba53d8e17f1d8a887128b7863c3924d.json new file mode 100644 index 0000000000..b9429cbab7 --- /dev/null +++ b/backend/.sqlx/query-9c7b2d9708a65764d91bf7f8a2cb9e59aba53d8e17f1d8a887128b7863c3924d.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET args = '{}'::jsonb WHERE id = ANY($1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [] + }, + "hash": "9c7b2d9708a65764d91bf7f8a2cb9e59aba53d8e17f1d8a887128b7863c3924d" +} diff --git a/backend/.sqlx/query-9d518842a9ad90ff9c28dc39690deb0ee6b62cf1d8ae1a02b28c23255d377b3d.json b/backend/.sqlx/query-9d518842a9ad90ff9c28dc39690deb0ee6b62cf1d8ae1a02b28c23255d377b3d.json new file mode 100644 index 0000000000..79bd8d0666 --- /dev/null +++ b/backend/.sqlx/query-9d518842a9ad90ff9c28dc39690deb0ee6b62cf1d8ae1a02b28c23255d377b3d.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT labels FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "labels", + "type_info": "TextArray" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "9d518842a9ad90ff9c28dc39690deb0ee6b62cf1d8ae1a02b28c23255d377b3d" +} diff --git a/backend/.sqlx/query-9d616812c5a6ae514f047ce2d035a07ff11d13472c25533824dec93c41ea609c.json b/backend/.sqlx/query-9d616812c5a6ae514f047ce2d035a07ff11d13472c25533824dec93c41ea609c.json new file mode 100644 index 0000000000..7471bb0bf3 --- /dev/null +++ b/backend/.sqlx/query-9d616812c5a6ae514f047ce2d035a07ff11d13472c25533824dec93c41ea609c.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT args AS \"args: Json>>\"\n FROM completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args: Json>>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "9d616812c5a6ae514f047ce2d035a07ff11d13472c25533824dec93c41ea609c" +} diff --git a/backend/.sqlx/query-9e2810312302b36d3b4d761481c00296ee84c9536228496e19b4ec5df1781bc5.json b/backend/.sqlx/query-9e2810312302b36d3b4d761481c00296ee84c9536228496e19b4ec5df1781bc5.json new file mode 100644 index 0000000000..70df593afe --- /dev/null +++ b/backend/.sqlx/query-9e2810312302b36d3b4d761481c00296ee84c9536228496e19b4ec5df1781bc5.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT COUNT(*) as count, \n MIN(scheduled_for) as oldest_job\n FROM v2_job_queue \n WHERE tag = $1 \n AND scheduled_for <= NOW() - $2::interval \n AND running = false\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "oldest_job", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Interval" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "9e2810312302b36d3b4d761481c00296ee84c9536228496e19b4ec5df1781bc5" +} diff --git a/backend/.sqlx/query-9e7e6fe1dfba032e586f64531e12529d57faf5e77f6792d5bda608ff9658d7c9.json b/backend/.sqlx/query-9e7e6fe1dfba032e586f64531e12529d57faf5e77f6792d5bda608ff9658d7c9.json new file mode 100644 index 0000000000..2ee7a1acef --- /dev/null +++ b/backend/.sqlx/query-9e7e6fe1dfba032e586f64531e12529d57faf5e77f6792d5bda608ff9658d7c9.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT EXISTS (SELECT 1 FROM v2_as_queue WHERE workspace_id = $1 AND schedule_path = $2 AND scheduled_for = $3)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "exists", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Timestamptz" + ] + }, + "nullable": [ + null + ] + }, + "hash": "9e7e6fe1dfba032e586f64531e12529d57faf5e77f6792d5bda608ff9658d7c9" +} diff --git a/backend/.sqlx/query-a0b3e10e077d30c1da135dff9feca3761d400391f1f46a8294da3e6c9af63887.json b/backend/.sqlx/query-a0b3e10e077d30c1da135dff9feca3761d400391f1f46a8294da3e6c9af63887.json new file mode 100644 index 0000000000..1afc61978e --- /dev/null +++ b/backend/.sqlx/query-a0b3e10e077d30c1da135dff9feca3761d400391f1f46a8294da3e6c9af63887.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_status (id, flow_status) SELECT unnest($1::uuid[]), $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "a0b3e10e077d30c1da135dff9feca3761d400391f1f46a8294da3e6c9af63887" +} diff --git a/backend/.sqlx/query-a0c35cb515a842067b294343c90f1bfbe4e2db85da9a478a07460733999e9beb.json b/backend/.sqlx/query-a0c35cb515a842067b294343c90f1bfbe4e2db85da9a478a07460733999e9beb.json new file mode 100644 index 0000000000..298a66c89c --- /dev/null +++ b/backend/.sqlx/query-a0c35cb515a842067b294343c90f1bfbe4e2db85da9a478a07460733999e9beb.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT count(*) AS \"count!\" FROM resume_job", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "a0c35cb515a842067b294343c90f1bfbe4e2db85da9a478a07460733999e9beb" +} diff --git a/backend/.sqlx/query-a21d501d3bda8b7cd04b9a75515222ee33c2cd863c8e3fde0527cee9be4e09e2.json b/backend/.sqlx/query-a21d501d3bda8b7cd04b9a75515222ee33c2cd863c8e3fde0527cee9be4e09e2.json new file mode 100644 index 0000000000..7a65d688b5 --- /dev/null +++ b/backend/.sqlx/query-a21d501d3bda8b7cd04b9a75515222ee33c2cd863c8e3fde0527cee9be4e09e2.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id FROM v2_job WHERE workspace_id = $1 and flow_innermost_root_job = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] + }, + "nullable": [ + false + ] + }, + "hash": "a21d501d3bda8b7cd04b9a75515222ee33c2cd863c8e3fde0527cee9be4e09e2" +} diff --git a/backend/.sqlx/query-a2b7d364705468bd9dfb8f10e0bcc151604feae83d4671dfb9ca77eb8fd8d4f1.json b/backend/.sqlx/query-a2b7d364705468bd9dfb8f10e0bcc151604feae83d4671dfb9ca77eb8fd8d4f1.json new file mode 100644 index 0000000000..fffd61d360 --- /dev/null +++ b/backend/.sqlx/query-a2b7d364705468bd9dfb8f10e0bcc151604feae83d4671dfb9ca77eb8fd8d4f1.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job_completed WHERE workspace_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "a2b7d364705468bd9dfb8f10e0bcc151604feae83d4671dfb9ca77eb8fd8d4f1" +} diff --git a/backend/.sqlx/query-a33e282d02c53e5d6142dc7e6882a6d8f3d068c55cddf209eb6b6431ca26c910.json b/backend/.sqlx/query-a33e282d02c53e5d6142dc7e6882a6d8f3d068c55cddf209eb6b6431ca26c910.json new file mode 100644 index 0000000000..20d1bfb045 --- /dev/null +++ b/backend/.sqlx/query-a33e282d02c53e5d6142dc7e6882a6d8f3d068c55cddf209eb6b6431ca26c910.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM queue WHERE workspace_id = $1 and root_job = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "a33e282d02c53e5d6142dc7e6882a6d8f3d068c55cddf209eb6b6431ca26c910" +} diff --git a/backend/.sqlx/query-a56eef5f5ecbe1a8d309ff65d9a8c456a3c165f7f2a107cf7fa6a4cdd30d55c0.json b/backend/.sqlx/query-a56eef5f5ecbe1a8d309ff65d9a8c456a3c165f7f2a107cf7fa6a4cdd30d55c0.json new file mode 100644 index 0000000000..eb852c75ee --- /dev/null +++ b/backend/.sqlx/query-a56eef5f5ecbe1a8d309ff65d9a8c456a3c165f7f2a107cf7fa6a4cdd30d55c0.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT preprocessed, script_entrypoint_override FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "preprocessed", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "script_entrypoint_override", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "a56eef5f5ecbe1a8d309ff65d9a8c456a3c165f7f2a107cf7fa6a4cdd30d55c0" +} diff --git a/backend/.sqlx/query-a68754521bf751450602f04dd4243199a18885e1739a5a0e7f6100eab6f3c803.json b/backend/.sqlx/query-a68754521bf751450602f04dd4243199a18885e1739a5a0e7f6100eab6f3c803.json new file mode 100644 index 0000000000..8d6e6a2416 --- /dev/null +++ b/backend/.sqlx/query-a68754521bf751450602f04dd4243199a18885e1739a5a0e7f6100eab6f3c803.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_runtime (id) VALUES ($1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "a68754521bf751450602f04dd4243199a18885e1739a5a0e7f6100eab6f3c803" +} diff --git a/backend/.sqlx/query-a810e7912b65e6d4b361c9d34aa4c34d17c8444699f7bf29cc6907cdac6106f3.json b/backend/.sqlx/query-a810e7912b65e6d4b361c9d34aa4c34d17c8444699f7bf29cc6907cdac6106f3.json new file mode 100644 index 0000000000..52c3039fa5 --- /dev/null +++ b/backend/.sqlx/query-a810e7912b65e6d4b361c9d34aa4c34d17c8444699f7bf29cc6907cdac6106f3.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_status (id, flow_status)\n SELECT unnest($1::uuid[]), $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "a810e7912b65e6d4b361c9d34aa4c34d17c8444699f7bf29cc6907cdac6106f3" +} diff --git a/backend/.sqlx/query-a8ccf0f70cb8286e9dcafda5cbd542af647ca392cf6e307dc9358ed8b2ba640f.json b/backend/.sqlx/query-a8ccf0f70cb8286e9dcafda5cbd542af647ca392cf6e307dc9358ed8b2ba640f.json new file mode 100644 index 0000000000..b4ffae3d05 --- /dev/null +++ b/backend/.sqlx/query-a8ccf0f70cb8286e9dcafda5cbd542af647ca392cf6e307dc9358ed8b2ba640f.json @@ -0,0 +1,36 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result AS \"result: sqlx::types::Json>\",\n result_columns,\n created_by AS \"created_by!\"\n FROM v2_job_completed c\n JOIN v2_job USING (id)\n WHERE c.id = $1 AND c.workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "result_columns", + "type_info": "TextArray" + }, + { + "ordinal": 2, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true, + false + ] + }, + "hash": "a8ccf0f70cb8286e9dcafda5cbd542af647ca392cf6e307dc9358ed8b2ba640f" +} diff --git a/backend/.sqlx/query-a91798f58fa5948cd1739df4fa2e07cbb3eb08c5d2d22b057796e1156ae2a122.json b/backend/.sqlx/query-a91798f58fa5948cd1739df4fa2e07cbb3eb08c5d2d22b057796e1156ae2a122.json new file mode 100644 index 0000000000..3dfa6d79e2 --- /dev/null +++ b/backend/.sqlx/query-a91798f58fa5948cd1739df4fa2e07cbb3eb08c5d2d22b057796e1156ae2a122.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT leaf_jobs->$1::text AS \"leaf_jobs: Json>\", parent_job\n FROM queue\n WHERE COALESCE((SELECT root_job FROM queue WHERE id = $2), $2) = id AND workspace_id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "leaf_jobs: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "parent_job", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + null, + true + ] + }, + "hash": "a91798f58fa5948cd1739df4fa2e07cbb3eb08c5d2d22b057796e1156ae2a122" +} diff --git a/backend/.sqlx/query-aaacf51f3a43617b60e4253549ec4cc6a3648992b590c6e0121e4d7434da516b.json b/backend/.sqlx/query-aaacf51f3a43617b60e4253549ec4cc6a3648992b590c6e0121e4d7434da516b.json new file mode 100644 index 0000000000..5ce9a0ea5b --- /dev/null +++ b/backend/.sqlx/query-aaacf51f3a43617b60e4253549ec4cc6a3648992b590c6e0121e4d7434da516b.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET created_by = $1 WHERE created_by = $2 AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "aaacf51f3a43617b60e4253549ec4cc6a3648992b590c6e0121e4d7434da516b" +} diff --git a/backend/.sqlx/query-ab04cda71f8e2be9acbecabe1ee5ef756b8e5c1955fbe111df9ee171dc262338.json b/backend/.sqlx/query-ab04cda71f8e2be9acbecabe1ee5ef756b8e5c1955fbe111df9ee171dc262338.json new file mode 100644 index 0000000000..3284fb1846 --- /dev/null +++ b/backend/.sqlx/query-ab04cda71f8e2be9acbecabe1ee5ef756b8e5c1955fbe111df9ee171dc262338.json @@ -0,0 +1,84 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job (id, runnable_id, runnable_path, kind, script_lang, tag, created_by, permissioned_as, permissioned_as_email, workspace_id, raw_flow) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 FROM generate_series(1, 1)) RETURNING id", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Int8", + "Varchar", + { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + }, + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Jsonb" + ] + }, + "nullable": [ + false + ] + }, + "hash": "ab04cda71f8e2be9acbecabe1ee5ef756b8e5c1955fbe111df9ee171dc262338" +} diff --git a/backend/.sqlx/query-ab9e47e5b510e7df5a41db12896675393a6bb27f8e14245410751961218a7df5.json b/backend/.sqlx/query-ab9e47e5b510e7df5a41db12896675393a6bb27f8e14245410751961218a7df5.json new file mode 100644 index 0000000000..868541a175 --- /dev/null +++ b/backend/.sqlx/query-ab9e47e5b510e7df5a41db12896675393a6bb27f8e14245410751961218a7df5.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COALESCE((SELECT MIN(started_at) as min_started_at\n FROM v2_as_queue\n WHERE script_path = $1 AND job_kind != 'dependencies' AND running = true AND workspace_id = $2 AND canceled = false AND concurrent_limit > 0), $3) as min_started_at, now() AS now", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "min_started_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 1, + "name": "now", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Timestamptz" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "ab9e47e5b510e7df5a41db12896675393a6bb27f8e14245410751961218a7df5" +} diff --git a/backend/.sqlx/query-ac94c16bff27deab63b898c1cdca9818c93ea0b4c3aaacbd9dcef11fcd9e68a3.json b/backend/.sqlx/query-ac94c16bff27deab63b898c1cdca9818c93ea0b4c3aaacbd9dcef11fcd9e68a3.json new file mode 100644 index 0000000000..602dcb8206 --- /dev/null +++ b/backend/.sqlx/query-ac94c16bff27deab63b898c1cdca9818c93ea0b4c3aaacbd9dcef11fcd9e68a3.json @@ -0,0 +1,92 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job (id, workspace_id, raw_code, raw_lock, raw_flow, tag, parent_job,\n created_by, permissioned_as, runnable_id, runnable_path, args, kind, trigger,\n script_lang, same_worker, pre_run_error, permissioned_as_email, visible_to_owner,\n flow_innermost_root_job, concurrent_limit, concurrency_time_window_s, timeout, flow_step_id,\n cache_ttl, priority, trigger_kind, script_entrypoint_override)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18,\n $19, $20, $21, $22, $23, $24, $25, $26,\n CASE WHEN $14::VARCHAR IS NOT NULL THEN 'schedule'::job_trigger_kind END,\n ($12::JSONB)->>'_ENTRYPOINT_OVERRIDE')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Text", + "Text", + "Jsonb", + "Varchar", + "Uuid", + "Varchar", + "Varchar", + "Int8", + "Varchar", + "Jsonb", + { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + }, + "Varchar", + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Bool", + "Text", + "Varchar", + "Bool", + "Uuid", + "Int4", + "Int4", + "Int4", + "Varchar", + "Int4", + "Int2" + ] + }, + "nullable": [] + }, + "hash": "ac94c16bff27deab63b898c1cdca9818c93ea0b4c3aaacbd9dcef11fcd9e68a3" +} diff --git a/backend/.sqlx/query-acc0b67c8e768b524b5cfb309e4307daeb0c095e07063c57b26ab94211bf6359.json b/backend/.sqlx/query-acc0b67c8e768b524b5cfb309e4307daeb0c095e07063c57b26ab94211bf6359.json new file mode 100644 index 0000000000..58f693df33 --- /dev/null +++ b/backend/.sqlx/query-acc0b67c8e768b524b5cfb309e4307daeb0c095e07063c57b26ab94211bf6359.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM v2_as_queue WHERE id = ANY($1) AND schedule_path IS NULL AND ($2::text[] IS NULL OR tag = ANY($2))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "TextArray" + ] + }, + "nullable": [ + true + ] + }, + "hash": "acc0b67c8e768b524b5cfb309e4307daeb0c095e07063c57b26ab94211bf6359" +} diff --git a/backend/.sqlx/query-ae8dfecd46425d5f86003eea9a578e9831fc0e700cc76ab9627afe9040a4efe0.json b/backend/.sqlx/query-ae8dfecd46425d5f86003eea9a578e9831fc0e700cc76ab9627afe9040a4efe0.json new file mode 100644 index 0000000000..c0703bc518 --- /dev/null +++ b/backend/.sqlx/query-ae8dfecd46425d5f86003eea9a578e9831fc0e700cc76ab9627afe9040a4efe0.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "create index concurrently if not exists ix_job_workspace_id_created_at_new_7 ON v2_job (workspace_id, created_at DESC) where kind in ('script', 'flow') AND parent_job IS NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "ae8dfecd46425d5f86003eea9a578e9831fc0e700cc76ab9627afe9040a4efe0" +} diff --git a/backend/.sqlx/query-af925931f3217bbd32313678989ad1a66bbd8dacd12dea36608cc20197df358f.json b/backend/.sqlx/query-af925931f3217bbd32313678989ad1a66bbd8dacd12dea36608cc20197df358f.json new file mode 100644 index 0000000000..b90300787b --- /dev/null +++ b/backend/.sqlx/query-af925931f3217bbd32313678989ad1a66bbd8dacd12dea36608cc20197df358f.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = JSONB_SET(\n JSONB_SET(flow_status, ARRAY['preprocessor_module'], $1),\n ARRAY['step'],\n $2\n )\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "af925931f3217bbd32313678989ad1a66bbd8dacd12dea36608cc20197df358f" +} diff --git a/backend/.sqlx/query-b06915e02398511033717ea13b710c86a24fe666884cfd49996dee961751ce51.json b/backend/.sqlx/query-b06915e02398511033717ea13b710c86a24fe666884cfd49996dee961751ce51.json new file mode 100644 index 0000000000..194fda66ef --- /dev/null +++ b/backend/.sqlx/query-b06915e02398511033717ea13b710c86a24fe666884cfd49996dee961751ce51.json @@ -0,0 +1,89 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH uuid_table as (\n select unnest($11::uuid[]) as uuid\n )\n INSERT INTO queue \n (id, script_hash, script_path, job_kind, language, args, tag, created_by, permissioned_as, email, scheduled_for, workspace_id, concurrent_limit, concurrency_time_window_s, timeout, flow_status)\n (SELECT uuid, $1, $2, $3, $4, ('{ \"uuid\": \"' || uuid || '\" }')::jsonb, $5, $6, $7, $8, $9, $10, $12, $13, $14, $15 FROM uuid_table) \n RETURNING id AS \"id!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Int8", + "Varchar", + { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + }, + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Timestamptz", + "Varchar", + "UuidArray", + "Int4", + "Int4", + "Int4", + "Jsonb" + ] + }, + "nullable": [ + true + ] + }, + "hash": "b06915e02398511033717ea13b710c86a24fe666884cfd49996dee961751ce51" +} diff --git a/backend/.sqlx/query-b0890c1bac6931d848afd88539a0b766a018957c1a325940df8914b28df60aca.json b/backend/.sqlx/query-b0890c1bac6931d848afd88539a0b766a018957c1a325940df8914b28df60aca.json new file mode 100644 index 0000000000..15b7b27002 --- /dev/null +++ b/backend/.sqlx/query-b0890c1bac6931d848afd88539a0b766a018957c1a325940df8914b28df60aca.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT tag AS \"tag!\", count(*) AS \"count!\" FROM queue WHERE\n scheduled_for <= now() - ('3 seconds')::interval AND running = false\n GROUP BY tag", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "tag!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "count!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + true, + null + ] + }, + "hash": "b0890c1bac6931d848afd88539a0b766a018957c1a325940df8914b28df60aca" +} diff --git a/backend/.sqlx/query-b186efe51e7bb1924efbd7e9b36085502a1e77e30e59c7310c78976f77a810a3.json b/backend/.sqlx/query-b186efe51e7bb1924efbd7e9b36085502a1e77e30e59c7310c78976f77a810a3.json new file mode 100644 index 0000000000..d856ab0109 --- /dev/null +++ b/backend/.sqlx/query-b186efe51e7bb1924efbd7e9b36085502a1e77e30e59c7310c78976f77a810a3.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT ai_resource, code_completion_model, ai_models FROM workspace_settings WHERE workspace_id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "ai_resource", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "code_completion_model", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "ai_models", + "type_info": "VarcharArray" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + true, + true, + false + ] + }, + "hash": "b186efe51e7bb1924efbd7e9b36085502a1e77e30e59c7310c78976f77a810a3" +} diff --git a/backend/.sqlx/query-b2e4dfaaee713604d0700ea4675ed2d4534e08471a60005bff85b952874c54c2.json b/backend/.sqlx/query-b2e4dfaaee713604d0700ea4675ed2d4534e08471a60005bff85b952874c54c2.json new file mode 100644 index 0000000000..fabcec9b2a --- /dev/null +++ b/backend/.sqlx/query-b2e4dfaaee713604d0700ea4675ed2d4534e08471a60005bff85b952874c54c2.json @@ -0,0 +1,71 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n email AS \"email!\",\n created_by AS \"created_by!\",\n parent_job, permissioned_as AS \"permissioned_as!\",\n script_path, schedule_path, flow_step_id, root_job,\n scheduled_for AS \"scheduled_for!: chrono::DateTime\"\n FROM v2_as_queue WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "email!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "parent_job", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "permissioned_as!", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "schedule_path", + "type_info": "Varchar" + }, + { + "ordinal": 6, + "name": "flow_step_id", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "root_job", + "type_info": "Uuid" + }, + { + "ordinal": 8, + "name": "scheduled_for!: chrono::DateTime", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true, + true, + true, + true, + true + ] + }, + "hash": "b2e4dfaaee713604d0700ea4675ed2d4534e08471a60005bff85b952874c54c2" +} diff --git a/backend/.sqlx/query-b3e41eaff54c5da5e38cff785c17b2d9e014be9d0794e72dc8566485e61492cd.json b/backend/.sqlx/query-b3e41eaff54c5da5e38cff785c17b2d9e014be9d0794e72dc8566485e61492cd.json new file mode 100644 index 0000000000..ce125516d2 --- /dev/null +++ b/backend/.sqlx/query-b3e41eaff54c5da5e38cff785c17b2d9e014be9d0794e72dc8566485e61492cd.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n script_path, args AS \"args: sqlx::types::Json>>\",\n tag AS \"tag!\", priority\n FROM completed_job\n WHERE id = $1 and workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "args: sqlx::types::Json>>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "tag!", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "priority", + "type_info": "Int2" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "b3e41eaff54c5da5e38cff785c17b2d9e014be9d0794e72dc8566485e61492cd" +} diff --git a/backend/.sqlx/query-b3fd0be8a7ef6d8dd8943aef45f1555d6e088cb981b230d1cbbf8e8b832cad43.json b/backend/.sqlx/query-b3fd0be8a7ef6d8dd8943aef45f1555d6e088cb981b230d1cbbf8e8b832cad43.json new file mode 100644 index 0000000000..4c668f9b25 --- /dev/null +++ b/backend/.sqlx/query-b3fd0be8a7ef6d8dd8943aef45f1555d6e088cb981b230d1cbbf8e8b832cad43.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET\n canceled_by = $2,\n canceled_reason = 're-deployment'\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "b3fd0be8a7ef6d8dd8943aef45f1555d6e088cb981b230d1cbbf8e8b832cad43" +} diff --git a/backend/.sqlx/query-b4a9abcb38997587b28655b0f4a212a5bd4039b57fab20b163617e33a4c9dd46.json b/backend/.sqlx/query-b4a9abcb38997587b28655b0f4a212a5bd4039b57fab20b163617e33a4c9dd46.json new file mode 100644 index 0000000000..a49baeefaf --- /dev/null +++ b/backend/.sqlx/query-b4a9abcb38997587b28655b0f4a212a5bd4039b57fab20b163617e33a4c9dd46.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_runtime (id) SELECT unnest($1::uuid[])", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [] + }, + "hash": "b4a9abcb38997587b28655b0f4a212a5bd4039b57fab20b163617e33a4c9dd46" +} diff --git a/backend/.sqlx/query-bb93ba18709648b47cfbd04d91afd3b38546b1a718d0abff6b2795d7c2a29c97.json b/backend/.sqlx/query-bb93ba18709648b47cfbd04d91afd3b38546b1a718d0abff6b2795d7c2a29c97.json new file mode 100644 index 0000000000..d6288765fe --- /dev/null +++ b/backend/.sqlx/query-bb93ba18709648b47cfbd04d91afd3b38546b1a718d0abff6b2795d7c2a29c97.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id AS \"id!\", flow_status, suspend AS \"suspend!\", script_path\n FROM queue\n WHERE id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "suspend!", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "bb93ba18709648b47cfbd04d91afd3b38546b1a718d0abff6b2795d7c2a29c97" +} diff --git a/backend/.sqlx/query-bca733ef3969c055269db2bc20dacd5ecb22e6d5378ca6bc5a83dae6b8e525c1.json b/backend/.sqlx/query-bca733ef3969c055269db2bc20dacd5ecb22e6d5378ca6bc5a83dae6b8e525c1.json new file mode 100644 index 0000000000..2307dbbce5 --- /dev/null +++ b/backend/.sqlx/query-bca733ef3969c055269db2bc20dacd5ecb22e6d5378ca6bc5a83dae6b8e525c1.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_completed SET flow_status = f.flow_status FROM v2_job_status f WHERE v2_job_completed.id = $1 AND f.id = $1 AND v2_job_completed.workspace_id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "bca733ef3969c055269db2bc20dacd5ecb22e6d5378ca6bc5a83dae6b8e525c1" +} diff --git a/backend/.sqlx/query-bcc79dc05e227625bc2ba70350a41a254e00e84030aefff91a7b420fe7513b0d.json b/backend/.sqlx/query-bcc79dc05e227625bc2ba70350a41a254e00e84030aefff91a7b420fe7513b0d.json new file mode 100644 index 0000000000..25db03d1b5 --- /dev/null +++ b/backend/.sqlx/query-bcc79dc05e227625bc2ba70350a41a254e00e84030aefff91a7b420fe7513b0d.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result #> $3 AS \"result: Json>\"\n FROM v2_job_completed WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + null + ] + }, + "hash": "bcc79dc05e227625bc2ba70350a41a254e00e84030aefff91a7b420fe7513b0d" +} diff --git a/backend/.sqlx/query-bcd7e2c47baf27de2b0919f415dc8cc78fdc1527020e3c73f82eb01f64670923.json b/backend/.sqlx/query-bcd7e2c47baf27de2b0919f415dc8cc78fdc1527020e3c73f82eb01f64670923.json new file mode 100644 index 0000000000..1060bafebd --- /dev/null +++ b/backend/.sqlx/query-bcd7e2c47baf27de2b0919f415dc8cc78fdc1527020e3c73f82eb01f64670923.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET\n args = '{\"reason\":\"PREPROCESSOR_ARGS_ARE_DISCARDED\"}'::jsonb,\n preprocessed = TRUE\n WHERE id = $1 AND preprocessed = FALSE", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "bcd7e2c47baf27de2b0919f415dc8cc78fdc1527020e3c73f82eb01f64670923" +} diff --git a/backend/.sqlx/query-bd0ca94343399fa2fa06d9304da4ed90a18a3c952783c419707ffbb38e232ce0.json b/backend/.sqlx/query-bd0ca94343399fa2fa06d9304da4ed90a18a3c952783c419707ffbb38e232ce0.json new file mode 100644 index 0000000000..2e06f25b98 --- /dev/null +++ b/backend/.sqlx/query-bd0ca94343399fa2fa06d9304da4ed90a18a3c952783c419707ffbb38e232ce0.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT tag AS \"tag!\", count(*) AS \"count!\" FROM v2_job_queue WHERE\n scheduled_for <= now() - ('3 seconds')::interval AND running = false\n GROUP BY tag", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "tag!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "count!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + null + ] + }, + "hash": "bd0ca94343399fa2fa06d9304da4ed90a18a3c952783c419707ffbb38e232ce0" +} diff --git a/backend/.sqlx/query-bd5a0c06e2f2361c9fc670eb0b975b58d65ca93d68b29124d04bd526239b9df2.json b/backend/.sqlx/query-bd5a0c06e2f2361c9fc670eb0b975b58d65ca93d68b29124d04bd526239b9df2.json new file mode 100644 index 0000000000..81a97984ee --- /dev/null +++ b/backend/.sqlx/query-bd5a0c06e2f2361c9fc670eb0b975b58d65ca93d68b29124d04bd526239b9df2.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET labels = $2 WHERE id = $1 AND $2::TEXT[] IS NOT NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "TextArray" + ] + }, + "nullable": [] + }, + "hash": "bd5a0c06e2f2361c9fc670eb0b975b58d65ca93d68b29124d04bd526239b9df2" +} diff --git a/backend/.sqlx/query-bf91cb319e5b83c2235292a9e3ce8aa1c097c94b01aad0d9f7bce76a2a272bcc.json b/backend/.sqlx/query-bf91cb319e5b83c2235292a9e3ce8aa1c097c94b01aad0d9f7bce76a2a272bcc.json new file mode 100644 index 0000000000..25caf0d4fe --- /dev/null +++ b/backend/.sqlx/query-bf91cb319e5b83c2235292a9e3ce8aa1c097c94b01aad0d9f7bce76a2a272bcc.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT success AS \"success!\"\n FROM completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "bf91cb319e5b83c2235292a9e3ce8aa1c097c94b01aad0d9f7bce76a2a272bcc" +} diff --git a/backend/.sqlx/query-bfcf13b04f07f7d29c66ef5ba270febc663a8dc5b596acfe8b6771a35bf6e6cc.json b/backend/.sqlx/query-bfcf13b04f07f7d29c66ef5ba270febc663a8dc5b596acfe8b6771a35bf6e6cc.json new file mode 100644 index 0000000000..9899208666 --- /dev/null +++ b/backend/.sqlx/query-bfcf13b04f07f7d29c66ef5ba270febc663a8dc5b596acfe8b6771a35bf6e6cc.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT flow_innermost_root_job FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "flow_innermost_root_job", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "bfcf13b04f07f7d29c66ef5ba270febc663a8dc5b596acfe8b6771a35bf6e6cc" +} diff --git a/backend/.sqlx/query-bff39cc57aba0729ddef1d53f3806c6736556f0a14b489d6708f9879393f9ea3.json b/backend/.sqlx/query-bff39cc57aba0729ddef1d53f3806c6736556f0a14b489d6708f9879393f9ea3.json new file mode 100644 index 0000000000..11e498f38d --- /dev/null +++ b/backend/.sqlx/query-bff39cc57aba0729ddef1d53f3806c6736556f0a14b489d6708f9879393f9ea3.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT usr.email, usage.executions\n FROM usr\n , LATERAL (\n SELECT COALESCE(SUM(duration_ms + 1000)/1000 , 0)::BIGINT executions\n FROM v2_as_completed_job\n WHERE workspace_id = $1\n AND job_kind NOT IN ('flow', 'flowpreview', 'flownode')\n AND email = usr.email\n AND now() - '1 week'::interval < created_at \n ) usage\n WHERE workspace_id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "executions", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + null + ] + }, + "hash": "bff39cc57aba0729ddef1d53f3806c6736556f0a14b489d6708f9879393f9ea3" +} diff --git a/backend/.sqlx/query-c00bae0d8c9bee37cbad4de4cb02c80d00f52a3fc32bf32271ebc90f7837abda.json b/backend/.sqlx/query-c00bae0d8c9bee37cbad4de4cb02c80d00f52a3fc32bf32271ebc90f7837abda.json new file mode 100644 index 0000000000..74aa6c4ffb --- /dev/null +++ b/backend/.sqlx/query-c00bae0d8c9bee37cbad4de4cb02c80d00f52a3fc32bf32271ebc90f7837abda.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue\n SET canceled_by = 'timeout'\n , canceled_reason = $1\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "c00bae0d8c9bee37cbad4de4cb02c80d00f52a3fc32bf32271ebc90f7837abda" +} diff --git a/backend/.sqlx/query-c03b4c5878bd0a0c545cb66b146d0b6ceae9de456d3ddb6008707589dbe30747.json b/backend/.sqlx/query-c03b4c5878bd0a0c545cb66b146d0b6ceae9de456d3ddb6008707589dbe30747.json new file mode 100644 index 0000000000..5cb05f49a0 --- /dev/null +++ b/backend/.sqlx/query-c03b4c5878bd0a0c545cb66b146d0b6ceae9de456d3ddb6008707589dbe30747.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT 1 FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "c03b4c5878bd0a0c545cb66b146d0b6ceae9de456d3ddb6008707589dbe30747" +} diff --git a/backend/.sqlx/query-c03decd33061ab912c9afed841092b05105c261976cce78c77d7f85abf9ad40c.json b/backend/.sqlx/query-c03decd33061ab912c9afed841092b05105c261976cce78c77d7f85abf9ad40c.json new file mode 100644 index 0000000000..17532bfc77 --- /dev/null +++ b/backend/.sqlx/query-c03decd33061ab912c9afed841092b05105c261976cce78c77d7f85abf9ad40c.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET args = NULL WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "c03decd33061ab912c9afed841092b05105c261976cce78c77d7f85abf9ad40c" +} diff --git a/backend/.sqlx/query-c0b96d2f421afc43e256a8475825623bcb3dd4cbc37d570fc4273127bbf77c24.json b/backend/.sqlx/query-c0b96d2f421afc43e256a8475825623bcb3dd4cbc37d570fc4273127bbf77c24.json new file mode 100644 index 0000000000..2015ab01d6 --- /dev/null +++ b/backend/.sqlx/query-c0b96d2f421afc43e256a8475825623bcb3dd4cbc37d570fc4273127bbf77c24.json @@ -0,0 +1,67 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n job_kind AS \"job_kind!: JobKind\",\n script_hash AS \"script_hash: ScriptHash\",\n flow_status AS \"flow_status!: Json>\",\n raw_flow AS \"raw_flow: Json>\"\n FROM queue WHERE id = $1 AND workspace_id = $2 LIMIT 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "job_kind!: JobKind", + "type_info": { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + } + }, + { + "ordinal": 1, + "name": "script_hash: ScriptHash", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "flow_status!: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "raw_flow: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "c0b96d2f421afc43e256a8475825623bcb3dd4cbc37d570fc4273127bbf77c24" +} diff --git a/backend/.sqlx/query-c202f6fbae6a727f88f3ac692985c70e6ebc68e4a16d02e4e36b79f3cfb1c661.json b/backend/.sqlx/query-c202f6fbae6a727f88f3ac692985c70e6ebc68e4a16d02e4e36b79f3cfb1c661.json new file mode 100644 index 0000000000..e1094f38ef --- /dev/null +++ b/backend/.sqlx/query-c202f6fbae6a727f88f3ac692985c70e6ebc68e4a16d02e4e36b79f3cfb1c661.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH suspend AS (\n UPDATE v2_job_queue SET suspend = $2, suspend_until = now() + $3\n WHERE id = $4\n RETURNING id\n ) UPDATE v2_job_status SET flow_status = JSONB_SET(\n flow_status,\n ARRAY['modules', flow_status->>'step'::TEXT],\n $1\n ) WHERE id = (SELECT id FROM suspend)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Int4", + "Interval", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "c202f6fbae6a727f88f3ac692985c70e6ebc68e4a16d02e4e36b79f3cfb1c661" +} diff --git a/backend/.sqlx/query-c4bdbf1c6bc7d93db4cf2633105b088b781354cb7c02628d9f8ff7f9ea0e7ed9.json b/backend/.sqlx/query-c4bdbf1c6bc7d93db4cf2633105b088b781354cb7c02628d9f8ff7f9ea0e7ed9.json new file mode 100644 index 0000000000..4d138db49c --- /dev/null +++ b/backend/.sqlx/query-c4bdbf1c6bc7d93db4cf2633105b088b781354cb7c02628d9f8ff7f9ea0e7ed9.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "CREATE INDEX CONCURRENTLY labeled_jobs_on_jobs ON v2_job_completed USING GIN ((result -> 'wm_labels')) WHERE result ? 'wm_labels'", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "c4bdbf1c6bc7d93db4cf2633105b088b781354cb7c02628d9f8ff7f9ea0e7ed9" +} diff --git a/backend/.sqlx/query-c5259e37703c3e48104438bad6e1f3615f4439c090a75e6fde03702a21589b25.json b/backend/.sqlx/query-c5259e37703c3e48104438bad6e1f3615f4439c090a75e6fde03702a21589b25.json new file mode 100644 index 0000000000..ee362d8845 --- /dev/null +++ b/backend/.sqlx/query-c5259e37703c3e48104438bad6e1f3615f4439c090a75e6fde03702a21589b25.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM v2_job WHERE parent_job = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "c5259e37703c3e48104438bad6e1f3615f4439c090a75e6fde03702a21589b25" +} diff --git a/backend/.sqlx/query-c71e12ec9d0054dd5605a4ea2ef77fa54ce686da9c93790420a91a0735589ac7.json b/backend/.sqlx/query-c71e12ec9d0054dd5605a4ea2ef77fa54ce686da9c93790420a91a0735589ac7.json new file mode 100644 index 0000000000..ecc62b1682 --- /dev/null +++ b/backend/.sqlx/query-c71e12ec9d0054dd5605a4ea2ef77fa54ce686da9c93790420a91a0735589ac7.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(JSONB_SET(flow_status, ARRAY['retry'], $1), ARRAY['modules', $3::TEXT, 'failed_retries'], $4)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "c71e12ec9d0054dd5605a4ea2ef77fa54ce686da9c93790420a91a0735589ac7" +} diff --git a/backend/.sqlx/query-c7be5fa2eaf66147c1213046e615f5e9fd168ef1e3aba8af64b15341055d6007.json b/backend/.sqlx/query-c7be5fa2eaf66147c1213046e615f5e9fd168ef1e3aba8af64b15341055d6007.json new file mode 100644 index 0000000000..d79a7f5465 --- /dev/null +++ b/backend/.sqlx/query-c7be5fa2eaf66147c1213046e615f5e9fd168ef1e3aba8af64b15341055d6007.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "create index concurrently if not exists ix_job_workspace_id_created_at_new_5 ON v2_job (workspace_id, created_at DESC) where kind in ('preview', 'flowpreview') AND parent_job IS NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "c7be5fa2eaf66147c1213046e615f5e9fd168ef1e3aba8af64b15341055d6007" +} diff --git a/backend/.sqlx/query-c7d595d2a12228c49359440ca3a9622f1de5f5ee4bbe5d2b23f6fdb6379cebf3.json b/backend/.sqlx/query-c7d595d2a12228c49359440ca3a9622f1de5f5ee4bbe5d2b23f6fdb6379cebf3.json new file mode 100644 index 0000000000..a3d8c2502f --- /dev/null +++ b/backend/.sqlx/query-c7d595d2a12228c49359440ca3a9622f1de5f5ee4bbe5d2b23f6fdb6379cebf3.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE token SET last_used_at = now() WHERE\n token = $1\n AND (expiration > NOW() OR expiration IS NULL)\n AND (workspace_id IS NULL OR workspace_id = $2)\n RETURNING owner, email, super_admin, scopes, label", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "owner", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "super_admin", + "type_info": "Bool" + }, + { + "ordinal": 3, + "name": "scopes", + "type_info": "TextArray" + }, + { + "ordinal": 4, + "name": "label", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [ + true, + true, + false, + true, + true + ] + }, + "hash": "c7d595d2a12228c49359440ca3a9622f1de5f5ee4bbe5d2b23f6fdb6379cebf3" +} diff --git a/backend/.sqlx/query-cd5f02cf10cbf92dd1df53a54f2110efa11a7731ad0f0e5509f55efabdf535cd.json b/backend/.sqlx/query-cd5f02cf10cbf92dd1df53a54f2110efa11a7731ad0f0e5509f55efabdf535cd.json new file mode 100644 index 0000000000..f5eb13f1fd --- /dev/null +++ b/backend/.sqlx/query-cd5f02cf10cbf92dd1df53a54f2110efa11a7731ad0f0e5509f55efabdf535cd.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT preprocessed FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "preprocessed", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "cd5f02cf10cbf92dd1df53a54f2110efa11a7731ad0f0e5509f55efabdf535cd" +} diff --git a/backend/.sqlx/query-cd6a2559d76e7c6462bd18c8f0bc07c31ca9bdd96f8f92ba19d90e6060721354.json b/backend/.sqlx/query-cd6a2559d76e7c6462bd18c8f0bc07c31ca9bdd96f8f92ba19d90e6060721354.json new file mode 100644 index 0000000000..f11e9daf54 --- /dev/null +++ b/backend/.sqlx/query-cd6a2559d76e7c6462bd18c8f0bc07c31ca9bdd96f8f92ba19d90e6060721354.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', flow_status->>'step', 'progress'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "cd6a2559d76e7c6462bd18c8f0bc07c31ca9bdd96f8f92ba19d90e6060721354" +} diff --git a/backend/.sqlx/query-cf12a70e7b75ae471a0944de34502384be156cf25129f9c52bda34b240cf469a.json b/backend/.sqlx/query-cf12a70e7b75ae471a0944de34502384be156cf25129f9c52bda34b240cf469a.json new file mode 100644 index 0000000000..962572fa3d --- /dev/null +++ b/backend/.sqlx/query-cf12a70e7b75ae471a0944de34502384be156cf25129f9c52bda34b240cf469a.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT leaf_jobs->$1::text AS \"leaf_jobs: Json>\", parent_job\n FROM v2_as_queue\n WHERE COALESCE((SELECT flow_innermost_root_job FROM v2_job WHERE id = $2), $2) = id AND workspace_id = $3", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "leaf_jobs: Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "parent_job", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + null, + true + ] + }, + "hash": "cf12a70e7b75ae471a0944de34502384be156cf25129f9c52bda34b240cf469a" +} diff --git a/backend/.sqlx/query-cf80f068b6a8906939f7ea0f1a8311fdabf78d6d5bd12e71070b1dae24df2352.json b/backend/.sqlx/query-cf80f068b6a8906939f7ea0f1a8311fdabf78d6d5bd12e71070b1dae24df2352.json new file mode 100644 index 0000000000..7373aec488 --- /dev/null +++ b/backend/.sqlx/query-cf80f068b6a8906939f7ea0f1a8311fdabf78d6d5bd12e71070b1dae24df2352.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'approvers'], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "cf80f068b6a8906939f7ea0f1a8311fdabf78d6d5bd12e71070b1dae24df2352" +} diff --git a/backend/.sqlx/query-cf85496774cd3ce58543dd0d52b5eadedad1a29049f8023e90deb57b19a41c72.json b/backend/.sqlx/query-cf85496774cd3ce58543dd0d52b5eadedad1a29049f8023e90deb57b19a41c72.json new file mode 100644 index 0000000000..047b758fdf --- /dev/null +++ b/backend/.sqlx/query-cf85496774cd3ce58543dd0d52b5eadedad1a29049f8023e90deb57b19a41c72.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(id) FROM v2_job_queue WHERE workspace_id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "cf85496774cd3ce58543dd0d52b5eadedad1a29049f8023e90deb57b19a41c72" +} diff --git a/backend/.sqlx/query-d25c58d2722ad3dcd91101ce6f66e1d802dd5d82e1cd5f5ed3a15cbc75eb6745.json b/backend/.sqlx/query-d25c58d2722ad3dcd91101ce6f66e1d802dd5d82e1cd5f5ed3a15cbc75eb6745.json new file mode 100644 index 0000000000..2872c1655b --- /dev/null +++ b/backend/.sqlx/query-d25c58d2722ad3dcd91101ce6f66e1d802dd5d82e1cd5f5ed3a15cbc75eb6745.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job_queue WHERE workspace_id = $1 AND id = $2 RETURNING 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "d25c58d2722ad3dcd91101ce6f66e1d802dd5d82e1cd5f5ed3a15cbc75eb6745" +} diff --git a/backend/.sqlx/query-d2a9e6a31bab0551d32093b1afe4e5d414cf439e4db3325b5bf6bbeb86c5bd2a.json b/backend/.sqlx/query-d2a9e6a31bab0551d32093b1afe4e5d414cf439e4db3325b5bf6bbeb86c5bd2a.json new file mode 100644 index 0000000000..4b96e7005b --- /dev/null +++ b/backend/.sqlx/query-d2a9e6a31bab0551d32093b1afe4e5d414cf439e4db3325b5bf6bbeb86c5bd2a.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH to_delete AS (\n SELECT id FROM v2_job_queue\n JOIN v2_job j USING (id)\n WHERE trigger_kind = 'schedule'\n AND trigger = $1\n AND j.workspace_id = $2\n AND flow_step_id IS NULL\n AND running = false\n FOR UPDATE\n ), deleted AS (\n DELETE FROM v2_job_queue\n WHERE id IN (SELECT id FROM to_delete)\n RETURNING id\n ) DELETE FROM v2_job WHERE id IN (SELECT id FROM deleted)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "d2a9e6a31bab0551d32093b1afe4e5d414cf439e4db3325b5bf6bbeb86c5bd2a" +} diff --git a/backend/.sqlx/query-d37a7c2c19beb6963794670312b4331ea22d3e06b487b8037c20cdaec392b311.json b/backend/.sqlx/query-d37a7c2c19beb6963794670312b4331ea22d3e06b487b8037c20cdaec392b311.json new file mode 100644 index 0000000000..896f7d92c7 --- /dev/null +++ b/backend/.sqlx/query-d37a7c2c19beb6963794670312b4331ea22d3e06b487b8037c20cdaec392b311.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status SET\n flow_status = jsonb_set(\n jsonb_set(flow_status, ARRAY['preprocessor_module', 'job'], to_jsonb($1::UUID::TEXT)),\n ARRAY['preprocessor_module', 'type'],\n to_jsonb('InProgress'::text)\n )\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "d37a7c2c19beb6963794670312b4331ea22d3e06b487b8037c20cdaec392b311" +} diff --git a/backend/.sqlx/query-d4d83d8177144c91aa489b5a42a45c83f8b069a52f681f14afb4931ac77baf45.json b/backend/.sqlx/query-d4d83d8177144c91aa489b5a42a45c83f8b069a52f681f14afb4931ac77baf45.json new file mode 100644 index 0000000000..3422605ef1 --- /dev/null +++ b/backend/.sqlx/query-d4d83d8177144c91aa489b5a42a45c83f8b069a52f681f14afb4931ac77baf45.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id AS \"id!\", flow_status, suspend AS \"suspend!\", script_path\n FROM v2_as_queue\n WHERE id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "suspend!", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "d4d83d8177144c91aa489b5a42a45c83f8b069a52f681f14afb4931ac77baf45" +} diff --git a/backend/.sqlx/query-d6c8f4e49cf7b6db5c979c88e02bd41c7b823186ac056a0a676da85dc5d9a027.json b/backend/.sqlx/query-d6c8f4e49cf7b6db5c979c88e02bd41c7b823186ac056a0a676da85dc5d9a027.json new file mode 100644 index 0000000000..d090c25a37 --- /dev/null +++ b/backend/.sqlx/query-d6c8f4e49cf7b6db5c979c88e02bd41c7b823186ac056a0a676da85dc5d9a027.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM v2_as_queue WHERE schedule_path = $1 AND workspace_id = $2 AND id != $3 AND running = true", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Text", + "Text", + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "d6c8f4e49cf7b6db5c979c88e02bd41c7b823186ac056a0a676da85dc5d9a027" +} diff --git a/backend/.sqlx/query-d6f62e25faf271876874fc09ee460313159bb6ad91227f5dec37cd28006e2add.json b/backend/.sqlx/query-d6f62e25faf271876874fc09ee460313159bb6ad91227f5dec37cd28006e2add.json new file mode 100644 index 0000000000..c4c138a886 --- /dev/null +++ b/backend/.sqlx/query-d6f62e25faf271876874fc09ee460313159bb6ad91227f5dec37cd28006e2add.json @@ -0,0 +1,35 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result AS \"result: sqlx::types::Json>\",\n result_columns,\n status = 'success' AS \"success!\"\n FROM v2_job_completed\n WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "result_columns", + "type_info": "TextArray" + }, + { + "ordinal": 2, + "name": "success!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + null + ] + }, + "hash": "d6f62e25faf271876874fc09ee460313159bb6ad91227f5dec37cd28006e2add" +} diff --git a/backend/.sqlx/query-d70ad8045589d746fc224ca950dcf967033942e489831cb5911723af1ec5161e.json b/backend/.sqlx/query-d70ad8045589d746fc224ca950dcf967033942e489831cb5911723af1ec5161e.json new file mode 100644 index 0000000000..0873f799d6 --- /dev/null +++ b/backend/.sqlx/query-d70ad8045589d746fc224ca950dcf967033942e489831cb5911723af1ec5161e.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT kind = 'identity' FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "d70ad8045589d746fc224ca950dcf967033942e489831cb5911723af1ec5161e" +} diff --git a/backend/.sqlx/query-d74d3511d394c7ab2931c413e5ae87df1799a0ea64822449350abab02ab570be.json b/backend/.sqlx/query-d74d3511d394c7ab2931c413e5ae87df1799a0ea64822449350abab02ab570be.json new file mode 100644 index 0000000000..e4f5aed798 --- /dev/null +++ b/backend/.sqlx/query-d74d3511d394c7ab2931c413e5ae87df1799a0ea64822449350abab02ab570be.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['approval_conditions'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "d74d3511d394c7ab2931c413e5ae87df1799a0ea64822449350abab02ab570be" +} diff --git a/backend/.sqlx/query-d7ce28c7cbd4974c72969858659a2a5c7448c919ae522e91332fa9a6212f5ddf.json b/backend/.sqlx/query-d7ce28c7cbd4974c72969858659a2a5c7448c919ae522e91332fa9a6212f5ddf.json new file mode 100644 index 0000000000..d1b5b0030c --- /dev/null +++ b/backend/.sqlx/query-d7ce28c7cbd4974c72969858659a2a5c7448c919ae522e91332fa9a6212f5ddf.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = JSONB_SET(flow_status, ARRAY['retry'], $1)\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "d7ce28c7cbd4974c72969858659a2a5c7448c919ae522e91332fa9a6212f5ddf" +} diff --git a/backend/.sqlx/query-d7f1e2920aec0f4eab9238d01370465945acdfa779f16b99cdc1a6b7ef84943e.json b/backend/.sqlx/query-d7f1e2920aec0f4eab9238d01370465945acdfa779f16b99cdc1a6b7ef84943e.json new file mode 100644 index 0000000000..dbc893740b --- /dev/null +++ b/backend/.sqlx/query-d7f1e2920aec0f4eab9238d01370465945acdfa779f16b99cdc1a6b7ef84943e.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id AS \"id!\", flow_status, suspend AS \"suspend!\", script_path\n FROM queue\n WHERE id = ( SELECT parent_job FROM queue WHERE id = $1 UNION ALL SELECT parent_job FROM completed_job WHERE id = $1)\n FOR UPDATE\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "suspend!", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "script_path", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true, + true, + true, + true + ] + }, + "hash": "d7f1e2920aec0f4eab9238d01370465945acdfa779f16b99cdc1a6b7ef84943e" +} diff --git a/backend/.sqlx/query-d91a447f3abcd39559d614ab7d423d0287bd34e463967fbaf0a3d590b59c9865.json b/backend/.sqlx/query-d91a447f3abcd39559d614ab7d423d0287bd34e463967fbaf0a3d590b59c9865.json new file mode 100644 index 0000000000..bce712700f --- /dev/null +++ b/backend/.sqlx/query-d91a447f3abcd39559d614ab7d423d0287bd34e463967fbaf0a3d590b59c9865.json @@ -0,0 +1,75 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result AS \"result: sqlx::types::Json>\", success AS \"success!\",\n language AS \"language: ScriptLang\",\n flow_status AS \"flow_status: sqlx::types::Json>\",\n created_by AS \"created_by!\"\n FROM completed_job\n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "success!", + "type_info": "Bool" + }, + { + "ordinal": 2, + "name": "language: ScriptLang", + "type_info": { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + true, + true, + true, + true, + true + ] + }, + "hash": "d91a447f3abcd39559d614ab7d423d0287bd34e463967fbaf0a3d590b59c9865" +} diff --git a/backend/.sqlx/query-d988e91087695742d75946100cf2b7593cb8eed2a97411697819849958c022b3.json b/backend/.sqlx/query-d988e91087695742d75946100cf2b7593cb8eed2a97411697819849958c022b3.json new file mode 100644 index 0000000000..15625b26c2 --- /dev/null +++ b/backend/.sqlx/query-d988e91087695742d75946100cf2b7593cb8eed2a97411697819849958c022b3.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT result AS \"result!: Json>\"\n FROM v2_job_completed WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result!: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "d988e91087695742d75946100cf2b7593cb8eed2a97411697819849958c022b3" +} diff --git a/backend/.sqlx/query-d99ae453289ae967ce92a221375aeca87ed9764bfa683b9d49294c24495ad392.json b/backend/.sqlx/query-d99ae453289ae967ce92a221375aeca87ed9764bfa683b9d49294c24495ad392.json new file mode 100644 index 0000000000..739ec47346 --- /dev/null +++ b/backend/.sqlx/query-d99ae453289ae967ce92a221375aeca87ed9764bfa683b9d49294c24495ad392.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT raw_flow->'failure_module' != 'null'::jsonb FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "d99ae453289ae967ce92a221375aeca87ed9764bfa683b9d49294c24495ad392" +} diff --git a/backend/.sqlx/query-db91141ae55b96a3237e05e3f127386339cb3c7a6f88bb2102498ec5d34f9537.json b/backend/.sqlx/query-db91141ae55b96a3237e05e3f127386339cb3c7a6f88bb2102498ec5d34f9537.json new file mode 100644 index 0000000000..cc6474870c --- /dev/null +++ b/backend/.sqlx/query-db91141ae55b96a3237e05e3f127386339cb3c7a6f88bb2102498ec5d34f9537.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "db91141ae55b96a3237e05e3f127386339cb3c7a6f88bb2102498ec5d34f9537" +} diff --git a/backend/.sqlx/query-dd5432830c1555ecbd6a0e45988fff455f3191f152e0900e09b71abb90d074ab.json b/backend/.sqlx/query-dd5432830c1555ecbd6a0e45988fff455f3191f152e0900e09b71abb90d074ab.json new file mode 100644 index 0000000000..f7690bb33a --- /dev/null +++ b/backend/.sqlx/query-dd5432830c1555ecbd6a0e45988fff455f3191f152e0900e09b71abb90d074ab.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id, result AS \"result: Json>\"\n FROM v2_job_completed WHERE id = ANY($1) AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "result: Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Text" + ] + }, + "nullable": [ + false, + true + ] + }, + "hash": "dd5432830c1555ecbd6a0e45988fff455f3191f152e0900e09b71abb90d074ab" +} diff --git a/backend/.sqlx/query-defd99dd2427cdc54bb662d1ba3a1aea7f410ef204ec3465f4fb6c9acd256c95.json b/backend/.sqlx/query-defd99dd2427cdc54bb662d1ba3a1aea7f410ef204ec3465f4fb6c9acd256c95.json new file mode 100644 index 0000000000..6aab7bc049 --- /dev/null +++ b/backend/.sqlx/query-defd99dd2427cdc54bb662d1ba3a1aea7f410ef204ec3465f4fb6c9acd256c95.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_queue SET\n suspend = $1,\n suspend_until = now() + interval '14 day',\n running = true\n WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "defd99dd2427cdc54bb662d1ba3a1aea7f410ef204ec3465f4fb6c9acd256c95" +} diff --git a/backend/.sqlx/query-df533f1988e409b70a3e0966825d01993cd52e8e85943440081b8dbd3b9ae5a4.json b/backend/.sqlx/query-df533f1988e409b70a3e0966825d01993cd52e8e85943440081b8dbd3b9ae5a4.json new file mode 100644 index 0000000000..a4f3b96782 --- /dev/null +++ b/backend/.sqlx/query-df533f1988e409b70a3e0966825d01993cd52e8e85943440081b8dbd3b9ae5a4.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue\n SET flow_status = flow_status - 'retry'\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "df533f1988e409b70a3e0966825d01993cd52e8e85943440081b8dbd3b9ae5a4" +} diff --git a/backend/.sqlx/query-e01c6ed633560647cfdf24f79298c0213ae4f66fdcc3a486120bb5116b1ce086.json b/backend/.sqlx/query-e01c6ed633560647cfdf24f79298c0213ae4f66fdcc3a486120bb5116b1ce086.json new file mode 100644 index 0000000000..ed8554404e --- /dev/null +++ b/backend/.sqlx/query-e01c6ed633560647cfdf24f79298c0213ae4f66fdcc3a486120bb5116b1ce086.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_runtime SET ping = NULL WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "e01c6ed633560647cfdf24f79298c0213ae4f66fdcc3a486120bb5116b1ce086" +} diff --git a/backend/.sqlx/query-e3ee812acd5bb9d5af39ca7dc61481ddd56a641e8e6f6c7a145f2cd5f3dc4602.json b/backend/.sqlx/query-e3ee812acd5bb9d5af39ca7dc61481ddd56a641e8e6f6c7a145f2cd5f3dc4602.json new file mode 100644 index 0000000000..2acb3c771e --- /dev/null +++ b/backend/.sqlx/query-e3ee812acd5bb9d5af39ca7dc61481ddd56a641e8e6f6c7a145f2cd5f3dc4602.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET args = $1, preprocessed = TRUE WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "e3ee812acd5bb9d5af39ca7dc61481ddd56a641e8e6f6c7a145f2cd5f3dc4602" +} diff --git a/backend/.sqlx/query-e653d36b607a16c0dfc0324690942ab25883b53a81ebb581fe019af2ec5eb567.json b/backend/.sqlx/query-e653d36b607a16c0dfc0324690942ab25883b53a81ebb581fe019af2ec5eb567.json new file mode 100644 index 0000000000..284cf3338f --- /dev/null +++ b/backend/.sqlx/query-e653d36b607a16c0dfc0324690942ab25883b53a81ebb581fe019af2ec5eb567.json @@ -0,0 +1,58 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id AS \"id!\", workspace_id AS \"workspace_id!\", parent_job, is_flow_step,\n flow_status AS \"flow_status: Box\", last_ping, same_worker\n FROM v2_as_queue\n WHERE running = true AND suspend = 0 AND suspend_until IS null AND scheduled_for <= now()\n AND (job_kind = 'flow' OR job_kind = 'flowpreview' OR job_kind = 'flownode')\n AND last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval\n AND canceled = false\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "workspace_id!", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "parent_job", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "is_flow_step", + "type_info": "Bool" + }, + { + "ordinal": 4, + "name": "flow_status: Box", + "type_info": "Jsonb" + }, + { + "ordinal": 5, + "name": "last_ping", + "type_info": "Timestamptz" + }, + { + "ordinal": 6, + "name": "same_worker", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true, + true, + true + ] + }, + "hash": "e653d36b607a16c0dfc0324690942ab25883b53a81ebb581fe019af2ec5eb567" +} diff --git a/backend/.sqlx/query-e67509f23f769854c8ee74677b4634b90631242e3e3991659a785ff1256d5f4d.json b/backend/.sqlx/query-e67509f23f769854c8ee74677b4634b90631242e3e3991659a785ff1256d5f4d.json new file mode 100644 index 0000000000..a7662bec95 --- /dev/null +++ b/backend/.sqlx/query-e67509f23f769854c8ee74677b4634b90631242e3e3991659a785ff1256d5f4d.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT canceled_by IS NOT NULL AS \"canceled!\" FROM v2_job_queue WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "canceled!", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "e67509f23f769854c8ee74677b4634b90631242e3e3991659a785ff1256d5f4d" +} diff --git a/backend/.sqlx/query-ecd62c48fe2fba2fc2582e9e7ae5590d5dea8c67f6ae7b14743ac4f265dd89a3.json b/backend/.sqlx/query-ecd62c48fe2fba2fc2582e9e7ae5590d5dea8c67f6ae7b14743ac4f265dd89a3.json new file mode 100644 index 0000000000..7431f3e1fb --- /dev/null +++ b/backend/.sqlx/query-ecd62c48fe2fba2fc2582e9e7ae5590d5dea8c67f6ae7b14743ac4f265dd89a3.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM v2_job WHERE id = ANY($1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray" + ] + }, + "nullable": [] + }, + "hash": "ecd62c48fe2fba2fc2582e9e7ae5590d5dea8c67f6ae7b14743ac4f265dd89a3" +} diff --git a/backend/.sqlx/query-ef8413620c6860c3bf200894c5917c9209817a9cd8eb3bcd05a74f55423054ae.json b/backend/.sqlx/query-ef8413620c6860c3bf200894c5917c9209817a9cd8eb3bcd05a74f55423054ae.json new file mode 100644 index 0000000000..58485a7cfb --- /dev/null +++ b/backend/.sqlx/query-ef8413620c6860c3bf200894c5917c9209817a9cd8eb3bcd05a74f55423054ae.json @@ -0,0 +1,30 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\"\n FROM v2_job\n WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "args: sqlx::types::Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray" + ] + }, + "nullable": [ + false, + true + ] + }, + "hash": "ef8413620c6860c3bf200894c5917c9209817a9cd8eb3bcd05a74f55423054ae" +} diff --git a/backend/.sqlx/query-ef8868893643a1a71531c1113d5cb38c5c204b3bc34c921b2f653c738af556a9.json b/backend/.sqlx/query-ef8868893643a1a71531c1113d5cb38c5c204b3bc34c921b2f653c738af556a9.json new file mode 100644 index 0000000000..055944bd70 --- /dev/null +++ b/backend/.sqlx/query-ef8868893643a1a71531c1113d5cb38c5c204b3bc34c921b2f653c738af556a9.json @@ -0,0 +1,29 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\", flow_status AS \"flow_status!: Json\"\n FROM completed_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "flow_status!: Json", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true + ] + }, + "hash": "ef8868893643a1a71531c1113d5cb38c5c204b3bc34c921b2f653c738af556a9" +} diff --git a/backend/.sqlx/query-f0d3c2641924b1f1026d4dfa19290850047653549ee20870e6272cb7d4cfb9aa.json b/backend/.sqlx/query-f0d3c2641924b1f1026d4dfa19290850047653549ee20870e6272cb7d4cfb9aa.json new file mode 100644 index 0000000000..5fa15ac703 --- /dev/null +++ b/backend/.sqlx/query-f0d3c2641924b1f1026d4dfa19290850047653549ee20870e6272cb7d4cfb9aa.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT parent_job FROM v2_job WHERE id = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "parent_job", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "f0d3c2641924b1f1026d4dfa19290850047653549ee20870e6272cb7d4cfb9aa" +} diff --git a/backend/.sqlx/query-f0fdeb7aea3e71099e7db0f4343bbd7ec86610ddc8589bf5b606fab0947c8b75.json b/backend/.sqlx/query-f0fdeb7aea3e71099e7db0f4343bbd7ec86610ddc8589bf5b606fab0947c8b75.json new file mode 100644 index 0000000000..26111685ba --- /dev/null +++ b/backend/.sqlx/query-f0fdeb7aea3e71099e7db0f4343bbd7ec86610ddc8589bf5b606fab0947c8b75.json @@ -0,0 +1,91 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n v2_as_queue.job_kind AS \"job_kind!: JobKind\",\n v2_as_queue.script_hash AS \"script_hash: ScriptHash\",\n v2_as_queue.raw_flow AS \"raw_flow: sqlx::types::Json>\",\n v2_as_completed_job.parent_job AS \"parent_job: Uuid\",\n v2_as_completed_job.created_at AS \"created_at!: chrono::NaiveDateTime\",\n v2_as_completed_job.created_by AS \"created_by!\",\n v2_as_queue.script_path,\n v2_as_queue.args AS \"args: sqlx::types::Json>\"\n FROM v2_as_queue\n JOIN v2_as_completed_job ON v2_as_completed_job.parent_job = v2_as_queue.id\n WHERE v2_as_completed_job.id = $1 AND v2_as_completed_job.workspace_id = $2\n LIMIT 1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "job_kind!: JobKind", + "type_info": { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + } + }, + { + "ordinal": 1, + "name": "script_hash: ScriptHash", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "raw_flow: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "parent_job: Uuid", + "type_info": "Uuid" + }, + { + "ordinal": 4, + "name": "created_at!: chrono::NaiveDateTime", + "type_info": "Timestamptz" + }, + { + "ordinal": 5, + "name": "created_by!", + "type_info": "Varchar" + }, + { + "ordinal": 6, + "name": "script_path", + "type_info": "Varchar" + }, + { + "ordinal": 7, + "name": "args: sqlx::types::Json>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true, + true, + true, + true, + true, + true, + true, + true + ] + }, + "hash": "f0fdeb7aea3e71099e7db0f4343bbd7ec86610ddc8589bf5b606fab0947c8b75" +} diff --git a/backend/.sqlx/query-f3571e1d2b57011e5f6a38725eb42d909456d28a98563923cca43e760862e5e0.json b/backend/.sqlx/query-f3571e1d2b57011e5f6a38725eb42d909456d28a98563923cca43e760862e5e0.json new file mode 100644 index 0000000000..804f35777e --- /dev/null +++ b/backend/.sqlx/query-f3571e1d2b57011e5f6a38725eb42d909456d28a98563923cca43e760862e5e0.json @@ -0,0 +1,24 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT flow_status->'user_states'->$1\n FROM v2_as_queue\n WHERE id = $2 AND workspace_id = $3\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "?column?", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Text", + "Uuid", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "f3571e1d2b57011e5f6a38725eb42d909456d28a98563923cca43e760862e5e0" +} diff --git a/backend/.sqlx/query-f3c78cb67379f9407f1f32ce3387184d7f4fcb04c07a8e2f07c5effc10f8fd5c.json b/backend/.sqlx/query-f3c78cb67379f9407f1f32ce3387184d7f4fcb04c07a8e2f07c5effc10f8fd5c.json new file mode 100644 index 0000000000..0cf878b15c --- /dev/null +++ b/backend/.sqlx/query-f3c78cb67379f9407f1f32ce3387184d7f4fcb04c07a8e2f07c5effc10f8fd5c.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job_status\n SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'approvers'], $2)\n WHERE id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "f3c78cb67379f9407f1f32ce3387184d7f4fcb04c07a8e2f07c5effc10f8fd5c" +} diff --git a/backend/.sqlx/query-f5c6d52f69b99dab6d7ec3aad2ec090a07fe82a2ccb17a1b3d903de499c2e7c8.json b/backend/.sqlx/query-f5c6d52f69b99dab6d7ec3aad2ec090a07fe82a2ccb17a1b3d903de499c2e7c8.json new file mode 100644 index 0000000000..19b691bbe5 --- /dev/null +++ b/backend/.sqlx/query-f5c6d52f69b99dab6d7ec3aad2ec090a07fe82a2ccb17a1b3d903de499c2e7c8.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET\n args = '{\"reason\":\"PREPROCESSOR_ARGS_ARE_DISCARDED\"}'::jsonb\n WHERE id = $1 AND args->'wm_trigger' IS NOT NULL", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "f5c6d52f69b99dab6d7ec3aad2ec090a07fe82a2ccb17a1b3d903de499c2e7c8" +} diff --git a/backend/.sqlx/query-f64ae18811e211dbf0cb98b43d3b018b0dcc0abc7e4a1f0b45885cfe18efd9b2.json b/backend/.sqlx/query-f64ae18811e211dbf0cb98b43d3b018b0dcc0abc7e4a1f0b45885cfe18efd9b2.json new file mode 100644 index 0000000000..99e04c9bff --- /dev/null +++ b/backend/.sqlx/query-f64ae18811e211dbf0cb98b43d3b018b0dcc0abc7e4a1f0b45885cfe18efd9b2.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "create index concurrently if not exists ix_job_workspace_id_created_at_new_3 ON v2_job (workspace_id, created_at DESC)", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "f64ae18811e211dbf0cb98b43d3b018b0dcc0abc7e4a1f0b45885cfe18efd9b2" +} diff --git a/backend/.sqlx/query-f746c5d2ffa24dd75124b5f8d04f587c9581ef407417ec979b8a3ab07816cc69.json b/backend/.sqlx/query-f746c5d2ffa24dd75124b5f8d04f587c9581ef407417ec979b8a3ab07816cc69.json new file mode 100644 index 0000000000..c65cfb397a --- /dev/null +++ b/backend/.sqlx/query-f746c5d2ffa24dd75124b5f8d04f587c9581ef407417ec979b8a3ab07816cc69.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE v2_job SET trigger = REGEXP_REPLACE(trigger,'u/' || $2 || '/(.*)','u/' || $1 || '/\\1') WHERE trigger LIKE ('u/' || $2 || '/%') AND workspace_id = $3", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "f746c5d2ffa24dd75124b5f8d04f587c9581ef407417ec979b8a3ab07816cc69" +} diff --git a/backend/.sqlx/query-f7b1445ec1f0d86efb6f8e0939430e7294bcac06bb7930dcf4d46427571662cb.json b/backend/.sqlx/query-f7b1445ec1f0d86efb6f8e0939430e7294bcac06bb7930dcf4d46427571662cb.json new file mode 100644 index 0000000000..5948eedef5 --- /dev/null +++ b/backend/.sqlx/query-f7b1445ec1f0d86efb6f8e0939430e7294bcac06bb7930dcf4d46427571662cb.json @@ -0,0 +1,35 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE queue SET mem_peak = $1, last_ping = now()\n WHERE id = $2\n RETURNING canceled AS \"canceled!\", canceled_by, canceled_reason", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "canceled!", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "canceled_by", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "canceled_reason", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + true, + true, + true + ] + }, + "hash": "f7b1445ec1f0d86efb6f8e0939430e7294bcac06bb7930dcf4d46427571662cb" +} diff --git a/backend/.sqlx/query-f822df86bf511fe0d3044b69525a6ff2524167877929886adca9b0fa3d3fee45.json b/backend/.sqlx/query-f822df86bf511fe0d3044b69525a6ff2524167877929886adca9b0fa3d3fee45.json new file mode 100644 index 0000000000..3adc1f8cd5 --- /dev/null +++ b/backend/.sqlx/query-f822df86bf511fe0d3044b69525a6ff2524167877929886adca9b0fa3d3fee45.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n DELETE\n FROM parallel_monitor_lock\n WHERE last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval \n RETURNING parent_flow_id, job_id, last_ping, (SELECT workspace_id FROM v2_job_queue q\n WHERE q.id = parent_flow_id AND q.running = true AND q.canceled_by IS NULL\n ) AS workspace_id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "parent_flow_id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "job_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "last_ping", + "type_info": "Timestamptz" + }, + { + "ordinal": 3, + "name": "workspace_id", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + true, + null + ] + }, + "hash": "f822df86bf511fe0d3044b69525a6ff2524167877929886adca9b0fa3d3fee45" +} diff --git a/backend/.sqlx/query-f8f25948ae14fcb71c666cdc5e51d888e1f22fb2300a78bbeafebf64e82658db.json b/backend/.sqlx/query-f8f25948ae14fcb71c666cdc5e51d888e1f22fb2300a78bbeafebf64e82658db.json new file mode 100644 index 0000000000..5167523212 --- /dev/null +++ b/backend/.sqlx/query-f8f25948ae14fcb71c666cdc5e51d888e1f22fb2300a78bbeafebf64e82658db.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id AS \"id!\" FROM queue WHERE parent_job = $1 AND workspace_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "f8f25948ae14fcb71c666cdc5e51d888e1f22fb2300a78bbeafebf64e82658db" +} diff --git a/backend/.sqlx/query-fce269376a0f08cb39359a3cb86be6b9823af022195b80db8ccbc3737576462c.json b/backend/.sqlx/query-fce269376a0f08cb39359a3cb86be6b9823af022195b80db8ccbc3737576462c.json new file mode 100644 index 0000000000..367f01ba75 --- /dev/null +++ b/backend/.sqlx/query-fce269376a0f08cb39359a3cb86be6b9823af022195b80db8ccbc3737576462c.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job_completed AS cj\n ( workspace_id\n , id\n , started_at\n , duration_ms\n , result\n , result_columns\n , canceled_by\n , canceled_reason\n , flow_status\n , memory_peak\n , status\n )\n VALUES ($1, $2, $3, COALESCE($12::bigint, (EXTRACT('epoch' FROM (now())) - EXTRACT('epoch' FROM (COALESCE($3, now()))))*1000), $5, $13, $7, $8, $9,$11, CASE WHEN $6::BOOL THEN 'canceled'::job_status\n WHEN $10::BOOL THEN 'skipped'::job_status\n WHEN $4::BOOL THEN 'success'::job_status\n ELSE 'failure'::job_status END)\n ON CONFLICT (id) DO UPDATE SET status = EXCLUDED.status, result = $5 RETURNING duration_ms AS \"duration_ms!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "duration_ms!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Uuid", + "Timestamptz", + "Bool", + "Jsonb", + "Bool", + "Varchar", + "Text", + "Jsonb", + "Bool", + "Int4", + "Int8", + "TextArray" + ] + }, + "nullable": [ + false + ] + }, + "hash": "fce269376a0f08cb39359a3cb86be6b9823af022195b80db8ccbc3737576462c" +} diff --git a/backend/.sqlx/query-fdedd3909a97db5d43d9c46ff77b800b8efd647121b538deb023f96dbaac3715.json b/backend/.sqlx/query-fdedd3909a97db5d43d9c46ff77b800b8efd647121b538deb023f96dbaac3715.json new file mode 100644 index 0000000000..905707255f --- /dev/null +++ b/backend/.sqlx/query-fdedd3909a97db5d43d9c46ff77b800b8efd647121b538deb023f96dbaac3715.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT args AS \"args: Json>>\"\n FROM v2_job WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "args: Json>>", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + true + ] + }, + "hash": "fdedd3909a97db5d43d9c46ff77b800b8efd647121b538deb023f96dbaac3715" +} diff --git a/backend/.sqlx/query-ff0403790674cdb07022af71c2377afbd8b3a660b3be27514b517c077c63c238.json b/backend/.sqlx/query-ff0403790674cdb07022af71c2377afbd8b3a660b3be27514b517c077c63c238.json new file mode 100644 index 0000000000..6a4a3b3d75 --- /dev/null +++ b/backend/.sqlx/query-ff0403790674cdb07022af71c2377afbd8b3a660b3be27514b517c077c63c238.json @@ -0,0 +1,84 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO v2_job (id, runnable_id, runnable_path, kind, script_lang, tag, created_by, permissioned_as, permissioned_as_email, workspace_id) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9 FROM generate_series(1, $10)) RETURNING id", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Int8", + "Varchar", + { + "Custom": { + "name": "job_kind", + "kind": { + "Enum": [ + "script", + "preview", + "flow", + "dependencies", + "flowpreview", + "script_hub", + "identity", + "flowdependencies", + "http", + "graphql", + "postgresql", + "noop", + "appdependencies", + "deploymentcallback", + "singlescriptflow", + "flowscript", + "flownode", + "appscript" + ] + } + } + }, + { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + }, + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Int4" + ] + }, + "nullable": [ + false + ] + }, + "hash": "ff0403790674cdb07022af71c2377afbd8b3a660b3be27514b517c077c63c238" +} diff --git a/backend/.sqlx/query-ff14230469026418966ec79b77f549b2fb27c90556484f3914666d5ad7f8f107.json b/backend/.sqlx/query-ff14230469026418966ec79b77f549b2fb27c90556484f3914666d5ad7f8f107.json new file mode 100644 index 0000000000..1744aa7167 --- /dev/null +++ b/backend/.sqlx/query-ff14230469026418966ec79b77f549b2fb27c90556484f3914666d5ad7f8f107.json @@ -0,0 +1,70 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n result #> $3 AS \"result: sqlx::types::Json>\",\n flow_status AS \"flow_status: sqlx::types::Json>\",\n language AS \"language: ScriptLang\",\n created_by AS \"created_by!\"\n FROM completed_job\n WHERE id = $1 AND workspace_id = $2 AND ($4::text[] IS NULL OR tag = ANY($4))", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "result: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 1, + "name": "flow_status: sqlx::types::Json>", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "language: ScriptLang", + "type_info": { + "Custom": { + "name": "script_lang", + "kind": { + "Enum": [ + "python3", + "deno", + "go", + "bash", + "postgresql", + "nativets", + "bun", + "mysql", + "bigquery", + "snowflake", + "graphql", + "powershell", + "mssql", + "php", + "bunnative", + "rust", + "ansible", + "csharp", + "oracledb" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "created_by!", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "TextArray", + "TextArray" + ] + }, + "nullable": [ + null, + true, + true, + true + ] + }, + "hash": "ff14230469026418966ec79b77f549b2fb27c90556484f3914666d5ad7f8f107" +} diff --git a/backend/Cargo.lock b/backend/Cargo.lock index a50ea3f309..b598b4c53f 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -442,7 +442,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -538,7 +538,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -560,7 +560,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -596,7 +596,7 @@ checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -651,9 +651,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.15" +version = "1.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc47e70fc35d054c8fcd296d47a61711f043ac80534a10b4f741904f81e73a90" +checksum = "50236e4d60fe8458de90a71c0922c761e41755adf091b1b03de1cef537179915" dependencies = [ "aws-credential-types", "aws-runtime", @@ -693,9 +693,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee7643696e7fdd74c10f9eb42848a87fe469d35eae9c3323f80aa98f350baac" +checksum = "76dd04d39cc12844c0994f2c9c5a6f5184c22e9188ec1ff723de41910a21dcad" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -713,14 +713,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] name = "aws-sdk-sso" -version = "1.57.0" +version = "1.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54bab121fe1881a74c338c5f723d1592bf3b53167f80268a1274f404e1acc38" +checksum = "16ff718c9ee45cc1ebd4774a0e086bb80a6ab752b4902edf1c9f56b86ee1f770" dependencies = [ "aws-credential-types", "aws-runtime", @@ -740,9 +740,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.58.0" +version = "1.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c8234fd024f7ac61c4e44ea008029bde934250f371efe7d4a39708397b1080c" +checksum = "5183e088715cc135d8d396fdd3bc02f018f0da4c511f53cb8d795b6a31c55809" dependencies = [ "aws-credential-types", "aws-runtime", @@ -762,9 +762,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.58.0" +version = "1.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba60e1d519d6f23a9df712c04fdeadd7872ac911c84b2f62a8bda92e129b7962" +checksum = "c9f944ef032717596639cea4a2118a3a457268ef51bbb5fde9637e54c465da00" dependencies = [ "aws-credential-types", "aws-runtime", @@ -785,9 +785,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.7" +version = "1.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "690118821e46967b3c4501d67d7d52dd75106a9c54cf36cefa1985cedbe94e05" +checksum = "0bc5bbd1e4a2648fd8c5982af03935972c24a2f9846b396de661d351ee3ce837" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -858,9 +858,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.7" +version = "1.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865f7050bbc7107a6c98a397a9fcd9413690c27fa718446967cf03b2d3ac517e" +checksum = "d526a12d9ed61fadefda24abe2e682892ba288c2018bcb38b1b4c111d13f6d92" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -902,9 +902,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.12" +version = "1.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28f6feb647fb5e0d5b50f0472c19a7db9462b74e2fec01bb0b44eedcc834e97" +checksum = "c7b8a53819e42f10d0821f56da995e1470b199686a1809168db6ca485665f042" dependencies = [ "base64-simd 0.8.0", "bytes", @@ -937,9 +937,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.3.4" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0df5a18c4f951c645300d365fec53a61418bcf4650f604f85fe2a665bfaa0c2" +checksum = "dfbd0a668309ec1f66c0f6bda4840dd6d4796ae26d699ebc266d7cc95c6d040f" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -1136,7 +1136,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.96", + "syn 2.0.98", "which 4.4.2", ] @@ -1157,7 +1157,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -1332,7 +1332,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -1434,7 +1434,7 @@ checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -1445,9 +1445,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" dependencies = [ "serde", ] @@ -1552,9 +1552,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.11" +version = "1.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" +checksum = "755717a7de9ec452bf7f3f1a3099085deabd7f2962b861dae91ecd7a365903d2" dependencies = [ "jobserver", "libc", @@ -1668,9 +1668,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.27" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" +checksum = "3e77c3243bd94243c03672cb5154667347c457ca271254724f9f393aee1c05ff" dependencies = [ "clap_builder", "clap_derive", @@ -1690,14 +1690,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.24" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" +checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2082,7 +2082,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2154,7 +2154,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2187,7 +2187,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -2264,7 +2264,7 @@ dependencies = [ "tokio", "tokio-util", "url", - "uuid 1.12.1", + "uuid 1.13.1", "xz2", "zstd", ] @@ -2364,7 +2364,7 @@ dependencies = [ "regex", "sha2 0.10.8", "unicode-segmentation", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -2531,7 +2531,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" dependencies = [ "serde", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -2714,7 +2714,7 @@ dependencies = [ "stringcase", "strum 0.25.0", "strum_macros 0.25.3", - "syn 2.0.96", + "syn 2.0.98", "thiserror 1.0.69", ] @@ -2826,7 +2826,7 @@ dependencies = [ "serde", "thiserror 1.0.69", "tokio", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -2892,15 +2892,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.18" +version = "0.99.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +checksum = "3da29a38df43d6f156149c9b43ded5e018ddff2a855cf2cfd62e8cd7d079c69f" dependencies = [ "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3005,7 +3005,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3028,7 +3028,7 @@ checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3185,7 +3185,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3205,7 +3205,7 @@ checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3410,7 +3410,7 @@ checksum = "32016f1242eb82af5474752d00fd8ebcd9004bd69b462b1c91de833972d08ed4" dependencies = [ "proc-macro2", "swc_macros_common", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3534,7 +3534,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3799,7 +3799,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -3964,7 +3964,7 @@ checksum = "f208758247e68e239acaa059e72e4ce1f30f2a4b6523f19c1b923d25b7e9cceb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -4527,7 +4527,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -4649,7 +4649,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5099,9 +5099,9 @@ dependencies = [ [[package]] name = "malachite-base" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7d99f6446827fb878a005ea5cf7db1d78d236391733012216a9b8eb5dbd824" +checksum = "5ea0ed76adf7defc1a92240b5c36d5368cfe9251640dcce5bd2d0b7c1fd87aeb" dependencies = [ "hashbrown 0.14.5", "itertools 0.11.0", @@ -5124,9 +5124,9 @@ dependencies = [ [[package]] name = "malachite-nz" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36157fa6b969ca652feefe159e202ebd85683e57463074492a7ec3eaa468c97" +checksum = "34a79feebb2bc9aa7762047c8e5495269a367da6b5a90a99882a0aeeac1841f7" dependencies = [ "itertools 0.11.0", "libm", @@ -5135,9 +5135,9 @@ dependencies = [ [[package]] name = "malachite-q" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dde29a4fcf7025f482745247951f7c5d0459671f59aedf09035b2e2c3746fdf" +checksum = "50f235d5747b1256b47620f5640c2a17a88c7569eebdf27cd9cb130e1a619191" dependencies = [ "itertools 0.11.0", "malachite-base", @@ -5302,7 +5302,7 @@ checksum = "a7ce64b975ed4f123575d11afd9491f2e37bbd5813fbfbc0f09ae1fbddea74e0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5341,7 +5341,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "termcolor", "thiserror 1.0.69", ] @@ -5406,7 +5406,7 @@ dependencies = [ "sha2 0.10.8", "subprocess", "thiserror 1.0.69", - "uuid 1.12.1", + "uuid 1.13.1", "zstd", ] @@ -5616,7 +5616,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5701,9 +5701,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oneshot" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e296cf87e61c9cfc1a61c3c63a0f7f286ed4554e0e22be84e8a38e1d264a2a29" +checksum = "79d72a7c0f743d2ebb0a2ad1d219db75fdc799092ed3a884c9144c42a31225bd" [[package]] name = "onig" @@ -5777,9 +5777,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.69" +version = "0.10.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e534d133a060a3c19daec1eb3e98ec6f4685978834f2dbadfe2ec215bab64e" +checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6" dependencies = [ "bitflags 2.8.0", "cfg-if", @@ -5798,7 +5798,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -5818,9 +5818,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.104" +version = "0.9.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc" dependencies = [ "cc", "libc", @@ -6196,7 +6196,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6222,22 +6222,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" +checksum = "dfe2e71e1471fe07709406bf725f710b02927c9c54b2b5b2ec0e8087d97c327d" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" +checksum = "f6e859e6e5bd50440ab63c47e3ebabc90f26251f7c73c3d3e837b74a1cc3fa67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6285,19 +6285,6 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" -[[package]] -name = "postgres-native-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d442770e2b1e244bb5eb03b31c79b65bb2568f413b899eaba850fa945a65954" -dependencies = [ - "futures", - "native-tls", - "tokio", - "tokio-native-tls", - "tokio-postgres 0.7.12", -] - [[package]] name = "postgres-native-tls" version = "0.5.0" @@ -6309,11 +6296,22 @@ dependencies = [ "tokio-postgres 0.7.11", ] +[[package]] +name = "postgres-native-tls" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f39498473c92f7b6820ae970382c1d83178a3454c618161cb772e8598d9f6f" +dependencies = [ + "native-tls", + "tokio", + "tokio-native-tls", + "tokio-postgres 0.7.13", +] + [[package]] name = "postgres-protocol" version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acda0ebdebc28befa84bee35e651e4c5f09073d668c7aed4cf7e23c3cda84b23" +source = "git+https://github.com/imor/rust-postgres?rev=20265ef38e32a06f76b6f9b678e2077fc2211f6b#20265ef38e32a06f76b6f9b678e2077fc2211f6b" dependencies = [ "base64 0.22.1", "byteorder", @@ -6329,8 +6327,9 @@ dependencies = [ [[package]] name = "postgres-protocol" -version = "0.6.7" -source = "git+https://github.com/imor/rust-postgres?rev=20265ef38e32a06f76b6f9b678e2077fc2211f6b#20265ef38e32a06f76b6f9b678e2077fc2211f6b" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ff0abab4a9b844b93ef7b81f1efc0a366062aaef2cd702c76256b5dc075c54" dependencies = [ "base64 0.22.1", "byteorder", @@ -6339,7 +6338,7 @@ dependencies = [ "hmac", "md-5 0.10.6", "memchr", - "rand 0.8.5", + "rand 0.9.0", "sha2 0.10.8", "stringprep", ] @@ -6351,24 +6350,24 @@ source = "git+https://github.com/imor/rust-postgres?rev=20265ef38e32a06f76b6f9b6 dependencies = [ "bytes", "fallible-iterator", - "postgres-protocol 0.6.7 (git+https://github.com/imor/rust-postgres?rev=20265ef38e32a06f76b6f9b678e2077fc2211f6b)", + "postgres-protocol 0.6.7", ] [[package]] name = "postgres-types" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f66ea23a2d0e5734297357705193335e0a957696f34bed2f2faefacb2fec336f" +checksum = "613283563cd90e1dfc3518d548caee47e0e725455ed619881f5cf21f36de4b48" dependencies = [ "array-init", "bit-vec", "bytes", "chrono", "fallible-iterator", - "postgres-protocol 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "postgres-protocol 0.6.8", "serde", "serde_json", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -6409,7 +6408,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" dependencies = [ "proc-macro2", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6449,7 +6448,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6460,7 +6459,7 @@ checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" dependencies = [ "proc-macro-rules-macros", "proc-macro2", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6472,7 +6471,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6533,7 +6532,7 @@ dependencies = [ "schemars", "serde", "serde_json", - "syn 2.0.96", + "syn 2.0.98", "thiserror 1.0.69", "typify", "unicode-ident", @@ -6553,7 +6552,7 @@ dependencies = [ "serde_json", "serde_tokenstream", "serde_yaml", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6596,7 +6595,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -6798,7 +6797,7 @@ checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.0", - "zerocopy 0.8.14", + "zerocopy 0.8.16", ] [[package]] @@ -6856,7 +6855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" dependencies = [ "getrandom 0.3.1", - "zerocopy 0.8.14", + "zerocopy 0.8.16", ] [[package]] @@ -7225,7 +7224,7 @@ dependencies = [ "rkyv_derive", "seahash", "tinyvec", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -7280,7 +7279,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.96", + "syn 2.0.98", "walkdir", ] @@ -7314,7 +7313,7 @@ dependencies = [ "borsh", "bytes", "num-traits", - "postgres-types 0.2.8", + "postgres-types 0.2.9", "rand 0.8.5", "rkyv", "serde", @@ -7366,7 +7365,7 @@ dependencies = [ "serde", "tempfile", "thiserror 1.0.69", - "toml 0.8.19", + "toml 0.8.20", "toolchain_find", ] @@ -7616,7 +7615,7 @@ dependencies = [ "serde", "thiserror 1.0.69", "url", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -7654,7 +7653,7 @@ dependencies = [ "schemars_derive", "serde", "serde_json", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -7666,7 +7665,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -7826,7 +7825,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -7837,7 +7836,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -7911,7 +7910,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -7932,7 +7931,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -7987,7 +7986,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -8337,7 +8336,7 @@ checksum = "01b2e185515564f15375f593fb966b5718bc624ba77fe49fa4616ad619690554" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -8388,7 +8387,7 @@ dependencies = [ "tokio-stream", "tracing", "url", - "uuid 1.12.1", + "uuid 1.13.1", "webpki-roots", ] @@ -8402,7 +8401,7 @@ dependencies = [ "quote", "sqlx-core", "sqlx-macros-core", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -8425,7 +8424,7 @@ dependencies = [ "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", - "syn 2.0.96", + "syn 2.0.98", "tempfile", "tokio", "url", @@ -8472,7 +8471,7 @@ dependencies = [ "stringprep", "thiserror 2.0.11", "tracing", - "uuid 1.12.1", + "uuid 1.13.1", "whoami", ] @@ -8513,7 +8512,7 @@ dependencies = [ "stringprep", "thiserror 2.0.11", "tracing", - "uuid 1.12.1", + "uuid 1.13.1", "whoami", ] @@ -8539,7 +8538,7 @@ dependencies = [ "sqlx-core", "tracing", "url", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -8576,7 +8575,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -8636,7 +8635,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -8649,7 +8648,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -8757,7 +8756,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -8806,7 +8805,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -8891,7 +8890,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -8998,7 +8997,7 @@ checksum = "63db0adcff29d220c3d151c5b25c0eabe7e32dd936212b84cdaa1392e3130497" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -9009,7 +9008,7 @@ checksum = "f486687bfb7b5c560868f69ed2d458b880cebc9babebcb67e49f31b55c5bf847" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -9032,7 +9031,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -9048,9 +9047,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.96" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -9080,7 +9079,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -9186,7 +9185,7 @@ dependencies = [ "tempfile", "thiserror 1.0.69", "time", - "uuid 1.12.1", + "uuid 1.13.1", "winapi", ] @@ -9355,7 +9354,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -9366,7 +9365,7 @@ checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -9416,7 +9415,7 @@ dependencies = [ "tokio-rustls 0.24.1", "tokio-util", "tracing", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -9601,7 +9600,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -9630,7 +9629,7 @@ dependencies = [ "percent-encoding", "phf", "pin-project-lite", - "postgres-protocol 0.6.7 (git+https://github.com/imor/rust-postgres?rev=20265ef38e32a06f76b6f9b678e2077fc2211f6b)", + "postgres-protocol 0.6.7", "postgres-types 0.2.7", "rand 0.8.5", "socket2", @@ -9641,9 +9640,9 @@ dependencies = [ [[package]] name = "tokio-postgres" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b5d3742945bc7d7f210693b0c58ae542c6fd47b17adbbda0885f3dcb34a6bdb" +checksum = "6c95d533c83082bb6490e0189acaa0bbeef9084e60471b696ca6988cd0541fb0" dependencies = [ "async-trait", "byteorder", @@ -9656,9 +9655,9 @@ dependencies = [ "percent-encoding", "phf", "pin-project-lite", - "postgres-protocol 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "postgres-types 0.2.8", - "rand 0.8.5", + "postgres-protocol 0.6.8", + "postgres-types 0.2.9", + "rand 0.9.0", "socket2", "tokio", "tokio-util", @@ -9786,9 +9785,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", "serde_spanned", @@ -9828,7 +9827,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.7.0", + "winnow 0.7.1", ] [[package]] @@ -9995,7 +9994,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -10224,7 +10223,7 @@ dependencies = [ "regress", "schemars", "serde_json", - "syn 2.0.96", + "syn 2.0.98", "thiserror 1.0.69", "unicode-ident", ] @@ -10241,7 +10240,7 @@ dependencies = [ "serde", "serde_json", "serde_tokenstream", - "syn 2.0.96", + "syn 2.0.98", "typify-impl", ] @@ -10252,7 +10251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f294bff79170ed1c5633812aff1e565c35d993a36e757f9bc0accf5eec4e6045" dependencies = [ "rand 0.8.5", - "uuid 1.12.1", + "uuid 1.13.1", "web-time", ] @@ -10534,11 +10533,11 @@ dependencies = [ [[package]] name = "uuid" -version = "1.12.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" +checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.3.1", "serde", ] @@ -10656,7 +10655,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "wasm-bindgen-shared", ] @@ -10690,7 +10689,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -10723,7 +10722,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -10860,7 +10859,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windmill" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "axum", @@ -10889,7 +10888,7 @@ dependencies = [ "tokio", "tracing", "url", - "uuid 1.12.1", + "uuid 1.13.1", "v8", "windmill-api", "windmill-api-client", @@ -10903,7 +10902,7 @@ dependencies = [ [[package]] name = "windmill-api" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "argon2", @@ -10948,7 +10947,7 @@ dependencies = [ "openssl", "pg_escape", "pin-project", - "postgres-native-tls 0.5.0 (git+https://github.com/imor/rust-postgres?rev=20265ef38e32a06f76b6f9b678e2077fc2211f6b)", + "postgres-native-tls 0.5.0", "prometheus", "quick_cache", "rand 0.9.0", @@ -10984,7 +10983,7 @@ dependencies = [ "ulid", "url", "urlencoding", - "uuid 1.12.1", + "uuid 1.13.1", "windmill-audit", "windmill-common", "windmill-git-sync", @@ -10996,7 +10995,7 @@ dependencies = [ [[package]] name = "windmill-api-client" -version = "1.456.0" +version = "1.457.1" dependencies = [ "base64 0.22.1", "chrono", @@ -11009,12 +11008,12 @@ dependencies = [ "serde", "serde_json", "syn 1.0.109", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] name = "windmill-audit" -version = "1.456.0" +version = "1.457.1" dependencies = [ "chrono", "serde", @@ -11027,21 +11026,21 @@ dependencies = [ [[package]] name = "windmill-autoscaling" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "serde", "serde_json", "sqlx", "tracing", - "uuid 1.12.1", + "uuid 1.13.1", "windmill-common", "windmill-queue", ] [[package]] name = "windmill-common" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "async-stream", @@ -11094,27 +11093,27 @@ dependencies = [ "tracing-loki", "tracing-opentelemetry", "tracing-subscriber", - "uuid 1.12.1", + "uuid 1.13.1", "windmill-macros", ] [[package]] name = "windmill-git-sync" -version = "1.456.0" +version = "1.457.1" dependencies = [ "regex", "serde", "serde_json", "sqlx", "tracing", - "uuid 1.12.1", + "uuid 1.13.1", "windmill-common", "windmill-queue", ] [[package]] name = "windmill-indexer" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "bytes", @@ -11131,25 +11130,25 @@ dependencies = [ "tokio", "tokio-tar", "tracing", - "uuid 1.12.1", + "uuid 1.13.1", "windmill-common", ] [[package]] name = "windmill-macros" -version = "1.456.0" +version = "1.457.1" dependencies = [ "itertools 0.14.0", "lazy_static", "proc-macro2", "quote", "regex", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] name = "windmill-parser" -version = "1.456.0" +version = "1.457.1" dependencies = [ "convert_case 0.6.0", "serde", @@ -11158,7 +11157,7 @@ dependencies = [ [[package]] name = "windmill-parser-bash" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "lazy_static", @@ -11170,7 +11169,7 @@ dependencies = [ [[package]] name = "windmill-parser-csharp" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "serde_json", @@ -11182,7 +11181,7 @@ dependencies = [ [[package]] name = "windmill-parser-go" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "gosyn", @@ -11194,7 +11193,7 @@ dependencies = [ [[package]] name = "windmill-parser-graphql" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "lazy_static", @@ -11206,7 +11205,7 @@ dependencies = [ [[package]] name = "windmill-parser-php" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "itertools 0.14.0", @@ -11217,7 +11216,7 @@ dependencies = [ [[package]] name = "windmill-parser-py" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "itertools 0.14.0", @@ -11228,7 +11227,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-imports" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "async-recursion", @@ -11248,7 +11247,7 @@ dependencies = [ [[package]] name = "windmill-parser-rust" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -11258,14 +11257,14 @@ dependencies = [ "quote", "regex", "serde_json", - "syn 2.0.96", + "syn 2.0.98", "toml 0.7.8", "windmill-parser", ] [[package]] name = "windmill-parser-sql" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "lazy_static", @@ -11277,7 +11276,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "lazy_static", @@ -11295,7 +11294,7 @@ dependencies = [ [[package]] name = "windmill-parser-wasm" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "getrandom 0.2.15", @@ -11317,7 +11316,7 @@ dependencies = [ [[package]] name = "windmill-parser-yaml" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "serde_json", @@ -11327,7 +11326,7 @@ dependencies = [ [[package]] name = "windmill-queue" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "async-recursion", @@ -11353,14 +11352,14 @@ dependencies = [ "tokio", "tracing", "ulid", - "uuid 1.12.1", + "uuid 1.13.1", "windmill-audit", "windmill-common", ] [[package]] name = "windmill-sql-datatype-parser-wasm" -version = "1.456.0" +version = "1.457.1" dependencies = [ "wasm-bindgen", "wasm-bindgen-test", @@ -11370,7 +11369,7 @@ dependencies = [ [[package]] name = "windmill-worker" -version = "1.456.0" +version = "1.457.1" dependencies = [ "anyhow", "async-recursion", @@ -11410,7 +11409,7 @@ dependencies = [ "opentelemetry", "oracle", "pem 3.0.4", - "postgres-native-tls 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "postgres-native-tls 0.5.1", "prometheus", "rand 0.9.0", "regex", @@ -11423,11 +11422,11 @@ dependencies = [ "tar", "tiberius", "tokio", - "tokio-postgres 0.7.12", + "tokio-postgres 0.7.13", "tokio-util", "tracing", "urlencoding", - "uuid 1.12.1", + "uuid 1.13.1", "windmill-audit", "windmill-common", "windmill-git-sync", @@ -11654,9 +11653,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" +checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f" dependencies = [ "memchr", ] @@ -11768,7 +11767,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "synstructure", ] @@ -11784,11 +11783,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.14" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468" +checksum = "7b8c07a70861ce02bad1607b5753ecb2501f67847b9f9ada7c160fff0ec6300c" dependencies = [ - "zerocopy-derive 0.8.14", + "zerocopy-derive 0.8.16", ] [[package]] @@ -11799,18 +11798,18 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] name = "zerocopy-derive" -version = "0.8.14" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1" +checksum = "5226bc9a9a9836e7428936cde76bb6b22feea1a8bfdbc0d241136e4d13417e25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] @@ -11830,7 +11829,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", "synstructure", ] @@ -11859,7 +11858,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.98", ] [[package]] diff --git a/backend/Cargo.toml b/backend/Cargo.toml index c174739a84..c53130bf1a 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windmill" -version = "1.456.0" +version = "1.457.1" authors.workspace = true edition.workspace = true @@ -30,7 +30,7 @@ members = [ ] [workspace.package] -version = "1.456.0" +version = "1.457.1" authors = ["Ruben Fiszel "] edition = "2021" diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt index 4076343f5a..77cb564474 100644 --- a/backend/ee-repo-ref.txt +++ b/backend/ee-repo-ref.txt @@ -1 +1 @@ -eec544f334523171a3143ce382090d8bd80a23a7 \ No newline at end of file +3dab441fe1eb5c9a042a6a4d9933ddea29c1bf4e \ No newline at end of file diff --git a/backend/migrations/20250131153251_ai_models.down.sql b/backend/migrations/20250131153251_ai_models.down.sql new file mode 100644 index 0000000000..76eaf5ba6b --- /dev/null +++ b/backend/migrations/20250131153251_ai_models.down.sql @@ -0,0 +1,5 @@ +ALTER TABLE workspace_settings ADD COLUMN code_completion_enabled BOOLEAN DEFAULT FALSE NOT NULL; + +UPDATE workspace_settings SET code_completion_enabled = TRUE WHERE code_completion_model IS NOT NULL; + +ALTER TABLE workspace_settings DROP COLUMN ai_models, DROP COLUMN code_completion_model; \ No newline at end of file diff --git a/backend/migrations/20250131153251_ai_models.up.sql b/backend/migrations/20250131153251_ai_models.up.sql new file mode 100644 index 0000000000..7145e0bb98 --- /dev/null +++ b/backend/migrations/20250131153251_ai_models.up.sql @@ -0,0 +1,24 @@ +ALTER TABLE workspace_settings + ADD COLUMN ai_models varchar(255)[] DEFAULT '{}' NOT NULL, + ADD COLUMN code_completion_model varchar(255); + +UPDATE workspace_settings +SET ai_models = CASE + WHEN ai_resource->>'provider' = 'openai' THEN ARRAY['gpt-4o'] + WHEN ai_resource->>'provider' = 'anthropic' THEN ARRAY['claude-3-5-sonnet-latest'] + WHEN ai_resource->>'provider' = 'mistral' THEN ARRAY['codestral-latest'] + ELSE ai_models +END +WHERE ai_resource->>'path' IS NOT NULL; + +UPDATE workspace_settings +SET code_completion_model = CASE + WHEN ai_resource->>'provider' = 'openai' THEN 'gpt-4o' + WHEN ai_resource->>'provider' = 'anthropic' THEN 'claude-3-5-sonnet-latest' + WHEN ai_resource->>'provider' = 'mistral' THEN 'codestral-latest' + ELSE code_completion_model +END +WHERE code_completion_enabled IS TRUE; + + +ALTER TABLE workspace_settings DROP COLUMN code_completion_enabled; \ No newline at end of file diff --git a/backend/migrations/20250201124344_v2_job_runtime.down.sql b/backend/migrations/20250201124344_v2_job_runtime.down.sql new file mode 100644 index 0000000000..45b34f0f7a --- /dev/null +++ b/backend/migrations/20250201124344_v2_job_runtime.down.sql @@ -0,0 +1,4 @@ +-- Add down migration script here +-- Lock `queue` in access exclusive to prevent deadlocks when dropping the foreign key to `queue`. +LOCK TABLE queue IN ACCESS EXCLUSIVE MODE; +DROP TABLE v2_job_runtime CASCADE; diff --git a/backend/migrations/20250201124344_v2_job_runtime.up.sql b/backend/migrations/20250201124344_v2_job_runtime.up.sql new file mode 100644 index 0000000000..60b3a99384 --- /dev/null +++ b/backend/migrations/20250201124344_v2_job_runtime.up.sql @@ -0,0 +1,14 @@ +-- Add up migration script here +CREATE TABLE IF NOT EXISTS v2_job_runtime ( + id UUID REFERENCES queue (id) ON DELETE CASCADE PRIMARY KEY NOT NULL, + -- Metrics fields: + ping TIMESTAMP WITH TIME ZONE DEFAULT now(), + memory_peak INTEGER +); + +CREATE POLICY admin_policy ON v2_job_runtime + AS PERMISSIVE + FOR ALL + TO windmill_admin; + +GRANT ALL ON v2_job_runtime TO windmill_user, windmill_admin; diff --git a/backend/migrations/20250201124345_v2_job_status.down.sql b/backend/migrations/20250201124345_v2_job_status.down.sql new file mode 100644 index 0000000000..fa8e14f3ff --- /dev/null +++ b/backend/migrations/20250201124345_v2_job_status.down.sql @@ -0,0 +1,4 @@ +-- Add down migration script here +-- Lock `queue` in access exclusive to prevent deadlocks when dropping the foreign key to `queue`. +LOCK TABLE queue IN ACCESS EXCLUSIVE MODE; +DROP TABLE v2_job_status CASCADE; diff --git a/backend/migrations/20250201124345_v2_job_status.up.sql b/backend/migrations/20250201124345_v2_job_status.up.sql new file mode 100644 index 0000000000..c43ab1f78a --- /dev/null +++ b/backend/migrations/20250201124345_v2_job_status.up.sql @@ -0,0 +1,16 @@ +-- Add up migration script here +CREATE TABLE IF NOT EXISTS v2_job_status ( + id UUID REFERENCES queue (id) ON DELETE CASCADE PRIMARY KEY NOT NULL, + -- Flow status fields: + flow_status JSONB, + flow_leaf_jobs JSONB, + -- Workflow as code fields: + workflow_as_code_status JSONB +); + +CREATE POLICY admin_policy ON v2_job_status + AS PERMISSIVE + FOR ALL + TO windmill_admin; + +GRANT ALL ON v2_job_status TO windmill_user, windmill_admin; diff --git a/backend/migrations/20250201124409_v2_job_queue_compatiblity_view.down.sql b/backend/migrations/20250201124409_v2_job_queue_compatiblity_view.down.sql new file mode 100644 index 0000000000..43f51a18ce --- /dev/null +++ b/backend/migrations/20250201124409_v2_job_queue_compatiblity_view.down.sql @@ -0,0 +1,3 @@ +-- Add down migration script here +DROP VIEW queue; +ALTER TABLE v2_job_queue RENAME TO queue; diff --git a/backend/migrations/20250201124409_v2_job_queue_compatiblity_view.up.sql b/backend/migrations/20250201124409_v2_job_queue_compatiblity_view.up.sql new file mode 100644 index 0000000000..6a4f1b9c74 --- /dev/null +++ b/backend/migrations/20250201124409_v2_job_queue_compatiblity_view.up.sql @@ -0,0 +1,48 @@ +-- Add down migration script here +ALTER TABLE queue RENAME TO v2_job_queue; +CREATE OR REPLACE VIEW queue AS ( + SELECT + id, + workspace_id, + parent_job AS parent_job, + created_by AS created_by, + created_at, + started_at, + scheduled_for, + running, + script_hash AS script_hash, + script_path AS script_path, + args AS args, + logs AS logs, + raw_code AS raw_code, + canceled AS canceled, + canceled_by, + canceled_reason, + last_ping AS last_ping, + job_kind AS job_kind, + env_id AS env_id, + schedule_path AS schedule_path, + permissioned_as AS permissioned_as, + flow_status AS flow_status, + raw_flow AS raw_flow, + is_flow_step AS is_flow_step, + language AS language, + suspend, + suspend_until, + same_worker AS same_worker, + raw_lock AS raw_lock, + pre_run_error AS pre_run_error, + email AS email, + visible_to_owner AS visible_to_owner, + mem_peak AS mem_peak, + root_job AS root_job, + leaf_jobs AS leaf_jobs, + tag, + concurrent_limit AS concurrent_limit, + concurrency_time_window_s AS concurrency_time_window_s, + timeout AS timeout, + flow_step_id AS flow_step_id, + cache_ttl AS cache_ttl, + priority + FROM v2_job_queue +); diff --git a/backend/migrations/20250201124410_v2_job_queue.down.sql b/backend/migrations/20250201124410_v2_job_queue.down.sql new file mode 100644 index 0000000000..7da7e1fa51 --- /dev/null +++ b/backend/migrations/20250201124410_v2_job_queue.down.sql @@ -0,0 +1,34 @@ +-- Add down migration script here +ALTER TABLE v2_job_queue + DROP COLUMN worker CASCADE, + DROP COLUMN extras CASCADE; +ALTER TABLE v2_job_queue RENAME COLUMN __parent_job TO parent_job; +ALTER TABLE v2_job_queue RENAME COLUMN __created_by TO created_by; +ALTER TABLE v2_job_queue RENAME COLUMN __script_hash TO script_hash; +ALTER TABLE v2_job_queue RENAME COLUMN __script_path TO script_path; +ALTER TABLE v2_job_queue RENAME COLUMN __args TO args; +ALTER TABLE v2_job_queue RENAME COLUMN __logs TO logs; +ALTER TABLE v2_job_queue RENAME COLUMN __raw_code TO raw_code; +ALTER TABLE v2_job_queue RENAME COLUMN __canceled TO canceled; +ALTER TABLE v2_job_queue RENAME COLUMN __last_ping TO last_ping; +ALTER TABLE v2_job_queue RENAME COLUMN __job_kind TO job_kind; +ALTER TABLE v2_job_queue RENAME COLUMN __env_id TO env_id; +ALTER TABLE v2_job_queue RENAME COLUMN __schedule_path TO schedule_path; +ALTER TABLE v2_job_queue RENAME COLUMN __permissioned_as TO permissioned_as; +ALTER TABLE v2_job_queue RENAME COLUMN __flow_status TO flow_status; +ALTER TABLE v2_job_queue RENAME COLUMN __raw_flow TO raw_flow; +ALTER TABLE v2_job_queue RENAME COLUMN __is_flow_step TO is_flow_step; +ALTER TABLE v2_job_queue RENAME COLUMN __language TO language; +ALTER TABLE v2_job_queue RENAME COLUMN __same_worker TO same_worker; +ALTER TABLE v2_job_queue RENAME COLUMN __raw_lock TO raw_lock; +ALTER TABLE v2_job_queue RENAME COLUMN __pre_run_error TO pre_run_error; +ALTER TABLE v2_job_queue RENAME COLUMN __email TO email; +ALTER TABLE v2_job_queue RENAME COLUMN __visible_to_owner TO visible_to_owner; +ALTER TABLE v2_job_queue RENAME COLUMN __mem_peak TO mem_peak; +ALTER TABLE v2_job_queue RENAME COLUMN __root_job TO root_job; +ALTER TABLE v2_job_queue RENAME COLUMN __leaf_jobs TO leaf_jobs; +ALTER TABLE v2_job_queue RENAME COLUMN __concurrent_limit TO concurrent_limit; +ALTER TABLE v2_job_queue RENAME COLUMN __concurrency_time_window_s TO concurrency_time_window_s; +ALTER TABLE v2_job_queue RENAME COLUMN __timeout TO timeout; +ALTER TABLE v2_job_queue RENAME COLUMN __flow_step_id TO flow_step_id; +ALTER TABLE v2_job_queue RENAME COLUMN __cache_ttl TO cache_ttl; diff --git a/backend/migrations/20250201124410_v2_job_queue.up.sql b/backend/migrations/20250201124410_v2_job_queue.up.sql new file mode 100644 index 0000000000..dfd0611fca --- /dev/null +++ b/backend/migrations/20250201124410_v2_job_queue.up.sql @@ -0,0 +1,34 @@ +-- Add up migration script here +ALTER TABLE v2_job_queue + ADD COLUMN IF NOT EXISTS worker VARCHAR(255), + ADD COLUMN IF NOT EXISTS extras JSONB; +ALTER TABLE v2_job_queue RENAME COLUMN parent_job TO __parent_job; +ALTER TABLE v2_job_queue RENAME COLUMN created_by TO __created_by; +ALTER TABLE v2_job_queue RENAME COLUMN script_hash TO __script_hash; +ALTER TABLE v2_job_queue RENAME COLUMN script_path TO __script_path; +ALTER TABLE v2_job_queue RENAME COLUMN args TO __args; +ALTER TABLE v2_job_queue RENAME COLUMN logs TO __logs; +ALTER TABLE v2_job_queue RENAME COLUMN raw_code TO __raw_code; +ALTER TABLE v2_job_queue RENAME COLUMN canceled TO __canceled; +ALTER TABLE v2_job_queue RENAME COLUMN last_ping TO __last_ping; +ALTER TABLE v2_job_queue RENAME COLUMN job_kind TO __job_kind; +ALTER TABLE v2_job_queue RENAME COLUMN env_id TO __env_id; +ALTER TABLE v2_job_queue RENAME COLUMN schedule_path TO __schedule_path; +ALTER TABLE v2_job_queue RENAME COLUMN permissioned_as TO __permissioned_as; +ALTER TABLE v2_job_queue RENAME COLUMN flow_status TO __flow_status; +ALTER TABLE v2_job_queue RENAME COLUMN raw_flow TO __raw_flow; +ALTER TABLE v2_job_queue RENAME COLUMN is_flow_step TO __is_flow_step; +ALTER TABLE v2_job_queue RENAME COLUMN language TO __language; +ALTER TABLE v2_job_queue RENAME COLUMN same_worker TO __same_worker; +ALTER TABLE v2_job_queue RENAME COLUMN raw_lock TO __raw_lock; +ALTER TABLE v2_job_queue RENAME COLUMN pre_run_error TO __pre_run_error; +ALTER TABLE v2_job_queue RENAME COLUMN email TO __email; +ALTER TABLE v2_job_queue RENAME COLUMN visible_to_owner TO __visible_to_owner; +ALTER TABLE v2_job_queue RENAME COLUMN mem_peak TO __mem_peak; +ALTER TABLE v2_job_queue RENAME COLUMN root_job TO __root_job; +ALTER TABLE v2_job_queue RENAME COLUMN leaf_jobs TO __leaf_jobs; +ALTER TABLE v2_job_queue RENAME COLUMN concurrent_limit TO __concurrent_limit; +ALTER TABLE v2_job_queue RENAME COLUMN concurrency_time_window_s TO __concurrency_time_window_s; +ALTER TABLE v2_job_queue RENAME COLUMN timeout TO __timeout; +ALTER TABLE v2_job_queue RENAME COLUMN flow_step_id TO __flow_step_id; +ALTER TABLE v2_job_queue RENAME COLUMN cache_ttl TO __cache_ttl; diff --git a/backend/migrations/20250201124422_v2_job_completed_compatibility_view.down.sql b/backend/migrations/20250201124422_v2_job_completed_compatibility_view.down.sql new file mode 100644 index 0000000000..5eb87e01e0 --- /dev/null +++ b/backend/migrations/20250201124422_v2_job_completed_compatibility_view.down.sql @@ -0,0 +1,3 @@ +-- Add down migration script here +DROP VIEW IF EXISTS completed_job; +ALTER TABLE IF EXISTS v2_job_completed RENAME TO completed_job; diff --git a/backend/migrations/20250201124422_v2_job_completed_compatibility_view.up.sql b/backend/migrations/20250201124422_v2_job_completed_compatibility_view.up.sql new file mode 100644 index 0000000000..7519a1c585 --- /dev/null +++ b/backend/migrations/20250201124422_v2_job_completed_compatibility_view.up.sql @@ -0,0 +1,39 @@ +-- Add down migration script here +ALTER TABLE completed_job RENAME TO v2_job_completed; +CREATE OR REPLACE VIEW completed_job AS ( + SELECT + id, + workspace_id, + parent_job AS parent_job, + created_by AS created_by, + created_at AS created_at, + duration_ms, + success AS success, + script_hash AS script_hash, + script_path AS script_path, + args AS args, + result, + logs AS logs, + deleted, + raw_code AS raw_code, + canceled AS canceled, + canceled_by, + canceled_reason, + job_kind AS job_kind, + env_id AS env_id, + schedule_path AS schedule_path, + permissioned_as AS permissioned_as, + flow_status, + raw_flow AS raw_flow, + is_flow_step AS is_flow_step, + language AS language, + started_at, + is_skipped AS is_skipped, + raw_lock AS raw_lock, + email AS email, + visible_to_owner AS visible_to_owner, + mem_peak AS mem_peak, + tag AS tag, + priority AS priority + FROM v2_job_completed +); diff --git a/backend/migrations/20250201124423_v2_job_completed.down.sql b/backend/migrations/20250201124423_v2_job_completed.down.sql new file mode 100644 index 0000000000..02391a6152 --- /dev/null +++ b/backend/migrations/20250201124423_v2_job_completed.down.sql @@ -0,0 +1,34 @@ +-- Add down migration script here +ALTER TABLE v2_job_completed + DROP COLUMN status CASCADE, + DROP COLUMN completed_at CASCADE, + DROP COLUMN worker CASCADE, + DROP COLUMN workflow_as_code_status CASCADE, + DROP COLUMN result_columns CASCADE, + DROP COLUMN retries CASCADE, + DROP COLUMN extras CASCADE; +ALTER TABLE v2_job_completed RENAME COLUMN memory_peak TO mem_peak; +ALTER TABLE v2_job_completed RENAME COLUMN __parent_job TO parent_job; +ALTER TABLE v2_job_completed RENAME COLUMN __created_by TO created_by; +ALTER TABLE v2_job_completed RENAME COLUMN __created_at TO created_at; +ALTER TABLE v2_job_completed RENAME COLUMN __success TO success; +ALTER TABLE v2_job_completed RENAME COLUMN __script_hash TO script_hash; +ALTER TABLE v2_job_completed RENAME COLUMN __script_path TO script_path; +ALTER TABLE v2_job_completed RENAME COLUMN __args TO args; +ALTER TABLE v2_job_completed RENAME COLUMN __logs TO logs; +ALTER TABLE v2_job_completed RENAME COLUMN __raw_code TO raw_code; +ALTER TABLE v2_job_completed RENAME COLUMN __canceled TO canceled; +ALTER TABLE v2_job_completed RENAME COLUMN __job_kind TO job_kind; +ALTER TABLE v2_job_completed RENAME COLUMN __env_id TO env_id; +ALTER TABLE v2_job_completed RENAME COLUMN __schedule_path TO schedule_path; +ALTER TABLE v2_job_completed RENAME COLUMN __permissioned_as TO permissioned_as; +ALTER TABLE v2_job_completed RENAME COLUMN __raw_flow TO raw_flow; +ALTER TABLE v2_job_completed RENAME COLUMN __is_flow_step TO is_flow_step; +ALTER TABLE v2_job_completed RENAME COLUMN __language TO language; +ALTER TABLE v2_job_completed RENAME COLUMN __is_skipped TO is_skipped; +ALTER TABLE v2_job_completed RENAME COLUMN __raw_lock TO raw_lock; +ALTER TABLE v2_job_completed RENAME COLUMN __email TO email; +ALTER TABLE v2_job_completed RENAME COLUMN __visible_to_owner TO visible_to_owner; +ALTER TABLE v2_job_completed RENAME COLUMN __tag TO tag; +ALTER TABLE v2_job_completed RENAME COLUMN __priority TO priority; +DROP TYPE IF EXISTS job_status CASCADE; diff --git a/backend/migrations/20250201124423_v2_job_completed.up.sql b/backend/migrations/20250201124423_v2_job_completed.up.sql new file mode 100644 index 0000000000..1aebff0b58 --- /dev/null +++ b/backend/migrations/20250201124423_v2_job_completed.up.sql @@ -0,0 +1,34 @@ +-- Add up migration script here +CREATE TYPE job_status AS ENUM ('success', 'failure', 'canceled', 'skipped'); +ALTER TABLE v2_job_completed + ADD COLUMN IF NOT EXISTS status job_status, + ADD COLUMN IF NOT EXISTS completed_at TIMESTAMP WITH TIME ZONE, + ADD COLUMN IF NOT EXISTS worker VARCHAR(255), + ADD COLUMN IF NOT EXISTS workflow_as_code_status JSONB, + ADD COLUMN IF NOT EXISTS result_columns TEXT[], + ADD COLUMN IF NOT EXISTS retries UUID[], + ADD COLUMN IF NOT EXISTS extras JSONB; +ALTER TABLE v2_job_completed RENAME COLUMN mem_peak TO memory_peak; +ALTER TABLE v2_job_completed RENAME COLUMN parent_job TO __parent_job; +ALTER TABLE v2_job_completed RENAME COLUMN created_by TO __created_by; +ALTER TABLE v2_job_completed RENAME COLUMN created_at TO __created_at; +ALTER TABLE v2_job_completed RENAME COLUMN success TO __success; +ALTER TABLE v2_job_completed RENAME COLUMN script_hash TO __script_hash; +ALTER TABLE v2_job_completed RENAME COLUMN script_path TO __script_path; +ALTER TABLE v2_job_completed RENAME COLUMN args TO __args; +ALTER TABLE v2_job_completed RENAME COLUMN logs TO __logs; +ALTER TABLE v2_job_completed RENAME COLUMN raw_code TO __raw_code; +ALTER TABLE v2_job_completed RENAME COLUMN canceled TO __canceled; +ALTER TABLE v2_job_completed RENAME COLUMN job_kind TO __job_kind; +ALTER TABLE v2_job_completed RENAME COLUMN env_id TO __env_id; +ALTER TABLE v2_job_completed RENAME COLUMN schedule_path TO __schedule_path; +ALTER TABLE v2_job_completed RENAME COLUMN permissioned_as TO __permissioned_as; +ALTER TABLE v2_job_completed RENAME COLUMN raw_flow TO __raw_flow; +ALTER TABLE v2_job_completed RENAME COLUMN is_flow_step TO __is_flow_step; +ALTER TABLE v2_job_completed RENAME COLUMN language TO __language; +ALTER TABLE v2_job_completed RENAME COLUMN is_skipped TO __is_skipped; +ALTER TABLE v2_job_completed RENAME COLUMN raw_lock TO __raw_lock; +ALTER TABLE v2_job_completed RENAME COLUMN email TO __email; +ALTER TABLE v2_job_completed RENAME COLUMN visible_to_owner TO __visible_to_owner; +ALTER TABLE v2_job_completed RENAME COLUMN tag TO __tag; +ALTER TABLE v2_job_completed RENAME COLUMN priority TO __priority; diff --git a/backend/migrations/20250201124430_v2_job_compatibility_view.down.sql b/backend/migrations/20250201124430_v2_job_compatibility_view.down.sql new file mode 100644 index 0000000000..45dd1e24a3 --- /dev/null +++ b/backend/migrations/20250201124430_v2_job_compatibility_view.down.sql @@ -0,0 +1,3 @@ +-- Add down migration script here +DROP VIEW IF EXISTS job; +ALTER TABLE IF EXISTS v2_job RENAME TO job; diff --git a/backend/migrations/20250201124430_v2_job_compatibility_view.up.sql b/backend/migrations/20250201124430_v2_job_compatibility_view.up.sql new file mode 100644 index 0000000000..246d46e2b6 --- /dev/null +++ b/backend/migrations/20250201124430_v2_job_compatibility_view.up.sql @@ -0,0 +1,6 @@ +-- Add down migration script here +ALTER TABLE job RENAME TO v2_job; +CREATE OR REPLACE VIEW job AS ( + SELECT id, raw_code, raw_lock, raw_flow, tag, workspace_id + FROM v2_job +); diff --git a/backend/migrations/20250201124431_v2_job.down.sql b/backend/migrations/20250201124431_v2_job.down.sql new file mode 100644 index 0000000000..663ecb106b --- /dev/null +++ b/backend/migrations/20250201124431_v2_job.down.sql @@ -0,0 +1,36 @@ +-- Add down migration script here +DROP POLICY see_folder_extra_perms_user ON v2_job; +DROP POLICY see_own_path ON v2_job; +DROP POLICY see_member_path ON v2_job; +DROP POLICY see_own ON v2_job; +DROP POLICY see_member ON v2_job; +DROP POLICY admin_policy ON v2_job; +ALTER TABLE v2_job + DROP COLUMN created_at CASCADE, + DROP COLUMN created_by CASCADE, + DROP COLUMN permissioned_as CASCADE, + DROP COLUMN permissioned_as_email CASCADE, + DROP COLUMN kind CASCADE, + DROP COLUMN runnable_id CASCADE, + DROP COLUMN runnable_path CASCADE, + DROP COLUMN parent_job CASCADE, + DROP COLUMN root_job CASCADE, + DROP COLUMN script_lang CASCADE, + DROP COLUMN script_entrypoint_override CASCADE, + DROP COLUMN flow_step CASCADE, + DROP COLUMN flow_step_id CASCADE, + DROP COLUMN flow_innermost_root_job CASCADE, + DROP COLUMN trigger CASCADE, + DROP COLUMN trigger_kind CASCADE, + DROP COLUMN same_worker CASCADE, + DROP COLUMN visible_to_owner CASCADE, + DROP COLUMN concurrent_limit CASCADE, + DROP COLUMN concurrency_time_window_s CASCADE, + DROP COLUMN cache_ttl CASCADE, + DROP COLUMN timeout CASCADE, + DROP COLUMN priority CASCADE, + DROP COLUMN preprocessed CASCADE, + DROP COLUMN args CASCADE, + DROP COLUMN labels CASCADE, + DROP COLUMN pre_run_error CASCADE; +DROP TYPE job_trigger_kind; diff --git a/backend/migrations/20250201124431_v2_job.up.sql b/backend/migrations/20250201124431_v2_job.up.sql new file mode 100644 index 0000000000..ab5f0769d6 --- /dev/null +++ b/backend/migrations/20250201124431_v2_job.up.sql @@ -0,0 +1,78 @@ +-- Add up migration script here +CREATE TYPE job_trigger_kind AS ENUM ( + 'webhook', 'http', 'websocket', 'kafka', 'email', 'nats', 'schedule', 'app', 'ui', 'postgres' +); + +ALTER TABLE v2_job + ADD COLUMN IF NOT EXISTS created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL, + ADD COLUMN IF NOT EXISTS created_by VARCHAR(255) DEFAULT 'missing' NOT NULL, + ADD COLUMN IF NOT EXISTS permissioned_as VARCHAR(55) DEFAULT 'g/all' NOT NULL, + ADD COLUMN IF NOT EXISTS permissioned_as_email VARCHAR(255) DEFAULT 'missing@email.xyz' NOT NULL, + ADD COLUMN IF NOT EXISTS kind job_kind DEFAULT 'script'::job_kind NOT NULL, + ADD COLUMN IF NOT EXISTS runnable_id BIGINT, + ADD COLUMN IF NOT EXISTS runnable_path VARCHAR(255), + ADD COLUMN IF NOT EXISTS parent_job UUID, + ADD COLUMN IF NOT EXISTS root_job UUID, + ADD COLUMN IF NOT EXISTS script_lang script_lang DEFAULT 'python3'::script_lang, + ADD COLUMN IF NOT EXISTS script_entrypoint_override VARCHAR(255), + ADD COLUMN IF NOT EXISTS flow_step INTEGER, + ADD COLUMN IF NOT EXISTS flow_step_id VARCHAR(255), + ADD COLUMN IF NOT EXISTS flow_innermost_root_job UUID, + ADD COLUMN IF NOT EXISTS trigger VARCHAR(255), + ADD COLUMN IF NOT EXISTS trigger_kind job_trigger_kind, + ADD COLUMN IF NOT EXISTS same_worker BOOLEAN DEFAULT FALSE NOT NULL, + ADD COLUMN IF NOT EXISTS visible_to_owner BOOLEAN DEFAULT TRUE NOT NULL, + ADD COLUMN IF NOT EXISTS concurrent_limit INTEGER, + ADD COLUMN IF NOT EXISTS concurrency_time_window_s INTEGER, + ADD COLUMN IF NOT EXISTS cache_ttl INTEGER, + ADD COLUMN IF NOT EXISTS timeout INTEGER, + ADD COLUMN IF NOT EXISTS priority SMALLINT, + ADD COLUMN IF NOT EXISTS preprocessed BOOLEAN, + ADD COLUMN IF NOT EXISTS args JSONB, + ADD COLUMN IF NOT EXISTS labels TEXT[], + ADD COLUMN IF NOT EXISTS pre_run_error TEXT; + +CREATE POLICY see_folder_extra_perms_user ON v2_job + AS PERMISSIVE + FOR ALL + TO windmill_user + USING ((visible_to_owner IS TRUE) AND (SPLIT_PART((runnable_path)::TEXT, '/'::TEXT, 1) = 'f'::TEXT) AND + (SPLIT_PART((runnable_path)::TEXT, '/'::TEXT, 2) = ANY ( + REGEXP_SPLIT_TO_ARRAY(CURRENT_SETTING('session.folders_read'::TEXT), ','::TEXT)))); + +CREATE POLICY see_own_path ON v2_job + AS PERMISSIVE + FOR ALL + TO windmill_user + USING ((visible_to_owner IS TRUE) AND (SPLIT_PART((runnable_path)::TEXT, '/'::TEXT, 1) = 'u'::TEXT) AND + (SPLIT_PART((runnable_path)::TEXT, '/'::TEXT, 2) = CURRENT_SETTING('session.user'::TEXT))); + +CREATE POLICY see_member_path ON v2_job + AS PERMISSIVE + FOR ALL + TO windmill_user + USING ((visible_to_owner IS TRUE) AND (SPLIT_PART((runnable_path)::TEXT, '/'::TEXT, 1) = 'g'::TEXT) AND + (SPLIT_PART((runnable_path)::TEXT, '/'::TEXT, 2) = ANY + (REGEXP_SPLIT_TO_ARRAY(CURRENT_SETTING('session.groups'::TEXT), ','::TEXT)))); + +CREATE POLICY see_own ON v2_job + AS PERMISSIVE + FOR ALL + TO windmill_user + USING ((SPLIT_PART((permissioned_as)::TEXT, '/'::TEXT, 1) = 'f'::TEXT) AND + (SPLIT_PART((permissioned_as)::TEXT, '/'::TEXT, 2) = CURRENT_SETTING('session.user'::TEXT))); + +CREATE POLICY see_member ON v2_job + AS PERMISSIVE + FOR ALL + TO windmill_user + USING ((SPLIT_PART((permissioned_as)::TEXT, '/'::TEXT, 1) = 'g'::TEXT) AND + (SPLIT_PART((permissioned_as)::TEXT, '/'::TEXT, 2) = ANY + (REGEXP_SPLIT_TO_ARRAY(CURRENT_SETTING('session.groups'::TEXT), ','::TEXT)))); + +CREATE POLICY admin_policy ON v2_job + AS PERMISSIVE + FOR ALL + TO windmill_admin; + +GRANT ALL ON v2_job TO windmill_user, windmill_admin; diff --git a/backend/migrations/20250201124743_v2_job_queue_sync.down.sql b/backend/migrations/20250201124743_v2_job_queue_sync.down.sql new file mode 100644 index 0000000000..b64ab629bf --- /dev/null +++ b/backend/migrations/20250201124743_v2_job_queue_sync.down.sql @@ -0,0 +1,4 @@ +-- Add down migration script here +DROP FUNCTION v2_job_queue_before_insert() CASCADE; +DROP FUNCTION v2_job_queue_after_insert() CASCADE; +DROP FUNCTION v2_job_queue_before_update() CASCADE; diff --git a/backend/migrations/20250201124743_v2_job_queue_sync.up.sql b/backend/migrations/20250201124743_v2_job_queue_sync.up.sql new file mode 100644 index 0000000000..2ac8a37ca2 --- /dev/null +++ b/backend/migrations/20250201124743_v2_job_queue_sync.up.sql @@ -0,0 +1,220 @@ +-- Add up migration script here +-- This trigger will be removed once all server(s)/worker(s) are updated to use `v2_*` tables +CREATE OR REPLACE FUNCTION v2_job_queue_before_insert() RETURNS TRIGGER AS $$ +DECLARE job v2_job; +BEGIN + IF NEW.__created_by IS NOT NULL THEN + -- v1 -> v2 + IF NEW.__logs IS NOT NULL THEN + INSERT INTO job_logs (job_id, workspace_id, logs) + VALUES (NEW.id, NEW.workspace_id, NEW.__logs) + ON CONFLICT (job_id) DO UPDATE SET + logs = CONCAT(job_logs.logs, EXCLUDED.logs) + ; + -- Need to be "before" to remove logs: + NEW.__logs := NULL; + END IF; + RETURN NEW; + END IF; + -- v2 -> v1 + -- When inserting to `v2_job_queue` from `v2` code, set `v1` columns: + SELECT * INTO job FROM v2_job WHERE id = NEW.id; + NEW.__parent_job := job.parent_job; + NEW.__created_by := job.created_by; + NEW.__script_hash := job.runnable_id; + NEW.__script_path := job.runnable_path; + NEW.__args := job.args; + -- __logs + NEW.__raw_code := job.raw_code; + NEW.__canceled := NEW.canceled_by IS NOT NULL; + -- __last_ping + NEW.__job_kind := job.kind; + NEW.__env_id := 123456789; -- Magic used bellow. + NEW.__schedule_path := CASE WHEN job.trigger_kind = 'schedule'::job_trigger_kind THEN job.trigger END; + NEW.__permissioned_as := job.permissioned_as; + -- __flow_status + NEW.__raw_flow := job.raw_flow; + NEW.__is_flow_step := job.flow_step_id IS NOT NULL; + NEW.__language := job.script_lang; + NEW.__same_worker := job.same_worker; + NEW.__raw_lock := job.raw_lock; + NEW.__pre_run_error := job.pre_run_error; + NEW.__email := job.permissioned_as_email; + NEW.__visible_to_owner := job.visible_to_owner; + -- __mem_peak + NEW.__root_job := job.flow_innermost_root_job; + -- __leaf_jobs + NEW.__concurrent_limit := job.concurrent_limit; + NEW.__concurrency_time_window_s := job.concurrency_time_window_s; + NEW.__timeout := job.timeout; + NEW.__flow_step_id := job.flow_step_id; + NEW.__cache_ttl := job.cache_ttl; + IF job.script_entrypoint_override IS NOT NULL THEN + NEW.__args = jsonb_set( + coalesce(NEW.__args, '{}'::JSONB), + '{_ENTRYPOINT_OVERRIDE}', + to_jsonb(job.script_entrypoint_override) + ); + END IF; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE TRIGGER v2_job_queue_before_insert_trigger + BEFORE INSERT ON v2_job_queue + FOR EACH ROW + WHEN (pg_trigger_depth() < 1) -- Prevent infinite loop v1 <-> v2 +EXECUTE FUNCTION v2_job_queue_before_insert(); + +-- v1 -> v2 +-- On every insert to `v2_job_queue`, insert to `v2_job`, `v2_job_runtime` and `v2_job_status` as well +-- This trigger will be removed once all server(s)/worker(s) are updated to use `v2_*` tables +CREATE OR REPLACE FUNCTION v2_job_queue_after_insert() RETURNS TRIGGER AS $$ BEGIN + INSERT INTO v2_job ( + id, workspace_id, created_at, created_by, permissioned_as, permissioned_as_email, + kind, runnable_id, runnable_path, parent_job, + script_lang, script_entrypoint_override, + flow_step, flow_step_id, flow_innermost_root_job, + trigger, trigger_kind, + tag, same_worker, visible_to_owner, concurrent_limit, concurrency_time_window_s, cache_ttl, timeout, priority, + preprocessed, args, pre_run_error, + raw_code, raw_lock, raw_flow + ) VALUES ( + NEW.id, NEW.workspace_id, NEW.created_at, NEW.__created_by, NEW.__permissioned_as, NEW.__email, + NEW.__job_kind, NEW.__script_hash, NEW.__script_path, NEW.__parent_job, + NEW.__language, NULLIF(NEW.__args->>'_ENTRYPOINT_OVERRIDE', '__WM_PREPROCESSOR'), + NULL, NEW.__flow_step_id, NEW.__root_job, + NEW.__schedule_path, CASE WHEN NEW.__schedule_path IS NOT NULL THEN 'schedule'::job_trigger_kind END, + NEW.tag, NEW.__same_worker, NEW.__visible_to_owner, NEW.__concurrent_limit, NEW.__concurrency_time_window_s, + NEW.__cache_ttl, NEW.__timeout, NEW.priority, + CASE WHEN ( + NEW.__args->>'_ENTRYPOINT_OVERRIDE' IN ('__WM_PREPROCESSOR', 'preprocessor') + OR NEW.__flow_status->'preprocessor_module' IS NOT NULL + ) THEN FALSE END, NEW.__args, NEW.__pre_run_error, + NEW.__raw_code, NEW.__raw_lock, NEW.__raw_flow + ) ON CONFLICT (id) DO UPDATE SET + workspace_id = EXCLUDED.workspace_id, + created_at = EXCLUDED.created_at, + created_by = EXCLUDED.created_by, + permissioned_as = EXCLUDED.permissioned_as, + permissioned_as_email = EXCLUDED.permissioned_as_email, + kind = EXCLUDED.kind, + runnable_id = EXCLUDED.runnable_id, + runnable_path = EXCLUDED.runnable_path, + parent_job = EXCLUDED.parent_job, + script_lang = EXCLUDED.script_lang, + script_entrypoint_override = EXCLUDED.script_entrypoint_override, + flow_step = EXCLUDED.flow_step, + flow_step_id = EXCLUDED.flow_step_id, + flow_innermost_root_job = EXCLUDED.flow_innermost_root_job, + trigger = EXCLUDED.trigger, + trigger_kind = EXCLUDED.trigger_kind, + tag = EXCLUDED.tag, + same_worker = EXCLUDED.same_worker, + visible_to_owner = EXCLUDED.visible_to_owner, + concurrent_limit = EXCLUDED.concurrent_limit, + concurrency_time_window_s = EXCLUDED.concurrency_time_window_s, + cache_ttl = EXCLUDED.cache_ttl, + timeout = EXCLUDED.timeout, + priority = EXCLUDED.priority, + preprocessed = EXCLUDED.preprocessed, + args = EXCLUDED.args, + pre_run_error = EXCLUDED.pre_run_error, + raw_code = COALESCE(v2_job.raw_code, EXCLUDED.raw_code), + raw_lock = COALESCE(v2_job.raw_lock, EXCLUDED.raw_lock), + raw_flow = COALESCE(v2_job.raw_flow, EXCLUDED.raw_flow) + ; + INSERT INTO v2_job_runtime (id, ping, memory_peak) + VALUES (NEW.id, NEW.__last_ping, NEW.__mem_peak) + ON CONFLICT (id) DO UPDATE SET + ping = COALESCE(v2_job_runtime.ping, EXCLUDED.ping), + memory_peak = COALESCE(v2_job_runtime.memory_peak, EXCLUDED.memory_peak) + ; + IF NEW.__flow_status IS NOT NULL OR NEW.__leaf_jobs IS NOT NULL THEN + INSERT INTO v2_job_status (id, flow_status, flow_leaf_jobs) + VALUES (NEW.id, NEW.__flow_status, NEW.__leaf_jobs) + ON CONFLICT (id) DO UPDATE SET + flow_status = COALESCE(v2_job_status.flow_status, EXCLUDED.flow_status), + flow_leaf_jobs = COALESCE(v2_job_status.flow_leaf_jobs, EXCLUDED.flow_leaf_jobs) + ; + END IF; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE TRIGGER v2_job_queue_after_insert_trigger + AFTER INSERT ON v2_job_queue + FOR EACH ROW + -- Prevent infinite loop v1 <-> v2 + WHEN (pg_trigger_depth() < 1 AND NEW.__created_by IS NOT NULL AND NEW.__env_id IS DISTINCT FROM 123456789) +EXECUTE FUNCTION v2_job_queue_after_insert(); + +-- On every update to `v2_job_queue`, update `v2_job`, `v2_job_runtime` and `v2_job_status` as well +-- This trigger will be removed once all server(s)/worker(s) are updated to use `v2_*` tables +CREATE OR REPLACE FUNCTION v2_job_queue_before_update() RETURNS TRIGGER AS $$ BEGIN + IF NEW.canceled_by IS NOT NULL THEN + NEW.__canceled := TRUE; + END IF; + -- `v2_job`: Only `args` are updated + IF NEW.__args::TEXT IS DISTINCT FROM OLD.__args::TEXT THEN + UPDATE v2_job SET + args = NEW.__args, + preprocessed = CASE WHEN preprocessed = FALSE THEN TRUE ELSE preprocessed END + WHERE id = NEW.id; + END IF; + -- `v2_job_runtime`: + IF NEW.__last_ping IS DISTINCT FROM OLD.__last_ping OR NEW.__mem_peak IS DISTINCT FROM OLD.__mem_peak THEN + INSERT INTO v2_job_runtime (id, ping, memory_peak) + VALUES (NEW.id, NEW.__last_ping, NEW.__mem_peak) + ON CONFLICT (id) DO UPDATE SET + ping = EXCLUDED.ping, + memory_peak = EXCLUDED.memory_peak + ; + END IF; + -- `v2_job_status`: + IF NEW.__flow_status::TEXT IS DISTINCT FROM OLD.__flow_status::TEXT OR + NEW.__leaf_jobs::TEXT IS DISTINCT FROM OLD.__leaf_jobs::TEXT THEN + IF NEW.__is_flow_step = false AND NEW.__parent_job IS NOT NULL THEN + -- `workflow_as_code`: + INSERT INTO v2_job_status (id, workflow_as_code_status) + VALUES (NEW.id, NEW.__flow_status) + ON CONFLICT (id) DO UPDATE SET + workflow_as_code_status = EXCLUDED.workflow_as_code_status + ; + ELSE + INSERT INTO v2_job_status (id, flow_status, flow_leaf_jobs) + VALUES (NEW.id, NEW.__flow_status, NEW.__leaf_jobs) + ON CONFLICT (id) DO UPDATE SET + flow_status = EXCLUDED.flow_status, + flow_leaf_jobs = EXCLUDED.flow_leaf_jobs + ; + END IF; + END IF; + -- `job_logs`: + IF NEW.__logs IS DISTINCT FROM OLD.__logs THEN + INSERT INTO job_logs (job_id, workspace_id, logs) + VALUES (NEW.id, NEW.workspace_id, NEW.__logs) + ON CONFLICT (job_id) DO UPDATE SET + logs = CONCAT(job_logs.logs, EXCLUDED.logs) + ; + NEW.__logs := NULL; + END IF; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE TRIGGER v2_job_queue_before_update_trigger + BEFORE UPDATE ON v2_job_queue + FOR EACH ROW + WHEN (pg_trigger_depth() < 1) -- Prevent infinite loop v1 <-> v2 +EXECUTE FUNCTION v2_job_queue_before_update(); + +-- v2 -> v1: update preprocessed args +CREATE OR REPLACE FUNCTION v2_job_after_update() RETURNS TRIGGER AS $$ BEGIN + UPDATE v2_job_queue SET __args = NEW.args WHERE id = NEW.id; + UPDATE v2_job_completed SET __args = NEW.args WHERE id = NEW.id; + RETURN NEW; +END $$ LANGUAGE PLPGSQL; + +CREATE OR REPLACE TRIGGER v2_job_after_update_trigger + AFTER UPDATE ON v2_job + FOR EACH ROW + WHEN (pg_trigger_depth() < 1 AND NEW.args::TEXT IS DISTINCT FROM OLD.args::TEXT) -- Prevent infinite loop v1 <-> v2 +EXECUTE FUNCTION v2_job_after_update(); diff --git a/backend/migrations/20250201124744_v2_job_completed_sync.down.sql b/backend/migrations/20250201124744_v2_job_completed_sync.down.sql new file mode 100644 index 0000000000..4875cd34ff --- /dev/null +++ b/backend/migrations/20250201124744_v2_job_completed_sync.down.sql @@ -0,0 +1,3 @@ +-- Add down migration script here +DROP FUNCTION v2_job_completed_before_insert() CASCADE; +DROP FUNCTION v2_job_completed_before_update() CASCADE; diff --git a/backend/migrations/20250201124744_v2_job_completed_sync.up.sql b/backend/migrations/20250201124744_v2_job_completed_sync.up.sql new file mode 100644 index 0000000000..d1017ca7fd --- /dev/null +++ b/backend/migrations/20250201124744_v2_job_completed_sync.up.sql @@ -0,0 +1,153 @@ +-- Add up migration script here + +-- v1 -> v2 +-- On every insert to `v2_job_completed`, insert to `v2_job` as well +-- This trigger will be removed once all server(s)/worker(s) are updated to use `v2_*` tables +CREATE OR REPLACE FUNCTION v2_job_completed_before_insert() RETURNS TRIGGER AS $$ +DECLARE job v2_job; +DECLARE final_labels TEXT[]; +BEGIN + -- New columns synchronization: + -- 1. `result_columns` <-> `flow_status._metadata.column_order` + -- 2. `v2_job.labels` <-> `result.wm_labels` + -- 3. v2 <-> flow_status._metadata.preprocessed_args` + IF NEW.__created_by IS NULL THEN + -- v2 -> v1 + -- When inserting to `v2_job_completed` from `v2` code, set `v1` columns: + SELECT * INTO job FROM v2_job WHERE id = NEW.id; + NEW.__parent_job := job.parent_job; + NEW.__created_by := job.created_by; + NEW.__created_at := job.created_at; + NEW.__success := NEW.status = 'success'::job_status; + NEW.__script_hash := job.runnable_id; + NEW.__script_path := job.runnable_path; + NEW.__args := job.args; + -- __logs + NEW.__raw_code := job.raw_code; + NEW.__canceled := NEW.status = 'canceled'::job_status; + NEW.__job_kind := job.kind; + -- __env_id + NEW.__schedule_path := CASE WHEN job.trigger_kind = 'schedule'::job_trigger_kind THEN job.trigger END; + NEW.__permissioned_as := job.permissioned_as; + NEW.__raw_flow := job.raw_flow; + NEW.__is_flow_step := job.flow_step_id IS NOT NULL; + NEW.__language := job.script_lang; + NEW.__is_skipped := NEW.status = 'skipped'::job_status; + NEW.__raw_lock := job.raw_lock; + NEW.__email := job.permissioned_as_email; + NEW.__visible_to_owner := job.visible_to_owner; + NEW.__tag := job.tag; + NEW.__priority := job.priority; + -- 1. `result_columns` -> `flow_status._metadata.column_order` + IF NEW.result_columns IS NOT NULL AND (NEW.flow_status IS NULL OR jsonb_typeof(NEW.flow_status) = 'object') THEN + NEW.flow_status := jsonb_set( + coalesce(NEW.flow_status, '{}'::JSONB), + '{_metadata}', + jsonb_set( + coalesce(NEW.flow_status->'_metadata', '{}'::JSONB), + '{column_order}', + to_jsonb(NEW.result_columns) + ) + ); + END IF; + -- 2. `v2_job.labels` -> `result.wm_labels` + IF job.labels IS NOT NULL AND (NEW.result IS NULL OR jsonb_typeof(NEW.result) = 'object') THEN + IF jsonb_typeof(NEW.result->'wm_labels') = 'array' AND ( + SELECT bool_and(jsonb_typeof(elem) = 'string') + FROM jsonb_array_elements(NEW.result->'wm_labels') AS elem + ) THEN + SELECT array_agg(DISTINCT all_labels) INTO final_labels + FROM unnest( + coalesce(job.labels, ARRAY[]::TEXT[]) || translate(NEW.result->>'wm_labels', '[]', '{}')::TEXT[] + ) all_labels; + ELSE + final_labels := job.labels; + END IF; + -- Update `v2_job.labels` if needed + IF job.labels IS DISTINCT FROM final_labels THEN + UPDATE v2_job SET labels = final_labels WHERE id = NEW.id; + END IF; + NEW.result := jsonb_set( + coalesce(NEW.result, '{}'::JSONB), + '{wm_labels}', + to_jsonb(final_labels) + ); + END IF; + -- 3. v2 -> flow_status._metadata.preprocessed_args` + IF job.kind = 'script' AND job.preprocessed = TRUE + AND (NEW.flow_status IS NULL OR jsonb_typeof(NEW.flow_status) = 'object') + THEN + NEW.flow_status := jsonb_set( + coalesce(NEW.flow_status, '{}'::JSONB), + '{_metadata}', + jsonb_set( + coalesce(NEW.flow_status->'_metadata', '{}'::JSONB), + '{preprocessed_args}', + 'true'::JSONB + ) + ); + END IF; + ELSE + -- v1 -> v2 + NEW.completed_at := now(); + NEW.status := CASE + WHEN NEW.__is_skipped THEN 'skipped'::job_status + WHEN NEW.__canceled THEN 'canceled'::job_status + WHEN NEW.__success THEN 'success'::job_status + ELSE 'failure'::job_status + END; + -- 1. `result_columns` <- `flow_status._metadata.column_order` + IF jsonb_typeof(NEW.flow_status->'_metadata'->'column_order') = 'array' AND ( + SELECT bool_and(jsonb_typeof(elem) = 'string') + FROM jsonb_array_elements(NEW.flow_status->'_metadata'->'column_order') AS elem + ) THEN + NEW.result_columns := translate(NEW.flow_status->'_metadata'->>'column_order', '[]', '{}')::TEXT[]; + END IF; + -- 2. `v2_job.labels` <- `result.wm_labels` + IF jsonb_typeof(NEW.result->'wm_labels') = 'array' AND ( + SELECT bool_and(jsonb_typeof(elem) = 'string') + FROM jsonb_array_elements(NEW.result->'wm_labels') AS elem + ) THEN + UPDATE v2_job SET + labels = ( + SELECT array_agg(DISTINCT all_labels) + FROM unnest( + coalesce(labels, ARRAY[]::TEXT[]) + || translate(NEW.result->>'wm_labels', '[]', '{}')::TEXT[] + ) all_labels + ) + WHERE id = NEW.id; + END IF; + -- 3. v2 <- flow_status._metadata.preprocessed_args` + IF NEW.flow_status->'_metadata'->'preprocessed_args' = 'true'::JSONB THEN + UPDATE v2_job SET + args = NEW.__args, + preprocessed = TRUE + WHERE id = NEW.id AND preprocessed = FALSE; + END IF; + END IF; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE TRIGGER v2_job_completed_before_insert_trigger + BEFORE INSERT ON v2_job_completed + FOR EACH ROW + WHEN (pg_trigger_depth() < 1) -- Prevent infinite loop v1 <-> v2 +EXECUTE FUNCTION v2_job_completed_before_insert(); + +CREATE OR REPLACE FUNCTION v2_job_completed_before_update() RETURNS TRIGGER AS $$ BEGIN + -- `v2_job`: Only `args` are updated + IF NEW.__args::TEXT IS DISTINCT FROM OLD.__args::TEXT THEN + UPDATE v2_job SET + args = NEW.__args, + preprocessed = CASE WHEN preprocessed = FALSE THEN TRUE ELSE preprocessed END + WHERE id = NEW.id; + END IF; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE TRIGGER v2_job_completed_before_update_trigger + BEFORE UPDATE ON v2_job_completed + FOR EACH ROW + WHEN (pg_trigger_depth() < 1) -- Prevent infinite loop v1 <-> v2 +EXECUTE FUNCTION v2_job_completed_before_update(); diff --git a/backend/migrations/20250201124748_v2_migrate_from_v1.down.sql b/backend/migrations/20250201124748_v2_migrate_from_v1.down.sql new file mode 100644 index 0000000000..6bc376fc3d --- /dev/null +++ b/backend/migrations/20250201124748_v2_migrate_from_v1.down.sql @@ -0,0 +1,2 @@ +-- Add down migration script here +-- Nothing to do here diff --git a/backend/migrations/20250201124748_v2_migrate_from_v1.up.sql b/backend/migrations/20250201124748_v2_migrate_from_v1.up.sql new file mode 100644 index 0000000000..d3095e0e3d --- /dev/null +++ b/backend/migrations/20250201124748_v2_migrate_from_v1.up.sql @@ -0,0 +1,194 @@ +-- Add up migration script here + +-- Set new columns in `v2_job_completed`: +UPDATE v2_job_completed +SET completed_at = started_at + (interval '1 millisecond' * duration_ms), + status = CASE + WHEN __is_skipped THEN 'skipped'::job_status + WHEN __canceled THEN 'canceled'::job_status + WHEN __success THEN 'success'::job_status + ELSE 'failure'::job_status + END, + result_columns = CASE + WHEN jsonb_typeof(flow_status->'_metadata'->'column_order') = 'array' AND ( + SELECT bool_and(jsonb_typeof(elem) = 'string') + FROM jsonb_array_elements(flow_status->'_metadata'->'column_order') AS elem + ) THEN translate(flow_status->'_metadata'->>'column_order', '[]', '{}')::TEXT[] + END +WHERE status IS NULL; + +-- Insert missing `v2_job` rows from `v2_job_queue`: +INSERT INTO v2_job ( + id, workspace_id, created_at, created_by, permissioned_as, permissioned_as_email, + kind, runnable_id, runnable_path, parent_job, + script_lang, script_entrypoint_override, + flow_step_id, flow_innermost_root_job, + trigger, trigger_kind, + tag, same_worker, visible_to_owner, concurrent_limit, concurrency_time_window_s, cache_ttl, timeout, priority, + preprocessed, args, pre_run_error, + raw_code, raw_lock, raw_flow +) SELECT + id, workspace_id, created_at, __created_by, __permissioned_as, __email, + __job_kind, __script_hash, __script_path, __parent_job, + __language, NULLIF(__args->>'_ENTRYPOINT_OVERRIDE', '__WM_PREPROCESSOR'), + __flow_step_id, __root_job, + __schedule_path, CASE WHEN __schedule_path IS NOT NULL THEN 'schedule'::job_trigger_kind END, + tag, __same_worker, __visible_to_owner, __concurrent_limit, __concurrency_time_window_s, + __cache_ttl, __timeout, priority, + CASE + WHEN __args->>'_ENTRYPOINT_OVERRIDE' IN ('__WM_PREPROCESSOR', 'preprocessor') THEN FALSE + WHEN __flow_status->'preprocessor_module' IS NOT NULL THEN __args->'wm_trigger' IS NULL + END, __args, __pre_run_error, + __raw_code, __raw_lock, __raw_flow +FROM v2_job_queue +WHERE NOT EXISTS (SELECT 1 FROM v2_job WHERE v2_job.id = v2_job_queue.id); + +-- Insert missing `v2_job` rows from `v2_job_completed`: +INSERT INTO v2_job ( + id, workspace_id, created_at, created_by, permissioned_as, permissioned_as_email, + kind, runnable_id, runnable_path, parent_job, + script_lang, script_entrypoint_override, + trigger, trigger_kind, + tag, visible_to_owner, priority, + preprocessed, args, + raw_code, raw_lock, raw_flow, + labels +) SELECT + id, workspace_id, __created_at, __created_by, __permissioned_as, __email, + __job_kind, __script_hash, __script_path, __parent_job, + __language, NULLIF(__args->>'_ENTRYPOINT_OVERRIDE', '__WM_PREPROCESSOR'), + __schedule_path, CASE WHEN __schedule_path IS NOT NULL THEN 'schedule'::job_trigger_kind END, + __tag, __visible_to_owner, __priority, + CASE WHEN v2_job_completed.flow_status->'_metadata'->'preprocessed_args' = 'true'::JSONB THEN TRUE END, __args, + __raw_code, __raw_lock, __raw_flow, + CASE + WHEN jsonb_typeof(result->'wm_labels') = 'array' AND ( + SELECT bool_and(jsonb_typeof(elem) = 'string') + FROM jsonb_array_elements(result->'wm_labels') AS elem + ) THEN ( + SELECT array_agg(DISTINCT all_labels) + FROM unnest( + translate(result->>'wm_labels', '[]', '{}')::TEXT[] + ) all_labels + ) + END +FROM v2_job_completed +WHERE NOT EXISTS (SELECT 1 FROM v2_job WHERE v2_job.id = v2_job_completed.id); + +-- Set existing `v2_job` rows from `v2_job_queue`: +UPDATE v2_job SET + created_at = v2_job_queue.created_at, + created_by = v2_job_queue.__created_by, + permissioned_as = v2_job_queue.__permissioned_as, + permissioned_as_email = v2_job_queue.__email, + kind = v2_job_queue.__job_kind, + runnable_id = v2_job_queue.__script_hash, + runnable_path = v2_job_queue.__script_path, + parent_job = v2_job_queue.__parent_job, + script_lang = v2_job_queue.__language, + script_entrypoint_override = NULLIF(v2_job_queue.__args->>'_ENTRYPOINT_OVERRIDE', '__WM_PREPROCESSOR'), + flow_step_id = v2_job_queue.__flow_step_id, + flow_innermost_root_job = v2_job_queue.__root_job, + trigger = v2_job_queue.__schedule_path, + trigger_kind = CASE WHEN v2_job_queue.__schedule_path IS NOT NULL THEN 'schedule'::job_trigger_kind END, + tag = v2_job_queue.tag, + same_worker = v2_job_queue.__same_worker, + visible_to_owner = v2_job_queue.__visible_to_owner, + concurrent_limit = v2_job_queue.__concurrent_limit, + concurrency_time_window_s = v2_job_queue.__concurrency_time_window_s, + cache_ttl = v2_job_queue.__cache_ttl, + timeout = v2_job_queue.__timeout, + priority = v2_job_queue.priority, + preprocessed = CASE + WHEN __args->>'_ENTRYPOINT_OVERRIDE' IN ('__WM_PREPROCESSOR', 'preprocessor') THEN FALSE + WHEN __flow_status->'preprocessor_module' IS NOT NULL THEN __args->'wm_trigger' IS NULL + END, + args = v2_job_queue.__args, + pre_run_error = v2_job_queue.__pre_run_error, + raw_code = COALESCE(v2_job.raw_code, v2_job_queue.__raw_code), + raw_lock = COALESCE(v2_job.raw_lock, v2_job_queue.__raw_lock), + raw_flow = COALESCE(v2_job.raw_flow, v2_job_queue.__raw_flow) +FROM v2_job_queue +WHERE v2_job.id = v2_job_queue.id AND v2_job.created_by = 'missing'; + +-- Set existing `v2_job` rows from `v2_job_completed`: +UPDATE v2_job SET + created_at = v2_job_completed.__created_at, + created_by = v2_job_completed.__created_by, + permissioned_as = v2_job_completed.__permissioned_as, + permissioned_as_email = v2_job_completed.__email, + kind = v2_job_completed.__job_kind, + runnable_id = v2_job_completed.__script_hash, + runnable_path = v2_job_completed.__script_path, + parent_job = v2_job_completed.__parent_job, + script_lang = v2_job_completed.__language, + script_entrypoint_override = NULLIF(v2_job_completed.__args->>'_ENTRYPOINT_OVERRIDE', '__WM_PREPROCESSOR'), + trigger = v2_job_completed.__schedule_path, + trigger_kind = CASE WHEN v2_job_completed.__schedule_path IS NOT NULL THEN 'schedule'::job_trigger_kind END, + tag = v2_job_completed.__tag, + visible_to_owner = v2_job_completed.__visible_to_owner, + priority = v2_job_completed.__priority, + preprocessed = CASE WHEN v2_job_completed.flow_status->'_metadata'->'preprocessed_args' = 'true'::JSONB THEN TRUE END, + args = v2_job_completed.__args, + raw_code = COALESCE(v2_job.raw_code, v2_job_completed.__raw_code), + raw_lock = COALESCE(v2_job.raw_lock, v2_job_completed.__raw_lock), + raw_flow = COALESCE(v2_job.raw_flow, v2_job_completed.__raw_flow), + labels = CASE + WHEN jsonb_typeof(v2_job_completed.result->'wm_labels') = 'array' AND ( + SELECT bool_and(jsonb_typeof(elem) = 'string') + FROM jsonb_array_elements(v2_job_completed.result->'wm_labels') AS elem + ) THEN ( + SELECT array_agg(DISTINCT all_labels) + FROM unnest( + coalesce(v2_job.labels, ARRAY[]::TEXT[]) + || translate(v2_job_completed.result->>'wm_labels', '[]', '{}')::TEXT[] + ) all_labels + ) + END +FROM v2_job_completed +WHERE v2_job.id = v2_job_completed.id AND v2_job.created_by = 'missing'; + +-- Migrate `v2_job_queue` moved columns to `v2_job_runtime`: +INSERT INTO v2_job_runtime (id, ping, memory_peak) +SELECT id, __last_ping, __mem_peak +FROM v2_job_queue +WHERE __last_ping IS NOT NULL OR __mem_peak IS NOT NULL + -- Locked ones will sync within triggers + FOR UPDATE SKIP LOCKED +ON CONFLICT (id) DO NOTHING; + +-- Migrate `v2_job_queue` moved columns to `v2_job_status` for `workflow_as_code`: +INSERT INTO v2_job_status (id, workflow_as_code_status) +SELECT id, __flow_status +FROM v2_job_queue +WHERE __flow_status IS NOT NULL AND __is_flow_step = false AND __parent_job IS NOT NULL + -- Locked ones will sync within triggers + FOR UPDATE SKIP LOCKED +ON CONFLICT (id) DO NOTHING; + +-- Migrate `v2_job_queue` moved columns to `v2_job_status`: +INSERT INTO v2_job_status (id, flow_status, flow_leaf_jobs) +SELECT id, __flow_status, __leaf_jobs +FROM v2_job_queue +WHERE __flow_status IS NOT NULL OR __leaf_jobs IS NOT NULL + -- Locked ones will sync within triggers + FOR UPDATE SKIP LOCKED +ON CONFLICT (id) DO NOTHING; + +-- Migrate old `v2_job_queue.__logs` to `job_logs` +INSERT INTO job_logs (job_id, workspace_id, logs) +SELECT id, workspace_id, __logs +FROM v2_job_queue +WHERE __logs IS NOT NULL +ON CONFLICT (job_id) DO UPDATE SET + logs = CONCAT(job_logs.logs, EXCLUDED.logs) +; + +-- Migrate old `v2_job_completed.__logs` to `job_logs` +INSERT INTO job_logs (job_id, workspace_id, logs) +SELECT id, workspace_id, __logs +FROM v2_job_completed +WHERE __logs IS NOT NULL AND __logs IS DISTINCT FROM '##DELETED##' +ON CONFLICT (job_id) DO UPDATE SET + logs = CONCAT(job_logs.logs, EXCLUDED.logs) +; diff --git a/backend/migrations/20250201124804_v2_job_runtime_sync.down.sql b/backend/migrations/20250201124804_v2_job_runtime_sync.down.sql new file mode 100644 index 0000000000..9c9fe30241 --- /dev/null +++ b/backend/migrations/20250201124804_v2_job_runtime_sync.down.sql @@ -0,0 +1,3 @@ +-- Add down migration script here +DROP FUNCTION v2_job_runtime_before_insert() CASCADE; +DROP FUNCTION v2_job_runtime_before_update() CASCADE; diff --git a/backend/migrations/20250201124804_v2_job_runtime_sync.up.sql b/backend/migrations/20250201124804_v2_job_runtime_sync.up.sql new file mode 100644 index 0000000000..26947c3615 --- /dev/null +++ b/backend/migrations/20250201124804_v2_job_runtime_sync.up.sql @@ -0,0 +1,31 @@ +-- Add up migration script here + +-- On every insert/update to `v2_job_runtime`, reflect to `v2_job_queue` as well +-- This triggers will be removed once all server(s)/worker(s) are updated to use `v2_*` tables +CREATE OR REPLACE FUNCTION v2_job_runtime_before_insert() RETURNS TRIGGER AS $$ BEGIN + UPDATE v2_job_queue + SET __last_ping = NEW.ping, __mem_peak = NEW.memory_peak + WHERE id = NEW.id; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE TRIGGER v2_job_runtime_before_insert_trigger + BEFORE INSERT ON v2_job_runtime + FOR EACH ROW + WHEN (pg_trigger_depth() < 1) -- Prevent infinite loop v2 <-> v1 +EXECUTE FUNCTION v2_job_runtime_before_insert(); + +CREATE OR REPLACE FUNCTION v2_job_runtime_before_update() RETURNS TRIGGER AS $$ BEGIN + IF NEW.ping IS DISTINCT FROM OLD.ping OR NEW.memory_peak IS DISTINCT FROM OLD.memory_peak THEN + UPDATE v2_job_queue + SET __last_ping = NEW.ping, __mem_peak = NEW.memory_peak + WHERE id = NEW.id; + END IF; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE TRIGGER v2_job_runtime_before_update_trigger + BEFORE UPDATE ON v2_job_runtime + FOR EACH ROW + WHEN (pg_trigger_depth() < 1) -- Prevent infinite loop v2 <-> v1 +EXECUTE FUNCTION v2_job_runtime_before_update(); diff --git a/backend/migrations/20250201124805_v2_job_status_sync.down.sql b/backend/migrations/20250201124805_v2_job_status_sync.down.sql new file mode 100644 index 0000000000..95ce39e16b --- /dev/null +++ b/backend/migrations/20250201124805_v2_job_status_sync.down.sql @@ -0,0 +1,3 @@ +-- Add down migration script here +DROP FUNCTION v2_job_status_before_insert() CASCADE; +DROP FUNCTION v2_job_status_before_update() CASCADE; diff --git a/backend/migrations/20250201124805_v2_job_status_sync.up.sql b/backend/migrations/20250201124805_v2_job_status_sync.up.sql new file mode 100644 index 0000000000..08e7e73dd2 --- /dev/null +++ b/backend/migrations/20250201124805_v2_job_status_sync.up.sql @@ -0,0 +1,37 @@ +-- Add up migration script here + +-- On every insert/update to `v2_job_status`, reflect to `v2_job_queue` as well +-- This triggers will be removed once all server(s)/worker(s) are updated to use `v2_*` tables +CREATE OR REPLACE FUNCTION v2_job_status_before_insert() RETURNS TRIGGER AS $$ BEGIN + UPDATE v2_job_queue + SET __flow_status = NEW.flow_status, __leaf_jobs = NEW.flow_leaf_jobs + WHERE id = NEW.id; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE TRIGGER v2_job_status_before_insert_trigger + BEFORE INSERT ON v2_job_status + FOR EACH ROW + WHEN (pg_trigger_depth() < 1) -- Prevent infinite loop v2 <-> v1 +EXECUTE FUNCTION v2_job_status_before_insert(); + +CREATE OR REPLACE FUNCTION v2_job_status_before_update() RETURNS TRIGGER AS $$ BEGIN + IF NEW.flow_status::TEXT IS DISTINCT FROM OLD.flow_status::TEXT OR + NEW.flow_leaf_jobs::TEXT IS DISTINCT FROM OLD.flow_leaf_jobs::TEXT THEN + UPDATE v2_job_queue + SET __flow_status = NEW.flow_status, __leaf_jobs = NEW.flow_leaf_jobs + WHERE id = NEW.id; + END IF; + IF NEW.workflow_as_code_status::TEXT IS DISTINCT FROM OLD.workflow_as_code_status::TEXT THEN + UPDATE v2_job_queue + SET __flow_status = NEW.workflow_as_code_status + WHERE id = NEW.id; + END IF; + RETURN NEW; +END $$ LANGUAGE plpgsql; + +CREATE OR REPLACE TRIGGER v2_job_status_before_update_trigger + BEFORE UPDATE ON v2_job_status + FOR EACH ROW + WHEN (pg_trigger_depth() < 1) -- Prevent infinite loop v2 <-> v1 +EXECUTE FUNCTION v2_job_status_before_update(); diff --git a/backend/migrations/20250201124919_v2_job_constraints.down.sql b/backend/migrations/20250201124919_v2_job_constraints.down.sql new file mode 100644 index 0000000000..72796ff008 --- /dev/null +++ b/backend/migrations/20250201124919_v2_job_constraints.down.sql @@ -0,0 +1,4 @@ +-- Add down migration script here +ALTER TABLE v2_job ALTER COLUMN workspace_id DROP NOT NULL; +ALTER TABLE v2_job ALTER COLUMN tag DROP DEFAULT; +ALTER TABLE v2_job ALTER COLUMN tag DROP NOT NULL; diff --git a/backend/migrations/20250201124919_v2_job_constraints.up.sql b/backend/migrations/20250201124919_v2_job_constraints.up.sql new file mode 100644 index 0000000000..b0ba090fa9 --- /dev/null +++ b/backend/migrations/20250201124919_v2_job_constraints.up.sql @@ -0,0 +1,4 @@ +-- Add up migration script here +ALTER TABLE v2_job ALTER COLUMN workspace_id SET NOT NULL; +ALTER TABLE v2_job ALTER COLUMN tag SET DEFAULT 'other'; +ALTER TABLE v2_job ALTER COLUMN tag SET NOT NULL; diff --git a/backend/migrations/20250201145628_v2_job_queue_constraints.down.sql b/backend/migrations/20250201145628_v2_job_queue_constraints.down.sql new file mode 100644 index 0000000000..9f13ce1b41 --- /dev/null +++ b/backend/migrations/20250201145628_v2_job_queue_constraints.down.sql @@ -0,0 +1,2 @@ +-- Add up migration script here +ALTER TABLE v2_job_queue ALTER COLUMN __created_by SET NOT NULL; diff --git a/backend/migrations/20250201145628_v2_job_queue_constraints.up.sql b/backend/migrations/20250201145628_v2_job_queue_constraints.up.sql new file mode 100644 index 0000000000..5eac732ab0 --- /dev/null +++ b/backend/migrations/20250201145628_v2_job_queue_constraints.up.sql @@ -0,0 +1,2 @@ +-- Add up migration script here +ALTER TABLE v2_job_queue ALTER COLUMN __created_by DROP NOT NULL; diff --git a/backend/migrations/20250201145629_v2_job_completed_constraints.down.sql b/backend/migrations/20250201145629_v2_job_completed_constraints.down.sql new file mode 100644 index 0000000000..bf4a399470 --- /dev/null +++ b/backend/migrations/20250201145629_v2_job_completed_constraints.down.sql @@ -0,0 +1,10 @@ +-- Add down migration script here +LOCK TABLE v2_job_completed IN ACCESS EXCLUSIVE MODE; +UPDATE v2_job_completed SET started_at = completed_at WHERE started_at IS NULL; +ALTER TABLE v2_job_completed ALTER COLUMN status DROP NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN completed_at DROP DEFAULT; +ALTER TABLE v2_job_completed ALTER COLUMN completed_at DROP NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN started_at SET NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN __created_at SET NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN __created_by SET NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN __success SET NOT NULL; diff --git a/backend/migrations/20250201145629_v2_job_completed_constraints.up.sql b/backend/migrations/20250201145629_v2_job_completed_constraints.up.sql new file mode 100644 index 0000000000..9c4772ec72 --- /dev/null +++ b/backend/migrations/20250201145629_v2_job_completed_constraints.up.sql @@ -0,0 +1,8 @@ +-- Add up migration script here +ALTER TABLE v2_job_completed ALTER COLUMN status SET NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN completed_at SET DEFAULT now(); +ALTER TABLE v2_job_completed ALTER COLUMN completed_at SET NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN started_at DROP NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN __created_at DROP NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN __created_by DROP NOT NULL; +ALTER TABLE v2_job_completed ALTER COLUMN __success DROP NOT NULL; diff --git a/backend/migrations/20250201145630_v2_queue_compatibility_view.down.sql b/backend/migrations/20250201145630_v2_queue_compatibility_view.down.sql new file mode 100644 index 0000000000..23bb72031f --- /dev/null +++ b/backend/migrations/20250201145630_v2_queue_compatibility_view.down.sql @@ -0,0 +1,2 @@ +-- Add down migration script here +DROP VIEW v2_as_queue; diff --git a/backend/migrations/20250201145630_v2_queue_compatibility_view.up.sql b/backend/migrations/20250201145630_v2_queue_compatibility_view.up.sql new file mode 100644 index 0000000000..76065477f9 --- /dev/null +++ b/backend/migrations/20250201145630_v2_queue_compatibility_view.up.sql @@ -0,0 +1,52 @@ +-- Add up migration script here +CREATE OR REPLACE VIEW v2_as_queue AS +SELECT + j.id, + j.workspace_id, + j.parent_job, + j.created_by, + j.created_at, + q.started_at, + q.scheduled_for, + q.running, + j.runnable_id AS script_hash, + j.runnable_path AS script_path, + j.args, + j.raw_code, + q.canceled_by IS NOT NULL AS canceled, + q.canceled_by, + q.canceled_reason, + r.ping AS last_ping, + j.kind AS job_kind, + CASE WHEN j.trigger_kind = 'schedule'::job_trigger_kind THEN j.trigger END + AS schedule_path, + j.permissioned_as, + s.flow_status, + j.raw_flow, + j.flow_step_id IS NOT NULL AS is_flow_step, + j.script_lang AS language, + q.suspend, + q.suspend_until, + j.same_worker, + j.raw_lock, + j.pre_run_error, + j.permissioned_as_email AS email, + j.visible_to_owner, + r.memory_peak AS mem_peak, + j.flow_innermost_root_job AS root_job, + s.flow_leaf_jobs AS leaf_jobs, + j.tag, + j.concurrent_limit, + j.concurrency_time_window_s, + j.timeout, + j.flow_step_id, + j.cache_ttl, + j.priority, + NULL::TEXT AS logs, + j.script_entrypoint_override, + j.preprocessed +FROM v2_job_queue q + JOIN v2_job j USING (id) + LEFT JOIN v2_job_runtime r USING (id) + LEFT JOIN v2_job_status s USING (id) +; diff --git a/backend/migrations/20250201145631_v2_completed_job_compatibility_view.down.sql b/backend/migrations/20250201145631_v2_completed_job_compatibility_view.down.sql new file mode 100644 index 0000000000..90ce271f4a --- /dev/null +++ b/backend/migrations/20250201145631_v2_completed_job_compatibility_view.down.sql @@ -0,0 +1,2 @@ +-- Add up migration script here +DROP VIEW v2_as_completed_job; diff --git a/backend/migrations/20250201145631_v2_completed_job_compatibility_view.up.sql b/backend/migrations/20250201145631_v2_completed_job_compatibility_view.up.sql new file mode 100644 index 0000000000..dd5b11ed2c --- /dev/null +++ b/backend/migrations/20250201145631_v2_completed_job_compatibility_view.up.sql @@ -0,0 +1,42 @@ +-- Add up migration script here +CREATE OR REPLACE VIEW v2_as_completed_job AS +SELECT + j.id, + j.workspace_id, + j.parent_job, + j.created_by, + j.created_at, + c.duration_ms, + c.status = 'success' AS success, + j.runnable_id AS script_hash, + j.runnable_path AS script_path, + j.args, + c.result, + FALSE AS deleted, + j.raw_code, + c.status = 'canceled' AS canceled, + c.canceled_by, + c.canceled_reason, + j.kind AS job_kind, + CASE WHEN j.trigger_kind = 'schedule'::job_trigger_kind THEN j.trigger END + AS schedule_path, + j.permissioned_as, + c.flow_status, + j.raw_flow, + j.flow_step_id IS NOT NULL AS is_flow_step, + j.script_lang AS language, + c.started_at, + c.status = 'skipped' AS is_skipped, + j.raw_lock, + j.permissioned_as_email AS email, + j.visible_to_owner, + c.memory_peak AS mem_peak, + j.tag, + j.priority, + NULL::TEXT AS logs, + c.result_columns, + j.script_entrypoint_override, + j.preprocessed +FROM v2_job_completed c + JOIN v2_job j USING (id) +; diff --git a/backend/migrations/20250201145632_v2_fix_no_runtime.down.sql b/backend/migrations/20250201145632_v2_fix_no_runtime.down.sql new file mode 100644 index 0000000000..d2f607c5b8 --- /dev/null +++ b/backend/migrations/20250201145632_v2_fix_no_runtime.down.sql @@ -0,0 +1 @@ +-- Add down migration script here diff --git a/backend/migrations/20250201145632_v2_fix_no_runtime.up.sql b/backend/migrations/20250201145632_v2_fix_no_runtime.up.sql new file mode 100644 index 0000000000..422e3071f2 --- /dev/null +++ b/backend/migrations/20250201145632_v2_fix_no_runtime.up.sql @@ -0,0 +1,8 @@ +-- Add up migration script here +-- Migrate `v2_job_queue` moved columns to `v2_job_runtime`: +INSERT INTO v2_job_runtime (id, ping, memory_peak) +SELECT id, __last_ping, __mem_peak +FROM v2_job_queue + -- Locked ones will sync within triggers + FOR UPDATE SKIP LOCKED +ON CONFLICT (id) DO NOTHING; diff --git a/backend/src/main.rs b/backend/src/main.rs index d4459a3371..e3b846bfb2 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -389,8 +389,8 @@ async fn windmill_main() -> anyhow::Result<()> { let (killpill_tx, mut killpill_rx) = tokio::sync::broadcast::channel::<()>(2); let mut monitor_killpill_rx = killpill_tx.subscribe(); - let server_killpill_rx = killpill_tx.subscribe(); let (killpill_phase2_tx, _killpill_phase2_rx) = tokio::sync::broadcast::channel::<()>(2); + let server_killpill_rx = killpill_phase2_tx.subscribe(); let shutdown_signal = windmill_common::shutdown_signal(killpill_tx.clone(), killpill_tx.subscribe()); @@ -646,9 +646,13 @@ Windmill Community Edition {GIT_VERSION} } } if killpill_phase2_tx.receiver_count() > 0 { - tracing::info!("Starting phase 2 of shutdown"); + if worker_mode { + tracing::info!("Starting phase 2 of shutdown"); + } killpill_phase2_tx.send(())?; - tracing::info!("Phase 2 of shutdown completed"); + if worker_mode { + tracing::info!("Phase 2 of shutdown completed"); + } } Ok(()) }; diff --git a/backend/src/monitor.rs b/backend/src/monitor.rs index b77d097ab1..5353d6fbf5 100644 --- a/backend/src/monitor.rs +++ b/backend/src/monitor.rs @@ -19,6 +19,7 @@ use tokio::{ join, sync::{mpsc, RwLock}, }; +use uuid::Uuid; #[cfg(feature = "embedding")] use windmill_api::embeddings::update_embeddings_db; @@ -36,7 +37,7 @@ use windmill_common::{ auth::JWT_SECRET, ee::CriticalErrorChannel, error, - flow_status::FlowStatusModule, + flow_status::{FlowStatus, FlowStatusModule}, global_settings::{ BASE_URL_SETTING, BUNFIG_INSTALL_SCOPES_SETTING, CRITICAL_ALERT_MUTE_UI_SETTING, CRITICAL_ERROR_CHANNELS_SETTING, DEFAULT_TAGS_PER_WORKSPACE_SETTING, @@ -735,11 +736,17 @@ pub async fn delete_expired_items(db: &DB) -> () { match db.begin().await { Ok(mut tx) => { let deleted_jobs = sqlx::query_scalar!( - "DELETE FROM completed_job WHERE created_at <= now() - ($1::bigint::text || ' s')::interval AND started_at + ((duration_ms/1000 + $1::bigint) || ' s')::interval <= now() RETURNING id", - job_retention_secs - ) - .fetch_all(&mut *tx) - .await; + "DELETE FROM v2_job_completed c + USING v2_job j + WHERE + created_at <= now() - ($1::bigint::text || ' s')::interval + AND completed_at + ($1::bigint::text || ' s')::interval <= now() + AND c.id = j.id + RETURNING c.id", + job_retention_secs + ) + .fetch_all(&mut *tx) + .await; match deleted_jobs { Ok(deleted_jobs) => { @@ -787,7 +794,7 @@ pub async fn delete_expired_items(db: &DB) -> () { } if let Err(e) = - sqlx::query!("DELETE FROM job WHERE id = ANY($1)", &deleted_jobs) + sqlx::query!("DELETE FROM v2_job WHERE id = ANY($1)", &deleted_jobs) .execute(&mut *tx) .await { @@ -1342,13 +1349,19 @@ pub async fn expose_queue_metrics(db: &Pool) { .ok(); if count > 0 { sqlx::query!( - "INSERT INTO metrics (id, value) - VALUES ($1, to_jsonb((SELECT EXTRACT(EPOCH FROM now() - scheduled_for) - FROM queue WHERE tag = $2 AND running = false AND scheduled_for <= now() - ('3 seconds')::interval - ORDER BY priority DESC NULLS LAST, scheduled_for LIMIT 1)))", - format!("queue_delay_{}", tag), - tag - ).execute(db).await.ok(); + "INSERT INTO metrics (id, value) + VALUES ($1, to_jsonb(( + SELECT EXTRACT(EPOCH FROM now() - scheduled_for) + FROM v2_job_queue + WHERE tag = $2 AND running = false AND scheduled_for <= now() - ('3 seconds')::interval + ORDER BY priority DESC NULLS LAST, scheduled_for LIMIT 1 + )))", + format!("queue_delay_{}", tag), + tag + ) + .execute(db) + .await + .ok(); } } } @@ -1507,26 +1520,30 @@ pub async fn reload_base_url_setting(db: &DB) -> error::Result<()> { async fn handle_zombie_jobs(db: &Pool, base_internal_url: &str, worker_name: &str) { if *RESTART_ZOMBIE_JOBS { let restarted = sqlx::query!( - "WITH zombie_jobs AS ( - UPDATE queue SET running = false, started_at = null - WHERE last_ping < now() - ($1 || ' seconds')::interval - AND running = true AND job_kind NOT IN ('flow', 'flowpreview', 'flownode', 'singlescriptflow') AND same_worker = false - RETURNING id, workspace_id, last_ping - ), - update_concurrency AS ( - UPDATE concurrency_counter cc - SET job_uuids = job_uuids - zj.id::text - FROM zombie_jobs zj - INNER JOIN concurrency_key ck ON ck.job_id = zj.id - WHERE cc.concurrency_id = ck.key - ) - SELECT id, workspace_id, last_ping FROM zombie_jobs", - *ZOMBIE_JOB_TIMEOUT, + "WITH zombie_jobs AS ( + UPDATE v2_job_queue q SET running = false, started_at = null + FROM v2_job j, v2_job_runtime r + WHERE j.id = q.id AND j.id = r.id + AND ping < now() - ($1 || ' seconds')::interval + AND running = true + AND kind NOT IN ('flow', 'flowpreview', 'flownode', 'singlescriptflow') + AND same_worker = false + RETURNING q.id, q.workspace_id, ping + ), + update_concurrency AS ( + UPDATE concurrency_counter cc + SET job_uuids = job_uuids - zj.id::text + FROM zombie_jobs zj + INNER JOIN concurrency_key ck ON ck.job_id = zj.id + WHERE cc.concurrency_id = ck.key ) - .fetch_all(db) - .await - .ok() - .unwrap_or_else(|| vec![]); + SELECT id, workspace_id, ping FROM zombie_jobs", + *ZOMBIE_JOB_TIMEOUT, + ) + .fetch_all(db) + .await + .ok() + .unwrap_or_else(|| vec![]); #[cfg(feature = "prometheus")] if METRICS_ENABLED.load(std::sync::atomic::Ordering::Relaxed) { @@ -1535,7 +1552,7 @@ async fn handle_zombie_jobs(db: &Pool, base_internal_url: &str, worker let base_url = BASE_URL.read().await.clone(); for r in restarted { - let last_ping = if let Some(x) = r.last_ping { + let last_ping = if let Some(x) = r.ping { format!("last ping at {x}") } else { "no last ping".to_string() @@ -1547,16 +1564,21 @@ async fn handle_zombie_jobs(db: &Pool, base_internal_url: &str, worker ); let _ = sqlx::query!(" - INSERT INTO job_logs (job_id, logs) VALUES ($1,'Restarted job after not receiving job''s ping for too long the ' || now() || '\n\n') - ON CONFLICT (job_id) DO UPDATE SET logs = job_logs.logs || '\nRestarted job after not receiving job''s ping for too long the ' || now() || '\n\n' WHERE job_logs.job_id = $1", r.id) - .execute(db).await; + INSERT INTO job_logs (job_id, logs) + VALUES ($1, 'Restarted job after not receiving job''s ping for too long the ' || now() || '\n\n') + ON CONFLICT (job_id) DO UPDATE SET logs = job_logs.logs || '\n' || EXCLUDED.logs + WHERE job_logs.job_id = $1", + r.id + ) + .execute(db) + .await; tracing::error!(error_message); report_critical_error(error_message, db.clone(), Some(&r.workspace_id), None).await; } } let mut timeout_query = - "SELECT * FROM queue WHERE last_ping < now() - ($1 || ' seconds')::interval + "SELECT * FROM v2_as_queue WHERE last_ping < now() - ($1 || ' seconds')::interval AND running = true AND job_kind NOT IN ('flow', 'flowpreview', 'flownode', 'singlescriptflow')" .to_string(); if *RESTART_ZOMBIE_JOBS { @@ -1637,20 +1659,28 @@ async fn handle_zombie_jobs(db: &Pool, base_internal_url: &str, worker } async fn handle_zombie_flows(db: &DB) -> error::Result<()> { - let flows = sqlx::query_as::<_, QueuedJob>( + let flows = sqlx::query!( r#" - SELECT * - FROM queue - WHERE running = true AND suspend = 0 AND suspend_until IS null AND scheduled_for <= now() AND (job_kind = 'flow' OR job_kind = 'flowpreview' OR job_kind = 'flownode') - AND last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval AND canceled = false + SELECT + id AS "id!", workspace_id AS "workspace_id!", parent_job, is_flow_step, + flow_status AS "flow_status: Box", last_ping, same_worker + FROM v2_as_queue + WHERE running = true AND suspend = 0 AND suspend_until IS null AND scheduled_for <= now() + AND (job_kind = 'flow' OR job_kind = 'flowpreview' OR job_kind = 'flownode') + AND last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval + AND canceled = false "#, - ).bind(FLOW_ZOMBIE_TRANSITION_TIMEOUT.as_str()) + FLOW_ZOMBIE_TRANSITION_TIMEOUT.as_str() + ) .fetch_all(db) .await?; for flow in flows { - let status = flow.parse_flow_status(); - if !flow.same_worker + let status = flow + .flow_status + .as_deref() + .and_then(|x| serde_json::from_str::(x).ok()); + if !flow.same_worker.unwrap_or(false) && status.is_some_and(|s| { s.modules .get(0) @@ -1682,7 +1712,8 @@ async fn handle_zombie_flows(db: &DB) -> error::Result<()> { } sqlx::query!( - "UPDATE queue SET running = false, started_at = null WHERE id = $1 AND canceled = false", + "UPDATE v2_job_queue SET running = false, started_at = null + WHERE id = $1 AND canceled_by IS NULL", flow.id ) .execute(&mut *tx) @@ -1695,44 +1726,40 @@ async fn handle_zombie_flows(db: &DB) -> error::Result<()> { let now = now_from_db(db).await?; let reason = format!( "{} was hanging in between 2 steps. Last ping: {last_ping:?} (now: {now})", - if flow.is_flow_step && flow.parent_job.is_some() { + if flow.is_flow_step.unwrap_or(false) && flow.parent_job.is_some() { format!("Flow was cancelled because subflow {id}") } else { format!("Flow {id} was cancelled because it") } ); report_critical_error(reason.clone(), db.clone(), Some(&flow.workspace_id), None).await; - cancel_zombie_flow_job(db, flow, reason).await?; + cancel_zombie_flow_job(db, flow.id, &flow.workspace_id, reason).await?; } } let flows2 = sqlx::query!( - " - DELETE - FROM parallel_monitor_lock - WHERE last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval - RETURNING parent_flow_id, job_id, last_ping - ", + r#" + DELETE + FROM parallel_monitor_lock + WHERE last_ping IS NOT NULL AND last_ping < NOW() - ($1 || ' seconds')::interval + RETURNING parent_flow_id, job_id, last_ping, (SELECT workspace_id FROM v2_job_queue q + WHERE q.id = parent_flow_id AND q.running = true AND q.canceled_by IS NULL + ) AS workspace_id + "#, FLOW_ZOMBIE_TRANSITION_TIMEOUT.as_str() ) .fetch_all(db) .await?; for flow in flows2 { - let in_queue = sqlx::query_as::<_, QueuedJob>( - "SELECT * FROM queue WHERE id = $1 AND running = true AND canceled = false", - ) - .bind(flow.parent_flow_id) - .fetch_optional(db) - .await?; - if let Some(job) = in_queue { + if let Some(parent_flow_workspace_id) = flow.workspace_id { tracing::error!( "parallel Zombie flow detected: {} in workspace {}. Last ping was: {:?}.", - job.id, - job.workspace_id, + flow.parent_flow_id, + parent_flow_workspace_id, flow.last_ping ); - cancel_zombie_flow_job(db, job, + cancel_zombie_flow_job(db, flow.parent_flow_id, &parent_flow_workspace_id, format!("Flow {} cancelled as one of the parallel branch {} was unable to make the last transition ", flow.parent_flow_id, flow.job_id)) .await?; } else { @@ -1744,27 +1771,28 @@ async fn handle_zombie_flows(db: &DB) -> error::Result<()> { async fn cancel_zombie_flow_job( db: &Pool, - flow: QueuedJob, + id: Uuid, + workspace_id: &str, message: String, ) -> Result<(), error::Error> { - let tx = db.begin().await.unwrap(); + let mut tx = db.begin().await?; tracing::error!( "zombie flow detected: {} in workspace {}. Cancelling it.", - flow.id, - flow.workspace_id + id, + workspace_id ); - let (ntx, _) = cancel_job( + (tx, _) = cancel_job( "monitor", Some(message), - flow.id, - flow.workspace_id.as_str(), + id, + workspace_id, tx, db, true, false, ) .await?; - ntx.commit().await?; + tx.commit().await?; Ok(()) } diff --git a/backend/tests/fixtures/base.sql b/backend/tests/fixtures/base.sql index f406e603d4..c5bec3454c 100644 --- a/backend/tests/fixtures/base.sql +++ b/backend/tests/fixtures/base.sql @@ -23,13 +23,13 @@ GRANT ALL PRIVILEGES ON TABLE workspace_key TO windmill_user; CREATE FUNCTION "notify_insert_on_completed_job" () RETURNS TRIGGER AS $$ BEGIN - PERFORM pg_notify('insert on completed_job', NEW.id::text); + PERFORM pg_notify('completed', NEW.id::text); RETURN NEW; END; $$ LANGUAGE PLPGSQL; CREATE TRIGGER "notify_insert_on_completed_job" - AFTER INSERT ON "completed_job" + AFTER INSERT ON "v2_job_completed" FOR EACH ROW EXECUTE FUNCTION "notify_insert_on_completed_job" (); @@ -37,18 +37,198 @@ EXECUTE FUNCTION "notify_insert_on_completed_job" (); CREATE FUNCTION "notify_queue" () RETURNS TRIGGER AS $$ BEGIN - PERFORM pg_notify('queue', NEW.id::text); + PERFORM pg_notify('queued', NEW.id::text); RETURN NEW; END; $$ LANGUAGE PLPGSQL; CREATE TRIGGER "notify_queue_after_insert" - AFTER INSERT ON "queue" + AFTER INSERT ON "v2_job_queue" FOR EACH ROW EXECUTE FUNCTION "notify_queue" (); CREATE TRIGGER "notify_queue_after_flow_status_update" - AFTER UPDATE ON "queue" + AFTER UPDATE ON "v2_job_status" FOR EACH ROW WHEN (NEW.flow_status IS DISTINCT FROM OLD.flow_status) -EXECUTE FUNCTION "notify_queue" (); \ No newline at end of file +EXECUTE FUNCTION "notify_queue" (); + +-- TODO(uael): remove before phase 4 +CREATE OR REPLACE FUNCTION zzz_v2_job_queue_integrity_check() RETURNS TRIGGER AS $$ +DECLARE job v2_job; +DECLARE job_runtime v2_job_runtime; +DECLARE job_status v2_job_status; +BEGIN + IF (OLD.canceled_by IS NOT NULL) IS DISTINCT FROM OLD.__canceled THEN + RAISE EXCEPTION 'canceled mismatch'; + END IF; + -- v2_job: + SELECT * INTO job FROM v2_job WHERE id = OLD.id; + IF job.tag IS DISTINCT FROM OLD.tag THEN + RAISE EXCEPTION 'tag mismatch'; + END IF; + IF job.workspace_id IS DISTINCT FROM OLD.workspace_id THEN + RAISE EXCEPTION 'workspace_id mismatch'; + END IF; + IF job.created_at IS DISTINCT FROM OLD.created_at THEN + RAISE EXCEPTION 'created_at mismatch'; + END IF; + IF job.created_by IS DISTINCT FROM OLD.__created_by THEN + RAISE EXCEPTION 'created_by mismatch'; + END IF; + IF job.permissioned_as IS DISTINCT FROM OLD.__permissioned_as THEN + RAISE EXCEPTION 'permissioned_as mismatch'; + END IF; + IF job.permissioned_as_email IS DISTINCT FROM OLD.__email THEN + RAISE EXCEPTION 'permissioned_as_email mismatch'; + END IF; + IF job.kind IS DISTINCT FROM OLD.__job_kind THEN + RAISE EXCEPTION 'kind mismatch'; + END IF; + IF job.runnable_id IS DISTINCT FROM OLD.__script_hash THEN + RAISE EXCEPTION 'runnable_id mismatch'; + END IF; + IF job.runnable_path IS DISTINCT FROM OLD.__script_path THEN + RAISE EXCEPTION 'runnable_path mismatch'; + END IF; + IF job.parent_job IS DISTINCT FROM OLD.__parent_job THEN + RAISE EXCEPTION 'parent_job mismatch'; + END IF; + IF job.script_lang IS DISTINCT FROM OLD.__language THEN + RAISE EXCEPTION 'script_lang mismatch'; + END IF; + IF job.script_entrypoint_override IS DISTINCT FROM NULLIF(OLD.__args->>'_ENTRYPOINT_OVERRIDE', '__WM_PREPROCESSOR') + AND OLD.__args->>'reason' IS DISTINCT FROM 'PREPROCESSOR_ARGS_ARE_DISCARDED' + THEN + RAISE EXCEPTION 'script_entrypoint_override mismatch'; + END IF; + IF job.flow_step_id IS DISTINCT FROM OLD.__flow_step_id THEN + RAISE EXCEPTION 'flow_step_id mismatch'; + END IF; + IF (job.flow_step_id IS NOT NULL) IS DISTINCT FROM OLD.__is_flow_step THEN + RAISE EXCEPTION 'is_flow_step mismatch'; + END IF; + IF job.flow_innermost_root_job IS DISTINCT FROM OLD.__root_job THEN + RAISE EXCEPTION 'flow_innermost_root_job mismatch'; + END IF; + IF job.trigger IS DISTINCT FROM OLD.__schedule_path THEN + RAISE EXCEPTION 'trigger mismatch'; + END IF; + IF job.same_worker IS DISTINCT FROM OLD.__same_worker THEN + RAISE EXCEPTION 'same_worker mismatch'; + END IF; + IF job.visible_to_owner IS DISTINCT FROM OLD.__visible_to_owner THEN + RAISE EXCEPTION 'visible_to_owner mismatch'; + END IF; + IF job.concurrent_limit IS DISTINCT FROM OLD.__concurrent_limit THEN + RAISE EXCEPTION 'concurrent_limit mismatch'; + END IF; + IF job.concurrency_time_window_s IS DISTINCT FROM OLD.__concurrency_time_window_s THEN + RAISE EXCEPTION 'concurrency_time_window_s mismatch'; + END IF; + IF job.cache_ttl IS DISTINCT FROM OLD.__cache_ttl THEN + RAISE EXCEPTION 'cache_ttl mismatch'; + END IF; + IF job.timeout IS DISTINCT FROM OLD.__timeout THEN + RAISE EXCEPTION 'timeout mismatch'; + END IF; + IF job.priority IS DISTINCT FROM OLD.priority THEN + RAISE EXCEPTION 'priority mismatch'; + END IF; + IF job.args::TEXT IS DISTINCT FROM OLD.__args::TEXT AND OLD.__args->>'_ENTRYPOINT_OVERRIDE' IS DISTINCT FROM '__WM_PREPROCESSOR' THEN + RAISE EXCEPTION 'args mismatch'; + END IF; + IF job.pre_run_error IS DISTINCT FROM OLD.__pre_run_error THEN + RAISE EXCEPTION 'pre_run_error mismatch'; + END IF; + -- v2_job_runtime: + SELECT * INTO job_runtime FROM v2_job_runtime WHERE id = OLD.id; + IF job_runtime.ping IS DISTINCT FROM OLD.__last_ping THEN + RAISE EXCEPTION 'ping mismatch'; + END IF; + IF job_runtime.memory_peak IS DISTINCT FROM OLD.__mem_peak THEN + RAISE EXCEPTION 'memory_peak mismatch'; + END IF; + -- v2_job_status: + IF EXISTS(SELECT 1 FROM v2_job_status WHERE id = OLD.id) THEN + SELECT * INTO job_status FROM v2_job_status WHERE id = OLD.id; + IF job_status.flow_status::TEXT IS DISTINCT FROM OLD.__flow_status::TEXT THEN + RAISE EXCEPTION 'flow_status mismatch'; + END IF; + IF job_status.flow_leaf_jobs::TEXT IS DISTINCT FROM OLD.__leaf_jobs::TEXT THEN + RAISE EXCEPTION 'leaf_jobs mismatch'; + END IF; + END IF; + RETURN OLD; +END $$ LANGUAGE PLPGSQL; + +CREATE OR REPLACE TRIGGER zzz_v2_job_queue_integrity_check_before_delete + BEFORE DELETE ON v2_job_queue + FOR EACH ROW +EXECUTE FUNCTION zzz_v2_job_queue_integrity_check(); + +-- TODO(uael): remove before phase 4 +CREATE OR REPLACE FUNCTION zzz_v2_job_completed_integrity_check() RETURNS TRIGGER AS $$ +DECLARE job v2_job; +BEGIN + IF (NEW.canceled_by IS NOT NULL) IS DISTINCT FROM NEW.__canceled THEN + RAISE EXCEPTION 'canceled mismatch'; + END IF; + SELECT * INTO job FROM v2_job WHERE id = NEW.id; + IF job.tag IS DISTINCT FROM NEW.__tag THEN + RAISE EXCEPTION 'tag mismatch % %', job.tag, NEW.__tag; + END IF; + IF job.workspace_id IS DISTINCT FROM NEW.workspace_id THEN + RAISE EXCEPTION 'workspace_id mismatch'; + END IF; + IF job.created_at IS DISTINCT FROM NEW.__created_at THEN + RAISE EXCEPTION 'created_at mismatch'; + END IF; + IF job.created_by IS DISTINCT FROM NEW.__created_by THEN + RAISE EXCEPTION 'created_by mismatch'; + END IF; + IF job.permissioned_as IS DISTINCT FROM NEW.__permissioned_as THEN + RAISE EXCEPTION 'permissioned_as mismatch'; + END IF; + IF job.permissioned_as_email IS DISTINCT FROM NEW.__email THEN + RAISE EXCEPTION 'permissioned_as_email mismatch'; + END IF; + IF job.kind IS DISTINCT FROM NEW.__job_kind THEN + RAISE EXCEPTION 'kind mismatch'; + END IF; + IF job.runnable_id IS DISTINCT FROM NEW.__script_hash THEN + RAISE EXCEPTION 'runnable_id mismatch'; + END IF; + IF job.runnable_path IS DISTINCT FROM NEW.__script_path THEN + RAISE EXCEPTION 'runnable_path mismatch'; + END IF; + IF job.parent_job IS DISTINCT FROM NEW.__parent_job THEN + RAISE EXCEPTION 'parent_job mismatch'; + END IF; + IF job.script_lang IS DISTINCT FROM NEW.__language THEN + RAISE EXCEPTION 'script_lang mismatch'; + END IF; + IF job.script_entrypoint_override IS DISTINCT FROM NULLIF(NEW.__args->>'_ENTRYPOINT_OVERRIDE', '__WM_PREPROCESSOR') + AND NEW.__args->>'reason' IS DISTINCT FROM 'PREPROCESSOR_ARGS_ARE_DISCARDED' + THEN + RAISE EXCEPTION 'script_entrypoint_override mismatch'; + END IF; + IF (job.flow_step_id IS NOT NULL) IS DISTINCT FROM NEW.__is_flow_step THEN + RAISE EXCEPTION 'is_flow_step mismatch'; + END IF; + IF job.trigger IS DISTINCT FROM NEW.__schedule_path THEN + RAISE EXCEPTION 'trigger mismatch'; + END IF; + IF job.visible_to_owner IS DISTINCT FROM NEW.__visible_to_owner THEN + RAISE EXCEPTION 'visible_to_owner mismatch'; + END IF; + IF job.args::TEXT IS DISTINCT FROM NEW.__args::TEXT AND NEW.__args->>'_ENTRYPOINT_OVERRIDE' IS DISTINCT FROM '__WM_PREPROCESSOR' THEN + RAISE EXCEPTION 'args mismatch'; + END IF; + RETURN NEW; +END $$ LANGUAGE PLPGSQL; + +CREATE OR REPLACE TRIGGER zzz_v2_job_completed_integrity_check_after_insert + AFTER INSERT ON v2_job_completed + FOR EACH ROW +EXECUTE FUNCTION zzz_v2_job_completed_integrity_check(); diff --git a/backend/tests/fixtures/hello.sql b/backend/tests/fixtures/hello.sql index 31490ce087..f273cdfeaa 100644 --- a/backend/tests/fixtures/hello.sql +++ b/backend/tests/fixtures/hello.sql @@ -13,6 +13,23 @@ export function main(world: string) { '', 'f/system/hello', 123412, 'deno', ''); +INSERT INTO public.script(workspace_id, created_by, content, schema, summary, description, path, hash, language, lock) VALUES ( +'test-workspace', +'system', +' +export async function preprocessor() { + return { foo: ''bar'', bar: ''baz'' }; +} + +export async function main(foo: string, bar: string) { + return ''Hello '' + foo + '' '' + bar; +} +', +'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"foo":{"default":null,"description":"","originalType":"string","type":"string"},"bar":{"default":null,"description":"","originalType":"string","type":"string"}},"required":["foo","bar"],"type":"object"}', +'', +'', +'f/system/hello_with_preprocessor', 123413, 'deno', ''); + INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES ( 'test-workspace', '', @@ -40,7 +57,7 @@ INSERT INTO public.flow(workspace_id, summary, description, path, versions, sche 'f/system/hello_with_nodes_flow', '{1443253234253454}', '{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"world":{"default":"world","description":"","type":"string"}},"required":[],"type":"object"}', -E'{"modules":[{"id":"a","value":{"type":"forloopflow","modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(world: string) {\\n const greet = `Hello ${world}!`;\\n console.log(greet)\\n return greet\\n}\\n","language":"deno","input_transforms":{"world":{"type":"javascript","expr":"flow_input.iter.value"}},"is_trigger":false}},{"id":"c","value":{"type":"rawscript","content":"export function main(hello: string) {\\n const dareyou = `Did you just say \\"${hello}\\"??!`;\\n console.log(dareyou)\\n return dareyou\\n}","language":"deno","input_transforms":{"hello":{"type":"javascript","value":"${results.b}","expr":"`${results.b}`"}},"is_trigger":false}}],"iterator":{"type":"javascript","expr":"[\'foo\', \'bar\', \'baz\']"},"skip_failures":true,"parallel":false}}],"same_worker":false}', +E'{"modules":[{"id":"a","value":{"type":"forloopflow","modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(world: string) {\\n const greet = `Hello ${world}!`;\\n console.log(greet)\\n return greet\\n}\\n","language":"deno","input_transforms":{"world":{"type":"javascript","expr":"flow_input.iter.value"}},"is_trigger":false}},{"id":"c","value":{"type":"rawscript","content":"export function main(hello: string) {\\n const dareyou = `Did you just say \\"${hello}\\"??!`;\\n console.log(dareyou)\\n return dareyou\\n}","language":"deno","input_transforms":{"hello":{"type":"javascript","value":"${results.b}","expr":"`${results.b}`"}},"is_trigger":false}}],"iterator":{"type":"javascript","expr":"[''foo'', ''bar'', ''baz'']"},"skip_failures":true,"parallel":false}}],"same_worker":false}', 'system' ); @@ -49,6 +66,26 @@ INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_b 'test-workspace', 'f/system/hello_with_nodes_flow', '{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"world":{"default":"world","description":"","type":"string"}},"required":[],"type":"object"}', -E'{"modules":[{"id":"a","value":{"type":"forloopflow","modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(world: string) {\\n const greet = `Hello ${world}!`;\\n console.log(greet)\\n return greet\\n}\\n","language":"deno","input_transforms":{"world":{"type":"javascript","expr":"flow_input.iter.value"}},"is_trigger":false}},{"id":"c","value":{"type":"rawscript","content":"export function main(hello: string) {\\n const dareyou = `Did you just say \\"${hello}\\"??!`;\\n console.log(dareyou)\\n return dareyou\\n}","language":"deno","input_transforms":{"hello":{"type":"javascript","value":"${results.b}","expr":"`${results.b}`"}},"is_trigger":false}}],"iterator":{"type":"javascript","expr":"[\'foo\', \'bar\', \'baz\']"},"skip_failures":true,"parallel":false}}],"same_worker":false}', +E'{"modules":[{"id":"a","value":{"type":"forloopflow","modules":[{"id":"b","value":{"type":"rawscript","content":"export function main(world: string) {\\n const greet = `Hello ${world}!`;\\n console.log(greet)\\n return greet\\n}\\n","language":"deno","input_transforms":{"world":{"type":"javascript","expr":"flow_input.iter.value"}},"is_trigger":false}},{"id":"c","value":{"type":"rawscript","content":"export function main(hello: string) {\\n const dareyou = `Did you just say \\"${hello}\\"??!`;\\n console.log(dareyou)\\n return dareyou\\n}","language":"deno","input_transforms":{"hello":{"type":"javascript","value":"${results.b}","expr":"`${results.b}`"}},"is_trigger":false}}],"iterator":{"type":"javascript","expr":"[''foo'', ''bar'', ''baz'']"},"skip_failures":true,"parallel":false}}],"same_worker":false}', +'system' +); + +INSERT INTO public.flow(workspace_id, summary, description, path, versions, schema, value, edited_by) VALUES ( +'test-workspace', +'', +'', +'f/system/hello_with_preprocessor', +'{1443253234253456}', +'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"foo":{"type":"string","description":"","default":""},"bar":{"type":"string","description":"","default":""}},"required":[],"type":"object","order":["foo","bar"]}', +E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export async function main(foo: string, bar: string) {\\n return ''Hello '' + foo + ''-'' + bar\\n}\\n","language":"deno","is_trigger":false,"input_transforms":{"bar":{"expr":"flow_input.bar","type":"javascript"},"foo":{"expr":"flow_input.foo","type":"javascript"}}}}],"preprocessor_module":{"id":"preprocessor","value":{"type":"rawscript","content":"export async function preprocessor(\\n\\twm_trigger: {\\n\\t\\tkind: ''http'' | ''email'' | ''webhook'' | ''websocket'' | ''kafka'' | ''nats'',\\n\\t\\thttp?: {\\n\\t\\t\\troute: string\\n\\t\\t\\tpath: string\\n\\t\\t\\tmethod: string\\n\\t\\t\\tparams: Record\\n\\t\\t\\tquery: Record\\n\\t\\t\\theaders: Record\\n\\t\\t},\\n\\t\\twebsocket?: {\\n\\t\\t\\turl: string\\n\\t\\t},\\n\\t\\tkafka?: {\\n\\t\\t\\tbrokers: string[]\\n\\t\\t\\ttopic: string\\n\\t\\t\\tgroup_id: string\\n\\t\\t},\\n\\t\\tnats?: {\\n\\t\\t\\tservers: string[]\\n\\t\\t\\tsubject: string\\n\\t\\t\\theaders?: Record\\n\\t\\t\\tstatus?: number\\n\\t\\t\\tdescription?: string\\n\\t\\t\\tlength: number\\n\\t\\t}\\n\\t},\\n) {\\n\\treturn {\\n\\t\\tfoo: ''bar'',\\n\\t\\tbar: ''baz''\\n\\t}\\n}","language":"deno","is_trigger":false,"input_transforms":{"wm_trigger":{"type":"static"}}}}}', +'system' +); + +INSERT INTO public.flow_version(id, workspace_id, path, schema, value, created_by) VALUES ( +1443253234253456, +'test-workspace', +'f/system/hello_with_preprocessor', +'{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"foo":{"type":"string","description":"","default":""},"bar":{"type":"string","description":"","default":""}},"required":[],"type":"object","order":["foo","bar"]}', +E'{"modules":[{"id":"a","value":{"type":"rawscript","content":"export async function main(foo: string, bar: string) {\\n return ''Hello '' + foo + ''-'' + bar\\n}\\n","language":"deno","is_trigger":false,"input_transforms":{"bar":{"expr":"flow_input.bar","type":"javascript"},"foo":{"expr":"flow_input.foo","type":"javascript"}}}}],"preprocessor_module":{"id":"preprocessor","value":{"type":"rawscript","content":"export async function preprocessor(\\n\\twm_trigger: {\\n\\t\\tkind: ''http'' | ''email'' | ''webhook'' | ''websocket'' | ''kafka'' | ''nats'',\\n\\t\\thttp?: {\\n\\t\\t\\troute: string\\n\\t\\t\\tpath: string\\n\\t\\t\\tmethod: string\\n\\t\\t\\tparams: Record\\n\\t\\t\\tquery: Record\\n\\t\\t\\theaders: Record\\n\\t\\t},\\n\\t\\twebsocket?: {\\n\\t\\t\\turl: string\\n\\t\\t},\\n\\t\\tkafka?: {\\n\\t\\t\\tbrokers: string[]\\n\\t\\t\\ttopic: string\\n\\t\\t\\tgroup_id: string\\n\\t\\t},\\n\\t\\tnats?: {\\n\\t\\t\\tservers: string[]\\n\\t\\t\\tsubject: string\\n\\t\\t\\theaders?: Record\\n\\t\\t\\tstatus?: number\\n\\t\\t\\tdescription?: string\\n\\t\\t\\tlength: number\\n\\t\\t}\\n\\t},\\n) {\\n\\treturn {\\n\\t\\tfoo: ''bar'',\\n\\t\\tbar: ''baz''\\n\\t}\\n}","language":"deno","is_trigger":false,"input_transforms":{"wm_trigger":{"type":"static"}}}}}', 'system' ); diff --git a/backend/tests/fixtures/result_format.sql b/backend/tests/fixtures/result_format.sql index 1f990e2d86..2cf8fa7299 100644 --- a/backend/tests/fixtures/result_format.sql +++ b/backend/tests/fixtures/result_format.sql @@ -1,3 +1,9 @@ +INSERT INTO public.v2_job ( + id, workspace_id, created_by, created_at, kind, script_lang +) VALUES ( + '1eecb96a-c8b0-4a3d-b1b6-087878c55e41', 'test-workspace', 'test-user', '2023-01-01 00:00:00', 'script', 'postgresql' +); + INSERT INTO public.completed_job ( id, workspace_id, created_by, created_at, duration_ms, success, flow_status, result, job_kind, language ) VALUES ( diff --git a/backend/tests/worker.rs b/backend/tests/worker.rs index 001b15ac45..2b4768c34e 100644 --- a/backend/tests/worker.rs +++ b/backend/tests/worker.rs @@ -18,8 +18,6 @@ use tokio::time::{timeout, Duration}; use windmill_api_client::types::{CreateFlowBody, RawScript}; -use sqlx::query; - #[cfg(feature = "enterprise")] use windmill_api_client::types::{EditSchedule, NewSchedule, ScriptArgs}; @@ -191,7 +189,6 @@ async fn set_jwt_secret() -> () { mod suspend_resume { use serde_json::json; - use sqlx::query_scalar; use super::*; @@ -202,11 +199,13 @@ mod suspend_resume { ) { loop { queue.by_ref().find(&flow).await.unwrap(); - if query_scalar("SELECT suspend > 0 FROM queue WHERE id = $1") - .bind(flow) - .fetch_one(db) - .await - .unwrap() + if sqlx::query_scalar!( + "SELECT suspend > 0 AS \"r!\" FROM v2_job_queue WHERE id = $1", + flow + ) + .fetch_one(db) + .await + .unwrap() { break; } @@ -360,7 +359,7 @@ mod suspend_resume { // ensure resumes are cleaned up through CASCADE when the flow is finished assert_eq!( 0, - query_scalar::<_, i64>("SELECT count(*) FROM resume_job") + sqlx::query_scalar!("SELECT count(*) AS \"count!\" FROM resume_job") .fetch_one(&db) .await .unwrap() @@ -927,7 +926,7 @@ impl RunJob { /* root job */ None, /* job_id */ None, /* is_flow_step */ false, - /* running */ false, + /* same_worker */ false, None, true, None, @@ -951,6 +950,21 @@ impl RunJob { let r = completed_job(uuid, db).await; r } + + /// push the job, spawn a worker, wait until the job is in completed_job + async fn run_until_complete_with>( + self, + db: &Pool, + port: u16, + test: impl Fn(Uuid) -> F, + ) -> CompletedJob { + let uuid = self.push(db).await; + let listener = listen_for_completed_jobs(db).await; + test(uuid).await; + in_test_worker(db, listener.find(&uuid), port).await; + let r = completed_job(uuid, db).await; + r + } } async fn run_job_in_new_worker_until_complete( @@ -1049,11 +1063,11 @@ fn spawn_test_worker( } async fn listen_for_completed_jobs(db: &Pool) -> impl Stream + Unpin { - listen_for_uuid_on(db, "insert on completed_job").await + listen_for_uuid_on(db, "completed").await } async fn listen_for_queue(db: &Pool) -> impl Stream + Unpin { - listen_for_uuid_on(db, "queue").await + listen_for_uuid_on(db, "queued").await } async fn listen_for_uuid_on( @@ -1078,7 +1092,7 @@ async fn listen_for_uuid_on( async fn completed_job(uuid: Uuid, db: &Pool) -> CompletedJob { sqlx::query_as::<_, CompletedJob>( - "SELECT *, result->'wm_labels' as labels FROM completed_job WHERE id = $1", + "SELECT *, result->'wm_labels' as labels FROM v2_as_completed_job WHERE id = $1", ) .bind(uuid) .fetch_one(db) @@ -3190,11 +3204,13 @@ async fn test_script_schedule_handlers(db: Pool) { let uuid = uuid.unwrap().unwrap(); - let completed_job = - query!("SELECT script_path FROM completed_job WHERE id = $1", uuid) - .fetch_one(&db2) - .await - .unwrap(); + let completed_job = sqlx::query!( + "SELECT script_path FROM v2_as_completed_job WHERE id = $1", + uuid + ) + .fetch_one(&db2) + .await + .unwrap(); if completed_job.script_path.is_none() || completed_job.script_path != Some("f/system/schedule_error_handler".to_string()) @@ -3259,7 +3275,7 @@ async fn test_script_schedule_handlers(db: Pool) { let uuid = uuid.unwrap().unwrap(); let completed_job = - query!("SELECT script_path FROM completed_job WHERE id = $1", uuid) + sqlx::query!("SELECT script_path FROM v2_as_completed_job WHERE id = $1", uuid) .fetch_one(&db2) .await .unwrap(); @@ -3342,11 +3358,13 @@ async fn test_flow_schedule_handlers(db: Pool) { let uuid = uuid.unwrap().unwrap(); - let completed_job = - query!("SELECT script_path FROM completed_job WHERE id = $1", uuid) - .fetch_one(&db2) - .await - .unwrap(); + let completed_job = sqlx::query!( + "SELECT script_path FROM v2_as_completed_job WHERE id = $1", + uuid + ) + .fetch_one(&db2) + .await + .unwrap(); if completed_job.script_path.is_none() || completed_job.script_path != Some("f/system/schedule_error_handler".to_string()) @@ -3412,7 +3430,7 @@ async fn test_flow_schedule_handlers(db: Pool) { let uuid = uuid.unwrap().unwrap(); let completed_job = - query!("SELECT script_path FROM completed_job WHERE id = $1", uuid) + sqlx::query!("SELECT script_path FROM v2_as_completed_job WHERE id = $1", uuid) .fetch_one(&db2) .await .unwrap(); @@ -3487,7 +3505,7 @@ async fn run_deployed_relative_imports( async move { completed.next().await; // deployed script - let script = query!( + let script = sqlx::query!( "SELECT hash FROM script WHERE path = $1", "f/system/test_import".to_string() ) @@ -3743,6 +3761,73 @@ async fn test_result_format(db: Pool) { assert_eq!(result.get(), correct_result); } +#[sqlx::test(fixtures("base"))] +async fn test_job_labels(db: Pool) { + initialize_tracing().await; + let server = ApiServer::start(db.clone()).await; + let port = server.addr.port(); + + let db = &db; + let test = |original_labels: &'static [&'static str]| async move { + let job = RunJob::from(JobPayload::RawFlow { + value: serde_json::from_value(json!({ + "modules": [{ + "id": "a", + "value": { + "type": "rawscript", + "content": r#"export function main(world: string) { + const greet = `Hello ${world}!`; + console.log(greet) + return { greet, wm_labels: ["yolo", "greet", "greet", world] }; + }"#, + "language": "deno", + "input_transforms": { + "world": { "type": "javascript", "expr": "flow_input.world" } + } + } + }], + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { "world": { "type": "string" } }, + "type": "object", + "order": [ "world" ] + } + })) + .unwrap(), + path: None, + restarted_from: None, + }) + .arg("world", json!("you")) + .run_until_complete_with(&db, port, |id| async move { + sqlx::query!( + "UPDATE v2_job SET labels = $2 WHERE id = $1 AND $2::TEXT[] IS NOT NULL", + id, + original_labels as &[&str], + ) + .execute(db) + .await + .unwrap(); + }) + .await; + + let result = job.json_result().unwrap(); + assert_eq!(result.get("greet"), Some(&json!("Hello you!"))); + let labels = sqlx::query_scalar!("SELECT labels FROM v2_job WHERE id = $1", job.id) + .fetch_one(db) + .await + .unwrap(); + let mut expected_labels = original_labels + .iter() + .chain(&["yolo", "greet", "you"]) + .map(ToString::to_string) + .collect::>(); + expected_labels.sort(); + assert_eq!(labels, Some(expected_labels)); + }; + test(&[]).await; + test(&["z", "a", "x"]).await; +} + async fn test_for_versions>( version_flags: impl Iterator>>, test: impl Fn() -> F, @@ -3799,6 +3884,53 @@ mod job_payload { test_for_versions(VERSION_FLAGS.iter().cloned(), test).await; } + #[sqlx::test(fixtures("base", "hello"))] + async fn test_script_hash_payload_with_preprocessor(db: Pool) { + initialize_tracing().await; + let server = ApiServer::start(db.clone()).await; + let port = server.addr.port(); + + let test = || async { + let db = &db; + let job = RunJob::from(JobPayload::ScriptHash { + hash: ScriptHash(123413), + path: "f/system/hello_with_preprocessor".to_string(), + custom_concurrency_key: None, + concurrent_limit: None, + concurrency_time_window_s: None, + cache_ttl: None, + dedicated_worker: None, + language: ScriptLang::Deno, + priority: None, + apply_preprocessor: true, + }) + .run_until_complete_with(db, port, |id| async move { + let job = sqlx::query!("SELECT preprocessed FROM v2_job WHERE id = $1", id) + .fetch_one(db) + .await + .unwrap(); + assert_eq!(job.preprocessed, Some(false)); + }) + .await; + + let args = job.args.as_ref().unwrap(); + assert_eq!(args.get("foo"), Some(&json!("bar"))); + assert_eq!(args.get("bar"), Some(&json!("baz"))); + // TODO: remove this check on v2 phase 4 + assert_eq!( + job.flow_status.as_ref().unwrap().get("_metadata"), + Some(&json!({"preprocessed_args": true})) + ); + assert_eq!(job.json_result().unwrap(), json!("Hello bar baz")); + let job = sqlx::query!("SELECT preprocessed FROM v2_job WHERE id = $1", job.id) + .fetch_one(db) + .await + .unwrap(); + assert_eq!(job.preprocessed, Some(true)); + }; + test_for_versions(VERSION_FLAGS.iter().cloned(), test).await; + } + #[sqlx::test(fixtures("base", "hello"))] async fn test_flow_script_payload(db: Pool) { initialize_tracing().await; @@ -4081,7 +4213,7 @@ mod job_payload { let result = RunJob::from(JobPayload::Flow { path: "f/system/hello_with_nodes_flow".to_string(), dedicated_worker: None, - apply_preprocessor: true, + apply_preprocessor: false, }) .run_until_complete(&db, port) .await @@ -4113,6 +4245,73 @@ mod job_payload { test_for_versions(VERSION_FLAGS.iter().cloned(), test).await; } + #[sqlx::test(fixtures("base", "hello"))] + async fn test_flow_payload_with_preprocessor(db: Pool) { + initialize_tracing().await; + let server = ApiServer::start(db.clone()).await; + let port = server.addr.port(); + + let db = &db; + let test = || async { + let job = RunJob::from(JobPayload::Flow { + path: "f/system/hello_with_preprocessor".to_string(), + dedicated_worker: None, + apply_preprocessor: true, + }) + .run_until_complete_with(db, port, |id| async move { + let job = sqlx::query!("SELECT preprocessed FROM v2_job WHERE id = $1", id) + .fetch_one(db) + .await + .unwrap(); + assert_eq!(job.preprocessed, Some(false)); + }) + .await; + + let args = job.args.as_ref().unwrap(); + let flow_status = job.flow_status.as_ref().unwrap(); + assert_eq!(args.get("foo"), Some(&json!("bar"))); + assert_eq!(args.get("bar"), Some(&json!("baz"))); + assert_eq!(job.json_result().unwrap(), json!("Hello bar-baz")); + let job = sqlx::query!("SELECT preprocessed FROM v2_job WHERE id = $1", job.id) + .fetch_one(db) + .await + .unwrap(); + assert_eq!(job.preprocessed, Some(true)); + let flow_status = serde_json::from_value::(flow_status.clone()).unwrap(); + let FlowStatusModule::Success { job, .. } = flow_status.preprocessor_module.unwrap() + else { + panic!("Expected a success preprocessor module"); + }; + let pp_id = job; + let job = sqlx::query!( + "SELECT preprocessed, script_entrypoint_override FROM v2_job WHERE id = $1", + pp_id + ) + .fetch_one(db) + .await + .unwrap(); + assert_eq!(job.preprocessed, Some(true)); + assert_eq!( + job.script_entrypoint_override.as_deref(), + Some("preprocessor") + ); + }; + // Test the not "lite" flow. + test_for_versions(VERSION_FLAGS.iter().cloned(), test).await; + // Deploy the flow to produce the "lite" version. + let _ = RunJob::from(JobPayload::FlowDependencies { + path: "f/system/hello_with_preprocessor".to_string(), + dedicated_worker: None, + version: 1443253234253456, + }) + .run_until_complete(db, port) + .await + .json_result() + .unwrap(); + // Test the "lite" flow. + test_for_versions(VERSION_FLAGS.iter().cloned(), test).await; + } + #[sqlx::test(fixtures("base", "hello"))] async fn test_restarted_flow_payload(db: Pool) { initialize_tracing().await; diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index 1d9fd7fc05..6827f449db 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -1,7 +1,7 @@ openapi: "3.0.3" info: - version: 1.456.0 + version: 1.457.1 title: Windmill API contact: @@ -1751,9 +1751,13 @@ paths: deploy_to: type: string ai_resource: - $ref: "#/components/schemas/AiResource" - code_completion_enabled: - type: boolean + $ref: "#/components/schemas/AIResource" + code_completion_model: + type: string + ai_models: + type: array + items: + type: string error_handler: type: string error_handler_extra_args: @@ -1777,7 +1781,7 @@ paths: operator_settings: $ref: "#/components/schemas/OperatorSettings" required: - - code_completion_enabled + - ai_models - automatic_billing - error_handler_muted_on_cancel @@ -2228,12 +2232,16 @@ paths: schema: type: object required: - - code_completion_enabled + - ai_models properties: ai_resource: - $ref: "#/components/schemas/AiResource" - code_completion_enabled: - type: boolean + $ref: "#/components/schemas/AIResource" + code_completion_model: + type: string + ai_models: + type: array + items: + type: string responses: "200": description: status @@ -2260,15 +2268,18 @@ paths: type: object properties: ai_provider: - type: string + $ref: "#/components/schemas/AIProvider" exists_ai_resource: type: boolean - code_completion_enabled: - type: boolean + code_completion_model: + type: string + ai_models: + type: array + items: + type: string required: - - ai_provider - exists_ai_resource - - code_completion_enabled + - ai_models /w/{workspace}/workspaces/edit_error_handler: post: @@ -11737,16 +11748,21 @@ components: schemas: $ref: "../../openflow.openapi.yaml#/components/schemas" - AiResource: + AIProvider: + type: string + enum: [openai, anthropic, mistral, deepseek, groq, openrouter, customai] + + AIResource: type: object properties: path: type: string provider: - type: string + $ref: "#/components/schemas/AIProvider" required: - path - provider + Script: type: object properties: @@ -12099,6 +12115,8 @@ components: type: number suspend: type: number + preprocessed: + type: boolean required: - id - running @@ -12206,6 +12224,8 @@ components: type: number aggregate_wait_time_ms: type: number + preprocessed: + type: boolean required: - id - created_by diff --git a/backend/windmill-api/src/ai.rs b/backend/windmill-api/src/ai.rs index 3b97ba18ce..d77943df9d 100644 --- a/backend/windmill-api/src/ai.rs +++ b/backend/windmill-api/src/ai.rs @@ -4,27 +4,21 @@ use crate::{ }; use anthropic::AnthropicCache; -use axum::{ - body::Bytes, - extract::{Path, Query}, - response::IntoResponse, - routing::post, - Extension, Router, -}; +use anyhow::Context; +use axum::{body::Bytes, extract::Path, response::IntoResponse, routing::post, Extension, Router}; +use http::HeaderMap; use lazy_static::lazy_static; -use mistral::MistralCache; -use openai::OpenaiCache; use quick_cache::sync::Cache; use reqwest::{Client, RequestBuilder}; -use serde::{Deserialize, Deserializer}; -use windmill_audit::audit_ee::audit_log; -use windmill_audit::ActionKind; -use windmill_common::error::{to_anyhow, Result}; - -use windmill_common::error::Error; - +use serde::{Deserialize, Serialize}; use serde_json::value::{RawValue, Value}; use std::collections::HashMap; +use windmill_audit::{audit_ee::audit_log, ActionKind}; +use windmill_common::error::{to_anyhow, Error, Result}; + +use mistral::MistralCache; +use openai::OpenaiCache; +use openai_api_compatible::OpenaiApiCompatibleCache; lazy_static::lazy_static! { static ref HTTP_CLIENT: Client = reqwest::ClientBuilder::new() @@ -33,16 +27,63 @@ lazy_static::lazy_static! { .build().unwrap(); } -trait AiRequest { - fn prepare_request(self, path: &str, body: Bytes) -> Result; +mod openai_api_compatible { + use super::*; + + #[derive(Deserialize, Clone, Debug)] + pub struct OpenaiApiCompatibleCache { + pub base_url: String, + pub api_key: Option, + } + + impl OpenaiApiCompatibleCache { + pub fn prepare_request(self, path: &str, body: Bytes) -> Result { + let url = format!("{}/{}", self.base_url, path); + + let mut request = HTTP_CLIENT + .post(url) + .header("content-type", "application/json") + .body(body); + + if let Some(api_key) = self.api_key { + request = request.header("Authorization", format!("Bearer {}", api_key)); + } + + Ok(request) + } + } + + pub async fn get_cached_value( + db: &DB, + w_id: &str, + resource: Value, + base_url: Option, + ) -> Result { + let mut resource: OpenaiApiCompatibleCache = if let Some(base_url) = base_url { + let api_key = match resource { + Value::Object(mut obj) => obj + .remove("api_key") + .map(|v| serde_json::from_value::(v.clone()).ok()) + .flatten(), + _ => None, + }; + OpenaiApiCompatibleCache { base_url, api_key } + } else { + serde_json::from_value(resource).with_context(|| "validating custom AI resource")? + }; + + if let Some(api_key) = resource.api_key { + resource.api_key = Some(get_variable_or_self(api_key, db, w_id).await?); + } + + Ok(KeyCache::OpenaiApiCompatible(resource)) + } } mod openai { use super::*; - use super::{get_variable_or_self, KeyCache}; - - const API_VERSION: &str = "2023-05-15"; + const API_VERSION: &str = "2024-10-21"; #[derive(Deserialize, Debug)] struct OpenaiResource { @@ -94,14 +135,14 @@ mod openai { } const BASE_URL: &str = "https://api.openai.com/v1"; - impl AiRequest for OpenaiCache { - fn prepare_request(self, openai_path: &str, mut body: Bytes) -> Result { + impl OpenaiCache { + pub fn prepare_request(self, openai_path: &str, mut body: Bytes) -> Result { let OpenaiCache { api_key, azure_base_path, organization_id, user } = self; if user.is_some() { tracing::debug!("Adding user to request body"); let mut json_body: HashMap> = serde_json::from_slice(&body) .map_err(|e| { - Error::InternalErr(format!("Failed to parse request body: {}", e)) + Error::internal_err(format!("Failed to parse request body: {}", e)) })?; let user_json_string = serde_json::Value::String(user.unwrap()).to_string(); // makes sure to escape characters @@ -109,12 +150,12 @@ mod openai { json_body.insert( "user".to_string(), RawValue::from_string(user_json_string) - .map_err(|e| Error::InternalErr(format!("Failed to parse user: {}", e)))?, + .map_err(|e| Error::internal_err(format!("Failed to parse user: {}", e)))?, ); body = serde_json::to_vec(&json_body) .map_err(|e| { - Error::InternalErr(format!("Failed to reserialize request body: {}", e)) + Error::internal_err(format!("Failed to reserialize request body: {}", e)) })? .into(); } @@ -163,13 +204,13 @@ mod openai { .send() .await .map_err(|err| { - Error::InternalErr(format!( + Error::internal_err(format!( "Failed to get OpenAI credentials using credentials flow: {}", err )) })?; let response = response.json::().await.map_err(|err| { - Error::InternalErr(format!( + Error::internal_err(format!( "Failed to parse OpenAI credentials from credentials flow: {}", err )) @@ -179,7 +220,7 @@ mod openai { pub async fn get_cached_value(db: &DB, w_id: &str, resource: Value) -> Result { let config = serde_json::from_value(resource) - .map_err(|e| Error::InternalErr(format!("validating openai resource {e:#}")))?; + .map_err(|e| Error::internal_err(format!("validating openai resource {e:#}")))?; let mut user = None::; let mut resource = match config { @@ -216,7 +257,7 @@ mod openai { let azure_base_path = if let Some(azure_base_path) = azure_base_path { Some( serde_json::from_value::(azure_base_path).map_err(|e| { - Error::InternalErr(format!("validating openai azure base path {e:#}")) + Error::internal_err(format!("validating openai azure base path {e:#}")) })?, ) } else { @@ -245,15 +286,9 @@ mod anthropic { const API_VERSION: &str = "2023-06-01"; - impl AnthropicCache { - pub fn new(api_key: String) -> Self { - Self { api_key } - } - } - const BASE_URL: &str = "https://api.anthropic.com"; - impl AiRequest for AnthropicCache { - fn prepare_request(self, anthropic_path: &str, body: Bytes) -> Result { + impl AnthropicCache { + pub fn prepare_request(self, anthropic_path: &str, body: Bytes) -> Result { let AnthropicCache { api_key } = self; let url = format!("{}/{}", BASE_URL, anthropic_path); let request = HTTP_CLIENT @@ -268,10 +303,9 @@ mod anthropic { pub async fn get_cached_value(db: &DB, w_id: &str, resource: Value) -> Result { let mut resource: AnthropicCache = serde_json::from_value(resource) - .map_err(|e| Error::InternalErr(format!("validating anthropic resource {e:#}")))?; + .map_err(|e| Error::internal_err(format!("validating anthropic resource {e:#}")))?; resource.api_key = get_variable_or_self(resource.api_key, db, w_id).await?; - let workspace_cache = AnthropicCache::new(resource.api_key); - Ok(KeyCache::Anthropic(workspace_cache)) + Ok(KeyCache::Anthropic(resource)) } } @@ -283,15 +317,9 @@ mod mistral { pub api_key: String, } - impl MistralCache { - pub fn new(api_key: String) -> Self { - Self { api_key } - } - } - const BASE_URL: &str = "https://api.mistral.ai"; - impl AiRequest for MistralCache { - fn prepare_request(self, mistral_path: &str, body: Bytes) -> Result { + impl MistralCache { + pub fn prepare_request(self, mistral_path: &str, body: Bytes) -> Result { let MistralCache { api_key } = self; let url = format!("{}/{}", BASE_URL, mistral_path); @@ -307,11 +335,9 @@ mod mistral { pub async fn get_cached_value(db: &DB, w_id: &str, resource: Value) -> Result { let mut resource: MistralCache = serde_json::from_value(resource) - .map_err(|e| Error::InternalErr(format!("validating mistral resource {e:#}")))?; + .map_err(|e| Error::internal_err(format!("validating mistral resource {e:#}")))?; resource.api_key = get_variable_or_self(resource.api_key, db, w_id).await?; - - let workspace_cache = MistralCache::new(resource.api_key); - Ok(KeyCache::Mistral(workspace_cache)) + Ok(KeyCache::Mistral(resource)) } } @@ -320,16 +346,17 @@ pub enum KeyCache { Openai(OpenaiCache), Anthropic(AnthropicCache), Mistral(MistralCache), + OpenaiApiCompatible(OpenaiApiCompatibleCache), } #[derive(Clone, Debug)] -pub struct AiCache { +pub struct AICache { pub path: String, pub cached_key: KeyCache, pub expires_at: std::time::Instant, } -impl AiCache { +impl AICache { pub fn new(path: String, cached_key: KeyCache) -> Self { Self { path, @@ -343,35 +370,57 @@ impl AiCache { } lazy_static! { - pub static ref AI_KEY_CACHE: Cache = Cache::new(500); + pub static ref AI_KEY_CACHE: Cache = Cache::new(500); } -#[derive(Deserialize, Debug)] -struct ProxyQueryParams { - no_cache: Option, +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "lowercase")] +pub enum AIProvider { + OpenAI, + Anthropic, + Mistral, + DeepSeek, + Groq, + OpenRouter, + CustomAI, } -#[derive(Deserialize, Debug)] -pub struct AiResource { - pub path: String, - #[serde(deserialize_with = "check_if_valid_ai_provider")] - pub provider: String, -} - -fn check_if_valid_ai_provider<'de, D>(provider: D) -> std::result::Result -where - D: Deserializer<'de>, -{ - let provider = String::deserialize(provider)?; - match provider.as_str() { - "anthropic" | "openai" | "mistral" => Ok(provider), - _ => Err(serde::de::Error::custom( - "Only the following Ai providers are supported: openai, anthropic and mistral" - .to_string(), - )), +impl AIProvider { + pub fn get_openai_compatible_base_url(&self) -> Result> { + match self { + AIProvider::DeepSeek => Ok(Some("https://api.deepseek.com/v1".to_string())), + AIProvider::Groq => Ok(Some("https://api.groq.com/openai/v1".to_string())), + AIProvider::OpenRouter => Ok(Some("https://openrouter.ai/api/v1".to_string())), + AIProvider::CustomAI => Ok(None), + _ => Err(Error::BadRequest( + "Please use the specific provider instead of the OpenAI compatible one".to_string(), + )), + } } } +impl TryFrom<&str> for AIProvider { + type Error = Error; + fn try_from(s: &str) -> Result { + match s { + "openai" => Ok(AIProvider::OpenAI), + "anthropic" => Ok(AIProvider::Anthropic), + "mistral" => Ok(AIProvider::Mistral), + "groq" => Ok(AIProvider::Groq), + "openrouter" => Ok(AIProvider::OpenRouter), + "deepseek" => Ok(AIProvider::DeepSeek), + "customai" => Ok(AIProvider::CustomAI), + _ => Err(Error::BadRequest(format!("Invalid AI provider: {}", s))), + } + } +} + +#[derive(Deserialize, Debug)] +pub struct AIResource { + pub path: String, + pub provider: AIProvider, +} + pub fn workspaced_service() -> Router { let router = Router::new().route("/proxy/*ai", post(proxy)); @@ -382,74 +431,105 @@ async fn proxy( authed: ApiAuthed, Extension(db): Extension, Path((w_id, ai_path)): Path<(String, String)>, - Query(query_params): Query, + headers: HeaderMap, body: Bytes, ) -> impl IntoResponse { let workspace_cache = AI_KEY_CACHE.get(&w_id); + let forced_resource_path = headers + .get("X-Resource-Path") + .map(|v| v.to_str().unwrap_or("").to_string()); let ai_cache = match workspace_cache { - Some(cache) if !cache.is_expired() && !query_params.no_cache.unwrap_or(false) => { - cache.cached_key - } + Some(cache) if !cache.is_expired() && forced_resource_path.is_none() => cache.cached_key, _ => { - let ai_resource = sqlx::query_scalar!( - "SELECT ai_resource FROM workspace_settings WHERE workspace_id = $1", - &w_id - ) - .fetch_one(&db) - .await?; + let (resource, resource_path, ai_provider) = if let Some(resource_path) = + forced_resource_path + { + // guess the provider from the resource type + let record = sqlx::query!( + "SELECT value, resource_type FROM resource WHERE path = $1 AND workspace_id = $2", + &resource_path, + &w_id + ) + .fetch_optional(&db) + .await? + .ok_or_else(|| { + Error::NotFound(format!( + "Could not find the resource {}, update the resource path in the workspace settings", resource_path + )) + })?; - if ai_resource.is_none() { - return Err(Error::InternalErr("AI resource not configured".to_string())); - } + ( + record.value, + resource_path, + AIProvider::try_from(record.resource_type.as_str())?, + ) + } else { + let ai_resource = sqlx::query_scalar!( + "SELECT ai_resource FROM workspace_settings WHERE workspace_id = $1", + &w_id + ) + .fetch_one(&db) + .await?; - let ai_resource = serde_json::from_value::(ai_resource.unwrap()) - .map_err(|e| Error::BadRequest(e.to_string()))?; - let ai_resource_path = ai_resource.path; + if ai_resource.is_none() { + return Err(Error::internal_err("AI resource not configured".to_string())); + } - let resource = sqlx::query_scalar!( - "SELECT value - FROM resource - WHERE path = $1 AND workspace_id = $2", - &ai_resource_path, - &w_id - ) - .fetch_optional(&db) - .await? - .ok_or_else(|| { - Error::InternalErr(format!( - "Could not find the {} resource at path {ai_resource_path}, update the resource path in the workspace settings", ai_resource.provider - )) - })?; + let ai_resource = serde_json::from_value::(ai_resource.unwrap()) + .map_err(|e| Error::BadRequest(e.to_string()))?; + + let resource = sqlx::query_scalar!( + "SELECT value + FROM resource + WHERE path = $1 AND workspace_id = $2", + &ai_resource.path, + &w_id + ) + .fetch_optional(&db) + .await? + .ok_or_else(|| { + Error::NotFound(format!( + "Could not find the {:?} resource at path {}, update the resource path in the workspace settings", ai_resource.provider, ai_resource.path + )) + })?; + + (resource, ai_resource.path, ai_resource.provider) + }; if resource.is_none() { - return Err(Error::InternalErr(format!( - "{} resource missing value", - ai_resource.provider + return Err(Error::internal_err(format!( + "{:?} resource missing value", + ai_provider ))); } let resource = resource.unwrap(); - let ai_cache = match ai_resource.provider.as_str() { - "openai" => openai::get_cached_value(&db, &w_id, resource).await, - "anthropic" => anthropic::get_cached_value(&db, &w_id, resource).await, - "mistral" => mistral::get_cached_value(&db, &w_id, resource).await, - provider => { - return Err(Error::BadRequest(format!("{} is not supported", provider))) + let ai_cache = match ai_provider { + AIProvider::OpenAI => openai::get_cached_value(&db, &w_id, resource).await, + AIProvider::Anthropic => anthropic::get_cached_value(&db, &w_id, resource).await, + AIProvider::Mistral => mistral::get_cached_value(&db, &w_id, resource).await, + _ => { + openai_api_compatible::get_cached_value( + &db, + &w_id, + resource, + ai_provider.get_openai_compatible_base_url()?, + ) + .await } }; let ai_cache = ai_cache?; - AI_KEY_CACHE.insert( - w_id.clone(), - AiCache::new(ai_resource_path, ai_cache.clone()), - ); + AI_KEY_CACHE.insert(w_id.clone(), AICache::new(resource_path, ai_cache.clone())); ai_cache } }; - let (path, request) = match ai_cache { - KeyCache::Openai(cached) => ("openai_path", cached.prepare_request(&ai_path, body)), - KeyCache::Anthropic(cached) => ("anthropic_path", cached.prepare_request(&ai_path, body)), - KeyCache::Mistral(cached) => ("mistral_path", cached.prepare_request(&ai_path, body)), + + let request = match ai_cache { + KeyCache::Openai(cached) => cached.prepare_request(&ai_path, body), + KeyCache::Anthropic(cached) => cached.prepare_request(&ai_path, body), + KeyCache::Mistral(cached) => cached.prepare_request(&ai_path, body), + KeyCache::OpenaiApiCompatible(cached) => cached.prepare_request(&ai_path, body), }; let response = request?.send().await.map_err(to_anyhow)?; @@ -463,7 +543,7 @@ async fn proxy( ActionKind::Execute, &w_id, Some(&authed.email), - Some([(path, &format!("{:?}", ai_path)[..])].into()), + Some([("ai_resource_path", &format!("{:?}", ai_path)[..])].into()), ) .await?; tx.commit().await?; diff --git a/backend/windmill-api/src/apps.rs b/backend/windmill-api/src/apps.rs index bf134adc7f..952ff6d77e 100644 --- a/backend/windmill-api/src/apps.rs +++ b/backend/windmill-api/src/apps.rs @@ -360,7 +360,7 @@ async fn list_apps( .fields(&["dm.deployment_msg"]); } - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let mut tx = user_db.begin(&authed).await?; let rows = sqlx::query_as::<_, ListableApp>(&sql) .fetch_all(&mut *tx) @@ -611,7 +611,7 @@ async fn get_public_app_by_secret( let decrypted = mc .decrypt_bytes_to_bytes(&(hex::decode(secret)?)) - .map_err(|e| Error::InternalErr(e.to_string()))?; + .map_err(|e| Error::internal_err(e.to_string()))?; let bytes = str::from_utf8(&decrypted).map_err(to_anyhow)?; let id: i64 = bytes.parse().map_err(to_anyhow)?; @@ -958,7 +958,7 @@ async fn delete_app( .execute(&db) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error deleting deployment metadata for script with path {path} in workspace {w_id}: {e:#}" )) })?; @@ -1061,7 +1061,7 @@ async fn update_app( sqlb.returning("path"); - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let npath_o: Option = sqlx::query_scalar(&sql).fetch_optional(&mut *tx).await?; not_found_if_none(npath_o, "App", path)? } else { @@ -1710,7 +1710,7 @@ async fn upload_s3_file_from_app( } }; - let s3_resource = s3_resource_opt.ok_or(Error::InternalErr( + let s3_resource = s3_resource_opt.ok_or(Error::internal_err( "No files storage resource defined at the workspace level".to_string(), ))?; let s3_client = build_object_store_client(&s3_resource).await?; @@ -1794,7 +1794,7 @@ async fn check_if_allowed_to_access_s3_file_from_app( let allowed = opt_authed.is_some() || sqlx::query_scalar!( r#"SELECT EXISTS ( - SELECT 1 FROM completed_job + SELECT 1 FROM v2_as_completed_job WHERE workspace_id = $2 AND (job_kind = 'appscript' OR job_kind = 'preview') AND created_by = 'anonymous' @@ -2034,7 +2034,10 @@ async fn build_args( safe_args.insert( k.to_string(), to_raw_value(&value.unwrap_or(Ok(serde_json::Value::Null)).map_err(|e| { - Error::InternalErr(format!("failed to serialize ctx variable for {}: {}", k, e)) + Error::internal_err(format!( + "failed to serialize ctx variable for {}: {}", + k, e + )) })?), ); } else if !arg_str.contains("\"$var:") && !arg_str.contains("\"$res:") { @@ -2054,7 +2057,7 @@ async fn build_args( ), ) .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "failed to remove sensitive variable(s)/resource(s) with error: {}", e )) diff --git a/backend/windmill-api/src/auth.rs b/backend/windmill-api/src/auth.rs index 64024f1ab1..71c6270477 100644 --- a/backend/windmill-api/src/auth.rs +++ b/backend/windmill-api/src/auth.rs @@ -151,12 +151,16 @@ impl AuthCache { } } _ => { - let user_o = sqlx::query_as::<_, (Option, Option, bool, Option>, Option)>( - "UPDATE token SET last_used_at = now() WHERE token = $1 AND (expiration > NOW() \ - OR expiration IS NULL) AND (workspace_id IS NULL OR workspace_id = $2) RETURNING owner, email, super_admin, scopes, label", + let user_o = sqlx::query!( + "UPDATE token SET last_used_at = now() WHERE + token = $1 + AND (expiration > NOW() OR expiration IS NULL) + AND (workspace_id IS NULL OR workspace_id = $2) + RETURNING owner, email, super_admin, scopes, label", + token, + w_id.as_ref(), ) - .bind(token) - .bind(w_id.as_ref()) + .map(|x| (x.owner, x.email, x.super_admin, x.scopes, x.label)) .fetch_optional(&self.db) .await .ok() @@ -251,12 +255,13 @@ impl AuthCache { (_, Some(email), super_admin, scopes, label) => { let username_override = username_override_from_label(label); if w_id.is_some() { - let row_o = sqlx::query_as::<_, (String, bool, bool)>( - "SELECT username, is_admin, operator FROM usr where email = $1 AND \ - workspace_id = $2 AND disabled = false", + let row_o = sqlx::query!( + "SELECT username, is_admin, operator FROM usr WHERE + email = $1 AND workspace_id = $2 AND disabled = false", + &email, + w_id.as_ref().unwrap() ) - .bind(&email) - .bind(&w_id.as_ref().unwrap()) + .map(|x| (x.username, x.is_admin, x.operator)) .fetch_optional(&self.db) .await .unwrap_or(Some(("error".to_string(), false, false))); diff --git a/backend/windmill-api/src/capture.rs b/backend/windmill-api/src/capture.rs index fe752336f3..4b933b01b4 100644 --- a/backend/windmill-api/src/capture.rs +++ b/backend/windmill-api/src/capture.rs @@ -412,7 +412,7 @@ async fn get_capture_trigger_config_and_owner( Ok(( serde_json::from_str(trigger_config.get()).map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error parsing capture config for {} trigger: {}", kind, e )) diff --git a/backend/windmill-api/src/concurrency_groups.rs b/backend/windmill-api/src/concurrency_groups.rs index 945df75573..3f7e41617f 100644 --- a/backend/windmill-api/src/concurrency_groups.rs +++ b/backend/windmill-api/src/concurrency_groups.rs @@ -16,7 +16,7 @@ use sql_builder::bind::Bind; use sql_builder::SqlBuilder; use uuid::Uuid; use windmill_common::db::UserDB; -use windmill_common::error::Error::{InternalErr, PermissionDenied}; +use windmill_common::error::Error::PermissionDenied; use windmill_common::error::{self, JsonResult}; use windmill_common::utils::require_admin; @@ -82,7 +82,7 @@ async fn prune_concurrency_group( if n_job_uuids > 0 { tx.commit().await?; - return Err(InternalErr( + return Err(error::Error::internal_err( "Concurrency group is currently in use, unable to remove it. Retry later.".to_string(), )); } @@ -157,22 +157,22 @@ async fn get_concurrent_intervals( let lq = ListCompletedQuery { order_desc: Some(true), ..lq }; let lqc = lq.clone(); let lqq: ListQueueQuery = lqc.into(); - let mut sqlb_q = SqlBuilder::select_from("queue") + let mut sqlb_q = SqlBuilder::select_from("v2_as_queue") .fields(UnifiedJob::queued_job_fields()) .order_by("created_at", lq.order_desc.unwrap_or(true)) .limit(row_limit) .clone(); - let mut sqlb_c = SqlBuilder::select_from("completed_job") + let mut sqlb_c = SqlBuilder::select_from("v2_as_completed_job") .fields(UnifiedJob::completed_job_fields()) .order_by("started_at", lq.order_desc.unwrap_or(true)) .limit(row_limit) .clone(); - let mut sqlb_q_user = SqlBuilder::select_from("queue") + let mut sqlb_q_user = SqlBuilder::select_from("v2_as_queue") .fields(&["id"]) .order_by("created_at", lq.order_desc.unwrap_or(true)) .limit(row_limit) .clone(); - let mut sqlb_c_user = SqlBuilder::select_from("completed_job") + let mut sqlb_c_user = SqlBuilder::select_from("v2_as_completed_job") .fields(&["id"]) .order_by("started_at", lq.order_desc.unwrap_or(true)) .limit(row_limit) diff --git a/backend/windmill-api/src/db.rs b/backend/windmill-api/src/db.rs index 6cff3872e7..d6af3baf84 100644 --- a/backend/windmill-api/src/db.rs +++ b/backend/windmill-api/src/db.rs @@ -405,60 +405,60 @@ async fn fix_job_completed_index(db: &DB) -> Result<(), Error> { .await?; }); - run_windmill_migration!("fix_job_completed_index_4", &db, { + run_windmill_migration!("fix_job_index_1", &db, { let migration_job_name = "fix_job_completed_index_4"; let mut i = 1; tracing::info!("step {i} of {migration_job_name} migration"); - sqlx::query("create index concurrently if not exists ix_completed_job_workspace_id_created_at_new_3 ON completed_job (workspace_id, created_at DESC)") + sqlx::query!("create index concurrently if not exists ix_job_workspace_id_created_at_new_3 ON v2_job (workspace_id, created_at DESC)") .execute(db) .await?; i += 1; tracing::info!("step {i} of {migration_job_name} migration"); - sqlx::query("create index concurrently if not exists ix_completed_job_workspace_id_created_at_new_8 ON completed_job (workspace_id, created_at DESC) where job_kind in ('deploymentcallback') AND parent_job IS NULL") + sqlx::query!("create index concurrently if not exists ix_job_workspace_id_created_at_new_8 ON v2_job (workspace_id, created_at DESC) where kind in ('deploymentcallback') AND parent_job IS NULL") .execute(db) .await?; i += 1; tracing::info!("step {i} of {migration_job_name} migration"); - sqlx::query("create index concurrently if not exists ix_completed_job_workspace_id_created_at_new_9 ON completed_job (workspace_id, created_at DESC) where job_kind in ('dependencies', 'flowdependencies', 'appdependencies') AND parent_job IS NULL") + sqlx::query!("create index concurrently if not exists ix_job_workspace_id_created_at_new_9 ON v2_job (workspace_id, created_at DESC) where kind in ('dependencies', 'flowdependencies', 'appdependencies') AND parent_job IS NULL") .execute(db) .await?; i += 1; tracing::info!("step {i} of {migration_job_name} migration"); - sqlx::query("create index concurrently if not exists ix_completed_job_workspace_id_created_at_new_5 ON completed_job (workspace_id, created_at DESC) where job_kind in ('preview', 'flowpreview') AND parent_job IS NULL") + sqlx::query!("create index concurrently if not exists ix_job_workspace_id_created_at_new_5 ON v2_job (workspace_id, created_at DESC) where kind in ('preview', 'flowpreview') AND parent_job IS NULL") .execute(db) .await?; i += 1; tracing::info!("step {i} of {migration_job_name} migration"); - sqlx::query("create index concurrently if not exists ix_completed_job_workspace_id_created_at_new_6 ON completed_job (workspace_id, created_at DESC) where job_kind in ('script', 'flow') AND parent_job IS NULL") + sqlx::query!("create index concurrently if not exists ix_job_workspace_id_created_at_new_6 ON v2_job (workspace_id, created_at DESC) where kind in ('script', 'flow') AND parent_job IS NULL") .execute(db) .await?; i += 1; tracing::info!("step {i} of {migration_job_name} migration"); - sqlx::query("create index concurrently if not exists ix_completed_job_workspace_id_created_at_new_7 ON completed_job (workspace_id, success, created_at DESC) where job_kind in ('script', 'flow') AND parent_job IS NULL") + sqlx::query!("create index concurrently if not exists ix_job_workspace_id_created_at_new_7 ON v2_job (workspace_id, created_at DESC) where kind in ('script', 'flow') AND parent_job IS NULL") .execute(db) .await?; i += 1; tracing::info!("step {i} of {migration_job_name} migration"); - sqlx::query("create index concurrently if not exists ix_completed_job_workspace_id_started_at_new_2 ON completed_job (workspace_id, started_at DESC)") + sqlx::query!("create index concurrently if not exists ix_completed_job_workspace_id_started_at_new_2 ON v2_job_completed (workspace_id, started_at DESC)") .execute(db) .await?; i += 1; tracing::info!("step {i} of {migration_job_name} migration"); - sqlx::query("create index concurrently if not exists root_job_index_by_path_2 ON completed_job (workspace_id, script_path, created_at desc) WHERE parent_job IS NULL") + sqlx::query!("create index concurrently if not exists root_job_index_by_path_2 ON v2_job (workspace_id, runnable_path, created_at desc) WHERE parent_job IS NULL") .execute(db) .await?; i += 1; tracing::info!("step {i} of {migration_job_name} migration"); - sqlx::query("create index concurrently if not exists ix_completed_job_created_at ON completed_job (created_at DESC)") + sqlx::query!("create index concurrently if not exists ix_job_created_at ON v2_job (created_at DESC)") .execute(db) .await?; @@ -492,10 +492,21 @@ async fn fix_job_completed_index(db: &DB) -> Result<(), Error> { .execute(db) .await?; sqlx::query!( - "CREATE INDEX CONCURRENTLY labeled_jobs_on_jobs ON completed_job USING GIN ((result -> 'wm_labels')) WHERE result ? 'wm_labels'" + "CREATE INDEX CONCURRENTLY labeled_jobs_on_jobs ON v2_job_completed USING GIN ((result -> 'wm_labels')) WHERE result ? 'wm_labels'" ).execute(db).await?; }); + run_windmill_migration!("v2_labeled_jobs_index", &db, { + tracing::info!("Special migration to add index concurrently on job labels"); + sqlx::query!( + "CREATE INDEX CONCURRENTLY ix_v2_job_labels ON v2_job + USING GIN (labels) + WHERE labels IS NOT NULL" + ) + .execute(db) + .await?; + }); + Ok(()) } diff --git a/backend/windmill-api/src/embeddings.rs b/backend/windmill-api/src/embeddings.rs index fd222bdbfa..30415156ce 100644 --- a/backend/windmill-api/src/embeddings.rs +++ b/backend/windmill-api/src/embeddings.rs @@ -90,7 +90,7 @@ async fn query_hub_scripts( Ok(Json(results)) } else { - Err(windmill_common::error::Error::InternalErr( + Err(windmill_common::error::Error::internal_err( "Embeddings db not initialized".to_string(), )) } @@ -124,7 +124,7 @@ async fn query_resource_types( Ok(Json(results)) } else { - Err(windmill_common::error::Error::InternalErr( + Err(windmill_common::error::Error::internal_err( "Embeddings db not initialized".to_string(), )) } diff --git a/backend/windmill-api/src/flows.rs b/backend/windmill-api/src/flows.rs index 1b283d43f3..5e779119a8 100644 --- a/backend/windmill-api/src/flows.rs +++ b/backend/windmill-api/src/flows.rs @@ -187,7 +187,7 @@ async fn list_flows( .fields(&["dm.deployment_msg"]); } - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let mut tx = user_db.begin(&authed).await?; let rows = sqlx::query_as::<_, ListableFlow>(&sql) .fetch_all(&mut *tx) @@ -704,7 +704,7 @@ async fn update_flow( w_id, ) .execute(&mut *tx) - .await.map_err(|e| error::Error::InternalErr(format!("Error updating flow due to flow update: {e:#}")))?; + .await.map_err(|e| error::Error::internal_err(format!("Error updating flow due to flow update: {e:#}")))?; if is_new_path { // if new path, must clone flow to new path and delete old flow for flow_version foreign key constraint @@ -721,7 +721,7 @@ async fn update_flow( .execute(&mut *tx) .await .map_err(|e| { - error::Error::InternalErr(format!("Error updating flow due to create new flow: {e:#}")) + error::Error::internal_err(format!("Error updating flow due to create new flow: {e:#}")) })?; sqlx::query!( @@ -733,7 +733,7 @@ async fn update_flow( .execute(&mut *tx) .await .map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "Error updating flow due to updating flow history path: {e:#}" )) })?; @@ -746,7 +746,7 @@ async fn update_flow( .execute(&mut *tx) .await .map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "Error updating flow due to deleting old flow: {e:#}" )) })?; @@ -781,7 +781,7 @@ async fn update_flow( .fetch_one(&mut *tx) .await .map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "Error updating flow due to flow history insert: {e:#}" )) })?; @@ -805,7 +805,7 @@ async fn update_flow( .bind(&flow_path) .bind(&w_id) .fetch_all(&mut *tx) - .await.map_err(|e| error::Error::InternalErr(format!("Error updating flow due to related schedules update: {e:#}")))?; + .await.map_err(|e| error::Error::internal_err(format!("Error updating flow due to related schedules update: {e:#}")))?; let schedule = sqlx::query_as::<_, Schedule>( "UPDATE schedule SET path = $1, script_path = $1 WHERE path = $2 AND workspace_id = $3 AND is_flow IS true RETURNING *") @@ -813,7 +813,7 @@ async fn update_flow( .bind(&flow_path) .bind(&w_id) .fetch_optional(&mut *tx) - .await.map_err(|e| error::Error::InternalErr(format!("Error updating flow due to related schedule update: {e:#}")))?; + .await.map_err(|e| error::Error::internal_err(format!("Error updating flow due to related schedule update: {e:#}")))?; if let Some(schedule) = schedule { clear_schedule(&mut tx, &flow_path, &w_id).await?; @@ -907,19 +907,23 @@ async fn update_flow( .execute(&mut *new_tx) .await .map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "Error updating flow due to updating dependency job field: {e:#}" )) })?; if let Some(old_dep_job) = old_dep_job { sqlx::query!( - "UPDATE queue SET canceled = true WHERE id = $1", - old_dep_job + "UPDATE v2_job_queue SET + canceled_by = $2, + canceled_reason = 're-deployment' + WHERE id = $1", + old_dep_job, + &authed.username ) .execute(&mut *new_tx) .await .map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "Error updating flow due to cancelling dependency job: {e:#}" )) })?; @@ -1204,7 +1208,7 @@ async fn delete_flow_by_path( .execute(&db) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error deleting deployment metadata for script with path {path} in workspace {w_id}: {e:#}" )) })?; diff --git a/backend/windmill-api/src/folders.rs b/backend/windmill-api/src/folders.rs index 208ec63985..cab039c64f 100644 --- a/backend/windmill-api/src/folders.rs +++ b/backend/windmill-api/src/folders.rs @@ -340,7 +340,7 @@ async fn update_folder( let sql = sqlb .sql() - .map_err(|e| error::Error::InternalErr(e.to_string()))?; + .map_err(|e| error::Error::internal_err(e.to_string()))?; let nfolder = sqlx::query_as::<_, Folder>(&sql) .fetch_optional(&mut *tx) .await?; diff --git a/backend/windmill-api/src/http_triggers.rs b/backend/windmill-api/src/http_triggers.rs index ef62928f2c..d0a0b43698 100644 --- a/backend/windmill-api/src/http_triggers.rs +++ b/backend/windmill-api/src/http_triggers.rs @@ -176,7 +176,7 @@ async fn list_triggers( } let sql = sqlb .sql() - .map_err(|e| error::Error::InternalErr(e.to_string()))?; + .map_err(|e| error::Error::internal_err(e.to_string()))?; let rows = sqlx::query_as::<_, Trigger>(&sql) .fetch_all(&mut *tx) .await?; @@ -590,7 +590,7 @@ async fn route_job( #[cfg(not(feature = "parquet"))] if trigger.static_asset_config.is_some() { - return error::Error::InternalErr( + return error::Error::internal_err( "Static asset configuration is not supported in this build".to_string(), ) .into_response(); @@ -608,14 +608,14 @@ async fn route_job( config.storage, ) .await?; - let s3_resource = s3_resource_opt.ok_or(error::Error::InternalErr( + let s3_resource = s3_resource_opt.ok_or(error::Error::internal_err( "No files storage resource defined at the workspace level".to_string(), ))?; let s3_client = build_object_store_client(&s3_resource).await?; let path = object_store::path::Path::from(config.s3); let s3_object = s3_client.get(&path).await.map_err(|err| { tracing::warn!("Error retrieving file from S3: {:?}", err); - error::Error::InternalErr(format!("Error retrieving file: {}", err.to_string())) + error::Error::internal_err(format!("Error retrieving file: {}", err.to_string())) })?; let mut response_headers = http::HeaderMap::new(); if let Some(ref e_tag) = s3_object.meta.e_tag { diff --git a/backend/windmill-api/src/inputs.rs b/backend/windmill-api/src/inputs.rs index 1271be1620..1ce3fa9226 100644 --- a/backend/windmill-api/src/inputs.rs +++ b/backend/windmill-api/src/inputs.rs @@ -133,7 +133,7 @@ async fn get_input_history( let mut tx = user_db.begin(&authed).await?; let sql = &format!( - "select id, created_at, created_by, 'null'::jsonb as args, success from completed_job \ + "select id, created_at, created_by, 'null'::jsonb as args, success from v2_as_completed_job \ where {} = $1 and job_kind = any($2) and workspace_id = $3 \ order by created_at desc limit $4 offset $5", r.runnable_type.column_name() @@ -204,16 +204,16 @@ async fn get_args_from_history_or_saved_input( let result_o = if let Some(input) = g.input { if input { sqlx::query_scalar!( - "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM input WHERE id = $1 AND workspace_id = $2", - job_or_input_id, - w_id, - g.allow_large.unwrap_or(true) - ) - .fetch_optional(&mut *tx) - .await? + "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM input WHERE id = $1 AND workspace_id = $2", + job_or_input_id, + w_id, + g.allow_large.unwrap_or(true) + ) + .fetch_optional(&mut *tx) + .await? } else { sqlx::query_scalar!( - "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM completed_job WHERE id = $1 AND workspace_id = $2", + "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM v2_job WHERE id = $1 AND workspace_id = $2", job_or_input_id, w_id, g.allow_large.unwrap_or(true) @@ -223,13 +223,15 @@ async fn get_args_from_history_or_saved_input( } } else { sqlx::query_scalar!( - "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM completed_job WHERE id = $1 AND workspace_id = $2 UNION ALL SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM input WHERE id = $1 AND workspace_id = $2", - job_or_input_id, - w_id, - g.allow_large.unwrap_or(true) - ) - .fetch_optional(&mut *tx) - .await? + "SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM v2_job WHERE id = $1 AND workspace_id = $2 + UNION ALL + SELECT CASE WHEN pg_column_size(args) < 40000 OR $3 THEN args ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as args FROM input WHERE id = $1 AND workspace_id = $2", + job_or_input_id, + w_id, + g.allow_large.unwrap_or(true) + ) + .fetch_optional(&mut *tx) + .await? }; tx.commit().await?; diff --git a/backend/windmill-api/src/job_helpers_ee.rs b/backend/windmill-api/src/job_helpers_ee.rs index 7b074a300a..b35f40d661 100644 --- a/backend/windmill-api/src/job_helpers_ee.rs +++ b/backend/windmill-api/src/job_helpers_ee.rs @@ -69,7 +69,7 @@ pub async fn get_s3_resource<'c>( _resource_type: Option, _job_id: Option, ) -> error::Result { - Err(error::Error::InternalErr( + Err(error::Error::internal_err( "Not implemented in Windmill's Open Source repository".to_string(), )) } @@ -81,7 +81,7 @@ pub async fn upload_file_from_req( _req: axum::extract::Request, _options: PutMultipartOpts, ) -> error::Result<()> { - Err(error::Error::InternalErr( + Err(error::Error::internal_err( "Not implemented in Windmill's Open Source repository".to_string(), )) } @@ -93,7 +93,7 @@ pub async fn upload_file_internal( _stream: impl Stream> + Unpin, _options: PutMultipartOpts, ) -> error::Result<()> { - Err(error::Error::InternalErr( + Err(error::Error::internal_err( "Not implemented in Windmill's Open Source repository".to_string(), )) } @@ -107,7 +107,7 @@ pub async fn download_s3_file_internal( _w_id: &str, _query: DownloadFileQuery, ) -> error::Result { - Err(error::Error::InternalErr( + Err(error::Error::internal_err( "Not implemented in Windmill's Open Source repository".to_string(), )) } @@ -120,7 +120,7 @@ pub async fn load_image_preview_internal( _w_id: &str, _query: LoadImagePreviewQuery, ) -> error::Result { - Err(error::Error::InternalErr( + Err(error::Error::internal_err( "Not implemented in Windmill's Open Source repository".to_string(), )) } diff --git a/backend/windmill-api/src/job_metrics.rs b/backend/windmill-api/src/job_metrics.rs index 2af59383a8..70e68ba3ed 100644 --- a/backend/windmill-api/src/job_metrics.rs +++ b/backend/windmill-api/src/job_metrics.rs @@ -171,7 +171,7 @@ async fn set_job_progress( if let Some(flow_job_id) = flow_job_id { // TODO: Return error if trying to set completed job? sqlx::query!( - "UPDATE queue + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['modules', flow_status->>'step', 'progress'], $1) WHERE id = $2", serde_json::json!(percent.clamp(0, 99)), diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index f039c220fb..d1630a7017 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -87,8 +87,8 @@ use windmill_common::{METRICS_DEBUG_ENABLED, METRICS_ENABLED}; use windmill_common::{get_latest_deployed_hash_for_path, BASE_URL}; use windmill_queue::{ - cancel_job, get_queued_job, get_result_and_success_by_id_from_flow, job_is_complete, push, - PushArgs, PushArgsOwned, PushIsolationLevel, + cancel_job, get_result_and_success_by_id_from_flow, job_is_complete, push, PushArgs, + PushArgsOwned, PushIsolationLevel, }; #[cfg(feature = "prometheus")] @@ -336,16 +336,21 @@ async fn get_root_job( Ok(Json(res)) } -async fn compute_root_job_for_flow(db: &DB, w_id: &str, job_id: Uuid) -> error::Result { - let mut job = get_queued_job(&job_id, w_id, db).await?; - while let Some(j) = job { - if let Some(uuid) = j.parent_job { - job = get_queued_job(&uuid, w_id, db).await?; - } else { - return Ok(j.id.to_string()); +async fn compute_root_job_for_flow(db: &DB, w_id: &str, mut job_id: Uuid) -> error::Result { + // TODO: use `root_job` ? + loop { + job_id = match sqlx::query_scalar!( + "SELECT parent_job FROM v2_job WHERE id = $1 AND workspace_id = $2", + job_id, + w_id + ) + .fetch_one(db) + .await + { + Ok(Some(job_id)) => job_id, + _ => return Ok(job_id.to_string()), } } - Ok(job_id.to_string()) } async fn get_db_clock(Extension(db): Extension) -> windmill_common::error::JsonResult { @@ -384,7 +389,7 @@ async fn cancel_job_api( ) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "timeout after 120s while cancelling job {id} in {w_id}: {e:#}" )) })??; @@ -495,7 +500,7 @@ async fn force_cancel( ) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "timeout after 120s while cancelling job {id} in {w_id}: {e:#}" )) })??; @@ -554,7 +559,7 @@ pub async fn get_path_tag_limits_cache_for_hash( .fetch_optional(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "querying getting path for hash {hash} in {w_id}: {e:#}" )) })?.ok_or_else(|| Error::NotFound(format!( @@ -602,7 +607,7 @@ async fn get_flow_job_debug_info( let mut job_ids = vec![]; let jobs_with_root = sqlx::query_scalar!( - "SELECT id FROM queue WHERE workspace_id = $1 and root_job = $2", + "SELECT id FROM v2_job WHERE workspace_id = $1 and flow_innermost_root_job = $2", &w_id, &id, ) @@ -672,23 +677,24 @@ async fn get_job( } macro_rules! get_job_query { - ("completed_job_view", $($opts:tt)*) => { + ("v2_as_completed_job", $($opts:tt)*) => { get_job_query!( - @impl "completed_job_view", ($($opts)*), - "duration_ms, success, result, deleted, is_skipped, result->'wm_labels' as labels, \ + @impl "v2_as_completed_job", ($($opts)*), + "duration_ms, success, result, result_columns, deleted, is_skipped, result->'wm_labels' as labels, \ CASE WHEN result is null or pg_column_size(result) < 90000 THEN result ELSE '\"WINDMILL_TOO_BIG\"'::jsonb END as result", ) }; - ("queue_view", $($opts:tt)*) => { + ("v2_as_queue", $($opts:tt)*) => { get_job_query!( - @impl "queue_view", ($($opts)*), + @impl "v2_as_queue", ($($opts)*), "scheduled_for, running, last_ping, suspend, suspend_until, same_worker, pre_run_error, visible_to_owner, \ - root_job, leaf_jobs, concurrent_limit, concurrency_time_window_s, timeout, flow_step_id, cache_ttl", + root_job, leaf_jobs, concurrent_limit, concurrency_time_window_s, timeout, flow_step_id, cache_ttl,\ + script_entrypoint_override", ) }; (@impl $table:literal, (with_logs: $with_logs:expr, $($rest:tt)*), $additional_fields:literal, $($args:tt)*) => { if $with_logs { - get_job_query!(@impl $table, ($($rest)*), $additional_fields, logs = const_format::formatcp!("right({}.logs, 20000)", $table), $($args)*) + get_job_query!(@impl $table, ($($rest)*), $additional_fields, logs = "right(job_logs.logs, 20000)", $($args)*) } else { get_job_query!(@impl $table, ($($rest)*), $additional_fields, logs = "null", $($args)*) } @@ -714,8 +720,8 @@ macro_rules! get_job_query { CASE WHEN args is null or pg_column_size(args) < 90000 THEN args ELSE '{{\"reason\": \"WINDMILL_TOO_BIG\"}}'::jsonb END as args, \ {logs} as logs, {code} as raw_code, canceled, canceled_by, canceled_reason, job_kind, \ schedule_path, permissioned_as, flow_status, {flow} as raw_flow, is_flow_step, language, \ - {lock} as raw_lock, email, visible_to_owner, mem_peak, tag, priority, {additional_fields} \ - FROM {table} \ + {lock} as raw_lock, email, visible_to_owner, mem_peak, tag, priority, preprocessed, {additional_fields} \ + FROM {table} LEFT JOIN job_logs ON id = job_id \ WHERE id = $1 AND {table}.workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3)) LIMIT 1", table = $table, additional_fields = $additional_fields, @@ -829,7 +835,7 @@ impl<'a> GetQuery<'a> { job_id: Uuid, workspace_id: &str, ) -> error::Result>> { - let query = get_job_query!("queue_view", + let query = get_job_query!("v2_as_queue", with_logs: self.with_logs, with_code: self.with_code, with_flow: self.with_flow, @@ -861,7 +867,7 @@ impl<'a> GetQuery<'a> { job_id: Uuid, workspace_id: &str, ) -> error::Result>> { - let query = get_job_query!("completed_job_view", + let query = get_job_query!("v2_as_completed_job", with_logs: self.with_logs, with_code: self.with_code, with_flow: self.with_flow, @@ -1009,10 +1015,10 @@ async fn get_job_logs( .flatten(); let record = sqlx::query!( - "SELECT created_by, CONCAT(coalesce(completed_job.logs, ''), coalesce(job_logs.logs, '')) as logs, job_logs.log_offset, job_logs.log_file_index - FROM completed_job - LEFT JOIN job_logs ON job_logs.job_id = completed_job.id - WHERE completed_job.id = $1 AND completed_job.workspace_id = $2 AND ($3::text[] IS NULL OR completed_job.tag = ANY($3))", + "SELECT created_by AS \"created_by!\", CONCAT(coalesce(v2_as_completed_job.logs, ''), coalesce(job_logs.logs, '')) as logs, job_logs.log_offset, job_logs.log_file_index + FROM v2_as_completed_job + LEFT JOIN job_logs ON job_logs.job_id = v2_as_completed_job.id + WHERE v2_as_completed_job.id = $1 AND v2_as_completed_job.workspace_id = $2 AND ($3::text[] IS NULL OR v2_as_completed_job.tag = ANY($3))", id, w_id, tags.as_ref().map(|v| v.as_slice()) @@ -1046,10 +1052,10 @@ async fn get_job_logs( Ok(content_plain(Body::from(logs))) } else { let text = sqlx::query!( - "SELECT created_by, CONCAT(coalesce(queue.logs, ''), coalesce(job_logs.logs, '')) as logs, coalesce(job_logs.log_offset, 0) as log_offset, job_logs.log_file_index - FROM queue - LEFT JOIN job_logs ON job_logs.job_id = queue.id - WHERE queue.id = $1 AND queue.workspace_id = $2 AND ($3::text[] IS NULL OR queue.tag = ANY($3))", + "SELECT created_by AS \"created_by!\", CONCAT(coalesce(v2_as_queue.logs, ''), coalesce(job_logs.logs, '')) as logs, coalesce(job_logs.log_offset, 0) as log_offset, job_logs.log_file_index + FROM v2_as_queue + LEFT JOIN job_logs ON job_logs.job_id = v2_as_queue.id + WHERE v2_as_queue.id = $1 AND v2_as_queue.workspace_id = $2 AND ($3::text[] IS NULL OR v2_as_queue.tag = ANY($3))", id, w_id, tags.as_ref().map(|v| v.as_slice()) @@ -1087,29 +1093,23 @@ async fn get_job_logs( } } -#[derive(FromRow)] -pub struct RawArgs { - pub args: Option>>, - pub created_by: String, -} - async fn get_args( OptAuthed(opt_authed): OptAuthed, Extension(db): Extension, Path((w_id, id)): Path<(String, Uuid)>, -) -> error::JsonResult> { +) -> JsonResult> { let tags = opt_authed .as_ref() .map(|authed| get_scope_tags(authed)) .flatten(); - let record = sqlx::query_as::<_, RawArgs>( - "SELECT created_by, args - FROM completed_job - WHERE completed_job.id = $1 AND completed_job.workspace_id = $2 AND ($3::text[] IS NULL OR completed_job.tag = ANY($3))", + let record = sqlx::query!( + "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\" + FROM v2_as_completed_job + WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + id, + &w_id, + tags.as_ref().map(|v| v.as_slice()) as Option<&[&str]>, ) - .bind(&id) - .bind(&w_id) - .bind(tags.as_ref().map(|v| v.as_slice())) .fetch_optional(&db) .await?; @@ -1124,14 +1124,14 @@ async fn get_args( Ok(Json(record.args.map(|x| x.0).unwrap_or_default())) } else { - let record = sqlx::query_as::<_, RawArgs>( - "SELECT created_by, args - FROM queue - WHERE queue.id = $1 AND queue.workspace_id = $2 AND ($3::text[] IS NULL OR queue.tag = ANY($3))", + let record = sqlx::query!( + "SELECT created_by AS \"created_by!\", args as \"args: sqlx::types::Json>\" + FROM v2_job + WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + id, + &w_id, + tags.as_ref().map(|v| v.as_slice()) as Option<&[&str]>, ) - .bind(&id) - .bind(&w_id) - .bind(tags.as_ref().map(|v| v.as_slice())) .fetch_optional(&db) .await?; let record = not_found_if_none(record, "Job Args", id.to_string())?; @@ -1399,7 +1399,7 @@ pub fn list_queue_jobs_query( tags: Option>, ) -> SqlBuilder { let (limit, offset) = paginate_without_limits(pagination); - let mut sqlb = SqlBuilder::select_from("queue") + let mut sqlb = SqlBuilder::select_from("v2_as_queue") .fields(fields) .order_by("created_at", lq.order_desc.unwrap_or(true)) .limit(limit) @@ -1488,75 +1488,36 @@ async fn cancel_jobs( ) -> error::JsonResult> { let mut uuids = vec![]; let mut tx = db.begin().await?; - let trivial_jobs = sqlx::query!("INSERT INTO completed_job AS cj + let trivial_jobs = sqlx::query!("INSERT INTO v2_job_completed AS cj ( workspace_id , id - , parent_job - , created_by - , created_at - , started_at , duration_ms - , success - , script_hash - , script_path - , args , result - , raw_code - , raw_lock - , canceled , canceled_by , canceled_reason - , job_kind - , schedule_path - , permissioned_as , flow_status - , raw_flow - , is_flow_step - , is_skipped - , language - , email - , visible_to_owner - , mem_peak - , tag - , priority + , status + , worker ) - SELECT workspace_id - , id - , parent_job - , created_by - , created_at - , now() + SELECT q.workspace_id + , q.id , 0 - , false - , script_hash - , script_path - , args , $4 - , raw_code - , raw_lock - , true , $1 - , canceled_reason - , job_kind - , schedule_path - , permissioned_as - , flow_status - , raw_flow - , is_flow_step - , false - , language - , email - , visible_to_owner - , mem_peak - , tag - , priority FROM queue - WHERE id = any($2) AND running = false AND parent_job IS NULL AND workspace_id = $3 AND schedule_path IS NULL FOR UPDATE SKIP LOCKED - ON CONFLICT (id) DO NOTHING RETURNING id", username, &jobs, w_id, serde_json::json!({"error": { "message": format!("Job canceled: cancel all by {username}"), "name": "Canceled", "reason": "cancel all", "canceler": username}})) + , 'cancel all' + , (SELECT flow_status FROM v2_job_status WHERE id = q.id) + , 'canceled'::job_status + , worker + FROM v2_job_queue q + JOIN v2_job USING (id) + WHERE q.id = any($2) AND running = false AND parent_job IS NULL AND q.workspace_id = $3 AND trigger IS NULL + FOR UPDATE SKIP LOCKED + ON CONFLICT (id) DO NOTHING RETURNING id AS \"id!\"", username, &jobs, w_id, serde_json::json!({"error": { "message": format!("Job canceled: cancel all by {username}"), "name": "Canceled", "reason": "cancel all", "canceler": username}})) .fetch_all(&mut *tx) .await?.into_iter().map(|x| x.id).collect::>(); sqlx::query!( - "DELETE FROM queue WHERE id = any($1) AND workspace_id = $2", + "DELETE FROM v2_job_queue WHERE id = any($1) AND workspace_id = $2", &trivial_jobs, w_id ) @@ -1624,7 +1585,7 @@ async fn cancel_selection( let mut tx = user_db.begin(&authed).await?; let tags = get_scope_tags(&authed).map(|v| v.iter().map(|s| s.to_string()).collect_vec()); let jobs_to_cancel = sqlx::query_scalar!( - "SELECT id FROM queue WHERE id = ANY($1) AND schedule_path IS NULL AND ($2::text[] IS NULL OR tag = ANY($2))", + "SELECT id AS \"id!\" FROM v2_as_queue WHERE id = ANY($1) AND schedule_path IS NULL AND ($2::text[] IS NULL OR tag = ANY($2))", &jobs, tags.as_ref().map(|v| v.as_slice()) ) @@ -1644,7 +1605,9 @@ async fn list_filtered_uuids( ) -> error::JsonResult> { require_admin(authed.is_admin, &authed.username)?; - let mut sqlb = SqlBuilder::select_from("queue").fields(&["id"]).clone(); + let mut sqlb = SqlBuilder::select_from("v2_as_queue") + .fields(&["id"]) + .clone(); sqlb = join_concurrency_key(lq.concurrency_key.as_ref(), sqlb); @@ -1681,7 +1644,7 @@ async fn count_queue_jobs( Ok(Json( sqlx::query_as!( QueueStats, - "SELECT coalesce(COUNT(*) FILTER(WHERE suspend = 0 AND running = false), 0) as \"database_length!\", coalesce(COUNT(*) FILTER(WHERE suspend > 0), 0) as \"suspended!\" FROM queue WHERE (workspace_id = $1 OR $2) AND scheduled_for <= now()", + "SELECT coalesce(COUNT(*) FILTER(WHERE suspend = 0 AND running = false), 0) as \"database_length!\", coalesce(COUNT(*) FILTER(WHERE suspend > 0), 0) as \"suspended!\" FROM v2_as_queue WHERE (workspace_id = $1 OR $2) AND scheduled_for <= now()", w_id, w_id == "admins" && cq.all_workspaces.unwrap_or(false), ) @@ -1703,7 +1666,7 @@ async fn count_completed_jobs_detail( Path(w_id): Path, Query(query): Query, ) -> error::JsonResult { - let mut sqlb = SqlBuilder::select_from("completed_job"); + let mut sqlb = SqlBuilder::select_from("v2_as_completed_job"); sqlb.field("COUNT(*) as count"); if !query.all_workspaces.unwrap_or(false) { @@ -1745,7 +1708,7 @@ async fn count_completed_jobs( Ok(Json( sqlx::query_as!( QueueStats, - "SELECT coalesce(COUNT(*), 0) as \"database_length!\", null::bigint as suspended FROM completed_job WHERE workspace_id = $1", + "SELECT coalesce(COUNT(*), 0) as \"database_length!\", null::bigint as suspended FROM v2_job_completed WHERE workspace_id = $1", w_id ) .fetch_one(&db) @@ -1959,7 +1922,7 @@ async fn resume_suspended_job_internal( if !approved { sqlx::query!( - "UPDATE queue SET suspend = 0 WHERE id = $1", + "UPDATE v2_job_queue SET suspend = 0 WHERE id = $1", parent_flow_info.id ) .execute(&mut *tx) @@ -2045,7 +2008,7 @@ async fn resume_immediately_if_relevant<'c>( if matches!(status.current_step(), Some(FlowStatusModule::WaitingForEvents { job, .. }) if job == &job_id) { sqlx::query!( - "UPDATE queue SET suspend = $1 WHERE id = $2", + "UPDATE v2_job_queue SET suspend = $1 WHERE id = $2", suspend, flow.id, ) @@ -2096,9 +2059,11 @@ async fn get_suspended_parent_flow_info(job_id: Uuid, db: &DB) -> error::Result< let flow = sqlx::query_as!( FlowInfo, r#" - SELECT id, flow_status, suspend, script_path - FROM queue - WHERE id = ( SELECT parent_job FROM queue WHERE id = $1 UNION ALL SELECT parent_job FROM completed_job WHERE id = $1) + SELECT q.id, f.flow_status, q.suspend, j.runnable_path AS script_path + FROM v2_job_queue q + JOIN v2_job j USING (id) + JOIN v2_job_status f USING (id) + WHERE id = ( SELECT parent_job FROM v2_job WHERE id = $1 ) FOR UPDATE "#, job_id, @@ -2116,8 +2081,8 @@ async fn get_suspended_flow_info<'c>( let flow = sqlx::query_as!( FlowInfo, r#" - SELECT id, flow_status, suspend, script_path - FROM queue + SELECT id AS "id!", flow_status, suspend AS "suspend!", script_path + FROM v2_as_queue WHERE id = $1 "#, job_id, @@ -2176,11 +2141,7 @@ pub async fn get_suspended_job_flow( let flow_id = sqlx::query_scalar!( r#" SELECT parent_job - FROM queue - WHERE id = $1 AND workspace_id = $2 - UNION ALL - SELECT parent_job - FROM completed_job + FROM v2_job WHERE id = $1 AND workspace_id = $2 "#, job, @@ -2286,8 +2247,10 @@ fn conditionally_require_authed_user( return Ok(()); } } - let error_msg = format!("Only users from one of the following groups are allowed to approve this workflow: {}", - approval_conditions.user_groups_required.join(", ")); + let error_msg = format!( + "Only users from one of the following groups are allowed to approve this workflow: {}", + approval_conditions.user_groups_required.join(", ") + ); return Err(Error::PermissionDenied(error_msg)); } } @@ -2317,7 +2280,7 @@ pub async fn get_flow_user_state( let r = sqlx::query_scalar!( r#" SELECT flow_status->'user_states'->$1 - FROM queue + FROM v2_as_queue WHERE id = $2 AND workspace_id = $3 "#, key, @@ -2339,8 +2302,9 @@ pub async fn set_flow_user_state( let mut tx = user_db.begin(&authed).await?; let r = sqlx::query_scalar!( r#" - UPDATE queue SET flow_status = JSONB_SET(flow_status, ARRAY['user_states'], JSONB_SET(COALESCE(flow_status->'user_states', '{}'::jsonb), ARRAY[$1], $2)) - WHERE id = $3 AND workspace_id = $4 AND job_kind IN ('flow', 'flowpreview', 'flownode') RETURNING 1 + UPDATE v2_job_status f SET flow_status = JSONB_SET(flow_status, ARRAY['user_states'], JSONB_SET(COALESCE(flow_status->'user_states', '{}'::jsonb), ARRAY[$1], $2)) + FROM v2_job j + WHERE f.id = $3 AND f.id = j.id AND j.workspace_id = $4 AND kind IN ('flow', 'flowpreview', 'flownode') RETURNING 1 "#, key, value, @@ -2682,6 +2646,7 @@ pub struct UnifiedJob { pub labels: Option, pub self_wait_time_ms: Option, pub aggregate_wait_time_ms: Option, + pub preprocessed: Option, } const CJ_FIELDS: &[&str] = &[ @@ -2719,6 +2684,7 @@ const CJ_FIELDS: &[&str] = &[ "result->'wm_labels' as labels", "self_wait_time_ms", "aggregate_wait_time_ms", + "preprocessed", ]; const QJ_FIELDS: &[&str] = &[ "'QueuedJob' as typ", @@ -2755,6 +2721,7 @@ const QJ_FIELDS: &[&str] = &[ "null as labels", "self_wait_time_ms", "aggregate_wait_time_ms", + "preprocessed", ]; impl UnifiedJob { @@ -2778,13 +2745,14 @@ impl<'a> From for Job { parent_job: uj.parent_job, created_by: uj.created_by, created_at: uj.created_at, - started_at: uj.started_at.unwrap_or(uj.created_at), + started_at: uj.started_at, duration_ms: uj.duration_ms.unwrap(), success: uj.success.unwrap(), script_hash: uj.script_hash, script_path: uj.script_path, args: None, result: None, + result_columns: None, logs: None, flow_status: None, deleted: uj.deleted, @@ -2803,6 +2771,7 @@ impl<'a> From for Job { tag: uj.tag, priority: uj.priority, labels: uj.labels, + preprocessed: uj.preprocessed, }, )), "QueuedJob" => Job::QueuedJob(JobExtended::new( @@ -2831,6 +2800,7 @@ impl<'a> From for Job { permissioned_as: uj.permissioned_as, is_flow_step: uj.is_flow_step, language: uj.language, + script_entrypoint_override: None, same_worker: false, pre_run_error: None, email: uj.email, @@ -2846,6 +2816,7 @@ impl<'a> From for Job { flow_step_id: None, cache_ttl: None, priority: uj.priority, + preprocessed: uj.preprocessed, }, )), t => panic!("job type {} not valid", t), @@ -3150,11 +3121,15 @@ pub async fn restart_flow( check_license_key_valid().await?; let mut tx = user_db.clone().begin(&authed).await?; - let completed_job = sqlx::query_as::<_, CompletedJob>( - "SELECT *, result->'wm_labels' as labels from completed_job WHERE id = $1 and workspace_id = $2", + let completed_job = sqlx::query!( + "SELECT + script_path, args AS \"args: sqlx::types::Json>>\", + tag AS \"tag!\", priority + FROM v2_as_completed_job + WHERE id = $1 and workspace_id = $2", + job_id, + &w_id, ) - .bind(job_id) - .bind(&w_id) .fetch_optional(&mut *tx) .await? .with_context(|| "Unable to find completed job with the given job UUID")?; @@ -3180,11 +3155,7 @@ pub async fn restart_flow( &db, tx, &w_id, - JobPayload::RestartedFlow { - completed_job_id: job_id, - step_id: step_id, - branch_or_iteration_n: branch_or_iteration_n, - }, + JobPayload::RestartedFlow { completed_job_id: job_id, step_id, branch_or_iteration_n }, push_args, &authed.username, &authed.email, @@ -3454,10 +3425,9 @@ pub async fn run_workflow_as_code( if !wkflow_query.skip_update.unwrap_or(false) { sqlx::query!( - "UPDATE queue SET flow_status = jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], jsonb_set(jsonb_set('{}'::jsonb, '{scheduled_for}', to_jsonb(now()::text)), '{name}', to_jsonb($4::text))) WHERE id = $2 AND workspace_id = $3", + "UPDATE v2_job_status SET flow_status = jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], jsonb_set(jsonb_set('{}'::jsonb, '{scheduled_for}', to_jsonb(now()::text)), '{name}', to_jsonb($3::text))) WHERE id = $2", uuid.to_string(), job_id, - w_id, entrypoint ).execute(&mut *tx).await?; } else { @@ -3587,17 +3557,21 @@ pub async fn run_wait_result_internal( } if result.is_none() { - let row = sqlx::query_as::<_, RawResultWithSuccess>( - "SELECT '' as created_by, result, language, flow_status, success FROM completed_job WHERE id = $1 AND workspace_id = $2", + let row = sqlx::query!( + "SELECT + result AS \"result: sqlx::types::Json>\", + result_columns, + status = 'success' AS \"success!\" + FROM v2_job_completed + WHERE id = $1 AND workspace_id = $2", + uuid, + &w_id ) - .bind(uuid) - .bind(&w_id) .fetch_optional(db) .await?; if let Some(mut raw_result) = row { format_result( - raw_result.language.as_ref(), - raw_result.flow_status.as_ref(), + raw_result.result_columns.as_ref(), raw_result.result.as_mut(), ); result = raw_result.result.map(|x| x.0); @@ -3682,10 +3656,10 @@ pub async fn run_wait_result( if let Some(windmill_headers) = windmill_headers { for (k, v) in windmill_headers { let k = HeaderName::from_str(k.as_str()).map_err(|err| { - Error::InternalErr(format!("Invalid header name {k}: {err}")) + Error::internal_err(format!("Invalid header name {k}: {err}")) })?; let v = HeaderValue::from_str(v.as_str()).map_err(|err| { - Error::InternalErr(format!("Invalid header value {v}: {err}")) + Error::internal_err(format!("Invalid header value {v}: {err}")) })?; headers.insert(k, v); } @@ -3704,7 +3678,7 @@ pub async fn run_wait_result( headers.insert( http::header::CONTENT_TYPE, HeaderValue::from_str(content_type.as_str()).map_err(|err| { - Error::InternalErr(format!("Invalid content type {content_type}: {err}")) + Error::internal_err(format!("Invalid content type {content_type}: {err}")) })?, ); return Ok((status_code_or_default, headers, serialized_result).into_response()); @@ -3729,17 +3703,19 @@ pub async fn run_wait_result( async fn delete_job_metadata_after_use(db: &DB, job_uuid: Uuid) -> Result<(), Error> { sqlx::query!( - "UPDATE completed_job - SET logs = '##DELETED##', args = '{}'::jsonb, result = '{}'::jsonb - WHERE id = $1", + "UPDATE v2_job SET args = '{}'::jsonb WHERE id = $1", job_uuid, ) .execute(db) .await?; sqlx::query!( - "UPDATE job_logs - SET logs = '##DELETED##' - WHERE job_id = $1", + "UPDATE v2_job_completed SET result = '{}'::jsonb WHERE id = $1", + job_uuid, + ) + .execute(db) + .await?; + sqlx::query!( + "UPDATE job_logs SET logs = '##DELETED##' WHERE job_id = $1", job_uuid, ) .execute(db) @@ -3750,7 +3726,7 @@ async fn delete_job_metadata_after_use(db: &DB, job_uuid: Uuid) -> Result<(), Er pub async fn check_queue_too_long(db: &DB, queue_limit: Option) -> error::Result<()> { if let Some(limit) = queue_limit { let count = sqlx::query_scalar!( - "SELECT COUNT(*) FROM queue WHERE canceled = false AND (scheduled_for <= now() + "SELECT COUNT(*) FROM v2_as_queue WHERE canceled = false AND (scheduled_for <= now() OR (suspend_until IS NOT NULL AND ( suspend <= 0 OR suspend_until <= now())))", @@ -3760,7 +3736,7 @@ pub async fn check_queue_too_long(db: &DB, queue_limit: Option) -> error::R .unwrap_or(0); if count > queue_limit.unwrap() { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "Number of queued job is too high: {count} > {limit}" ))); } @@ -3872,7 +3848,7 @@ pub async fn run_wait_result_job_by_path_get( return Ok(Json(serde_json::json!("")).into_response()); } let payload_r = run_query.payload.map(decode_payload).map(|x| { - x.map_err(|e| Error::InternalErr(format!("Impossible to decode query payload: {e:#?}"))) + x.map_err(|e| Error::internal_err(format!("Impossible to decode query payload: {e:#?}"))) }); let mut payload_args = if let Some(payload) = payload_r { @@ -3967,7 +3943,7 @@ pub async fn run_wait_result_flow_by_path_get( } let payload_r = run_query.payload.clone().map(decode_payload).map(|x| { x.map_err(|e| { - error::Error::InternalErr(format!("Impossible to decode query payload: {e:#?}")) + error::Error::internal_err(format!("Impossible to decode query payload: {e:#?}")) }) }); @@ -4551,7 +4527,7 @@ async fn run_dependencies_job( } if req.raw_scripts.len() != 1 || req.raw_scripts[0].script_path != req.entrypoint { - return Err(error::Error::InternalErr( + return Err(error::Error::internal_err( "For now only a single raw script can be passed to this endpoint, and the entrypoint should be set to the script path".to_string(), )); } @@ -4790,10 +4766,10 @@ async fn add_batch_jobs( ) .fetch_optional(&mut *tx) .await? - .ok_or_else(|| Error::InternalErr(format!("not found flow at path {:?}", path)))?; + .ok_or_else(|| Error::internal_err(format!("not found flow at path {:?}", path)))?; let value = serde_json::from_str::(value_json.value.get()).map_err(|err| { - Error::InternalErr(format!( + Error::internal_err(format!( "could not convert json to flow for {path}: {err:?}" )) })?; @@ -4860,47 +4836,68 @@ async fn add_batch_jobs( let uuids = sqlx::query_scalar!( r#"WITH uuid_table as ( - select gen_random_uuid() as uuid from generate_series(1, $5) + select gen_random_uuid() as uuid from generate_series(1, $16) ) - INSERT INTO job - (id, workspace_id, raw_code, raw_lock, raw_flow) - (SELECT uuid, $1, $2, $3, $4 FROM uuid_table) - RETURNING id"#, + INSERT INTO v2_job + (id, workspace_id, raw_code, raw_lock, raw_flow, tag, runnable_id, runnable_path, kind, + script_lang, created_by, permissioned_as, permissioned_as_email, concurrent_limit, + concurrency_time_window_s, timeout, args) + (SELECT uuid, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, + ('{ "uuid": "' || uuid || '" }')::jsonb FROM uuid_table) + RETURNING id AS "id!""#, w_id, raw_code, raw_lock, raw_flow.map(sqlx::types::Json) as Option>, - n + tag, + hash.map(|h| h.0), + path, + job_kind.clone() as JobKind, + language as ScriptLang, + authed.username, + username_to_permissioned_as(&authed.username), + authed.email, + concurrent_limit, + concurrent_time_window_s, + timeout, + n, ) .fetch_all(&mut *tx) .await?; let uuids = sqlx::query_scalar!( r#"WITH uuid_table as ( - select unnest($11::uuid[]) as uuid + select unnest($4::uuid[]) as uuid ) - INSERT INTO queue - (id, script_hash, script_path, job_kind, language, args, tag, created_by, permissioned_as, email, scheduled_for, workspace_id, concurrent_limit, concurrency_time_window_s, timeout, flow_status) - (SELECT uuid, $1, $2, $3, $4, ('{ "uuid": "' || uuid || '" }')::jsonb, $5, $6, $7, $8, $9, $10, $12, $13, $14, $15 FROM uuid_table) + INSERT INTO v2_job_queue + (id, workspace_id, scheduled_for, tag) + (SELECT uuid, $1, $2, $3 FROM uuid_table) RETURNING id"#, - hash.map(|h| h.0), - path, - job_kind.clone() as JobKind, - language as ScriptLang, - tag, - authed.username, - username_to_permissioned_as(&authed.username), - authed.email, - Utc::now(), - w_id, + w_id, + Utc::now(), + tag, + &uuids + ) + .fetch_all(&mut *tx) + .await?; + + sqlx::query!( + "INSERT INTO v2_job_runtime (id) SELECT unnest($1::uuid[])", + &uuids, + ) + .execute(&mut *tx) + .await?; + + if let Some(flow_status) = flow_status { + sqlx::query!( + "INSERT INTO v2_job_status (id, flow_status) + SELECT unnest($1::uuid[]), $2", &uuids, - concurrent_limit, - concurrent_time_window_s, - timeout, - flow_status.map(sqlx::types::Json) as Option> + sqlx::types::Json(flow_status) as sqlx::types::Json ) - .fetch_all(&mut *tx) + .execute(&mut *tx) .await?; + } if let Some(custom_concurrency_key) = custom_concurrency_key { sqlx::query!( @@ -5138,7 +5135,7 @@ async fn get_log_file(Path((_w_id, file_p)): Path<(String, String)>) -> error::R .unwrap(); return Ok(res); } else { - return Err(error::Error::InternalErr(format!( + return Err(error::Error::internal_err(format!( "Error getting bytes from file: {}", file_p ))); @@ -5150,7 +5147,7 @@ async fn get_log_file(Path((_w_id, file_p)): Path<(String, String)>) -> error::R ))); } } else { - return Err(error::Error::InternalErr(format!( + return Err(error::Error::internal_err(format!( "Object store client not present and file not found on server logs volume at {local_file}" ))); } @@ -5177,29 +5174,33 @@ async fn get_job_update( Path((w_id, job_id)): Path<(String, Uuid)>, Query(JobUpdateQuery { running, log_offset, get_progress }): Query, ) -> error::JsonResult { - let record = sqlx::query_as::<_, JobUpdateRow>( - "SELECT running, substr(concat(coalesce(queue.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) as logs, mem_peak, - CASE WHEN is_flow_step is true then NULL else flow_status END as flow_status, - job_logs.log_offset + char_length(job_logs.logs) + 1 as log_offset, created_by - FROM queue - LEFT JOIN job_logs ON job_logs.job_id = queue.id - WHERE queue.workspace_id = $2 AND queue.id = $3", + let record = sqlx::query!( + "SELECT + running AS \"running!\", + substr(concat(coalesce(v2_as_queue.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs, + mem_peak, + CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\", + job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset, + created_by AS \"created_by!\" + FROM v2_as_queue + LEFT JOIN job_logs ON job_logs.job_id = v2_as_queue.id + WHERE v2_as_queue.workspace_id = $2 AND v2_as_queue.id = $3", + log_offset, + &w_id, + job_id ) - .bind(log_offset) - .bind(&w_id) - .bind(&job_id) .fetch_optional(&db) .await?; let progress: Option = if get_progress == Some(true) { sqlx::query_scalar!( - "SELECT scalar_int FROM job_stats WHERE workspace_id = $1 AND job_id = $2 AND metric_id = $3", - &w_id, - job_id, - "progress_perc" - ) - .fetch_optional(&db) - .await?.and_then(|inner| inner) + "SELECT scalar_int FROM job_stats WHERE workspace_id = $1 AND job_id = $2 AND metric_id = $3", + &w_id, + job_id, + "progress_perc" + ) + .fetch_optional(&db) + .await?.and_then(|inner| inner) } else { None }; @@ -5227,17 +5228,20 @@ async fn get_job_update( .map(|x: sqlx::types::Json>| x.0), })) } else { - let record = sqlx::query_as::<_, JobUpdateRow>( - "SELECT false as running, substr(concat(coalesce(completed_job.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) as logs, mem_peak, - CASE WHEN is_flow_step is true then NULL else flow_status END as flow_status, - job_logs.log_offset + char_length(job_logs.logs) + 1 as log_offset, created_by - FROM completed_job - LEFT JOIN job_logs ON job_logs.job_id = completed_job.id - WHERE completed_job.workspace_id = $2 AND id = $3", + let record = sqlx::query!( + "SELECT + substr(concat(coalesce(v2_as_completed_job.logs, ''), job_logs.logs), greatest($1 - job_logs.log_offset, 0)) AS logs, + mem_peak, + CASE WHEN is_flow_step is true then NULL else flow_status END AS \"flow_status: sqlx::types::Json>\", + job_logs.log_offset + char_length(job_logs.logs) + 1 AS log_offset, + created_by AS \"created_by!\" + FROM v2_as_completed_job + LEFT JOIN job_logs ON job_logs.job_id = v2_as_completed_job.id + WHERE v2_as_completed_job.workspace_id = $2 AND v2_as_completed_job.id = $3", + log_offset, + &w_id, + job_id ) - .bind(log_offset) - .bind(&w_id) - .bind(&job_id) .fetch_optional(&db) .await?; if let Some(record) = record { @@ -5380,7 +5384,7 @@ pub fn list_completed_jobs_query( join_outstanding_wait_times: bool, tags: Option>, ) -> SqlBuilder { - let mut sqlb = SqlBuilder::select_from("completed_job") + let mut sqlb = SqlBuilder::select_from("v2_as_completed_job") .fields(fields) .order_by("created_at", lq.order_desc.unwrap_or(true)) .offset(offset) @@ -5523,20 +5527,10 @@ async fn get_completed_job<'a>( #[derive(FromRow)] pub struct RawResult { pub result: Option>>, - pub flow_status: Option>>, - pub language: Option, + pub result_columns: Option>, pub created_by: Option, } -#[derive(FromRow)] -pub struct RawResultWithSuccess { - pub result: Option>>, - pub flow_status: Option>>, - pub language: Option, - pub success: bool, - pub created_by: String, -} - async fn get_completed_job_result( OptAuthed(opt_authed): OptAuthed, Extension(db): Extension, @@ -5548,27 +5542,38 @@ async fn get_completed_job_result( .map(|authed| get_scope_tags(authed)) .flatten(); let result_o = if let Some(json_path) = json_path { - sqlx::query_as::<_, RawResult>( - "SELECT result #> $3 as result, flow_status, language, created_by FROM completed_job WHERE id = $1 AND workspace_id = $2 AND ($4::text[] IS NULL OR tag = ANY($4))", + sqlx::query_as!( + RawResult, + "SELECT + result #> $3 AS \"result: sqlx::types::Json>\", + result_columns, + created_by AS \"created_by!\" + FROM v2_job_completed c + JOIN v2_job USING (id) + WHERE c.id = $1 AND c.workspace_id = $2 AND ($4::text[] IS NULL OR tag = ANY($4))", + id, + &w_id, + json_path.split(".").collect::>() as Vec<&str>, + tags.as_ref().map(|v| v.as_slice()) as Option<&[&str]>, ) - .bind(id) - .bind(&w_id) - .bind( - json_path - .split(".") - .map(|x| x.to_string()) - .collect::>(), - ) - .bind(tags.as_ref().map(|v| v.as_slice())) .fetch_optional(&db) .await? } else { - sqlx::query_as::<_, RawResult>("SELECT result, flow_status, language, created_by FROM completed_job WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))") - .bind(id) - .bind(&w_id) - .bind(tags.as_ref().map(|v| v.as_slice())) - .fetch_optional(&db) - .await? + sqlx::query_as!( + RawResult, + "SELECT + result AS \"result: sqlx::types::Json>\", + result_columns, + created_by AS \"created_by!\" + FROM v2_job_completed c + JOIN v2_job USING (id) + WHERE c.id = $1 AND c.workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + id, + &w_id, + tags.as_ref().map(|v| v.as_slice()) as Option<&[&str]>, + ) + .fetch_optional(&db) + .await? }; let mut raw_result = not_found_if_none(result_o, "Completed Job", id.to_string())?; @@ -5579,7 +5584,7 @@ async fn get_completed_job_result( let mut parent_job = id; while parent_job != suspended_job { let p_job = sqlx::query_scalar!( - "SELECT parent_job FROM queue WHERE id = $1 AND workspace_id = $2", + "SELECT parent_job FROM v2_job WHERE id = $1 AND workspace_id = $2", parent_job, &w_id ) @@ -5612,8 +5617,7 @@ async fn get_completed_job_result( } format_result( - raw_result.language.as_ref(), - raw_result.flow_status.as_ref(), + raw_result.result_columns.as_ref(), raw_result.result.as_mut(), ); @@ -5646,7 +5650,7 @@ async fn count_by_tag( TagCount, r#" SELECT tag as "tag!", COUNT(*) as "count!" - FROM completed_job + FROM v2_as_completed_job WHERE started_at > NOW() - make_interval(secs => $1) AND ($2::text IS NULL OR workspace_id = $2) GROUP BY tag ORDER BY "count!" DESC @@ -5683,21 +5687,24 @@ async fn get_completed_job_result_maybe( .as_ref() .map(|authed| get_scope_tags(authed)) .flatten(); - let result_o = sqlx::query_as::<_, RawResultWithSuccess>( - "SELECT result, success, language, flow_status, created_by FROM completed_job WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + let result_o = sqlx::query!( + "SELECT + result AS \"result: sqlx::types::Json>\", + result_columns, + status = 'success' AS \"success!\", + created_by AS \"created_by!\" + FROM v2_job_completed c + JOIN v2_job j USING (id) + WHERE c.id = $1 AND c.workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3))", + id, + &w_id, + tags.as_ref().map(|v| v.as_slice()) as Option<&[&str]>, ) - .bind(id) - .bind(&w_id) - .bind(tags.as_ref().map(|v| v.as_slice())) .fetch_optional(&db) .await?; if let Some(mut res) = result_o { - format_result( - res.language.as_ref(), - res.flow_status.as_ref(), - res.result.as_mut(), - ); + format_result(res.result_columns.as_ref(), res.result.as_mut()); if opt_authed.is_none() && res.created_by != "anonymous" { return Err(Error::BadRequest( "As a non logged in user, you can only see jobs ran by anonymous users".to_string(), @@ -5715,7 +5722,7 @@ async fn get_completed_job_result_maybe( .into_response()) } else if get_started.is_some_and(|x| x) { let started = sqlx::query_scalar!( - "SELECT running FROM queue WHERE id = $1 AND workspace_id = $2", + "SELECT running AS \"running!\" FROM v2_job_queue WHERE id = $1 AND workspace_id = $2", id, w_id ) @@ -5752,8 +5759,17 @@ async fn delete_completed_job<'a>( require_admin(authed.is_admin, &authed.username)?; let tags = get_scope_tags(&authed); let job_o = sqlx::query_as::<_, CompletedJob>( - "UPDATE completed_job SET args = null, logs = '', result = null, deleted = true WHERE id = $1 AND workspace_id = $2 AND ($3::text[] IS NULL OR tag = ANY($3)) \ - RETURNING *, null as labels", + "WITH mark_as_deleted AS ( + UPDATE v2_job_completed c SET + result = NULL, + deleted = TRUE + FROM v2_job j + WHERE c.id = $1 + AND j.id = c.id + AND c.workspace_id = $2 + AND ($3::TEXT[] IS NULL OR tag = ANY($3)) + RETURNING c.id + ) SELECT * FROM v2_as_completed_job WHERE id = (SELECT id FROM mark_as_deleted)", ) .bind(id) .bind(&w_id) @@ -5763,6 +5779,9 @@ async fn delete_completed_job<'a>( let cj = not_found_if_none(job_o, "Completed Job", id.to_string())?; + sqlx::query!("UPDATE v2_job SET args = NULL WHERE id = $1", id) + .execute(&mut *tx) + .await?; sqlx::query!("DELETE FROM job_logs WHERE job_id = $1", id) .execute(&mut *tx) .await?; diff --git a/backend/windmill-api/src/postgres_triggers/handler.rs b/backend/windmill-api/src/postgres_triggers/handler.rs index 5bcfb69acc..760be062f7 100644 --- a/backend/windmill-api/src/postgres_triggers/handler.rs +++ b/backend/windmill-api/src/postgres_triggers/handler.rs @@ -153,7 +153,7 @@ pub async fn get_raw_postgres_connection(db: &Database) -> Result pub_data, - Err(Error::SqlErr(sqlx::Error::RowNotFound)) => { + Err(Error::SqlErr { error: sqlx::Error::RowNotFound, .. }) => { return Err(Error::NotFound( "Publication was not found, please create a new publication".to_string(), )) @@ -1378,7 +1378,7 @@ pub async fn create_template_script( let rows: Vec = sqlx::query_as(&query) .fetch_all(&mut connection) .await - .map_err(error::Error::SqlErr)?; + .map_err(|e| error::Error::SqlErr { error: e, location: "pg_trigger".to_string() })?; let mut mapper: HashMap>> = HashMap::new(); diff --git a/backend/windmill-api/src/postgres_triggers/mod.rs b/backend/windmill-api/src/postgres_triggers/mod.rs index 0bd87ed262..8adb635030 100644 --- a/backend/windmill-api/src/postgres_triggers/mod.rs +++ b/backend/windmill-api/src/postgres_triggers/mod.rs @@ -52,7 +52,7 @@ pub async fn get_database_resource( .map_err(|_| Error::NotFound("Database resource do not exist".to_string()))?; let resource = match resource { - Some(resource) => serde_json::from_value::(resource).map_err(Error::SerdeJson)?, + Some(resource) => serde_json::from_value::(resource)?, None => { return { Err(Error::NotFound( diff --git a/backend/windmill-api/src/raw_apps.rs b/backend/windmill-api/src/raw_apps.rs index 59f2471c4d..bb2763b73d 100644 --- a/backend/windmill-api/src/raw_apps.rs +++ b/backend/windmill-api/src/raw_apps.rs @@ -110,7 +110,7 @@ async fn list_apps( sqlb.and_where_eq("app.path", "?".bind(path_exact)); } - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let mut tx = user_db.begin(&authed).await?; let rows = sqlx::query_as::<_, ListableApp>(&sql) .fetch_all(&mut *tx) @@ -293,7 +293,7 @@ async fn update_app( sqlb.returning("path"); - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let npath_o: Option = sqlx::query_scalar(&sql).fetch_optional(&mut *tx).await?; not_found_if_none(npath_o, "Raw App", path)?; diff --git a/backend/windmill-api/src/resources.rs b/backend/windmill-api/src/resources.rs index 88f8d79c29..f3f2285cd0 100644 --- a/backend/windmill-api/src/resources.rs +++ b/backend/windmill-api/src/resources.rs @@ -31,7 +31,6 @@ use windmill_audit::ActionKind; use windmill_common::{ db::UserDB, error::{Error, JsonResult, Result}, - jobs::QueuedJob, utils::{not_found_if_none, paginate, require_admin, Pagination, StripPath}, variables, }; @@ -262,7 +261,7 @@ async fn list_resources( sqlb.and_where_like_left("resource.path", path_start); } - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let mut tx = user_db.begin(&authed).await?; let rows = sqlx::query_as::<_, ListableResource>(&sql) .fetch_all(&mut *tx) @@ -516,7 +515,7 @@ pub async fn transform_json_value<'c>( Value::String(y) if y.starts_with("$res:") => { let path = y.strip_prefix("$res:").unwrap(); if path.split("/").count() < 2 { - return Err(Error::InternalErr(format!("Invalid resource path: {path}"))); + return Err(Error::internal_err(format!("Invalid resource path: {path}"))); } let mut tx: Transaction<'_, Postgres> = authed_transaction_or_default(authed, user_db.clone(), db).await?; @@ -537,21 +536,28 @@ pub async fn transform_json_value<'c>( } Value::String(y) if y.starts_with("$") && job_id.is_some() => { let mut tx = authed_transaction_or_default(authed, user_db.clone(), db).await?; - let job = sqlx::query_as::<_, QueuedJob>( - "SELECT * FROM queue WHERE id = $1 AND workspace_id = $2", + let job_id = job_id.unwrap(); + let job = sqlx::query!( + "SELECT + email AS \"email!\", + created_by AS \"created_by!\", + parent_job, permissioned_as AS \"permissioned_as!\", + script_path, schedule_path, flow_step_id, root_job, + scheduled_for AS \"scheduled_for!: chrono::DateTime\" + FROM v2_as_queue WHERE id = $1 AND workspace_id = $2", + job_id, + workspace ) - .bind(job_id.unwrap()) - .bind(workspace) .fetch_optional(&mut *tx) .await?; tx.commit().await?; - let job = not_found_if_none(job, "Job", job_id.unwrap().to_string())?; + let job = not_found_if_none(job, "Job", job_id.to_string())?; let flow_path = if let Some(uuid) = job.parent_job { let mut tx: Transaction<'_, Postgres> = authed_transaction_or_default(authed, user_db.clone(), db).await?; - let p = sqlx::query_scalar!("SELECT script_path FROM queue WHERE id = $1", uuid) + let p = sqlx::query_scalar!("SELECT runnable_path FROM v2_job WHERE id = $1", uuid) .fetch_optional(&mut *tx) .await? .flatten(); @@ -563,11 +569,11 @@ pub async fn transform_json_value<'c>( let variables = variables::get_reserved_variables( db, - &job.workspace_id, + workspace, token, &job.email, &job.created_by, - &job.id.to_string(), + &job_id.to_string(), &job.permissioned_as, job.script_path.clone(), job.parent_job.map(|x| x.to_string()), @@ -815,7 +821,7 @@ async fn update_resource( } } - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let npath_o: Option = sqlx::query_scalar(&sql).fetch_optional(&mut *tx).await?; let npath = not_found_if_none(npath_o, "Resource", path)?; @@ -1165,7 +1171,7 @@ async fn update_resource_type( sqlb.set_str("description", ndesc); } sqlb.set_str("edited_at", "now()"); - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let mut tx = user_db.begin(&authed).await?; sqlx::query(&sql).execute(&mut *tx).await?; diff --git a/backend/windmill-api/src/schedule.rs b/backend/windmill-api/src/schedule.rs index 79e8c4dcb4..109957da04 100644 --- a/backend/windmill-api/src/schedule.rs +++ b/backend/windmill-api/src/schedule.rs @@ -196,7 +196,7 @@ async fn create_schedule( .bind(&ns.cron_version.unwrap_or("v2".to_string())) .fetch_one(&mut *tx) .await - .map_err(|e| Error::InternalErr(format!("inserting schedule in {w_id}: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("inserting schedule in {w_id}: {e:#}")))?; handle_deployment_metadata( &authed.email, @@ -282,7 +282,7 @@ async fn edit_schedule( .bind(&es.cron_version) .fetch_one(&mut *tx) .await - .map_err(|e| Error::InternalErr(format!("updating schedule in {w_id}: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("updating schedule in {w_id}: {e:#}")))?; handle_deployment_metadata( &authed.email, @@ -356,7 +356,7 @@ async fn list_schedule( if let Some(path_start) = &lsq.path_start { sqlb.and_where_like_left("path", path_start); } - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let rows = sqlx::query_as::<_, Schedule>(&sql) .fetch_all(&mut *tx) .await?; @@ -407,8 +407,8 @@ async fn list_schedule_with_jobs( let mut tx = user_db.begin(&authed).await?; let (per_page, offset) = paginate(pagination); let rows = sqlx::query_as!(ScheduleWJobs, - "SELECT schedule.*, t.jobs FROM schedule, LATERAL ( SELECT ARRAY (SELECT json_build_object('id', id, 'success', success, 'duration_ms', duration_ms) FROM completed_job WHERE - completed_job.schedule_path = schedule.path AND completed_job.workspace_id = $1 AND parent_job IS NULL AND is_skipped = False ORDER BY started_at DESC LIMIT 20) AS jobs ) t + "SELECT schedule.*, t.jobs FROM schedule, LATERAL ( SELECT ARRAY (SELECT json_build_object('id', id, 'success', success, 'duration_ms', duration_ms) FROM v2_as_completed_job WHERE + v2_as_completed_job.schedule_path = schedule.path AND v2_as_completed_job.workspace_id = $1 AND parent_job IS NULL AND is_skipped = False ORDER BY started_at DESC LIMIT 20) AS jobs ) t WHERE schedule.workspace_id = $1 ORDER BY schedule.edited_at desc LIMIT $2 OFFSET $3", w_id, per_page as i64, @@ -832,17 +832,30 @@ pub struct EditSchedule { } pub async fn clear_schedule<'c>( - db: &mut Transaction<'c, Postgres>, + tx: &mut Transaction<'c, Postgres>, path: &str, w_id: &str, ) -> Result<()> { tracing::info!("Clearing schedule {}", path); sqlx::query!( - "DELETE FROM queue WHERE schedule_path = $1 AND running = false AND workspace_id = $2 AND is_flow_step = false", + "WITH to_delete AS ( + SELECT id FROM v2_job_queue + JOIN v2_job j USING (id) + WHERE trigger_kind = 'schedule' + AND trigger = $1 + AND j.workspace_id = $2 + AND flow_step_id IS NULL + AND running = false + FOR UPDATE + ), deleted AS ( + DELETE FROM v2_job_queue + WHERE id IN (SELECT id FROM to_delete) + RETURNING id + ) DELETE FROM v2_job WHERE id IN (SELECT id FROM deleted)", path, w_id ) - .execute(&mut **db) + .execute(&mut **tx) .await?; Ok(()) } diff --git a/backend/windmill-api/src/scripts.rs b/backend/windmill-api/src/scripts.rs index 10ac5aa387..cbeb13e106 100644 --- a/backend/windmill-api/src/scripts.rs +++ b/backend/windmill-api/src/scripts.rs @@ -311,7 +311,7 @@ async fn list_scripts( .fields(&["dm.deployment_msg"]); } - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let mut tx = user_db.begin(&authed).await?; let rows = sqlx::query_as::<_, ListableScript>(&sql) .fetch_all(&mut *tx) @@ -1337,7 +1337,7 @@ async fn archive_script_by_path( ) .fetch_one(&db) .await - .map_err(|e| Error::InternalErr(format!("archiving script in {w_id}: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("archiving script in {w_id}: {e:#}")))?; audit_log( &mut *tx, &authed, @@ -1387,7 +1387,7 @@ async fn archive_script_by_hash( .bind(&hash.0) .fetch_one(&mut *tx) .await - .map_err(|e| Error::InternalErr(format!("archiving script in {w_id}: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("archiving script in {w_id}: {e:#}")))?; audit_log( &mut *tx, @@ -1427,7 +1427,7 @@ async fn delete_script_by_hash( .bind(&w_id) .fetch_one(&db) .await - .map_err(|e| Error::InternalErr(format!("deleting script by hash {w_id}: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("deleting script by hash {w_id}: {e:#}")))?; audit_log( &mut *tx, @@ -1487,7 +1487,7 @@ async fn delete_script_by_path( ) .fetch_one(&db) .await - .map_err(|e| Error::InternalErr(format!("deleting script by path {w_id}: {e:#}")))? + .map_err(|e| Error::internal_err(format!("deleting script by path {w_id}: {e:#}")))? } else { // If the script is draft only, we can delete it without admin permissions but we still need write permissions sqlx::query_scalar!( @@ -1497,7 +1497,7 @@ async fn delete_script_by_path( ) .fetch_one(&mut *tx) .await - .map_err(|e| Error::InternalErr(format!("deleting script by path {w_id}: {e:#}")))? + .map_err(|e| Error::internal_err(format!("deleting script by path {w_id}: {e:#}")))? }; sqlx::query!( @@ -1559,7 +1559,7 @@ async fn delete_script_by_path( .execute(&db) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error deleting deployment metadata for script with path {path} in workspace {w_id}: {e:#}" )) })?; diff --git a/backend/windmill-api/src/service_logs.rs b/backend/windmill-api/src/service_logs.rs index 277a08bca9..b11646fbe0 100644 --- a/backend/windmill-api/src/service_logs.rs +++ b/backend/windmill-api/src/service_logs.rs @@ -83,7 +83,7 @@ async fn list_files( if let Some(true) = lq.with_error { sqlb.and_where("err_lines > 0"); } - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let rows = sqlx::query_as::<_, LogFile>(&sql).fetch_all(&db).await?; Ok(Json(rows)) } @@ -114,7 +114,7 @@ async fn get_log_file( return Ok(content_plain(Body::from(bytes::Bytes::from(bytes)))); } Err(e) => { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "Error pulling the bytes: {}", e ))); @@ -122,7 +122,7 @@ async fn get_log_file( } } Err(e) => { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "Error fetching the file: {}", e ))); diff --git a/backend/windmill-api/src/settings.rs b/backend/windmill-api/src/settings.rs index c527eb481a..37a33ee81a 100644 --- a/backend/windmill-api/src/settings.rs +++ b/backend/windmill-api/src/settings.rs @@ -132,7 +132,7 @@ pub async fn test_s3_bucket( if first_file.is_some() { if let Err(e) = first_file.as_ref().unwrap() { tracing::error!("error listing bucket: {e:#}"); - error::Error::InternalErr(format!("Failed to list files in blob storage: {e:#}")); + error::Error::internal_err(format!("Failed to list files in blob storage: {e:#}")); } tracing::info!("Listed files: {:?}", first_file.unwrap()); } else { @@ -156,7 +156,7 @@ pub async fn test_s3_bucket( .await .map_err(to_anyhow)?; if content != Bytes::from_static(b"hello") { - return Err(error::Error::InternalErr( + return Err(error::Error::internal_err( "Failed to read back from blob storage".to_string(), )); } @@ -232,7 +232,7 @@ pub async fn set_global_setting_internal( generate_instance_username_for_all_users(db) .await .map_err(|err| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "Failed to generate instance wide usernames: {}", err )) @@ -349,7 +349,7 @@ pub async fn get_latest_key_renewal_attempt( Some(last_attempt) => { let last_attempt_result = serde_json::from_value::(last_attempt.value) .map_err(|e| { - error::Error::InternalErr(format!("Failed to parse last attempt: {}", e)) + error::Error::internal_err(format!("Failed to parse last attempt: {}", e)) })?; Ok(Json(Some(KeyRenewalAttempt { result: last_attempt_result, diff --git a/backend/windmill-api/src/slack_approvals.rs b/backend/windmill-api/src/slack_approvals.rs index 8d39131e7d..652c7b1721 100644 --- a/backend/windmill-api/src/slack_approvals.rs +++ b/backend/windmill-api/src/slack_approvals.rs @@ -977,17 +977,17 @@ async fn get_modal_blocks( let (job_kind, script_hash, raw_flow, parent_job_id, created_at, created_by, script_path, args) = sqlx::query!( "SELECT - queue.job_kind AS \"job_kind: JobKind\", - queue.script_hash AS \"script_hash: ScriptHash\", - queue.raw_flow AS \"raw_flow: sqlx::types::Json>\", - completed_job.parent_job AS \"parent_job: Uuid\", - completed_job.created_at AS \"created_at: chrono::NaiveDateTime\", - completed_job.created_by AS \"created_by!\", - queue.script_path, - queue.args AS \"args: sqlx::types::Json>\" - FROM queue - JOIN completed_job ON completed_job.parent_job = queue.id - WHERE completed_job.id = $1 AND completed_job.workspace_id = $2 + v2_as_queue.job_kind AS \"job_kind!: JobKind\", + v2_as_queue.script_hash AS \"script_hash: ScriptHash\", + v2_as_queue.raw_flow AS \"raw_flow: sqlx::types::Json>\", + v2_as_completed_job.parent_job AS \"parent_job: Uuid\", + v2_as_completed_job.created_at AS \"created_at!: chrono::NaiveDateTime\", + v2_as_completed_job.created_by AS \"created_by!\", + v2_as_queue.script_path, + v2_as_queue.args AS \"args: sqlx::types::Json>\" + FROM v2_as_queue + JOIN v2_as_completed_job ON v2_as_completed_job.parent_job = v2_as_queue.id + WHERE v2_as_completed_job.id = $1 AND v2_as_completed_job.workspace_id = $2 LIMIT 1", job_id, &w_id diff --git a/backend/windmill-api/src/users.rs b/backend/windmill-api/src/users.rs index c0159480e7..71bfeb2c2a 100644 --- a/backend/windmill-api/src/users.rs +++ b/backend/windmill-api/src/users.rs @@ -474,7 +474,7 @@ async fn list_user_usage( FROM usr , LATERAL ( SELECT COALESCE(SUM(duration_ms + 1000)/1000 , 0)::BIGINT executions - FROM completed_job + FROM v2_as_completed_job WHERE workspace_id = $1 AND job_kind NOT IN ('flow', 'flowpreview', 'flownode') AND email = usr.email @@ -487,7 +487,7 @@ async fn list_user_usage( .fetch_all(&mut *tx), ) .await - .map_err(|e| Error::InternalErr(format!("Timed out while fetching user usage: {e:#}")))??; + .map_err(|e| Error::internal_err(format!("Timed out while fetching user usage: {e:#}")))??; tx.commit().await?; Ok(Json(rows)) } @@ -695,7 +695,7 @@ async fn global_whoami( ) .fetch_one(&db) .await - .map_err(|e| Error::InternalErr(format!("fetching global identity: {e:#}"))); + .map_err(|e| Error::internal_err(format!("fetching global identity: {e:#}"))); if let Ok(user) = user { Ok(Json(user)) @@ -1591,7 +1591,7 @@ async fn login( if let Some((email, hash, super_admin, first_time_user)) = email_w_h { let parsed_hash = - PasswordHash::new(&hash).map_err(|e| Error::InternalErr(e.to_string()))?; + PasswordHash::new(&hash).map_err(|e| Error::internal_err(e.to_string()))?; if argon2 .verify_password(password.as_bytes(), &parsed_hash) .is_err() @@ -2315,25 +2315,9 @@ async fn update_username_in_workpsace<'c>( .execute(&mut **tx) .await?; - // ---- queue ---- + // ---- v2_job ---- sqlx::query!( - r#"UPDATE queue SET script_path = REGEXP_REPLACE(script_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE script_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, - new_username, - old_username, - w_id - ).execute(&mut **tx) - .await?; - - sqlx::query!( - r#"UPDATE queue SET schedule_path = REGEXP_REPLACE(schedule_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE schedule_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, - new_username, - old_username, - w_id - ).execute(&mut **tx) - .await?; - - sqlx::query!( - "UPDATE queue SET permissioned_as = ('u/' || $1) WHERE permissioned_as = ('u/' || $2) AND workspace_id = $3", + r#"UPDATE v2_job SET runnable_path = REGEXP_REPLACE(runnable_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE runnable_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, new_username, old_username, w_id @@ -2342,44 +2326,7 @@ async fn update_username_in_workpsace<'c>( .await?; sqlx::query!( - "UPDATE queue SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", - new_username, - old_username, - w_id - ) - .execute(&mut **tx) - .await - .unwrap(); - - sqlx::query!( - "UPDATE queue SET created_by = $1 WHERE created_by = $2 AND workspace_id = $3", - new_username, - old_username, - w_id - ) - .execute(&mut **tx) - .await - .unwrap(); - - // ---- completed_job ---- - sqlx::query!( - r#"UPDATE completed_job SET script_path = REGEXP_REPLACE(script_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE script_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, - new_username, - old_username, - w_id - ).execute(&mut **tx) - .await?; - - sqlx::query!( - r#"UPDATE completed_job SET schedule_path = REGEXP_REPLACE(schedule_path,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE schedule_path LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, - new_username, - old_username, - w_id - ).execute(&mut **tx) - .await?; - - sqlx::query!( - "UPDATE completed_job SET permissioned_as = ('u/' || $1) WHERE permissioned_as = ('u/' || $2) AND workspace_id = $3", + r#"UPDATE v2_job SET trigger = REGEXP_REPLACE(trigger,'u/' || $2 || '/(.*)','u/' || $1 || '/\1') WHERE trigger LIKE ('u/' || $2 || '/%') AND workspace_id = $3"#, new_username, old_username, w_id @@ -2388,24 +2335,42 @@ async fn update_username_in_workpsace<'c>( .await?; sqlx::query!( - "UPDATE completed_job SET created_by = $1 WHERE created_by = $2 AND workspace_id = $3", + "UPDATE v2_job SET permissioned_as = ('u/' || $1) WHERE permissioned_as = ('u/' || $2) AND workspace_id = $3", new_username, old_username, w_id ) .execute(&mut **tx) - .await - .unwrap(); + .await?; sqlx::query!( - "UPDATE completed_job SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + "UPDATE v2_job SET created_by = $1 WHERE created_by = $2 AND workspace_id = $3", new_username, old_username, w_id ) .execute(&mut **tx) - .await - .unwrap(); + .await?; + + // ---- v2_job_queue ---- + sqlx::query!( + "UPDATE v2_job_queue SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + new_username, + old_username, + w_id + ) + .execute(&mut **tx) + .await?; + + // ---- v2_job_completed ---- + sqlx::query!( + "UPDATE v2_job_completed SET canceled_by = $1 WHERE canceled_by = $2 AND workspace_id = $3", + new_username, + old_username, + w_id + ) + .execute(&mut **tx) + .await?; // ---- resources---- sqlx::query!( diff --git a/backend/windmill-api/src/users_ee.rs b/backend/windmill-api/src/users_ee.rs index 0e20d5bf84..7a11239a2f 100644 --- a/backend/windmill-api/src/users_ee.rs +++ b/backend/windmill-api/src/users_ee.rs @@ -17,7 +17,7 @@ pub async fn create_user( _argon2: Arc>, mut _nu: NewUser, ) -> Result<(StatusCode, String)> { - Err(Error::InternalErr( + Err(Error::internal_err( "Not implemented in Windmill's Open Source repository".to_string(), )) } @@ -29,7 +29,7 @@ pub async fn set_password( _user_email: &str, _ep: EditPassword, ) -> Result { - Err(Error::InternalErr( + Err(Error::internal_err( "Not implemented in Windmill's Open Source repository".to_string(), )) } diff --git a/backend/windmill-api/src/utils.rs b/backend/windmill-api/src/utils.rs index 5e7adde1e6..439944e2b2 100644 --- a/backend/windmill-api/src/utils.rs +++ b/backend/windmill-api/src/utils.rs @@ -76,7 +76,7 @@ pub async fn generate_instance_wide_unique_username<'c>( let mut i = 1; while username_conflict { if i > 1000 { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "too many username conflicts for {}", email ))); @@ -168,7 +168,7 @@ pub async fn get_instance_username_or_create_pending<'c>( ) .execute(&mut **tx) .await - .map_err(|e| Error::InternalErr(format!("creating pending user: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("creating pending user: {e:#}")))?; Ok(username) } diff --git a/backend/windmill-api/src/variables.rs b/backend/windmill-api/src/variables.rs index 48800621b6..37960e8583 100644 --- a/backend/windmill-api/src/variables.rs +++ b/backend/windmill-api/src/variables.rs @@ -196,7 +196,7 @@ async fn get_variable( ) } #[cfg(not(feature = "oauth2"))] - return Err(Error::InternalErr("Require oauth2 feature".to_string())); + return Err(Error::internal_err("Require oauth2 feature".to_string())); } else if !value.is_empty() && decrypt_secret { let _ = tx.commit().await; let mc = build_crypt(&db, &w_id).await?; @@ -558,7 +558,7 @@ async fn update_variable( } } - let sql = sqlb.sql().map_err(|e| Error::InternalErr(e.to_string()))?; + let sql = sqlb.sql().map_err(|e| Error::internal_err(e.to_string()))?; let npath_o: Option = sqlx::query_scalar(&sql).fetch_optional(&mut *tx).await?; @@ -662,7 +662,7 @@ pub async fn get_value_internal<'c>( .await? } #[cfg(not(feature = "oauth2"))] - return Err(Error::InternalErr("Require oauth2 feature".to_string())); + return Err(Error::internal_err("Require oauth2 feature".to_string())); } else if !value.is_empty() { tx.commit().await?; let mc = build_crypt(&db, &w_id).await?; diff --git a/backend/windmill-api/src/websocket_triggers.rs b/backend/windmill-api/src/websocket_triggers.rs index f90bb8def0..a28ed01425 100644 --- a/backend/windmill-api/src/websocket_triggers.rs +++ b/backend/windmill-api/src/websocket_triggers.rs @@ -154,7 +154,7 @@ async fn list_websocket_triggers( } let sql = sqlb .sql() - .map_err(|e| error::Error::InternalErr(e.to_string()))?; + .map_err(|e| error::Error::internal_err(e.to_string()))?; let rows = sqlx::query_as::<_, WebsocketTrigger>(&sql) .fetch_all(&mut *tx) .await?; diff --git a/backend/windmill-api/src/workspaces.rs b/backend/windmill-api/src/workspaces.rs index 244f95215c..088b8d0617 100644 --- a/backend/windmill-api/src/workspaces.rs +++ b/backend/windmill-api/src/workspaces.rs @@ -8,7 +8,7 @@ use std::collections::HashMap; -use crate::ai::{AiResource, AI_KEY_CACHE}; +use crate::ai::{AIProvider, AIResource, AI_KEY_CACHE}; use crate::db::ApiAuthed; use crate::users_ee::send_email_if_possible; use crate::utils::get_instance_username_or_create_pending; @@ -199,7 +199,9 @@ pub struct WorkspaceSettings { pub webhook: Option, pub deploy_to: Option, pub ai_resource: Option, - pub code_completion_enabled: bool, + pub ai_models: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub code_completion_model: Option, pub error_handler: Option, pub error_handler_extra_args: Option, pub error_handler_muted_on_cancel: Option, @@ -268,7 +270,8 @@ struct EditWebhook { #[derive(Deserialize)] struct EditCopilotConfig { ai_resource: Option, - code_completion_enabled: bool, + code_completion_model: Option, + ai_models: Vec, } #[derive(Deserialize, Serialize, Debug)] @@ -431,7 +434,7 @@ async fn get_settings( ) .fetch_one(&mut *tx) .await - .map_err(|e| Error::InternalErr(format!("getting settings: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("getting settings: {e:#}")))?; tx.commit().await?; Ok(Json(settings)) @@ -454,7 +457,7 @@ async fn get_deploy_to( ) .fetch_one(&mut *tx) .await - .map_err(|e| Error::InternalErr(format!("getting deploy_to: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("getting deploy_to: {e:#}")))?; tx.commit().await?; Ok(Json(settings)) @@ -682,27 +685,37 @@ async fn edit_copilot_config( let mut tx = db.begin().await?; if let Some(ai_resource) = &eo.ai_resource { - let path = serde_json::from_value::(ai_resource.clone()) - .map_err(|e| Error::BadRequest(e.to_string()))? - .path; + let parsed_ai_resource = serde_json::from_value::(ai_resource.clone()) + .map_err(|e| Error::BadRequest(e.to_string()))?; + + #[cfg(not(feature = "enterprise"))] + { + if matches!(parsed_ai_resource.provider, AIProvider::CustomAI) { + return Err(Error::BadRequest( + "Custom AI is only available on EE".to_string(), + )); + } + } + sqlx::query!( - "UPDATE workspace_settings SET ai_resource = $1, code_completion_enabled = $2 WHERE workspace_id = $3", + "UPDATE workspace_settings SET ai_resource = $1, code_completion_model = $2, ai_models = $3 WHERE workspace_id = $4", ai_resource, - eo.code_completion_enabled, + eo.code_completion_model, + eo.ai_models.as_slice(), &w_id ) .execute(&mut *tx) .await?; if let Some(cached) = AI_KEY_CACHE.get(&w_id) { - if cached.path != path { + if cached.path != parsed_ai_resource.path { AI_KEY_CACHE.remove(&w_id); } } } else { sqlx::query!( - "UPDATE workspace_settings SET ai_resource = NULL, code_completion_enabled = $1 WHERE workspace_id = $2", - eo.code_completion_enabled, + "UPDATE workspace_settings SET ai_resource = NULL, code_completion_model = $1, ai_models = '{}' WHERE workspace_id = $2", + eo.code_completion_model, &w_id, ) .execute(&mut *tx) @@ -720,8 +733,8 @@ async fn edit_copilot_config( [ ("ai_resource", &format!("{:?}", eo.ai_resource)[..]), ( - "code_completion_enabled", - &format!("{:?}", eo.code_completion_enabled)[..], + "code_completion_model", + &format!("{:?}", eo.code_completion_model)[..], ), ] .into(), @@ -735,9 +748,12 @@ async fn edit_copilot_config( #[derive(Serialize)] struct CopilotInfo { - pub ai_provider: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub ai_provider: Option, pub exists_ai_resource: bool, - pub code_completion_enabled: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub code_completion_model: Option, + pub ai_models: Vec, } async fn get_copilot_info( Extension(db): Extension, @@ -745,33 +761,26 @@ async fn get_copilot_info( ) -> JsonResult { let mut tx = db.begin().await?; let record = sqlx::query!( - "SELECT ai_resource, code_completion_enabled FROM workspace_settings WHERE workspace_id = $1", + "SELECT ai_resource, code_completion_model, ai_models FROM workspace_settings WHERE workspace_id = $1", &w_id ) .fetch_one(&mut *tx) .await - .map_err(|e| Error::InternalErr(format!("getting ai_resource and code_completion_enabled: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("getting ai_resource and code_completion_model: {e:#}")))?; tx.commit().await?; let (ai_provider, exists_ai_resource) = if let Some(ai_resource) = record.ai_resource { - let ai_resource = serde_json::from_value::(ai_resource); - let exist = ai_resource.is_ok(); - ( - if exist { - ai_resource.unwrap().provider - } else { - "".to_string() - }, - exist, - ) + let ai_resource = serde_json::from_value::(ai_resource)?; + (Some(ai_resource.provider), true) } else { - ("".to_string(), false) + (None, false) }; Ok(Json(CopilotInfo { ai_provider, exists_ai_resource, - code_completion_enabled: record.code_completion_enabled, + code_completion_model: record.code_completion_model, + ai_models: record.ai_models, })) } @@ -801,7 +810,7 @@ async fn edit_large_file_storage_config( if let Some(lfs_config) = new_config.large_file_storage { let serialized_lfs_config = serde_json::to_value::(lfs_config) - .map_err(|err| Error::InternalErr(err.to_string()))?; + .map_err(|err| Error::internal_err(err.to_string()))?; sqlx::query!( "UPDATE workspace_settings SET large_file_storage = $1 WHERE workspace_id = $2", @@ -870,7 +879,7 @@ async fn edit_git_sync_config( if let Some(git_sync_settings) = new_config.git_sync_settings { let serialized_config = serde_json::to_value::(git_sync_settings) - .map_err(|err| Error::InternalErr(err.to_string()))?; + .map_err(|err| Error::internal_err(err.to_string()))?; sqlx::query!( "UPDATE workspace_settings SET git_sync = $1 WHERE workspace_id = $2", @@ -936,7 +945,7 @@ async fn edit_deploy_ui_config( if let Some(deploy_ui_settings) = new_config.deploy_ui_settings { let serialized_config = serde_json::to_value::(deploy_ui_settings) - .map_err(|err| Error::InternalErr(err.to_string()))?; + .map_err(|err| Error::internal_err(err.to_string()))?; sqlx::query!( "UPDATE workspace_settings SET deploy_ui = $1 WHERE workspace_id = $2", @@ -1031,7 +1040,7 @@ async fn get_default_scripts( ) .fetch_optional(&mut *tx) .await - .map_err(|err| Error::InternalErr(format!("getting default_app: {err}")))?; + .map_err(|err| Error::internal_err(format!("getting default_app: {err}")))?; tx.commit().await?; Ok(Json(default_scripts.flatten())) @@ -1105,7 +1114,7 @@ async fn get_default_app( ) .fetch_one(&mut *tx) .await - .map_err(|err| Error::InternalErr(format!("getting default_app: {err}")))?; + .map_err(|err| Error::internal_err(format!("getting default_app: {err}")))?; tx.commit().await?; Ok(Json(WorkspaceDefaultApp { default_app_path })) diff --git a/backend/windmill-api/src/workspaces_ee.rs b/backend/windmill-api/src/workspaces_ee.rs index d5fd2cdda1..aa8799e233 100644 --- a/backend/windmill-api/src/workspaces_ee.rs +++ b/backend/windmill-api/src/workspaces_ee.rs @@ -9,7 +9,7 @@ pub async fn edit_auto_invite( _w_id: String, _ea: EditAutoInvite, ) -> windmill_common::error::Result { - Err(windmill_common::error::Error::InternalErr( + Err(windmill_common::error::Error::internal_err( "Not implemented on OSS".to_string(), )) } diff --git a/backend/windmill-api/src/workspaces_export.rs b/backend/windmill-api/src/workspaces_export.rs index 0a417ff916..1f55d0172a 100644 --- a/backend/windmill-api/src/workspaces_export.rs +++ b/backend/windmill-api/src/workspaces_export.rs @@ -241,7 +241,9 @@ struct SimplifiedSettings { error_handler_extra_args: Option, error_handler_muted_on_cancel: bool, ai_resource: Option, - code_completion_enabled: bool, + ai_models: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + code_completion_model: Option, large_file_storage: Option, git_sync: Option, default_app: Option, @@ -558,7 +560,7 @@ pub(crate) async fn tarball_workspace( for group in groups { let extra_perms: HashMap = serde_json::from_value(group.extra_perms) .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "Error parsing extra_perms for group {}: {}", group.name, e )) @@ -617,7 +619,8 @@ pub(crate) async fn tarball_workspace( deploy_to, error_handler, ai_resource, - code_completion_enabled, + ai_models, + code_completion_model, error_handler_extra_args, error_handler_muted_on_cancel, large_file_storage, @@ -635,7 +638,7 @@ pub(crate) async fn tarball_workspace( .map(|v| serde_json::to_string_pretty(&v).ok()) .ok() .flatten() - .ok_or_else(|| Error::InternalErr("Error serializing settings".to_string()))?; + .ok_or_else(|| Error::internal_err("Error serializing settings".to_string()))?; archive .write_to_archive(&settings_str, "settings.json") @@ -654,7 +657,7 @@ pub(crate) async fn tarball_workspace( .map(|v| serde_json::to_string_pretty(&v).ok()) .ok() .flatten() - .ok_or_else(|| Error::InternalErr("Error serializing enryption key".to_string()))?; + .ok_or_else(|| Error::internal_err("Error serializing enryption key".to_string()))?; archive .write_to_archive(&key_json, "encryption_key.json") .await?; diff --git a/backend/windmill-api/src/workspaces_extra.rs b/backend/windmill-api/src/workspaces_extra.rs index a8f0c8721d..2378e85c02 100644 --- a/backend/windmill-api/src/workspaces_extra.rs +++ b/backend/windmill-api/src/workspaces_extra.rs @@ -144,7 +144,7 @@ pub(crate) async fn change_workspace_id( .await?; sqlx::query!( - "UPDATE completed_job SET workspace_id = $1 WHERE workspace_id = $2", + "UPDATE v2_job_completed SET workspace_id = $1 WHERE workspace_id = $2", &rw.new_id, &old_id ) @@ -269,7 +269,7 @@ pub(crate) async fn change_workspace_id( .await?; sqlx::query!( - "UPDATE queue SET workspace_id = $1 WHERE workspace_id = $2", + "UPDATE v2_job_queue SET workspace_id = $1 WHERE workspace_id = $2", &rw.new_id, &old_id ) @@ -277,7 +277,7 @@ pub(crate) async fn change_workspace_id( .await?; sqlx::query!( - "UPDATE job SET workspace_id = $1 WHERE workspace_id = $2", + "UPDATE v2_job SET workspace_id = $1 WHERE workspace_id = $2", &rw.new_id, &old_id ) @@ -430,7 +430,10 @@ pub(crate) async fn delete_workspace( sqlx::query!("DELETE FROM dependency_map WHERE workspace_id = $1", &w_id) .execute(&mut *tx) .await?; - sqlx::query!("DELETE FROM queue WHERE workspace_id = $1", &w_id) + sqlx::query!("DELETE FROM v2_job_queue WHERE workspace_id = $1", &w_id) + .execute(&mut *tx) + .await?; + sqlx::query!("DELETE FROM v2_job WHERE workspace_id = $1", &w_id) .execute(&mut *tx) .await?; sqlx::query!("DELETE FROM capture WHERE workspace_id = $1", &w_id) @@ -468,9 +471,12 @@ pub(crate) async fn delete_workspace( .execute(&mut *tx) .await?; - sqlx::query!("DELETE FROM completed_job WHERE workspace_id = $1", &w_id) - .execute(&mut *tx) - .await?; + sqlx::query!( + "DELETE FROM v2_job_completed WHERE workspace_id = $1", + &w_id + ) + .execute(&mut *tx) + .await?; sqlx::query!("DELETE FROM job_stats WHERE workspace_id = $1", &w_id) .execute(&mut *tx) diff --git a/backend/windmill-common/src/auth.rs b/backend/windmill-common/src/auth.rs index 017131388d..52a966b105 100644 --- a/backend/windmill-common/src/auth.rs +++ b/backend/windmill-common/src/auth.rs @@ -67,7 +67,7 @@ pub async fn is_super_admin_email(db: &DB, email: &str) -> Result { let is_admin = sqlx::query_scalar!("SELECT super_admin FROM password WHERE email = $1", email) .fetch_optional(db) .await - .map_err(|e| Error::InternalErr(format!("fetching super admin: {e:#}")))? + .map_err(|e| Error::internal_err(format!("fetching super admin: {e:#}")))? .unwrap_or(false); Ok(is_admin) @@ -81,7 +81,7 @@ pub async fn is_devops_email(db: &DB, email: &str) -> Result { let is_devops = sqlx::query_scalar!("SELECT devops FROM password WHERE email = $1", email) .fetch_optional(db) .await - .map_err(|e| Error::InternalErr(format!("fetching super admin: {e:#}")))? + .map_err(|e| Error::internal_err(format!("fetching super admin: {e:#}")))? .unwrap_or(false); Ok(is_devops) @@ -123,7 +123,7 @@ pub async fn fetch_authed_from_permissioned_as( if let Some(r) = r { (r.is_admin, r.operator) } else { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "user {name} not found in workspace {w_id}" ))); } diff --git a/backend/windmill-common/src/bench.rs b/backend/windmill-common/src/bench.rs index 0e89af571c..dafbfdb6e5 100644 --- a/backend/windmill-common/src/bench.rs +++ b/backend/windmill-common/src/bench.rs @@ -84,6 +84,7 @@ pub async fn benchmark_init(benchmark_jobs: i32, db: &DB) { let benchmark_kind = std::env::var("BENCHMARK_KIND").unwrap_or("noop".to_string()); if benchmark_jobs > 0 { + let mut tx = db.begin().await.unwrap(); match benchmark_kind.as_str() { "dedicated" => { // you need to create the script first, check https://github.com/windmill-labs/windmill/blob/b76a92cfe454c686f005c65f534e29e039f3c706/benchmarks/lib.ts#L47 @@ -92,10 +93,10 @@ pub async fn benchmark_init(benchmark_jobs: i32, db: &DB) { "f/benchmarks/dedicated", "admins" ) - .fetch_one(db) + .fetch_one(&mut *tx) .await .unwrap_or_else(|_e| panic!("failed to insert dedicated jobs")); - sqlx::query!("INSERT INTO queue (id, script_hash, script_path, job_kind, language, tag, created_by, permissioned_as, email, scheduled_for, workspace_id) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 FROM generate_series(1, $11))", + let uuids = sqlx::query_scalar!("INSERT INTO v2_job (id, runnable_id, runnable_path, kind, script_lang, tag, created_by, permissioned_as, permissioned_as_email, workspace_id) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9 FROM generate_series(1, $10)) RETURNING id", hash, "f/benchmarks/dedicated", JobKind::Script as JobKind, @@ -104,12 +105,21 @@ pub async fn benchmark_init(benchmark_jobs: i32, db: &DB) { "admin", "u/admin", "admin@windmill.dev", - chrono::Utc::now(), "admins", benchmark_jobs ) - .execute(db) - .await.unwrap_or_else(|_e| panic!("failed to insert dedicated jobs")); + .fetch_all(&mut *tx) + .await.unwrap_or_else(|_e| panic!("failed to insert dedicated jobs (1)")); + sqlx::query!("INSERT INTO v2_job_queue (id, workspace_id, scheduled_for, tag) SELECT unnest($1::uuid[]), $2, now(), $3", &uuids, "admins", "admins:f/benchmarks/dedicated") + .execute(&mut *tx) + .await.unwrap_or_else(|_e| panic!("failed to insert dedicated jobs (2)")); + sqlx::query!( + "INSERT INTO v2_job_runtime (id) SELECT unnest($1::uuid[])", + &uuids + ) + .execute(&mut *tx) + .await + .unwrap_or_else(|_e| panic!("failed to insert dedicated jobs (3)")); } "parallelflow" => { //create dedicated script @@ -124,9 +134,9 @@ pub async fn benchmark_init(benchmark_jobs: i32, db: &DB) { "flow", "admin", ) - .execute(db) + .execute(&mut *tx) .await.unwrap_or_else(|_e| panic!("failed to insert parallelflow jobs {_e:#}")); - sqlx::query!("INSERT INTO queue (id, script_hash, script_path, job_kind, language, tag, created_by, permissioned_as, email, scheduled_for, workspace_id, raw_flow, flow_status) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12 FROM generate_series(1, 1))", + let uuids = sqlx::query_scalar!("INSERT INTO v2_job (id, runnable_id, runnable_path, kind, script_lang, tag, created_by, permissioned_as, permissioned_as_email, workspace_id, raw_flow) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 FROM generate_series(1, 1)) RETURNING id", None::, None::, JobKind::FlowPreview as JobKind, @@ -135,7 +145,6 @@ pub async fn benchmark_init(benchmark_jobs: i32, db: &DB) { "admin", "u/admin", "admin@windmill.dev", - chrono::Utc::now(), "admins", serde_json::from_str::(r#" { @@ -169,7 +178,24 @@ pub async fn benchmark_init(benchmark_jobs: i32, db: &DB) { "preprocessor_module": null } "#).unwrap(), - serde_json::from_str::(r#" + ) + .fetch_all(&mut *tx) + .await.unwrap_or_else(|_e| panic!("failed to insert parallelflow jobs (1)")); + sqlx::query!("INSERT INTO v2_job_queue (id, workspace_id, scheduled_for, tag) SELECT unnest($1::uuid[]), $2, now(), $3", &uuids, "admins", "flow") + .execute(&mut *tx) + .await.unwrap_or_else(|_e| panic!("failed to insert parallelflow jobs (2)")); + sqlx::query!( + "INSERT INTO v2_job_runtime (id) SELECT unnest($1::uuid[])", + &uuids + ) + .execute(&mut *tx) + .await + .unwrap_or_else(|_e| panic!("failed to insert parallelflow jobs (3)")); + sqlx::query!( + "INSERT INTO v2_job_status (id, flow_status) SELECT unnest($1::uuid[]), $2", + &uuids, + serde_json::from_str::( + r#" { "step": 0, "modules": [ @@ -186,13 +212,16 @@ pub async fn benchmark_init(benchmark_jobs: i32, db: &DB) { "preprocessor_module": null } - "#).unwrap() + "# + ) + .unwrap() ) - .execute(db) - .await.unwrap_or_else(|_e| panic!("failed to insert parallelflow jobs")); + .execute(&mut *tx) + .await + .unwrap_or_else(|_e| panic!("failed to insert parallelflow jobs (4)")); } _ => { - sqlx::query!("INSERT INTO queue (id, script_hash, script_path, job_kind, language, tag, created_by, permissioned_as, email, scheduled_for, workspace_id) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 FROM generate_series(1, $11))", + let uuids = sqlx::query_scalar!("INSERT INTO v2_job (id, runnable_id, runnable_path, kind, script_lang, tag, created_by, permissioned_as, permissioned_as_email, workspace_id) (SELECT gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9 FROM generate_series(1, $10)) RETURNING id", None::, None::, JobKind::Noop as JobKind, @@ -201,13 +230,23 @@ pub async fn benchmark_init(benchmark_jobs: i32, db: &DB) { "admin", "u/admin", "admin@windmill.dev", - chrono::Utc::now(), "admins", benchmark_jobs ) - .execute(db) - .await.unwrap_or_else(|_e| panic!("failed to insert noop jobs")); + .fetch_all(&mut *tx) + .await.unwrap_or_else(|_e| panic!("failed to insert noop jobs (1)")); + sqlx::query!("INSERT INTO v2_job_queue (id, workspace_id, scheduled_for, tag) SELECT unnest($1::uuid[]), $2, now(), $3", &uuids, "admins", "deno") + .execute(&mut *tx) + .await.unwrap_or_else(|_e| panic!("failed to insert noop jobs (2)")); + sqlx::query!( + "INSERT INTO v2_job_runtime (id) SELECT unnest($1::uuid[])", + &uuids + ) + .execute(&mut *tx) + .await + .unwrap_or_else(|_e| panic!("failed to insert noop jobs (3)")); } } + tx.commit().await.unwrap(); } } diff --git a/backend/windmill-common/src/cache.rs b/backend/windmill-common/src/cache.rs index 83cec0b417..7447213605 100644 --- a/backend/windmill-common/src/cache.rs +++ b/backend/windmill-common/src/cache.rs @@ -389,7 +389,7 @@ pub mod flow { async move { fetch_node.await.and_then(|data| match data { RawData::Script(data) => Ok(data), - RawData::Flow(_) => Err(error::Error::InternalErr(format!( + RawData::Flow(_) => Err(error::Error::internal_err(format!( "Flow node ({:x}) isn't a script node.", node.0 ))), @@ -410,7 +410,7 @@ pub mod flow { async move { fetch_node.await.and_then(|data| match data { RawData::Flow(data) => Ok(data), - RawData::Script(_) => Err(error::Error::InternalErr(format!( + RawData::Script(_) => Err(error::Error::internal_err(format!( "Flow node ({:x}) isn't a flow node.", node.0 ))), @@ -639,7 +639,7 @@ pub mod job { async move { fetch_preview.await.and_then(|data| match data { RawData::Flow(data) => Ok(data), - RawData::Script(_) => Err(error::Error::InternalErr(format!( + RawData::Script(_) => Err(error::Error::internal_err(format!( "Job ({job}) isn't a flow job." ))), }) @@ -659,7 +659,7 @@ pub mod job { async move { fetch_preview.await.and_then(|data| match data { RawData::Script(data) => Ok(data), - RawData::Flow(_) => Err(error::Error::InternalErr(format!( + RawData::Flow(_) => Err(error::Error::internal_err(format!( "Job ({job}) isn't a script job." ))), }) @@ -681,7 +681,7 @@ pub mod job { match (raw_lock, raw_code, raw_flow) { (None, None, None) => sqlx::query!( "SELECT raw_code, raw_lock, raw_flow AS \"raw_flow: Json>\" \ - FROM job WHERE id = $1 LIMIT 1", + FROM v2_job WHERE id = $1 LIMIT 1", job ) .fetch_optional(e) @@ -723,7 +723,7 @@ pub mod job { .await .map(|(data, _meta)| data), (AppScript, Some(id)) => app::fetch_script(e, AppScriptId(id)).await, - _ => Err(error::Error::InternalErr(format!( + _ => Err(error::Error::internal_err(format!( "Isn't a script job: {:?}", kind ))), @@ -748,7 +748,7 @@ pub mod job { Ok(raw_flow) => Ok(raw_flow), Err(_) => flow::fetch_version(e, id).await, }, - _ => Err(error::Error::InternalErr(format!( + _ => Err(error::Error::internal_err(format!( "Isn't a flow job {:?}", kind ))), @@ -807,7 +807,7 @@ const _: () = { fn resolve(mut src: Self::Untrusted) -> error::Result { let Some(meta) = src.meta.take() else { - return Err(error::Error::InternalErr("Invalid script src".to_string())); + return Err(error::Error::internal_err("Invalid script src".to_string())); }; Ok(ScriptFull { data: Arc::new(ScriptData { code: src.content, lock: src.lock }), @@ -842,7 +842,7 @@ const _: () = { RawNode { raw_code: Some(code), raw_lock: lock, .. } => { Ok(Self::Script(Arc::new(ScriptData { code, lock }))) } - _ => Err(error::Error::InternalErr( + _ => Err(error::Error::internal_err( "Invalid raw data src".to_string(), )), } diff --git a/backend/windmill-common/src/error.rs b/backend/windmill-common/src/error.rs index 426354a13d..faf1a72d1b 100644 --- a/backend/windmill-common/src/error.rs +++ b/backend/windmill-common/src/error.rs @@ -22,8 +22,6 @@ pub type JsonResult = std::result::Result, Error>; #[derive(Debug, Error)] pub enum Error { - #[error("Uuid Error {0}")] - UuidErr(#[from] uuid::Error), #[error("Bad config: {0}")] BadConfig(String), #[error("Connecting to database: {0}")] @@ -40,26 +38,34 @@ pub enum Error { RequireAdmin(String), #[error("{0}")] ExecutionErr(String), - #[error("IO error: {0}")] - IoErr(#[from] io::Error), - #[error("Sql error: {0}")] - SqlErr(#[from] sqlx::Error), + #[error("IoErr: {error:#} @{location:#}")] + IoErr { error: io::Error, location: String }, + #[error("Utf8Err: {error:#} @{location:#}")] + Utf8Err { error: std::string::FromUtf8Error, location: String }, + #[error("UuidErr: {error:#} @{location:#}")] + UuidErr { error: uuid::Error, location: String }, + #[error("SqlErr: {error:#} @{location:#}")] + SqlErr { error: sqlx::Error, location: String }, + #[error("SerdeJson: {error:#} @{location:#}")] + SerdeJson { error: serde_json::Error, location: String }, #[error("Bad request: {0}")] BadRequest(String), #[error("Quota exceeded: {0}")] QuotaExceeded(String), #[error("Internal: {0}")] InternalErr(String), + #[error("Internal: {message} @{location}")] + InternalErrLoc { message: String, location: String }, #[error("Internal: {0}: {1}")] InternalErrAt(&'static Location<'static>, String), - #[error("Hexadecimal decoding error: {0}")] - HexErr(#[from] hex::FromHexError), + #[error("HexErr: {error:#} @{location:#}")] + HexErr { error: hex::FromHexError, location: String }, #[error("Migrating database: {0}")] DatabaseMigration(#[from] MigrateError), - #[error("Non-zero exit status: {0}")] - ExitStatus(i32), - #[error("Err: {0:#}")] - Anyhow(#[from] anyhow::Error), + #[error("Non-zero exit status for {0}: {1}")] + ExitStatus(String, i32), + #[error("Error: {error:#} @{location:#}")] + Anyhow { error: anyhow::Error, location: String }, #[error("Error: {0:#?}")] JsonErr(serde_json::Value), #[error("{0}")] @@ -68,10 +74,63 @@ pub enum Error { AlreadyCompleted(String), #[error("Find python error: {0}")] FindPythonError(String), - #[error("{0}")] - Utf8(#[from] std::string::FromUtf8Error), - #[error("Encoding/decoding error: {0}")] - SerdeJson(#[from] serde_json::Error), +} + +fn prettify_location(location: &'static Location<'static>) -> String { + location + .to_string() + .split("/") + .last() + .unwrap_or("unknown") + .to_string() +} +impl From for Error { + #[track_caller] + fn from(e: anyhow::Error) -> Self { + Self::Anyhow { error: e, location: prettify_location(std::panic::Location::caller()) } + } +} + +impl From for Error { + #[track_caller] + fn from(e: sqlx::Error) -> Self { + Self::SqlErr { error: e, location: prettify_location(std::panic::Location::caller()) } + } +} + +impl From for Error { + #[track_caller] + fn from(e: uuid::Error) -> Self { + Self::UuidErr { error: e, location: prettify_location(std::panic::Location::caller()) } + } +} + +impl From for Error { + #[track_caller] + fn from(e: std::string::FromUtf8Error) -> Self { + Self::Utf8Err { error: e, location: prettify_location(std::panic::Location::caller()) } + } +} + +impl From for Error { + #[track_caller] + fn from(e: io::Error) -> Self { + Self::IoErr { error: e, location: prettify_location(std::panic::Location::caller()) } + } +} + +impl From for Error { + #[track_caller] + fn from(e: hex::FromHexError) -> Self { + Self::HexErr { error: e, location: prettify_location(std::panic::Location::caller()) } + } +} + +impl From for Error { + #[track_caller] + fn from(e: serde_json::Error) -> Self { + Self::SerdeJson { error: e, location: prettify_location(std::panic::Location::caller()) } + } } impl Error { @@ -86,10 +145,20 @@ impl Error { pub fn relocate_internal(self, loc: &'static Location<'static>) -> Self { match self { - Self::InternalErr(s) | Self::InternalErrAt(_, s) => Self::InternalErrAt(loc, s), + Self::InternalErrLoc { message, .. } + | Self::InternalErrAt(_, message) + | Self::InternalErr(message) => Self::InternalErrAt(loc, message), _ => self, } } + + #[track_caller] + pub fn internal_err>(msg: T) -> Self { + Self::InternalErrLoc { + message: msg.as_ref().to_string(), + location: prettify_location(std::panic::Location::caller()), + } + } } pub fn relocate_internal(loc: &'static Location<'static>) -> impl FnOnce(Error) -> Error { @@ -109,9 +178,10 @@ impl IntoResponse for Error { Self::NotFound(_) => axum::http::StatusCode::NOT_FOUND, Self::NotAuthorized(_) => axum::http::StatusCode::UNAUTHORIZED, Self::RequireAdmin(_) => axum::http::StatusCode::FORBIDDEN, - Self::SqlErr(_) | Self::BadRequest(_) | Self::AiError(_) | Self::QuotaExceeded(_) => { - axum::http::StatusCode::BAD_REQUEST - } + Self::SqlErr { .. } + | Self::BadRequest(_) + | Self::AiError(_) + | Self::QuotaExceeded(_) => axum::http::StatusCode::BAD_REQUEST, _ => axum::http::StatusCode::INTERNAL_SERVER_ERROR, }; diff --git a/backend/windmill-common/src/flows.rs b/backend/windmill-common/src/flows.rs index b4e23bb342..31152aa938 100644 --- a/backend/windmill-common/src/flows.rs +++ b/backend/windmill-common/src/flows.rs @@ -736,7 +736,7 @@ pub async fn resolve_value( with_code: bool, ) -> Result<(), Error> { let mut val = serde_json::from_str::(value.get()).map_err(|err| { - Error::InternalErr(format!("resolve: Failed to parse flow value: {}", err)) + Error::internal_err(format!("resolve: Failed to parse flow value: {}", err)) })?; for module in &mut val.modules { resolve_module(e, workspace_id, &mut module.value, with_code).await?; @@ -755,7 +755,7 @@ pub async fn resolve_module( use FlowModuleValue::*; let mut val = serde_json::from_str::(value.get()).map_err(|err| { - Error::InternalErr(format!( + Error::internal_err(format!( "resolve: Failed to parse flow module value: {}", err )) diff --git a/backend/windmill-common/src/jobs.rs b/backend/windmill-common/src/jobs.rs index 13a8dd7e8a..1c764b12df 100644 --- a/backend/windmill-common/src/jobs.rs +++ b/backend/windmill-common/src/jobs.rs @@ -11,8 +11,6 @@ use uuid::Uuid; pub const ENTRYPOINT_OVERRIDE: &str = "_ENTRYPOINT_OVERRIDE"; -pub const PREPROCESSOR_FAKE_ENTRYPOINT: &str = "__WM_PREPROCESSOR"; - use crate::{ apps::AppScriptId, error::{self, to_anyhow, Error}, @@ -71,6 +69,7 @@ pub struct QueuedJob { pub script_hash: Option, #[serde(skip_serializing_if = "Option::is_none")] pub script_path: Option, + pub script_entrypoint_override: Option, pub args: Option>>>, #[serde(skip_serializing_if = "Option::is_none")] pub logs: Option, @@ -116,6 +115,8 @@ pub struct QueuedJob { pub cache_ttl: Option, #[serde(skip_serializing_if = "Option::is_none")] pub priority: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub preprocessed: Option, } impl QueuedJob { @@ -170,6 +171,7 @@ impl Default for QueuedJob { flow_status: None, is_flow_step: false, language: None, + script_entrypoint_override: None, same_worker: false, pre_run_error: None, email: "".to_string(), @@ -185,6 +187,7 @@ impl Default for QueuedJob { flow_step_id: None, cache_ttl: None, priority: None, + preprocessed: None, } } } @@ -197,7 +200,7 @@ pub struct CompletedJob { pub parent_job: Option, pub created_by: String, pub created_at: chrono::DateTime, - pub started_at: chrono::DateTime, + pub started_at: Option>, pub duration_ms: i64, pub success: bool, #[serde(skip_serializing_if = "Option::is_none")] @@ -207,6 +210,7 @@ pub struct CompletedJob { pub args: Option>>>, #[serde(skip_serializing_if = "Option::is_none")] pub result: Option>>, + pub result_columns: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub logs: Option, pub deleted: bool, @@ -234,6 +238,8 @@ pub struct CompletedJob { pub priority: Option, #[serde(skip_serializing_if = "Option::is_none")] pub labels: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub preprocessed: Option, } impl CompletedJob { @@ -251,12 +257,6 @@ impl CompletedJob { } } -#[derive(sqlx::FromRow)] -pub struct BranchResults { - pub result: sqlx::types::Json>, - pub id: Uuid, -} - #[derive(Debug, Clone)] pub enum JobPayload { ScriptHub { @@ -480,7 +480,7 @@ pub async fn script_hash_to_tag_and_limits<'c>( .fetch_one(&mut **db) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "querying getting tag for hash {script_hash}: {e:#}" )) })?; @@ -535,19 +535,9 @@ pub async fn get_payload_tag_from_prefixed_path( Ok((payload, tag, on_behalf_of)) } -#[derive(Deserialize)] -struct FlowStatusMetadata { - column_order: Vec, -} - -#[derive(Deserialize)] -struct FlowStatusWithMetadataOnly { - _metadata: FlowStatusMetadata, -} - pub fn order_columns( rows: Option>>, - column_order: Vec, + column_order: &Vec, ) -> Option> { if let Some(mut rows) = rows { if let Some(first_row) = rows.get(0) { @@ -555,7 +545,7 @@ pub fn order_columns( if let Ok(first_row) = first_row { let mut new_first_row = IndexMap::new(); for col in column_order { - if let Some(val) = first_row.get(&col) { + if let Some(val) = first_row.get(col) { new_first_row.insert(col.clone(), val.clone()); } } @@ -572,39 +562,21 @@ pub fn order_columns( } pub fn format_result( - language: Option<&ScriptLang>, - flow_status: Option<&sqlx::types::Json>>, + result_columns: Option<&Vec>, result: Option<&mut sqlx::types::Json>>, ) -> () { - match language { - Some(&ScriptLang::Postgresql) - | Some(&ScriptLang::Mysql) - | Some(&ScriptLang::Snowflake) - | Some(&ScriptLang::Bigquery) => { - if let Some(Ok(flow_status)) = - flow_status.map(|x| serde_json::from_str::(x.get())) - { - if let Some(result) = result { - let rows = serde_json::from_str::>>(result.get()).ok(); - if let Some(ordered_result) = - order_columns(rows, flow_status._metadata.column_order) - { - *result = sqlx::types::Json(ordered_result); - } - } + if let Some(result_columns) = result_columns { + if let Some(result) = result { + let rows = serde_json::from_str::>>(result.get()).ok(); + if let Some(ordered_result) = order_columns(rows, result_columns) { + *result = sqlx::types::Json(ordered_result); } } - _ => {} } } pub fn format_completed_job_result(mut cj: CompletedJob) -> CompletedJob { - format_result( - cj.language.as_ref(), - cj.flow_status.as_ref(), - cj.result.as_mut(), - ); - + format_result(cj.result_columns.as_ref(), cj.result.as_mut()); cj } diff --git a/backend/windmill-common/src/lib.rs b/backend/windmill-common/src/lib.rs index e47c4fc87f..4bb224e21b 100644 --- a/backend/windmill-common/src/lib.rs +++ b/backend/windmill-common/src/lib.rs @@ -36,7 +36,6 @@ pub mod job_s3_helpers_ee; pub mod jobs; pub mod more_serde; pub mod oauth2; -pub mod teams_ee; pub mod otel_ee; pub mod queue; pub mod s3_helpers; @@ -44,6 +43,7 @@ pub mod schedule; pub mod scripts; pub mod server; pub mod stats_ee; +pub mod teams_ee; pub mod tracing_init; pub mod users; pub mod utils; diff --git a/backend/windmill-common/src/queue.rs b/backend/windmill-common/src/queue.rs index 6cbb5611c5..39ec349c91 100644 --- a/backend/windmill-common/src/queue.rs +++ b/backend/windmill-common/src/queue.rs @@ -3,14 +3,14 @@ use std::collections::HashMap; use sqlx::{Pool, Postgres}; pub async fn get_queue_counts(db: &Pool) -> HashMap { - sqlx::query_as::<_, (String, i64)>( - "SELECT tag, count(*) as count FROM queue WHERE + sqlx::query!( + "SELECT tag AS \"tag!\", count(*) AS \"count!\" FROM v2_job_queue WHERE scheduled_for <= now() - ('3 seconds')::interval AND running = false GROUP BY tag", ) .fetch_all(db) .await .ok() - .map(|v| v.into_iter().map(|(k, v)| (k, v as u32)).collect()) + .map(|v| v.into_iter().map(|x| (x.tag, x.count as u32)).collect()) .unwrap_or_else(|| HashMap::new()) } diff --git a/backend/windmill-common/src/s3_helpers.rs b/backend/windmill-common/src/s3_helpers.rs index 0274d0f38d..01507f5b6a 100644 --- a/backend/windmill-common/src/s3_helpers.rs +++ b/backend/windmill-common/src/s3_helpers.rs @@ -298,7 +298,7 @@ pub async fn build_s3_client(s3_resource_ref: &S3Resource) -> error::Result Result workspace_id, err ); - Err(Error::SqlErr(err)) + return Err(err.into()); } } } diff --git a/backend/windmill-common/src/variables.rs b/backend/windmill-common/src/variables.rs index 353b26ecb5..48746152ef 100644 --- a/backend/windmill-common/src/variables.rs +++ b/backend/windmill-common/src/variables.rs @@ -105,7 +105,7 @@ pub async fn get_workspace_key(w_id: &str, db: &DB) -> crate::error::Result String { pub fn decrypt(mc: &MagicCrypt256, value: String) -> error::Result { mc.decrypt_base64_to_string(value).map_err(|e| match e { - MagicCryptError::DecryptError(_) => error::Error::InternalErr( + MagicCryptError::DecryptError(_) => error::Error::internal_err( "Could not decrypt value. The value may have been encrypted with a different key." .to_string(), ), - _ => error::Error::InternalErr(e.to_string()), + _ => error::Error::internal_err(e.to_string()), }) } diff --git a/backend/windmill-common/src/worker.rs b/backend/windmill-common/src/worker.rs index 241679301f..65c77a5ee7 100644 --- a/backend/windmill-common/src/worker.rs +++ b/backend/windmill-common/src/worker.rs @@ -103,33 +103,65 @@ lazy_static::lazy_static! { pub static ref DISABLE_FLOW_SCRIPT: bool = std::env::var("DISABLE_FLOW_SCRIPT").ok().is_some_and(|x| x == "1" || x == "true"); } +fn format_pull_query(peek: String) -> String { + format!( + "WITH peek AS ( + {} + ), q AS ( + UPDATE v2_job_queue SET + running = true, + started_at = coalesce(started_at, now()), + suspend_until = null + WHERE id = (SELECT id FROM peek) + RETURNING + started_at, scheduled_for, running, + canceled_by, canceled_reason, canceled_by IS NOT NULL AS canceled, + suspend, suspend_until + ), r AS ( + UPDATE v2_job_runtime SET + ping = now() + WHERE id = (SELECT id FROM peek) + RETURNING ping AS last_ping, memory_peak AS mem_peak + ), j AS ( + SELECT + id, workspace_id, parent_job, created_by, created_at, runnable_id AS script_hash, + runnable_path AS script_path, args, kind AS job_kind, + CASE WHEN trigger_kind = 'schedule' THEN trigger END AS schedule_path, + permissioned_as, permissioned_as_email AS email, script_lang AS language, + flow_innermost_root_job AS root_job, flow_step_id, flow_step_id IS NOT NULL AS is_flow_step, + same_worker, pre_run_error, visible_to_owner, tag, concurrent_limit, + concurrency_time_window_s, timeout, cache_ttl, priority, raw_code, raw_lock, + raw_flow, script_entrypoint_override, preprocessed + FROM v2_job + WHERE id = (SELECT id FROM peek) + ) SELECT id, workspace_id, parent_job, created_by, created_at, started_at, scheduled_for, + running, script_hash, script_path, args, null as logs, canceled, canceled_by, + canceled_reason, last_ping, job_kind, schedule_path, permissioned_as, + flow_status, is_flow_step, language, suspend, suspend_until, + same_worker, pre_run_error, email, visible_to_owner, mem_peak, + root_job, flow_leaf_jobs as leaf_jobs, tag, concurrent_limit, concurrency_time_window_s, + timeout, flow_step_id, cache_ttl, priority, raw_code, raw_lock, raw_flow, + script_entrypoint_override, preprocessed + FROM q, r, j + LEFT JOIN v2_job_status f USING (id)", + peek + ) +} + pub async fn make_suspended_pull_query(wc: &WorkerConfig) { if wc.worker_tags.len() == 0 { tracing::error!("Empty tags in worker tags, skipping"); return; } - let query = format!( - "UPDATE queue - SET running = true - , started_at = coalesce(started_at, now()) - , last_ping = now() - , suspend_until = null - WHERE id = ( - SELECT id - FROM queue - WHERE suspend_until IS NOT NULL AND (suspend <= 0 OR suspend_until <= now()) AND tag IN ({}) - ORDER BY priority DESC NULLS LAST, created_at - FOR UPDATE SKIP LOCKED - LIMIT 1 - ) - RETURNING id, workspace_id, parent_job, created_by, created_at, started_at, scheduled_for, - running, script_hash, script_path, args, null as logs, canceled, canceled_by, - canceled_reason, last_ping, job_kind, schedule_path, permissioned_as, - flow_status, is_flow_step, language, suspend, suspend_until, - same_worker, pre_run_error, email, visible_to_owner, mem_peak, - root_job, leaf_jobs, tag, concurrent_limit, concurrency_time_window_s, - timeout, flow_step_id, cache_ttl, priority, - raw_code, raw_lock, raw_flow", wc.worker_tags.iter().map(|x| format!("'{x}'")).join(", ")); + let query = format_pull_query(format!( + "SELECT id + FROM v2_job_queue + WHERE suspend_until IS NOT NULL AND (suspend <= 0 OR suspend_until <= now()) AND tag IN ({}) + ORDER BY priority DESC NULLS LAST, created_at + FOR UPDATE SKIP LOCKED + LIMIT 1", + wc.worker_tags.iter().map(|x| format!("'{x}'")).join(", ") + )); let mut l = WORKER_SUSPENDED_PULL_QUERY.write().await; *l = query; } @@ -141,31 +173,17 @@ pub async fn make_pull_query(wc: &WorkerConfig) { tracing::error!("Empty tags in priority tags, skipping"); continue; } - let query = format!("UPDATE queue - SET running = true - , started_at = coalesce(started_at, now()) - , last_ping = now() - , suspend_until = null - WHERE id = ( - SELECT id - FROM queue + let query = format_pull_query(format!( + "SELECT id + FROM v2_job_queue WHERE running = false AND tag IN ({}) AND scheduled_for <= now() ORDER BY priority DESC NULLS LAST, scheduled_for FOR UPDATE SKIP LOCKED - LIMIT 1 - ) - RETURNING id, workspace_id, parent_job, created_by, created_at, started_at, scheduled_for, - running, script_hash, script_path, args, null as logs, canceled, canceled_by, - canceled_reason, last_ping, job_kind, schedule_path, permissioned_as, - flow_status, is_flow_step, language, suspend, suspend_until, - same_worker, pre_run_error, email, visible_to_owner, mem_peak, - root_job, leaf_jobs, tag, concurrent_limit, concurrency_time_window_s, - timeout, flow_step_id, cache_ttl, priority, - raw_code, raw_lock, raw_flow", tags.tags.iter().map(|x| format!("'{x}'")).join(", ")); - + LIMIT 1", + tags.tags.iter().map(|x| format!("'{x}'")).join(", ") + )); queries.push(query); } - let mut l = WORKER_PULL_QUERIES.write().await; *l = queries; } @@ -907,7 +925,7 @@ impl Default for WorkerConfigOpt { } } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Clone)] pub struct WorkerConfig { pub worker_tags: Vec, pub priority_tags_sorted: Vec, @@ -919,6 +937,13 @@ pub struct WorkerConfig { pub env_vars: HashMap, } +impl std::fmt::Debug for WorkerConfig { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "WorkerConfig {{ worker_tags: {:?}, priority_tags_sorted: {:?}, dedicated_worker: {:?}, init_bash: {:?}, cache_clear: {:?}, additional_python_paths: {:?}, pip_local_dependencies: {:?}, env_vars: {:?} }}", + self.worker_tags, self.priority_tags_sorted, self.dedicated_worker, self.init_bash, self.cache_clear, self.additional_python_paths, self.pip_local_dependencies, self.env_vars.iter().map(|(k, v)| format!("{}: {}{} ({} chars)", k, &v[..3.min(v.len())], "***", v.len())).collect::>().join(", ")) + } +} + #[derive(PartialEq, Debug, Clone)] pub struct PriorityTags { pub priority: u8, diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index 2405be5b61..48f66fcf5b 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -34,23 +34,21 @@ use windmill_common::{ error::{self, to_anyhow, Error}, flow_status::{ BranchAllStatus, FlowCleanupModule, FlowStatus, FlowStatusModule, FlowStatusModuleWParent, - Iterator, JobResult, RestartedFrom, RetryStatus, MAX_RETRY_ATTEMPTS, MAX_RETRY_INTERVAL, + Iterator as FlowIterator, JobResult, RestartedFrom, RetryStatus, MAX_RETRY_ATTEMPTS, + MAX_RETRY_INTERVAL, }, flows::{ add_virtual_items_if_necessary, FlowModule, FlowModuleValue, FlowValue, InputTransform, }, - jobs::{ - get_payload_tag_from_prefixed_path, CompletedJob, JobKind, JobPayload, QueuedJob, RawCode, - ENTRYPOINT_OVERRIDE, PREPROCESSOR_FAKE_ENTRYPOINT, - }, + jobs::{get_payload_tag_from_prefixed_path, JobKind, JobPayload, QueuedJob, RawCode}, schedule::Schedule, scripts::{get_full_hub_script_by_path, ScriptHash, ScriptLang}, users::{SUPERADMIN_NOTIFICATION_EMAIL, SUPERADMIN_SECRET_EMAIL}, utils::{not_found_if_none, report_critical_error, StripPath, WarnAfterExt}, worker::{ to_raw_value, CLOUD_HOSTED, DEFAULT_TAGS_PER_WORKSPACE, DEFAULT_TAGS_WORKSPACES, - DISABLE_FLOW_SCRIPT, MIN_VERSION_IS_AT_LEAST_1_427, MIN_VERSION_IS_AT_LEAST_1_432, - MIN_VERSION_IS_AT_LEAST_1_440, NO_LOGS, WORKER_PULL_QUERIES, WORKER_SUSPENDED_PULL_QUERY, + DISABLE_FLOW_SCRIPT, MIN_VERSION_IS_AT_LEAST_1_432, MIN_VERSION_IS_AT_LEAST_1_440, NO_LOGS, + WORKER_PULL_QUERIES, WORKER_SUSPENDED_PULL_QUERY, }, DB, METRICS_ENABLED, }; @@ -173,7 +171,7 @@ pub async fn cancel_single_job<'c>( }); } else { let id: Option = sqlx::query_scalar!( - "UPDATE queue SET canceled = true, canceled_by = $1, canceled_reason = $2, scheduled_for = now(), suspend = 0 WHERE id = $3 AND workspace_id = $4 AND (canceled = false OR canceled_reason != $2) RETURNING id", + "UPDATE v2_job_queue SET canceled_by = $1, canceled_reason = $2, scheduled_for = now(), suspend = 0 WHERE id = $3 AND workspace_id = $4 AND (canceled_by IS NULL OR canceled_reason != $2) RETURNING id", username, reason, job_running.id, @@ -249,7 +247,7 @@ pub async fn cancel_job<'c>( while !jobs.is_empty() { let p_job = jobs.pop(); let new_jobs = sqlx::query_scalar!( - "SELECT id FROM queue WHERE parent_job = $1 AND workspace_id = $2", + "SELECT id AS \"id!\" FROM v2_job WHERE parent_job = $1 AND workspace_id = $2", p_job, w_id ) @@ -361,7 +359,7 @@ async fn cancel_persistent_script_jobs_internal<'c>( // we could have retrieved the job IDs in the first query where we retrieve the hashes, but just in case a job was inserted in the queue right in-between the two above query, we re-do the fetch here let jobs_to_cancel = sqlx::query_scalar::<_, Uuid>( - "SELECT id FROM queue WHERE workspace_id = $1 AND script_path = $2 AND canceled = false", + "SELECT id FROM v2_as_queue WHERE workspace_id = $1 AND script_path = $2 AND canceled = false", ) .bind(w_id) .bind(script_path) @@ -395,23 +393,43 @@ pub struct WrappedError { pub trait ValidableJson { fn is_valid_json(&self) -> bool; + fn wm_labels(&self) -> Option>; +} + +#[derive(serde::Deserialize)] +struct ResultLabels { + wm_labels: Vec, } impl ValidableJson for WrappedError { fn is_valid_json(&self) -> bool { true } + + fn wm_labels(&self) -> Option> { + None + } } impl ValidableJson for Box { fn is_valid_json(&self) -> bool { !self.get().is_empty() } + + fn wm_labels(&self) -> Option> { + serde_json::from_str::(self.get()) + .ok() + .map(|r| r.wm_labels) + } } -impl ValidableJson for Arc> { +impl ValidableJson for Arc { fn is_valid_json(&self) -> bool { - !self.get().is_empty() + T::is_valid_json(&self) + } + + fn wm_labels(&self) -> Option> { + T::wm_labels(&self) } } @@ -419,12 +437,22 @@ impl ValidableJson for serde_json::Value { fn is_valid_json(&self) -> bool { true } + + fn wm_labels(&self) -> Option> { + serde_json::from_value::(self.clone()) + .ok() + .map(|r| r.wm_labels) + } } impl ValidableJson for Json { fn is_valid_json(&self) -> bool { self.0.is_valid_json() } + + fn wm_labels(&self) -> Option> { + self.0.wm_labels() + } } pub async fn register_metric( @@ -499,6 +527,7 @@ pub async fn add_completed_job_error( false, false, Json(&result), + None, mem_peak, canceled_by, flow_is_done, @@ -518,6 +547,7 @@ pub async fn add_completed_job( success: bool, skipped: bool, result: Json<&T>, + result_columns: Option>, mem_peak: i32, canceled_by: Option, flow_is_done: bool, @@ -528,11 +558,12 @@ pub async fn add_completed_job( // add_time!(bench, "add_completed_job start"); if !result.is_valid_json() { - return Err(Error::InternalErr( + return Err(Error::internal_err( "Result of job is invalid json (empty)".to_string(), )); } + let result_columns = result_columns.as_ref(); let _job_id = queued_job.id; let (opt_uuid, _duration, _skip_downstream_error_handlers) = (|| async { let mut tx = db.begin().await?; @@ -546,105 +577,60 @@ pub async fn add_completed_job( serde_json::to_string(&result).unwrap_or_else(|_| "".to_string()) ); - let (raw_code, raw_lock, raw_flow) = if !*MIN_VERSION_IS_AT_LEAST_1_427.read().await { - sqlx::query!( - "SELECT raw_code, raw_lock, raw_flow AS \"raw_flow: Json>\" - FROM job WHERE id = $1 AND workspace_id = $2 LIMIT 1", - &job_id, - &queued_job.workspace_id - ) - .fetch_one(db) - .map_ok(|record| (record.raw_code, record.raw_lock, record.raw_flow)) - .or_else(|_| { - sqlx::query!( - "SELECT raw_code, raw_lock, raw_flow AS \"raw_flow: Json>\" - FROM queue WHERE id = $1 AND workspace_id = $2 LIMIT 1", - &job_id, - &queued_job.workspace_id - ) - .fetch_one(db) - .map_ok(|record| (record.raw_code, record.raw_lock, record.raw_flow)) - }) - .await - .unwrap_or_default() - } else { - (None, None, None) - }; - let mem_peak = mem_peak.max(queued_job.mem_peak.unwrap_or(0)); // add_time!(bench, "add_completed_job query START"); let _duration = sqlx::query_scalar!( - "INSERT INTO completed_job AS cj + "INSERT INTO v2_job_completed AS cj ( workspace_id , id - , parent_job - , created_by - , created_at , started_at , duration_ms - , success - , script_hash - , script_path - , args , result - , raw_code - , raw_lock - , canceled + , result_columns , canceled_by , canceled_reason - , job_kind - , schedule_path - , permissioned_as , flow_status - , raw_flow - , is_flow_step - , is_skipped - , language - , email - , visible_to_owner - , mem_peak - , tag - , priority + , memory_peak + , status ) - VALUES ($1, $2, $3, $4, $5, COALESCE($6, now()), COALESCE($30::bigint, (EXTRACT('epoch' FROM (now())) - EXTRACT('epoch' FROM (COALESCE($6, now()))))*1000), $7, $8, $9,\ - $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29) - ON CONFLICT (id) DO UPDATE SET success = $7, result = $11 RETURNING duration_ms", - queued_job.workspace_id, - queued_job.id, - queued_job.parent_job, - queued_job.created_by, - queued_job.created_at, - queued_job.started_at, - success, - queued_job.script_hash.map(|x| x.0), - queued_job.script_path, - &queued_job.args as &Option>>>, - result as Json<&T>, - raw_code, - raw_lock, - canceled_by.is_some(), - canceled_by.clone().map(|cb| cb.username).flatten(), - canceled_by.clone().map(|cb| cb.reason).flatten(), - queued_job.job_kind.clone() as JobKind, - queued_job.schedule_path, - queued_job.permissioned_as, - &queued_job.flow_status as &Option>>, - &raw_flow as &Option>>, - queued_job.is_flow_step, - skipped, - queued_job.language.clone() as Option, - queued_job.email, - queued_job.visible_to_owner, - if mem_peak > 0 { Some(mem_peak) } else { None }, - queued_job.tag, - queued_job.priority, - duration, + VALUES ($1, $2, $3, COALESCE($12::bigint, (EXTRACT('epoch' FROM (now())) - EXTRACT('epoch' FROM (COALESCE($3, now()))))*1000), $5, $13, $7, $8, $9,\ + $11, CASE WHEN $6::BOOL THEN 'canceled'::job_status + WHEN $10::BOOL THEN 'skipped'::job_status + WHEN $4::BOOL THEN 'success'::job_status + ELSE 'failure'::job_status END) + ON CONFLICT (id) DO UPDATE SET status = EXCLUDED.status, result = $5 RETURNING duration_ms AS \"duration_ms!\"", + /* $1 */ queued_job.workspace_id, + /* $2 */ queued_job.id, + /* $3 */ queued_job.started_at, + /* $4 */ success, + /* $5 */ result as Json<&T>, + /* $6 */ canceled_by.is_some(), + /* $7 */ canceled_by.clone().map(|cb| cb.username).flatten(), + /* $8 */ canceled_by.clone().map(|cb| cb.reason).flatten(), + /* $9 */ &queued_job.flow_status as &Option>>, + /* $10 */ skipped, + /* $11 */ if mem_peak > 0 { Some(mem_peak) } else { None }, + /* $12 */ duration, + /* $13 */ result_columns as Option<&Vec>, ) .fetch_one(&mut *tx) .await - .map_err(|e| Error::InternalErr(format!("Could not add completed job {job_id}: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("Could not add completed job {job_id}: {e:#}")))?; + if let Some(labels) = result.wm_labels() { + sqlx::query!( + "UPDATE v2_job SET labels = ( + SELECT array_agg(DISTINCT all_labels) + FROM unnest(coalesce(labels, ARRAY[]::TEXT[]) || $2) all_labels + ) WHERE id = $1", + job_id, + labels as Vec + ) + .execute(&mut *tx) + .await + .map_err(|e| Error::InternalErr(format!("Could not update job labels: {e:#}")))?; + } if !queued_job.is_flow_step { if _duration > 500 @@ -652,7 +638,7 @@ pub async fn add_completed_job( || queued_job.job_kind == JobKind::Preview) { if let Err(e) = sqlx::query!( - "UPDATE completed_job SET flow_status = q.flow_status FROM queue q WHERE completed_job.id = $1 AND q.id = $1 AND q.workspace_id = $2 AND completed_job.workspace_id = $2 AND q.flow_status IS NOT NULL", + "UPDATE v2_job_completed SET flow_status = f.flow_status FROM v2_job_status f WHERE v2_job_completed.id = $1 AND f.id = $1 AND v2_job_completed.workspace_id = $2", &queued_job.id, &queued_job.workspace_id ) @@ -663,16 +649,25 @@ pub async fn add_completed_job( } if let Some(parent_job) = queued_job.parent_job { if let Err(e) = sqlx::query_scalar!( - "UPDATE queue SET flow_status = jsonb_set(jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], COALESCE(flow_status->$1, '{}'::jsonb)), array[$1, 'duration_ms'], to_jsonb($2::bigint)) WHERE id = $3 AND workspace_id = $4", - &queued_job.id.to_string(), - _duration, - parent_job, - &queued_job.workspace_id - ) - .execute(&mut *tx) - .await { - tracing::error!("Could not update parent job flow_status: {}", e); - } + "UPDATE v2_job_status SET + flow_status = jsonb_set( + jsonb_set( + COALESCE(flow_status, '{}'::jsonb), + array[$1], + COALESCE(flow_status->$1, '{}'::jsonb) + ), + array[$1, 'duration_ms'], + to_jsonb($2::bigint) + ) + WHERE id = $3", + &queued_job.id.to_string(), + _duration, + parent_job + ) + .execute(&mut *tx) + .await { + tracing::error!("Could not update parent job flow_status: {}", e); + } } } // tracing::error!("Added completed job {:#?}", queued_job); @@ -689,12 +684,17 @@ pub async fn add_completed_job( parent_job ); sqlx::query!( - "UPDATE queue SET last_ping = now() WHERE id = $1 AND workspace_id = $2 AND canceled = false", - parent_job, - &queued_job.workspace_id - ) - .execute(&mut *tx) - .await?; + "UPDATE v2_job_runtime r SET + ping = now() + FROM v2_job_queue q + WHERE r.id = $1 AND q.id = r.id + AND q.workspace_id = $2 + AND canceled_by IS NULL", + parent_job, + &queued_job.workspace_id + ) + .execute(&mut *tx) + .await?; if flow_is_done { let r = sqlx::query_scalar!( "UPDATE parallel_monitor_lock SET last_ping = now() WHERE parent_flow_id = $1 and job_id = $2 RETURNING 1", @@ -703,9 +703,9 @@ pub async fn add_completed_job( ).fetch_optional(&mut *tx).await?; if r.is_some() { tracing::info!( - "parallel flow iteration is done, setting parallel monitor last ping lock for job {}", - &queued_job.id - ); + "parallel flow iteration is done, setting parallel monitor last ping lock for job {}", + &queued_job.id + ); } } } @@ -728,21 +728,21 @@ pub async fn add_completed_job( // otherwise flow rescheduling is done inside handle_flow let schedule_next_tick = !queued_job.is_flow() || !success && sqlx::query_scalar!( - "SELECT - flow_status->>'step' = '0' - AND ( - jsonb_array_length(flow_status->'modules') = 0 - OR flow_status->'modules'->0->>'type' = 'WaitingForPriorSteps' - OR ( - flow_status->'modules'->0->>'type' = 'Failure' - AND flow_status->'modules'->0->>'job' = $1 - ) - ) - FROM completed_job WHERE id = $2 AND workspace_id = $3", - Uuid::nil().to_string(), - &queued_job.id, - &queued_job.workspace_id - ).fetch_optional(&mut *tx).await?.flatten().unwrap_or(false); + "SELECT + flow_status->>'step' = '0' + AND ( + jsonb_array_length(flow_status->'modules') = 0 + OR flow_status->'modules'->0->>'type' = 'WaitingForPriorSteps' + OR ( + flow_status->'modules'->0->>'type' = 'Failure' + AND flow_status->'modules'->0->>'job' = $1 + ) + ) + FROM v2_job_completed WHERE id = $2 AND workspace_id = $3", + Uuid::nil().to_string(), + &queued_job.id, + &queued_job.workspace_id + ).fetch_optional(&mut *tx).await?.flatten().unwrap_or(false); if schedule_next_tick { if let Err(err) = handle_maybe_scheduled_job( @@ -782,7 +782,7 @@ pub async fn add_completed_job( let w_id: &String = &queued_job.workspace_id; if !matches!(err, Error::QuotaExceeded(_)) { report_error_to_workspace_handler_or_critical_side_channel( - &queued_job, + &queued_job, db, format!( "Failed to push schedule error handler job to handle failed job ({base_url}/run/{}?workspace={w_id}): {}", @@ -798,9 +798,9 @@ pub async fn add_completed_job( }; } else { tracing::error!( - "Schedule {schedule_path} in {} not found. Impossible to schedule again and apply schedule handlers", - &queued_job.workspace_id - ); + "Schedule {schedule_path} in {} not found. Impossible to schedule again and apply schedule handlers", + &queued_job.workspace_id + ); } } } @@ -818,10 +818,10 @@ pub async fn add_completed_job( } }; if let Err(e) = sqlx::query_scalar!( - "UPDATE concurrency_counter SET job_uuids = job_uuids - $2 WHERE concurrency_id = $1", - concurrency_key, - queued_job.id.hyphenated().to_string(), - ) + "UPDATE concurrency_counter SET job_uuids = job_uuids - $2 WHERE concurrency_id = $1", + concurrency_key, + queued_job.id.hyphenated().to_string(), + ) .execute(&mut *tx) .await { @@ -835,9 +835,9 @@ pub async fn add_completed_job( .execute(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!( - "Error updating to add ended_at timestamp concurrency_key={concurrency_key}: {e:#}" - )) + Error::internal_err(format!( + "Error updating to add ended_at timestamp concurrency_key={concurrency_key}: {e:#}" + )) }) { tracing::error!("Could not update concurrency_key: {}", e); } @@ -898,16 +898,19 @@ pub async fn add_completed_job( sqlx::query_scalar!("SELECT premium FROM workspace WHERE id = $1", w_id) .fetch_one(db) .await - .map_err(|e| Error::InternalErr(format!("fetching if {w_id} is premium: {e:#}")))?; + .map_err(|e| { + Error::internal_err(format!("fetching if {w_id} is premium: {e:#}")) + })?; let _ = sqlx::query!( - "INSERT INTO usage (id, is_workspace, month_, usage) - VALUES ($1, TRUE, EXTRACT(YEAR FROM current_date) * 12 + EXTRACT(MONTH FROM current_date), $2) - ON CONFLICT (id, is_workspace, month_) DO UPDATE SET usage = usage.usage + $2", - w_id, - additional_usage as i32) - .execute(db) - .await - .map_err(|e| Error::InternalErr(format!("updating usage: {e:#}"))); + "INSERT INTO usage (id, is_workspace, month_, usage) + VALUES ($1, TRUE, EXTRACT(YEAR FROM current_date) * 12 + EXTRACT(MONTH FROM current_date), $2) + ON CONFLICT (id, is_workspace, month_) DO UPDATE SET usage = usage.usage + $2", + w_id, + additional_usage as i32 + ) + .execute(db) + .await + .map_err(|e| Error::internal_err(format!("updating usage: {e:#}"))); if !premium_workspace { let _ = sqlx::query!( @@ -915,10 +918,11 @@ pub async fn add_completed_job( VALUES ($1, FALSE, EXTRACT(YEAR FROM current_date) * 12 + EXTRACT(MONTH FROM current_date), $2) ON CONFLICT (id, is_workspace, month_) DO UPDATE SET usage = usage.usage + $2", queued_job.email, - additional_usage as i32) - .execute(db) - .await - .map_err(|e| Error::InternalErr(format!("updating usage: {e:#}"))); + additional_usage as i32 + ) + .execute(db) + .await + .map_err(|e| Error::internal_err(format!("updating usage: {e:#}"))); } } @@ -928,15 +932,14 @@ pub async fn add_completed_job( if let Ok(flow) = cache::job::fetch_flow(db, job.job_kind, job.script_hash).await { return flow.value().failure_module.is_some(); } - sqlx::query_scalar!("SELECT raw_flow->'failure_module' != 'null'::jsonb FROM job WHERE id = $1", job.id) - .fetch_one(db) - .or_else(|_| - sqlx::query_scalar!("SELECT raw_flow->'failure_module' != 'null'::jsonb FROM completed_job WHERE id = $1", job.id) - .fetch_one(db) - ) - .await - .unwrap_or(Some(false)) - .unwrap_or(false) + sqlx::query_scalar!( + "SELECT raw_flow->'failure_module' != 'null'::jsonb FROM v2_job WHERE id = $1", + job.id + ) + .fetch_one(db) + .await + .unwrap_or(Some(false)) + .unwrap_or(false) } if queued_job.email == ERROR_HANDLER_USER_EMAIL { @@ -1157,7 +1160,8 @@ pub async fn report_error_to_workspace_handler_or_critical_side_channel( let w_id = &queued_job.workspace_id; let (error_handler, error_handler_extra_args) = sqlx::query_as::<_, (Option, Option>>)>( "SELECT error_handler, error_handler_extra_args FROM workspace_settings WHERE workspace_id = $1", - ).bind(&w_id) + ) + .bind(&w_id) .fetch_optional(db) .await .ok() @@ -1209,11 +1213,12 @@ pub async fn send_error_to_workspace_handler<'a, 'c, T: Serialize + Send + Sync> let w_id = &queued_job.workspace_id; let (error_handler, error_handler_extra_args, error_handler_muted_on_cancel) = sqlx::query_as::<_, (Option, Option>>, bool)>( "SELECT error_handler, error_handler_extra_args, error_handler_muted_on_cancel FROM workspace_settings WHERE workspace_id = $1", - ).bind(&w_id) + ) + .bind(&w_id) .fetch_optional(db) .await .context("fetching error handler info from workspace_settings")? - .ok_or_else(|| Error::InternalErr(format!("no workspace settings for id {w_id}")))?; + .ok_or_else(|| Error::internal_err(format!("no workspace settings for id {w_id}")))?; if is_canceled && error_handler_muted_on_cancel { return Ok(()); @@ -1291,7 +1296,7 @@ pub async fn handle_maybe_scheduled_job<'c>( tx.commit().await?; Ok::<(), Error>(()) }) - .map_err(|e| Error::InternalErr(format!("Pushing next scheduled job timedout: {e:#}"))) + .map_err(|e| Error::internal_err(format!("Pushing next scheduled job timedout: {e:#}"))) .unwrap_or_else(|e| Err(e)) }) .retry( @@ -1324,7 +1329,7 @@ pub async fn handle_maybe_scheduled_job<'c>( Error::QuotaExceeded(_) => {} _ => { report_error_to_workspace_handler_or_critical_side_channel(job, db, - format!("Could not schedule next job for {} with err {}. Schedule disabled", schedule.path, err.to_string()) + format!("Could not schedule next job for {} with err {}. Schedule disabled", schedule.path, err.to_string()), ).await; } } @@ -1334,8 +1339,8 @@ pub async fn handle_maybe_scheduled_job<'c>( Error::QuotaExceeded(_) => Err(err), _ => { report_error_to_workspace_handler_or_critical_side_channel(job, db, - format!("Could not schedule next job for {} and could not disable schedule with err {}.", schedule.path, disable_err) - ).await; + format!("Could not schedule next job for {} and could not disable schedule with err {}.", schedule.path, disable_err), + ).await; Err(to_anyhow(disable_err).into()) } }, @@ -1381,15 +1386,23 @@ async fn apply_schedule_handlers<'a, 'c, T: Serialize + Send + Sync>( let times = schedule.on_failure_times.unwrap_or(1).max(1); let exact = schedule.on_failure_exact.unwrap_or(false); if times > 1 || exact { - let past_jobs = sqlx::query_as::<_, CompletedJobSubset>( - "SELECT success, result, started_at FROM completed_job WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4 ORDER BY created_at DESC LIMIT $5", + let past_jobs = sqlx::query!( + "SELECT + success AS \"success!\", + result AS \"result: Json>\", + started_at AS \"started_at!\" + FROM v2_as_completed_job + WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4 + ORDER BY created_at DESC + LIMIT $5", + &schedule.workspace_id, + &schedule.path, + script_path, + job_id, + if exact { times } else { times - 1 } as i64 ) - .bind(&schedule.workspace_id) - .bind(&schedule.path) - .bind(script_path) - .bind(job_id) - .bind(if exact { times } else { times - 1 } as i64,) - .fetch_all(db).await?; + .fetch_all(db) + .await?; let match_times = if exact { past_jobs.len() == times as usize @@ -1444,15 +1457,22 @@ async fn apply_schedule_handlers<'a, 'c, T: Serialize + Send + Sync>( if let Some(ref on_recovery_path) = schedule.on_recovery.clone() { let tx = db.begin().await?; let times = schedule.on_recovery_times.unwrap_or(1).max(1); - let past_jobs = sqlx::query_as::<_, CompletedJobSubset>( - "SELECT success, result, started_at FROM completed_job WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4 ORDER BY created_at DESC LIMIT $5", + let past_jobs = sqlx::query!( + "SELECT + success AS \"success!\", + result AS \"result: Json>\", + started_at AS \"started_at!\"\ + FROM v2_as_completed_job WHERE workspace_id = $1 AND schedule_path = $2 AND script_path = $3 AND id != $4 + ORDER BY created_at DESC + LIMIT $5", + &schedule.workspace_id, + &schedule.path, + script_path, + job_id, + times as i64 ) - .bind(&schedule.workspace_id) - .bind(&schedule.path) - .bind(script_path) - .bind(job_id) - .bind(times as i64) - .fetch_all(db).await?; + .fetch_all(db) + .await?; if past_jobs.len() < times as usize { return Ok(()); @@ -1464,7 +1484,7 @@ async fn apply_schedule_handlers<'a, 'c, T: Serialize + Send + Sync>( return Ok(()); } - let failed_job = past_jobs[past_jobs.len() - 1].clone(); + let failed_job = &past_jobs[past_jobs.len() - 1]; if !failed_job.success { handle_recovered_schedule( @@ -1476,7 +1496,8 @@ async fn apply_schedule_handlers<'a, 'c, T: Serialize + Send + Sync>( schedule.is_flow, w_id, &on_recovery_path, - failed_job, + failed_job.result.as_ref().map(AsRef::as_ref), + failed_job.started_at, result, times, started_at, @@ -1622,7 +1643,8 @@ async fn handle_recovered_schedule<'a, 'c, T: Serialize + Send + Sync>( is_flow: bool, w_id: &str, on_recovery_path: &str, - error_job: CompletedJobSubset, + result: Option<&Box>, + started_at: DateTime, successful_job_result: Json<&'a T>, successful_times: i32, successful_job_started_at: DateTime, @@ -1632,10 +1654,7 @@ async fn handle_recovered_schedule<'a, 'c, T: Serialize + Send + Sync>( get_payload_tag_from_prefixed_path(on_recovery_path, db, w_id).await?; let mut extra = HashMap::new(); - extra.insert( - "error_started_at".to_string(), - to_raw_value(&error_job.started_at), - ); + extra.insert("error_started_at".to_string(), to_raw_value(&started_at)); extra.insert("schedule_path".to_string(), to_raw_value(&schedule_path)); extra.insert("path".to_string(), to_raw_value(&script_path)); extra.insert("is_flow".to_string(), to_raw_value(&is_flow)); @@ -1661,9 +1680,8 @@ async fn handle_recovered_schedule<'a, 'c, T: Serialize + Send + Sync>( } } - let args = error_job - .result - .and_then(|x| serde_json::from_str::>>(x.0.get()).ok()) + let args = result + .and_then(|x| serde_json::from_str::>>(x.get()).ok()) .unwrap_or_else(HashMap::new); let (email, permissioned_as) = if let Some(on_behalf_of) = on_behalf_of.as_ref() { @@ -1878,7 +1896,7 @@ pub async fn pull( ); sqlx::query_scalar!( - "SELECT null FROM queue WHERE id = $1 FOR UPDATE", + "SELECT null FROM v2_job_queue WHERE id = $1 FOR UPDATE", pulled_job.id ) .fetch_one(&mut *tx) @@ -1901,7 +1919,7 @@ pub async fn pull( .fetch_one(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "Error getting concurrency count for script path {job_script_path}: {e:#}" )) })?; @@ -1912,14 +1930,14 @@ pub async fn pull( job_concurrency_key, f64::from(job_custom_concurrency_time_window_s), ).fetch_one(&mut *tx).await.map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "Error getting completed count for key {job_concurrency_key}: {e:#}" )) })?; let min_started_at = sqlx::query!( "SELECT COALESCE((SELECT MIN(started_at) as min_started_at - FROM queue + FROM v2_as_queue WHERE script_path = $1 AND job_kind != 'dependencies' AND running = true AND workspace_id = $2 AND canceled = false AND concurrent_limit > 0), $3) as min_started_at, now() AS now", job_script_path, &pulled_job.workspace_id, @@ -1928,7 +1946,7 @@ pub async fn pull( .fetch_one(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "Error getting concurrency count for script path {job_script_path}: {e:#}" )) })?; @@ -1956,7 +1974,7 @@ pub async fn pull( .fetch_one(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "Error decreasing concurrency count for script path {job_script_path}: {e:#}" )) })?; @@ -1966,7 +1984,7 @@ pub async fn pull( let job_uuid: Uuid = pulled_job.id; let avg_script_duration: Option = sqlx::query_scalar!( "SELECT CAST(ROUND(AVG(duration_ms), 0) AS BIGINT) AS avg_duration_s FROM - (SELECT duration_ms FROM concurrency_key LEFT JOIN completed_job ON completed_job.id = concurrency_key.job_id WHERE key = $1 AND ended_at IS NOT NULL + (SELECT duration_ms FROM concurrency_key LEFT JOIN v2_as_completed_job ON v2_as_completed_job.id = concurrency_key.job_id WHERE key = $1 AND ended_at IS NOT NULL ORDER BY ended_at DESC LIMIT 10) AS t", job_concurrency_key @@ -1998,7 +2016,7 @@ pub async fn pull( loop { let nestimated = estimated_next_schedule_timestamp + inc; let jobs_in_window = sqlx::query_scalar!( - "SELECT COUNT(*) FROM queue LEFT JOIN concurrency_key ON concurrency_key.job_id = queue.id + "SELECT COUNT(*) FROM v2_as_queue LEFT JOIN concurrency_key ON concurrency_key.job_id = v2_as_queue.id WHERE key = $1 AND running = false AND canceled = false AND scheduled_for >= $2 AND scheduled_for < $3", job_concurrency_key, estimated_next_schedule_timestamp, @@ -2022,18 +2040,18 @@ pub async fn pull( // if using posgtres, then we're able to re-queue the entire batch of scheduled job for this script_path, so we do it sqlx::query!( - "UPDATE queue - SET running = false - , started_at = null - , scheduled_for = $1 - , last_ping = null - WHERE id = $2", - estimated_next_schedule_timestamp, - job_uuid, - ) - .fetch_all(&mut *tx) - .await - .map_err(|e| Error::InternalErr(format!("Could not update and re-queue job {job_uuid}. The job will be marked as running but it is not running: {e:#}")))?; + "WITH ping AS (UPDATE v2_job_runtime SET ping = NULL WHERE id = $2 RETURNING id) + UPDATE v2_job_queue SET + running = false, + started_at = null, + scheduled_for = $1 + WHERE id = (SELECT id FROM ping)", + estimated_next_schedule_timestamp, + job_uuid, + ) + .fetch_all(&mut *tx) + .await + .map_err(|e| Error::internal_err(format!("Could not update and re-queue job {job_uuid}. The job will be marked as running but it is not running: {e:#}")))?; tx.commit().await? } } @@ -2193,17 +2211,6 @@ fn fullpath_with_workspace( ) } -#[derive(FromRow)] -pub struct ResultR { - result: Option>>, -} - -#[derive(FromRow)] -pub struct ResultWithId { - result: Option>>, - id: Uuid, -} - pub async fn get_result_by_id( db: Pool, w_id: String, @@ -2222,25 +2229,29 @@ pub async fn get_result_by_id( { Ok(res) => Ok(res), Err(_) => { - let running_flow_job =sqlx::query_as::<_, QueuedJob>( - "SELECT * FROM queue WHERE COALESCE((SELECT root_job FROM queue WHERE id = $1), $1) = id AND workspace_id = $2" - ).bind(flow_id) - .bind(&w_id) - .fetch_optional(&db).await?; - match running_flow_job { - Some(job) => { - let restarted_from = windmill_common::utils::not_found_if_none( - job.parse_flow_status() - .map(|status| status.restarted_from) - .flatten(), + let root = sqlx::query!( + "SELECT + id As \"id!\", + flow_status->'restarted_from'->'flow_job_id' AS \"restarted_from: Json\" + FROM v2_as_queue + WHERE COALESCE((SELECT flow_innermost_root_job FROM v2_job WHERE id = $1), $1) = id AND workspace_id = $2", + flow_id, + &w_id + ) + .fetch_optional(&db) + .await?; + match root { + Some(root) => { + let restarted_from_id = not_found_if_none( + root.restarted_from, "Id not found in the result's mapping of the root job and root job had no restarted from information", - format!("parent: {}, root: {}, id: {}", flow_id, job.id, node_id), + format!("parent: {}, root: {}, id: {}", flow_id, root.id, node_id), )?; get_result_by_id_from_original_flow( &db, w_id.as_str(), - &restarted_from.flow_job_id, + &restarted_from_id, node_id.as_str(), json_path.clone(), ) @@ -2261,12 +2272,6 @@ pub async fn get_result_by_id( } } -#[derive(FromRow)] -struct FlowJobResult { - leaf_jobs: Option>>, - parent_job: Option, -} - pub async fn get_result_and_success_by_id_from_flow( db: &Pool, w_id: &str, @@ -2307,7 +2312,8 @@ pub async fn get_result_and_success_by_id_from_flow( let success = match &job_result { JobResult::SingleJob(job_id) => { sqlx::query_scalar!( - "SELECT success FROM completed_job WHERE id = $1 AND workspace_id = $2", + "SELECT success AS \"success!\" + FROM v2_as_completed_job WHERE id = $1 AND workspace_id = $2", job_id, w_id ) @@ -2324,7 +2330,11 @@ pub async fn get_result_and_success_by_id_from_flow( SELECT module->>'type' = 'Success' FROM modules WHERE module->>'id' = $3"#, - if completed { "completed_job" } else { "queue" } + if completed { + "v2_as_completed_job" + } else { + "v2_as_queue" + } ); sqlx::query_scalar(&query) .bind(flow_id) @@ -2333,7 +2343,9 @@ pub async fn get_result_and_success_by_id_from_flow( .fetch_optional(db) .await? .ok_or_else(|| { - error::Error::InternalErr(format!("Could not get success from flow job status")) + error::Error::internal_err(format!( + "Could not get success from flow job status" + )) })? } }; @@ -2363,11 +2375,14 @@ pub async fn get_result_by_id_from_running_flow_inner( flow_id: &Uuid, node_id: &str, ) -> error::Result { - let flow_job_result = sqlx::query_as::<_, FlowJobResult>( - "SELECT leaf_jobs->$1::text as leaf_jobs, parent_job FROM queue WHERE COALESCE((SELECT root_job FROM queue WHERE id = $2), $2) = id AND workspace_id = $3") - .bind(node_id) - .bind(flow_id) - .bind(w_id) + let flow_job_result = sqlx::query!( + "SELECT leaf_jobs->$1::text AS \"leaf_jobs: Json>\", parent_job + FROM v2_as_queue + WHERE COALESCE((SELECT flow_innermost_root_job FROM v2_job WHERE id = $2), $2) = id AND workspace_id = $3", + node_id, + flow_id, + w_id, + ) .fetch_optional(db) .await?; @@ -2384,11 +2399,14 @@ pub async fn get_result_by_id_from_running_flow_inner( if job_result.is_none() && flow_job_result.parent_job.is_some() { let parent_job = flow_job_result.parent_job.unwrap(); - let root_job = sqlx::query_scalar!("SELECT root_job FROM queue WHERE id = $1", parent_job) - .fetch_optional(db) - .await? - .flatten() - .unwrap_or(parent_job); + let root_job = sqlx::query_scalar!( + "SELECT flow_innermost_root_job FROM v2_job WHERE id = $1", + parent_job + ) + .fetch_optional(db) + .await? + .flatten() + .unwrap_or(parent_job); return get_result_by_id_from_running_flow_inner(db, w_id, &root_job, node_id).await; } @@ -2401,18 +2419,13 @@ pub async fn get_result_by_id_from_running_flow_inner( Ok(result_id) } -#[async_recursion] async fn get_completed_flow_node_result_rec( db: &Pool, w_id: &str, - subflows: Vec, + subflows: impl std::iter::Iterator, node_id: &str, ) -> error::Result> { - for subflow in subflows { - let flow_status = subflow.parse_flow_status().ok_or_else(|| { - error::Error::InternalErr(format!("Could not parse flow status of {}", subflow.id)) - })?; - + for (id, flow_status) in subflows { if let Some(node_status) = flow_status .modules .iter() @@ -2423,15 +2436,27 @@ async fn get_completed_flow_node_result_rec( (Some(_), Some(jobs)) => Ok(Some(JobResult::ListJob(jobs))), _ => Err(error::Error::NotFound(format!( "Flow result by id not found going top-down in subflows (currently: {}), (id: {})", - subflow.id, + id, node_id, ))), }; } else { - let subflows = sqlx::query_as::<_, CompletedJob>( - "SELECT *, null as labels FROM completed_job WHERE parent_job = $1 AND workspace_id = $2 AND flow_status IS NOT NULL", - ).bind(subflow.id).bind(w_id).fetch_all(db).await?; - match get_completed_flow_node_result_rec(db, w_id, subflows, node_id).await? { + let subflows = sqlx::query!( + "SELECT id AS \"id!\", flow_status AS \"flow_status!: Json\" + FROM v2_as_completed_job + WHERE parent_job = $1 AND workspace_id = $2 AND flow_status IS NOT NULL", + id, + w_id + ) + .map(|record| (record.id, record.flow_status.0)) + .fetch_all(db) + .await? + .into_iter(); + match Box::pin(get_completed_flow_node_result_rec( + db, w_id, subflows, node_id, + )) + .await? + { Some(res) => return Ok(Some(res)), None => continue, }; @@ -2447,23 +2472,25 @@ async fn get_result_by_id_from_original_flow_inner( completed_flow_id: &Uuid, node_id: &str, ) -> error::Result { - let flow_job = sqlx::query_as::<_, CompletedJob>( - "SELECT *, null as labels FROM completed_job WHERE id = $1 AND workspace_id = $2", + let flow_job = sqlx::query!( + "SELECT id, flow_status AS \"flow_status!: Json\" + FROM v2_job_completed WHERE id = $1 AND workspace_id = $2", + completed_flow_id, + w_id ) - .bind(completed_flow_id) - .bind(w_id) + .map(|record| (record.id, record.flow_status.0)) .fetch_optional(db) .await?; - let flow_job = windmill_common::utils::not_found_if_none( + let flow_job = not_found_if_none( flow_job, "Root completed job", format!("root: {}, id: {}", completed_flow_id, node_id), )?; - match get_completed_flow_node_result_rec(db, w_id, vec![flow_job], node_id).await? { + match get_completed_flow_node_result_rec(db, w_id, [flow_job].into_iter(), node_id).await? { Some(res) => Ok(res), - None => Err(error::Error::NotFound(format!( + None => Err(Error::NotFound(format!( "Flow result by id not found going top-down from {}, (id: {})", completed_flow_id, node_id ))), @@ -2499,26 +2526,26 @@ async fn extract_result_from_job_result( let Some(job_id) = job_ids.get(idx).cloned() else { return Ok(to_raw_value(&serde_json::Value::Null)); }; - Ok(sqlx::query_as::<_, ResultR>( - "SELECT result #> $3 as result FROM completed_job WHERE id = $1 AND workspace_id = $2", - ) - .bind(job_id) - .bind(w_id) - .bind( - parts.map(|x| x.to_string()).collect::>() + Ok(sqlx::query_scalar!( + "SELECT result #> $3 AS \"result: Json>\" + FROM v2_job_completed WHERE id = $1 AND workspace_id = $2", + job_id, + w_id, + parts.collect::>() as Vec<&str> ) .fetch_optional(db) .await? - .map(|r| r.result.map(|x| x.0)) .flatten() + .map(|x| x.0) .unwrap_or_else(|| to_raw_value(&serde_json::Value::Null))) } None => { - let rows = sqlx::query_as::<_, ResultWithId>( - "SELECT id, result FROM completed_job WHERE id = ANY($1) AND workspace_id = $2", + let rows = sqlx::query!( + "SELECT id, result AS \"result: Json>\" + FROM v2_job_completed WHERE id = ANY($1) AND workspace_id = $2", + job_ids.as_slice(), + w_id ) - .bind(job_ids.as_slice()) - .bind(w_id) .fetch_all(db) .await? .into_iter() @@ -2535,15 +2562,15 @@ async fn extract_result_from_job_result( Ok(to_raw_value(&result)) } }, - JobResult::SingleJob(x) => Ok(sqlx::query_as::<_, ResultR>( - "SELECT result #> $3 as result FROM completed_job WHERE id = $1 AND workspace_id = $2", - ) - .bind(x) - .bind(w_id) - .bind( + JobResult::SingleJob(x) => Ok(sqlx::query!( + "SELECT result #> $3 AS \"result: Json>\" + FROM v2_job_completed WHERE id = $1 AND workspace_id = $2", + x, + w_id, json_path - .map(|x| x.split(".").map(|x| x.to_string()).collect::>()) - .unwrap_or_default(), + .as_ref() + .map(|x| x.split(".").collect::>()) + .unwrap_or_default() as Vec<&str>, ) .fetch_optional(db) .await? @@ -2564,7 +2591,7 @@ pub async fn delete_job<'c>( } let job_removed = sqlx::query_scalar!( - "DELETE FROM queue WHERE workspace_id = $1 AND id = $2 RETURNING 1", + "DELETE FROM v2_job_queue WHERE workspace_id = $1 AND id = $2 RETURNING 1", w_id, job_id ) @@ -2588,7 +2615,7 @@ pub async fn delete_job<'c>( pub async fn job_is_complete(db: &DB, id: Uuid, w_id: &str) -> error::Result { Ok(sqlx::query_scalar!( - "SELECT EXISTS(SELECT 1 FROM completed_job WHERE id = $1 AND workspace_id = $2)", + "SELECT EXISTS(SELECT 1 FROM v2_job_completed WHERE id = $1 AND workspace_id = $2)", id, w_id ) @@ -2604,7 +2631,7 @@ async fn get_queued_job_tx<'c>( ) -> error::Result> { sqlx::query_as::<_, QueuedJob>( "SELECT * - FROM queue WHERE id = $1 AND workspace_id = $2", + FROM v2_as_queue WHERE id = $1 AND workspace_id = $2", ) .bind(id) .bind(w_id) @@ -2616,7 +2643,7 @@ async fn get_queued_job_tx<'c>( pub async fn get_queued_job(id: &Uuid, w_id: &str, db: &DB) -> error::Result> { sqlx::query_as::<_, QueuedJob>( "SELECT * - FROM queue WHERE id = $1 AND workspace_id = $2", + FROM v2_as_queue WHERE id = $1 AND workspace_id = $2", ) .bind(id) .bind(w_id) @@ -2744,7 +2771,7 @@ pub async fn push<'c, 'd>( parent_job: Option, root_job: Option, job_id: Option, - is_flow_step: bool, + _is_flow_step: bool, mut same_worker: bool, pre_run_error: Option<&windmill_common::error::Error>, visible_to_owner: bool, @@ -2761,7 +2788,7 @@ pub async fn push<'c, 'd>( .fetch_one(_db) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "fetching if {workspace_id} is premium and overquota: {e:#}" )) })?; @@ -2780,7 +2807,7 @@ pub async fn push<'c, 'd>( ) .fetch_one(_db) .await - .map_err(|e| Error::InternalErr(format!("updating usage: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("updating usage: {e:#}")))?; let user_usage = if !premium_workspace { Some(sqlx::query_scalar!( @@ -2792,7 +2819,7 @@ pub async fn push<'c, 'd>( ) .fetch_one(_db) .await - .map_err(|e| Error::InternalErr(format!("updating usage: {e:#}")))?) + .map_err(|e| Error::internal_err(format!("updating usage: {e:#}")))?) } else { None }; @@ -2843,11 +2870,13 @@ pub async fn push<'c, 'd>( ))); } - let in_queue = - sqlx::query_scalar!("SELECT COUNT(id) FROM queue WHERE email = $1", email) - .fetch_one(_db) - .await? - .unwrap_or(0); + let in_queue = sqlx::query_scalar!( + "SELECT COUNT(id) FROM v2_as_queue WHERE email = $1", + email + ) + .fetch_one(_db) + .await? + .unwrap_or(0); if in_queue > MAX_FREE_EXECS.into() { return Err(error::Error::QuotaExceeded(format!( @@ -2856,7 +2885,7 @@ pub async fn push<'c, 'd>( } let concurrent_runs = sqlx::query_scalar!( - "SELECT COUNT(id) FROM queue WHERE running = true AND email = $1", + "SELECT COUNT(id) FROM v2_as_queue WHERE running = true AND email = $1", email ) .fetch_one(_db) @@ -2875,16 +2904,16 @@ pub async fn push<'c, 'd>( workspace_usage } else { sqlx::query_scalar!( - "SELECT usage.usage + 1 FROM usage - WHERE is_workspace IS TRUE AND - month_ = EXTRACT(YEAR FROM current_date) * 12 + EXTRACT(MONTH FROM current_date) - AND id = $1", - workspace_id - ) - .fetch_optional(_db) - .await? - .flatten() - .unwrap_or(1) + "SELECT usage.usage + 1 FROM usage + WHERE is_workspace IS TRUE AND + month_ = EXTRACT(YEAR FROM current_date) * 12 + EXTRACT(MONTH FROM current_date) + AND id = $1", + workspace_id + ) + .fetch_optional(_db) + .await? + .flatten() + .unwrap_or(1) }; if workspace_usage > MAX_FREE_EXECS @@ -2898,7 +2927,7 @@ pub async fn push<'c, 'd>( } let in_queue_workspace = sqlx::query_scalar!( - "SELECT COUNT(id) FROM queue WHERE workspace_id = $1", + "SELECT COUNT(id) FROM v2_job_queue WHERE workspace_id = $1", workspace_id ) .fetch_one(_db) @@ -2912,7 +2941,7 @@ pub async fn push<'c, 'd>( } let concurrent_runs_workspace = sqlx::query_scalar!( - "SELECT COUNT(id) FROM queue WHERE running = true AND workspace_id = $1", + "SELECT COUNT(id) FROM v2_job_queue WHERE running = true AND workspace_id = $1", workspace_id ) .fetch_one(_db) @@ -2929,6 +2958,7 @@ pub async fn push<'c, 'd>( } } + let mut preprocessed = None; let ( script_hash, script_path, @@ -2958,10 +2988,7 @@ pub async fn push<'c, 'd>( } => { let extra = args.extra.get_or_insert_with(HashMap::new); if apply_preprocessor { - extra.insert( - ENTRYPOINT_OVERRIDE.to_string(), - to_raw_value(&PREPROCESSOR_FAKE_ENTRYPOINT), - ); + preprocessed = Some(false); extra.entry("wm_trigger".to_string()).or_insert_with(|| { to_raw_value(&serde_json::json!({ "kind": "webhook", @@ -3344,7 +3371,7 @@ pub async fn push<'c, 'd>( ) .fetch_optional(&mut *ntx) .await? - .ok_or_else(|| Error::InternalErr(format!("not found flow at path {:?}", path)))?; + .ok_or_else(|| Error::internal_err(format!("not found flow at path {:?}", path)))?; // Do not use the lite version unless all workers are updated. let data = if *DISABLE_FLOW_SCRIPT @@ -3376,6 +3403,7 @@ pub async fn push<'c, 'd>( status.preprocessor_module = None; extra.remove("wm_trigger"); } else { + preprocessed = Some(false); extra.entry("wm_trigger".to_string()).or_insert_with(|| { to_raw_value(&serde_json::json!({ "kind": "webhook", @@ -3650,12 +3678,9 @@ pub async fn push<'c, 'd>( let mut tx = tx.into_tx().await?; let job_id: Uuid = if let Some(job_id) = job_id { - let conflicting_id = sqlx::query_scalar!( - "SELECT 1 FROM queue WHERE id = $1 UNION ALL select 1 FROM completed_job WHERE id = $1", - job_id - ) - .fetch_optional(&mut *tx) - .await?; + let conflicting_id = sqlx::query_scalar!("SELECT 1 FROM v2_job WHERE id = $1", job_id) + .fetch_optional(&mut *tx) + .await?; if conflicting_id.is_some() { return Err(Error::BadRequest(format!( @@ -3683,12 +3708,12 @@ pub async fn push<'c, 'd>( ) .execute(&mut *tx) .await - .map_err(|e| Error::InternalErr(format!("Could not insert concurrency_key={concurrency_key} for job_id={job_id} script_path={script_path:?} workspace_id={workspace_id}: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("Could not insert concurrency_key={concurrency_key} for job_id={job_id} script_path={script_path:?} workspace_id={workspace_id}: {e:#}")))?; } let stringified_args = if *JOB_ARGS_AUDIT_LOGS { Some(serde_json::to_string(&args).map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "Could not serialize args for audit log of job {job_id}: {e:#}" )) })?) @@ -3697,72 +3722,87 @@ pub async fn push<'c, 'd>( }; let raw_flow = raw_flow.map(Json); + let preprocessed = preprocessed.or_else(|| match flow_step_id.as_deref() { + Some("preprocessor") => Some(false), + _ => None, + }); sqlx::query!( - "INSERT INTO job (id, workspace_id, raw_code, raw_lock, raw_flow, tag) - VALUES ($1, $2, $3, $4, $5, $6)", + "INSERT INTO v2_job (id, workspace_id, raw_code, raw_lock, raw_flow, tag, parent_job, + created_by, permissioned_as, runnable_id, runnable_path, args, kind, trigger, + script_lang, same_worker, pre_run_error, permissioned_as_email, visible_to_owner, + flow_innermost_root_job, concurrent_limit, concurrency_time_window_s, timeout, flow_step_id, + cache_ttl, priority, trigger_kind, script_entrypoint_override, preprocessed) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, + $19, $20, $21, $22, $23, $24, $25, $26, + CASE WHEN $14::VARCHAR IS NOT NULL THEN 'schedule'::job_trigger_kind END, + ($12::JSONB)->>'_ENTRYPOINT_OVERRIDE', $27)", job_id, workspace_id, raw_code, raw_lock, - raw_flow.as_ref() as Option<&Json>, + raw_flow as Option>, tag, - ) - .execute(&mut *tx) - .warn_after_seconds(1) - .await?; - - let (raw_code, raw_lock, raw_flow) = if !*MIN_VERSION_IS_AT_LEAST_1_427.read().await { - (raw_code, raw_lock, raw_flow) - } else { - (None, None, None) - }; - - tracing::debug!("Pushing job {job_id} with tag {tag}, schedule_path {schedule_path:?}, script_path: {script_path:?}, email {email}, workspace_id {workspace_id}"); - let uuid = sqlx::query_scalar!( - "INSERT INTO queue - (workspace_id, id, running, parent_job, created_by, permissioned_as, scheduled_for, - script_hash, script_path, raw_code, raw_lock, args, job_kind, schedule_path, raw_flow, \ - flow_status, is_flow_step, language, started_at, same_worker, pre_run_error, email, \ - visible_to_owner, root_job, tag, concurrent_limit, concurrency_time_window_s, timeout, \ - flow_step_id, cache_ttl, priority, last_ping) - VALUES ($1, $2, $3, $4, $5, $6, COALESCE($7, now()), $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, CASE WHEN $3 THEN now() END, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, NULL) \ - RETURNING id", - workspace_id, - job_id, - is_running, parent_job, user, permissioned_as, - scheduled_for_o, script_hash, script_path.clone(), - raw_code, - raw_lock, Json(args) as Json, job_kind.clone() as JobKind, schedule_path, - raw_flow.as_ref() as Option<&Json>, - flow_status.map(Json) as Option>, - is_flow_step, language as Option, same_worker, pre_run_error.map(|e| e.to_string()), email, visible_to_owner, root_job, - tag, concurrent_limit, - if concurrent_limit.is_some() { concurrency_time_window_s } else { None }, + if concurrent_limit.is_some() { + concurrency_time_window_s + } else { + None + }, custom_timeout, flow_step_id, cache_ttl, final_priority, + preprocessed, + ) + .execute(&mut *tx) + .warn_after_seconds(1) + .await?; + + tracing::debug!("Pushing job {job_id} with tag {tag}, schedule_path {schedule_path:?}, script_path: {script_path:?}, email {email}, workspace_id {workspace_id}"); + let uuid = sqlx::query_scalar!( + "INSERT INTO v2_job_queue + (workspace_id, id, running, scheduled_for, started_at, tag, priority) + VALUES ($1, $2, $3, COALESCE($4, now()), CASE WHEN $3 THEN now() END, $5, $6) \ + RETURNING id AS \"id!\"", + workspace_id, + job_id, + is_running, + scheduled_for_o, + tag, + final_priority, ) .fetch_one(&mut *tx) .warn_after_seconds(1) .await - .map_err(|e| Error::InternalErr(format!("Could not insert into queue {job_id} with tag {tag}, schedule_path {schedule_path:?}, script_path: {script_path:?}, email {email}, workspace_id {workspace_id}: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("Could not insert into queue {job_id} with tag {tag}, schedule_path {schedule_path:?}, script_path: {script_path:?}, email {email}, workspace_id {workspace_id}: {e:#}")))?; + + sqlx::query!("INSERT INTO v2_job_runtime (id) VALUES ($1)", job_id) + .execute(&mut *tx) + .await?; + if let Some(flow_status) = flow_status { + sqlx::query!( + "INSERT INTO v2_job_status (id, flow_status) VALUES ($1, $2)", + job_id, + Json(flow_status) as Json, + ) + .execute(&mut *tx) + .await?; + } tracing::debug!("Pushed {job_id}"); // TODO: technically the job isn't queued yet, as the transaction can be rolled back. Should be solved when moving these metrics to the queue abstraction. @@ -3791,7 +3831,7 @@ pub async fn push<'c, 'd>( ) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "Could not get permissions directly for job {job_id}: {e:#}" )) })? @@ -3912,17 +3952,17 @@ async fn restarted_flows_resolution( let row = sqlx::query!( "SELECT script_path, script_hash AS \"script_hash: ScriptHash\", - job_kind AS \"job_kind: JobKind\", + job_kind AS \"job_kind!: JobKind\", flow_status AS \"flow_status: Json>\", raw_flow AS \"raw_flow: Json>\" - FROM completed_job WHERE id = $1 and workspace_id = $2", + FROM v2_as_completed_job WHERE id = $1 and workspace_id = $2", completed_flow_id, workspace_id, ) .fetch_one(db) // TODO: should we try to use the passed-in `tx` here? .await .map_err(|err| { - Error::InternalErr(format!( + Error::internal_err(format!( "completed job not found for UUID {} in workspace {}: {}", completed_flow_id, workspace_id, err )) @@ -3936,7 +3976,7 @@ async fn restarted_flows_resolution( .flow_status .as_ref() .and_then(|v| serde_json::from_str::(v.get()).ok()) - .ok_or(Error::InternalErr(format!( + .ok_or(Error::internal_err(format!( "Unable to parse flow status for job {} in workspace {}", completed_flow_id, workspace_id, )))?; @@ -3966,14 +4006,14 @@ async fn restarted_flows_resolution( match module_definition.get_value() { Ok(FlowModuleValue::BranchAll { branches, parallel, .. }) => { if parallel { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "Module {} is a parallel branchall. It can only be restarted at a given branch if it's sequential", restart_step_id, ))); } let total_branch_number = module.flow_jobs().map(|v| v.len()).unwrap_or(0); if total_branch_number <= branch_or_iteration_n { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "Branch-all module {} has only {} branches. It can't be restarted on branch {}", restart_step_id, total_branch_number, @@ -4004,14 +4044,14 @@ async fn restarted_flows_resolution( } Ok(FlowModuleValue::ForloopFlow { parallel, .. }) => { if parallel { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "Module {} is not parallel loop. It can only be restarted at a given iteration if it's sequential", restart_step_id, ))); } let total_iterations = module.flow_jobs().map(|v| v.len()).unwrap_or(0); if total_iterations <= branch_or_iteration_n { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "For-loop module {} doesn't cannot be restarted on iteration number {} as it has only {} iterations", restart_step_id, branch_or_iteration_n, @@ -4027,7 +4067,7 @@ async fn restarted_flows_resolution( truncated_modules.push(FlowStatusModule::InProgress { id: module.id(), job: new_flow_jobs[new_flow_jobs.len() - 1], // set to last finished job from completed flow - iterator: Some(Iterator { + iterator: Some(FlowIterator { index: branch_or_iteration_n - 1, // same deal as above, this refers to the last finished job itered: vec![], // Setting itered to empty array here, such that input transforms will be re-computed by worker_flows }), @@ -4041,7 +4081,7 @@ async fn restarted_flows_resolution( }); } _ => { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "Module {} is not a branchall or forloop, unable to restart it at step {:?}", restart_step_id, branch_or_iteration_n @@ -4057,7 +4097,7 @@ async fn restarted_flows_resolution( step_n = step_n + 1; match module.clone() { FlowStatusModule::Success { .. } => Ok(truncated_modules.push(module)), - _ => Err(Error::InternalErr(format!( + _ => Err(Error::internal_err(format!( "Flow cannot be restarted from a non successful module", ))), }?; @@ -4066,7 +4106,7 @@ async fn restarted_flows_resolution( if !dependent_module { // step not found in flow. - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "Flow cannot be restarted from step {} as it could not be found.", restart_step_id ))); diff --git a/backend/windmill-queue/src/schedule.rs b/backend/windmill-queue/src/schedule.rs index ea9f476ab6..fd4bcab4b4 100644 --- a/backend/windmill-queue/src/schedule.rs +++ b/backend/windmill-queue/src/schedule.rs @@ -71,7 +71,7 @@ pub async fn push_scheduled_job<'c>( let next = next.with_timezone(&chrono::Utc); let already_exists: bool = query_scalar!( - "SELECT EXISTS (SELECT 1 FROM queue WHERE workspace_id = $1 AND schedule_path = $2 AND scheduled_for = $3)", + "SELECT EXISTS (SELECT 1 FROM v2_as_queue WHERE workspace_id = $1 AND schedule_path = $2 AND scheduled_for = $3)", &schedule.workspace_id, &schedule.path, next @@ -149,7 +149,7 @@ pub async fn push_scheduled_job<'c>( if schedule.retry.is_some() { let parsed_retry = serde_json::from_value::(schedule.retry.clone().unwrap()) .map_err(|err| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "Unable to parse retry information from schedule: {}", err.to_string(), )) diff --git a/backend/windmill-worker/nsjail/download.py.config.proto b/backend/windmill-worker/nsjail/download.py.config.proto index b910e1c690..5c2989417f 100644 --- a/backend/windmill-worker/nsjail/download.py.config.proto +++ b/backend/windmill-worker/nsjail/download.py.config.proto @@ -22,6 +22,7 @@ keep_caps: true keep_env: true mount_proc: true + mount { src: "/bin" dst: "/bin" @@ -75,11 +76,12 @@ mount { } mount { - src: "{CACHE_DIR}" - dst: "{CACHE_DIR}" + src: "{TARGET_DIR}" + dst: "{TARGET_DIR}" is_bind: true rw: true } + mount { src: "{PY_INSTALL_DIR}" dst: "{PY_INSTALL_DIR}" diff --git a/backend/windmill-worker/nsjail/download.py.pip.config.proto b/backend/windmill-worker/nsjail/download.py.pip.config.proto index 15e5c6c7f6..6e2a8a1974 100644 --- a/backend/windmill-worker/nsjail/download.py.pip.config.proto +++ b/backend/windmill-worker/nsjail/download.py.pip.config.proto @@ -73,13 +73,6 @@ mount { is_bind: true } -mount { - src: "{CACHE_DIR}" - dst: "{CACHE_DIR}" - is_bind: true - rw: true -} - mount { src: "/dev/urandom" dst: "/dev/urandom" diff --git a/backend/windmill-worker/nsjail/run.bun.config.proto b/backend/windmill-worker/nsjail/run.bun.config.proto index 751452251d..527d49cf7a 100644 --- a/backend/windmill-worker/nsjail/run.bun.config.proto +++ b/backend/windmill-worker/nsjail/run.bun.config.proto @@ -156,14 +156,6 @@ mount { iface_no_lo: true -mount { - src: "{CACHE_DIR}" - dst: "/tmp/windmill/cache_nomount/bun" - is_bind: true - mandatory: false - rw: true -} - {SHARED_MOUNT} envar: "HOME=/tmp/{LANG}" diff --git a/backend/windmill-worker/nsjail/run.php.config.proto b/backend/windmill-worker/nsjail/run.php.config.proto index 2a6722cfaf..d3752d33b7 100644 --- a/backend/windmill-worker/nsjail/run.php.config.proto +++ b/backend/windmill-worker/nsjail/run.php.config.proto @@ -124,14 +124,6 @@ mount { iface_no_lo: true -mount { - src: "{CACHE_DIR}" - dst: "/tmp/windmill/cache/php" - is_bind: true - rw: true - mandatory: false -} - {SHARED_MOUNT} envar: "HOME=/tmp" diff --git a/backend/windmill-worker/src/bun_executor.rs b/backend/windmill-worker/src/bun_executor.rs index 77bad32a5d..4fc471df91 100644 --- a/backend/windmill-worker/src/bun_executor.rs +++ b/backend/windmill-worker/src/bun_executor.rs @@ -1,12 +1,11 @@ #[cfg(feature = "deno_core")] use std::time::Instant; -use std::{collections::HashMap, fs, io, path::Path, process::Stdio}; +use std::{collections::HashMap, fs, path::Path, process::Stdio}; +use anyhow::Context; use base64::Engine; use itertools::Itertools; -#[cfg(not(feature = "deno_core"))] -use serde_json::value::to_raw_value; use serde_json::value::RawValue; use sha2::Digest; @@ -19,9 +18,8 @@ use crate::common::build_envs_map; use crate::{ common::{ - create_args_and_out_file, get_main_override, get_reserved_variables, parse_npm_config, - read_file, read_file_content, read_result, start_child_process, write_file_binary, - OccupancyMetrics, + create_args_and_out_file, get_reserved_variables, parse_npm_config, read_file, + read_file_content, read_result, start_child_process, write_file_binary, OccupancyMetrics, }, handle_child::handle_child, AuthedClientBackgroundTask, BUNFIG_INSTALL_SCOPES, BUN_BUNDLE_CACHE_DIR, BUN_CACHE_DIR, @@ -45,7 +43,7 @@ use windmill_common::variables; use windmill_common::{ error::{self, Result}, get_latest_hash_for_path, - jobs::{QueuedJob, PREPROCESSOR_FAKE_ENTRYPOINT}, + jobs::QueuedJob, scripts::ScriptLang, worker::{exists_in_cache, save_cache, write_file}, DB, @@ -531,7 +529,7 @@ pub async fn generate_wrapper_mjs( format!("{job_dir}/wrapper.js"), format!("{job_dir}/wrapper.mjs"), ) - .map_err(|e| error::Error::InternalErr(format!("Could not move wrapper to mjs: {e:#}")))?; + .map_err(|e| error::Error::internal_err(format!("Could not move wrapper to mjs: {e:#}")))?; Ok(()) } @@ -644,7 +642,7 @@ pub fn copy_recursively( source: impl AsRef, destination: impl AsRef, skip: Option<&Vec>, -) -> io::Result<()> { +) -> Result<()> { let mut stack = Vec::new(); stack.push(( source.as_ref().to_path_buf(), @@ -652,7 +650,9 @@ pub fn copy_recursively( 0, )); while let Some((current_source, current_destination, level)) = stack.pop() { - for entry in fs::read_dir(¤t_source)? { + for entry in fs::read_dir(¤t_source) + .context(format!("reading directory {current_source:?}"))? + { let entry = entry?; let filetype = entry.file_type()?; let destination = current_destination.join(entry.file_name()); @@ -670,7 +670,11 @@ pub fn copy_recursively( fs::create_dir_all(&destination)?; stack.push((entry.path(), destination, level + 1)); } else { - fs::hard_link(&original, &destination)? + fs::hard_link(&original, &destination).map_err(|e| { + error::Error::internal_err(format!( + "hard linking from {original:?} to {destination:?}: {e:#}" + )) + })?; } } } @@ -816,7 +820,7 @@ async fn write_lock(splitted_lockb_2: &str, job_dir: &str, is_binary: bool) -> R "bun.lockb", &base64::engine::general_purpose::STANDARD .decode(splitted_lockb_2) - .map_err(|_| error::Error::InternalErr(format!("Could not decode bun.lockb")))?, + .map_err(|_| error::Error::internal_err(format!("Could not decode bun.lockb")))?, ) .await?; } else { @@ -875,16 +879,8 @@ pub async fn handle_bun_job( if codebase.is_some() { annotation.nodejs = true } - let (main_override, apply_preprocessor) = match get_main_override(job.args.as_ref()) { - Some(main_override) => { - if main_override == PREPROCESSOR_FAKE_ENTRYPOINT { - (None, true) - } else { - (Some(main_override), false) - } - } - None => (None, false), - }; + let main_override = job.script_entrypoint_override.as_deref(); + let apply_preprocessor = !job.is_flow_step && job.preprocessed == Some(false); #[cfg(not(feature = "enterprise"))] if annotation.nodejs || annotation.npm { @@ -984,7 +980,7 @@ pub async fn handle_bun_job( "bunfig.toml".to_string(), ]), ) { - fs::remove_dir_all(&buntar_path)?; + fs::remove_dir_all(&buntar_path).context("deleting buntar directory")?; tracing::error!("Could not create buntar: {e}"); } } @@ -1051,9 +1047,12 @@ pub async fn handle_bun_job( return Ok(()) as error::Result<()>; } // let mut start = Instant::now(); - let args = - windmill_parser_ts::parse_deno_signature(inner_content, true, main_override.clone())? - .args; + let args = windmill_parser_ts::parse_deno_signature( + inner_content, + true, + main_override.map(ToString::to_string), + )? + .args; let pre_args = if apply_preprocessor { Some( @@ -1087,7 +1086,7 @@ pub async fn handle_bun_job( let spread = args.into_iter().map(|x| x.name).join(","); // logs.push_str(format!("infer args: {:?}\n", start.elapsed().as_micros()).as_str()); // we cannot use Bun.read and Bun.write because it results in an EBADF error on cloud - let main_name = main_override.unwrap_or("main".to_string()); + let main_name = main_override.unwrap_or("main"); let main_import = if codebase.is_some() || has_bundle_cache { "./main.js" @@ -1297,7 +1296,7 @@ try {{ tracing::error!( r#""deno_core" feature is not activated, but "//native" annotation used. Returning empty value..."# ); - return Ok(to_raw_value("").unwrap()); + return Err(error::Error::internal_err("deno_core feature is not activated, but //native annotation used. Returning empty value...".to_string())); } #[cfg(feature = "deno_core")] @@ -1355,7 +1354,6 @@ try {{ &NSJAIL_CONFIG_RUN_BUN_CONTENT .replace("{LANG}", if annotation.nodejs { "nodejs" } else { "bun" }) .replace("{JOB_DIR}", job_dir) - .replace("{CACHE_DIR}", BUN_CACHE_DIR) .replace("{CLONE_NEWUSER}", &(!*DISABLE_NUSER).to_string()) .replace( "{SHARED_MOUNT}", @@ -1496,13 +1494,13 @@ try {{ let args = read_file(&format!("{job_dir}/args.json")) .await .map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "error while reading args from preprocessing: {e:#}" )) })?; let args: HashMap> = serde_json::from_str(args.get()).map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "error while deserializing args from preprocessing: {e:#}" )) })?; @@ -1625,7 +1623,7 @@ pub async fn start_worker( &base64::engine::general_purpose::STANDARD .decode(lock) .map_err(|_| { - error::Error::InternalErr("Could not decode bun.lockb".to_string()) + error::Error::internal_err("Could not decode bun.lockb".to_string()) })?, ) .await?; diff --git a/backend/windmill-worker/src/common.rs b/backend/windmill-worker/src/common.rs index 099300f621..a64a32c869 100644 --- a/backend/windmill-worker/src/common.rs +++ b/backend/windmill-worker/src/common.rs @@ -12,7 +12,6 @@ use sqlx::types::Json; use sqlx::{Pool, Postgres}; use tokio::process::Command; use tokio::{fs::File, io::AsyncReadExt}; -use windmill_common::jobs::ENTRYPOINT_OVERRIDE; #[cfg(feature = "parquet")] use windmill_common::s3_helpers::{ @@ -149,13 +148,13 @@ pub async fn transform_json<'a>( let inner_vs = v.get(); if (*RE_RES_VAR).is_match(inner_vs) { let value = serde_json::from_str(inner_vs).map_err(|e| { - error::Error::InternalErr(format!("Error while parsing inner arg: {e:#}")) + error::Error::internal_err(format!("Error while parsing inner arg: {e:#}")) })?; let transformed = transform_json_value(&k, &client.get_authed().await, workspace, value, job, db) .await?; let as_raw = serde_json::from_value(transformed).map_err(|e| { - error::Error::InternalErr(format!("Error while parsing inner arg: {e:#}")) + error::Error::internal_err(format!("Error while parsing inner arg: {e:#}")) })?; r.insert(k.to_string(), as_raw); } else { @@ -177,13 +176,13 @@ pub async fn transform_json_as_values<'a>( let inner_vs = v.get(); if (*RE_RES_VAR).is_match(inner_vs) { let value = serde_json::from_str(inner_vs).map_err(|e| { - error::Error::InternalErr(format!("Error while parsing inner arg: {e:#}")) + error::Error::internal_err(format!("Error while parsing inner arg: {e:#}")) })?; let transformed = transform_json_value(&k, &client.get_authed().await, workspace, value, job, db) .await?; let as_raw = serde_json::from_value(transformed).map_err(|e| { - error::Error::InternalErr(format!("Error while parsing inner arg: {e:#}")) + error::Error::internal_err(format!("Error while parsing inner arg: {e:#}")) })?; r.insert(k.to_string(), as_raw); } else { @@ -237,7 +236,7 @@ pub async fn transform_json_value( Value::String(y) if y.starts_with("$res:") => { let path = y.strip_prefix("$res:").unwrap(); if path.split("/").count() < 2 { - return Err(Error::InternalErr(format!( + return Err(Error::internal_err(format!( "Argument `{name}` is an invalid resource path: {path}", ))); } @@ -256,14 +255,14 @@ pub async fn transform_json_value( let mc = build_crypt_with_key_suffix(&db, &job.workspace_id, &job.id.to_string()).await?; decrypt(&mc, encrypted.to_string()).and_then(|x| { - serde_json::from_str(&x).map_err(|e| Error::InternalErr(e.to_string())) + serde_json::from_str(&x).map_err(|e| Error::internal_err(e.to_string())) }) // let path = y.strip_prefix("$res:").unwrap(); } Value::String(y) if y.starts_with("$") => { let flow_path = if let Some(uuid) = job.parent_job { - sqlx::query_scalar!("SELECT script_path FROM queue WHERE id = $1", uuid) + sqlx::query_scalar!("SELECT runnable_path FROM v2_job WHERE id = $1", uuid) .fetch_optional(db) .await? .flatten() @@ -397,7 +396,7 @@ pub async fn get_reserved_variables( db: &sqlx::Pool, ) -> Result, Error> { let flow_path = if let Some(uuid) = job.parent_job { - sqlx::query_scalar!("SELECT script_path FROM queue WHERE id = $1", uuid) + sqlx::query_scalar!("SELECT runnable_path FROM v2_job WHERE id = $1", uuid) .fetch_optional(db) .await? .flatten() @@ -440,15 +439,6 @@ pub async fn build_envs_map(context: Vec) -> HashMap>>>) -> Option { - return args - .map(|x| { - x.0.get(ENTRYPOINT_OVERRIDE) - .map(|x| x.get().to_string().replace("\"", "")) - }) - .flatten(); -} - pub fn sizeof_val(v: &serde_json::Value) -> usize { std::mem::size_of::() + match v { @@ -570,7 +560,7 @@ impl OccupancyMetrics { pub async fn start_child_process(mut cmd: Command, executable: &str) -> Result { return cmd .spawn() - .map_err(|err| tentatively_improve_error(Error::IoErr(err), executable)); + .map_err(|err| tentatively_improve_error(err.into(), executable)); } pub async fn resolve_job_timeout( @@ -930,7 +920,7 @@ fn tentatively_improve_error(err: Error, executable: &str) -> Error { let err_msg = "program not found"; if err.to_string().contains(&err_msg) { - return Error::InternalErr(format!( + return Error::internal_err(format!( "Executable {executable} not found on worker. PATH: {}", *PATH_ENV )); @@ -967,5 +957,5 @@ pub fn build_http_client(timeout_duration: std::time::Duration) -> error::Result .timeout(timeout_duration) .connect_timeout(std::time::Duration::from_secs(10)) .build() - .map_err(|e| Error::InternalErr(format!("Error building http client: {e:#}"))) + .map_err(|e| Error::internal_err(format!("Error building http client: {e:#}"))) } diff --git a/backend/windmill-worker/src/dedicated_worker.rs b/backend/windmill-worker/src/dedicated_worker.rs index 56ea01c038..fb3a30176c 100644 --- a/backend/windmill-worker/src/dedicated_worker.rs +++ b/backend/windmill-worker/src/dedicated_worker.rs @@ -78,7 +78,7 @@ pub async fn handle_dedicated_process( //do not cache local dependencies use crate::{handle_child::process_status, PROXY_ENVS}; - + let cmd_name = format!("dedicated {command_path}"); let mut child = { let mut cmd = Command::new(command_path); cmd.current_dir(job_dir) @@ -126,7 +126,7 @@ pub async fn handle_dedicated_process( .wait() .await .expect("child process encountered an error"); - if let Err(e) = process_status(status) { + if let Err(e) = process_status(&cmd_name, status) { tracing::error!("child exit status was not success: {e:#}"); } else { tracing::info!("child exit status was success"); @@ -185,14 +185,14 @@ pub async fn handle_dedicated_process( let result = Arc::new(result); append_logs(&job.id, &job.workspace_id, logs.clone(), db).await; if line.starts_with("wm_res[success]:") { - job_completed_tx.send(JobCompleted { job , result, mem_peak: 0, canceled_by: None, success: true, cached_res_path: None, token: token.to_string(), duration: None }).await.unwrap() + job_completed_tx.send(JobCompleted { job , result, result_columns: None, mem_peak: 0, canceled_by: None, success: true, cached_res_path: None, token: token.to_string(), duration: None }).await.unwrap() } else { - job_completed_tx.send(JobCompleted { job , result, mem_peak: 0, canceled_by: None, success: false, cached_res_path: None, token: token.to_string(), duration: None }).await.unwrap() + job_completed_tx.send(JobCompleted { job , result, result_columns: None, mem_peak: 0, canceled_by: None, success: false, cached_res_path: None, token: token.to_string(), duration: None }).await.unwrap() } }, Err(e) => { tracing::error!("Could not deserialize job result `{line}`: {e:?}"); - job_completed_tx.send(JobCompleted { job , result: Arc::new(to_raw_value(&serde_json::json!({"error": format!("Could not deserialize job result `{line}`: {e:?}")}))), mem_peak: 0, canceled_by: None, success: false, cached_res_path: None, token: token.to_string(), duration: None }).await.unwrap(); + job_completed_tx.send(JobCompleted { job , result: Arc::new(to_raw_value(&serde_json::json!({"error": format!("Could not deserialize job result `{line}`: {e:?}")}))), result_columns: None, mem_peak: 0, canceled_by: None, success: false, cached_res_path: None, token: token.to_string(), duration: None }).await.unwrap(); }, }; logs = init_log.clone(); @@ -470,7 +470,7 @@ pub async fn create_dedicated_worker_map( if let Ok(v) = value { if let Some(v) = v { let value = serde_json::from_str::(v.get()).map_err(|err| { - Error::InternalErr(format!( + Error::internal_err(format!( "could not convert json to flow for {flow_path}: {err:?}" )) }); @@ -622,7 +622,7 @@ async fn spawn_dedicated_worker( .bind(&w_id) .fetch_optional(&db) .await - .map_err(|e| Error::InternalErr(format!("expected content and lock: {e:#}"))) + .map_err(|e| Error::internal_err(format!("expected content and lock: {e:#}"))) .map(|x| x.map(|y| (y.0, y.1, y.2, y.3, if y.4 { y.5.map(|z| z.to_string()) } else { None }))) }; if let Ok(q) = q { diff --git a/backend/windmill-worker/src/deno_executor.rs b/backend/windmill-worker/src/deno_executor.rs index 2385771a15..6a7bed5c38 100644 --- a/backend/windmill-worker/src/deno_executor.rs +++ b/backend/windmill-worker/src/deno_executor.rs @@ -7,17 +7,15 @@ use windmill_queue::{append_logs, CanceledBy}; use crate::{ common::{ - create_args_and_out_file, get_main_override, get_reserved_variables, parse_npm_config, - read_file, read_result, start_child_process, OccupancyMetrics, + create_args_and_out_file, get_reserved_variables, parse_npm_config, read_file, read_result, + start_child_process, OccupancyMetrics, }, handle_child::handle_child, AuthedClientBackgroundTask, DENO_CACHE_DIR, DENO_PATH, DISABLE_NSJAIL, HOME_ENV, NPM_CONFIG_REGISTRY, PATH_ENV, TZ_ENV, }; use tokio::{fs::File, io::AsyncReadExt, process::Command}; -use windmill_common::{ - error::Result, jobs::PREPROCESSOR_FAKE_ENTRYPOINT, worker::write_file, BASE_URL, -}; +use windmill_common::{error::Result, worker::write_file, BASE_URL}; use windmill_common::{ error::{self}, jobs::QueuedJob, @@ -197,24 +195,19 @@ pub async fn handle_deno_job( let logs1 = "\n\n--- DENO CODE EXECUTION ---\n".to_string(); append_logs(&job.id, &job.workspace_id, logs1, db).await; - let (main_override, apply_preprocessor) = match get_main_override(job.args.as_ref()) { - Some(main_override) => { - if main_override == PREPROCESSOR_FAKE_ENTRYPOINT { - (None, true) - } else { - (Some(main_override), false) - } - } - None => (None, false), - }; + let main_override = job.script_entrypoint_override.as_deref(); + let apply_preprocessor = !job.is_flow_step && job.preprocessed == Some(false); write_file(job_dir, "main.ts", inner_content)?; let write_wrapper_f = async { // let mut start = Instant::now(); - let args = - windmill_parser_ts::parse_deno_signature(inner_content, true, main_override.clone())? - .args; + let args = windmill_parser_ts::parse_deno_signature( + inner_content, + true, + main_override.map(ToString::to_string), + )? + .args; let pre_args = if apply_preprocessor { Some( @@ -246,7 +239,7 @@ pub async fn handle_deno_job( .join("\n "); let spread = args.into_iter().map(|x| x.name).join(","); - let main_name = main_override.unwrap_or("main".to_string()); + let main_name = main_override.unwrap_or("main"); // logs.push_str(format!("infer args: {:?}\n", start.elapsed().as_micros()).as_str()); let (preprocessor_import, preprocessor) = if let Some(pre_args) = pre_args { let pre_spread = pre_args.into_iter().map(|x| x.name).join(","); @@ -432,13 +425,13 @@ try {{ let args = read_file(&format!("{job_dir}/args.json")) .await .map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "error while reading args from preprocessing: {e:#}" )) })?; let args: HashMap> = serde_json::from_str(args.get()).map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "error while deserializing args from preprocessing: {e:#}" )) })?; diff --git a/backend/windmill-worker/src/handle_child.rs b/backend/windmill-worker/src/handle_child.rs index 5dcdbfa287..7294950363 100644 --- a/backend/windmill-worker/src/handle_child.rs +++ b/backend/windmill-worker/src/handle_child.rs @@ -206,17 +206,14 @@ pub async fn handle_child( let set_reason = async { if matches!(kill_reason, KillReason::Timeout { .. }) { - if let Err(err) = sqlx::query( - r#" - UPDATE queue - SET canceled = true - , canceled_by = 'timeout' - , canceled_reason = $1 - WHERE id = $2 - "#, + if let Err(err) = sqlx::query!( + "UPDATE v2_job_queue + SET canceled_by = 'timeout' + , canceled_reason = $1 + WHERE id = $2", + format!("duration > {}", timeout_duration.as_secs()), + job_id ) - .bind(format!("duration > {}", timeout_duration.as_secs())) - .bind(job_id) .execute(&db) .await { @@ -426,7 +423,7 @@ pub async fn handle_child( _ if *too_many_logs.borrow() => Err(Error::ExecutionErr(format!( "logs or result reached limit. (current max size: {MAX_RESULT_SIZE} characters)" ))), - Ok(Ok(status)) => process_status(status), + Ok(Ok(status)) => process_status(&child_name, status), Ok(Err(kill_reason)) => match kill_reason { KillReason::AlreadyCompleted => { Err(Error::AlreadyCompleted("Job already completed".to_string())) @@ -644,23 +641,31 @@ where } } if job_id != Uuid::nil() { - let (canceled, canceled_by, canceled_reason, already_completed) = sqlx::query_as::<_, (bool, Option, Option, bool)>("UPDATE queue SET mem_peak = $1, last_ping = now() WHERE id = $2 RETURNING canceled, canceled_by, canceled_reason, false") - .bind(*mem_peak) - .bind(job_id) + let (canceled_by, canceled_reason, already_completed) = sqlx::query!( + "UPDATE v2_job_runtime r SET + memory_peak = $1, + ping = now() + FROM v2_job_queue q + WHERE r.id = $2 AND q.id = r.id + RETURNING canceled_by, canceled_reason", + *mem_peak, + job_id + ) + .map(|x| (x.canceled_by, x.canceled_reason, false)) .fetch_optional(&db) .await .unwrap_or_else(|e| { tracing::error!(%e, "error updating job {job_id}: {e:#}"); - Some((false, None, None, false)) + Some((None, None, false)) }) .unwrap_or_else(|| { // if the job is not in queue, it can only be in the completed_job so it is already complete - (false, None, None, true) + (None, None, true) }); if already_completed { return UpdateJobPollingExit::AlreadyCompleted } - if canceled { + if canceled_by.is_some() { canceled_by_ref.replace(CanceledBy { username: canceled_by.clone(), reason: canceled_reason.clone(), @@ -714,11 +719,11 @@ pub fn lines_to_stream( }) } -pub fn process_status(status: ExitStatus) -> error::Result<()> { +pub fn process_status(program: &str, status: ExitStatus) -> error::Result<()> { if status.success() { Ok(()) } else if let Some(code) = status.code() { - Err(error::Error::ExitStatus(code)) + Err(error::Error::ExitStatus(program.to_string(), code)) } else { #[cfg(any(target_os = "linux", target_os = "macos"))] return Err(error::Error::ExecutionErr(format!( diff --git a/backend/windmill-worker/src/js_eval.rs b/backend/windmill-worker/src/js_eval.rs index 482bfea3ed..9aab144296 100644 --- a/backend/windmill-worker/src/js_eval.rs +++ b/backend/windmill-worker/src/js_eval.rs @@ -42,6 +42,8 @@ use uuid::Uuid; #[cfg(feature = "deno_core")] use windmill_common::error::Error; +#[cfg(feature = "deno_core")] +use windmill_common::worker::{write_file, TMP_DIR}; use windmill_common::{flow_status::JobResult, DB}; use windmill_queue::CanceledBy; @@ -885,7 +887,7 @@ pub async fn eval_fetch_timeout( let future = async { let r = tokio::select! { - r = eval_fetch(&mut js_runtime, &js_expr, Some(env_code), load_client) => Ok(r), + r = eval_fetch(&mut js_runtime, &js_expr, Some(env_code), load_client, &job_id) => Ok(r), _ = memory_limit_rx.recv() => Err(Error::ExecutionErr("Memory limit reached, killing isolate".to_string())) }; @@ -934,12 +936,44 @@ pub async fn eval_fetch_timeout( #[cfg(feature = "deno_core")] const WINDMILL_CLIENT: &str = include_str!("./windmill-client.js"); +#[cfg(feature = "deno_core")] +const ERROR_DIR: &str = const_format::concatcp!(TMP_DIR, "/native_errors"); + +#[cfg(feature = "deno_core")] +fn write_error_expr(expr: &str, uuid: &Uuid) { + if let Err(e) = std::fs::create_dir_all(ERROR_DIR) { + tracing::error!("failed to create error dir {ERROR_DIR}: {e}"); + return; + } + let dir_entries = match std::fs::read_dir(ERROR_DIR) { + Ok(entries) => entries.count(), + Err(_) => { + tracing::error!("failed to read error dir {ERROR_DIR}"); + return; + } + }; + + if dir_entries >= 100 { + tracing::info!("Too many error files in {ERROR_DIR}, skipping write"); + return; + } + + let path = format!("/{uuid}.js"); + tracing::info!( + "nativets job {uuid} failed, writing error expr to {ERROR_DIR}/{path} for debugging: {path}" + ); + if let Err(e) = write_file(ERROR_DIR, &path, expr) { + tracing::error!("failed to write error expr to file {path}: {e}"); + } +} + #[cfg(feature = "deno_core")] async fn eval_fetch( js_runtime: &mut JsRuntime, expr: &str, env_code: Option, load_client: bool, + job_id: &Uuid, ) -> anyhow::Result> { if load_client { if let Some(env_code) = env_code.as_ref() { @@ -951,26 +985,42 @@ async fn eval_fetch( .await?; } } - + use anyhow::Context; let _ = js_runtime .load_side_es_module_from_code( &deno_core::resolve_url("file:///eval.ts")?, format!("{}\n{expr}", env_code.unwrap_or_default()), ) - .await?; + .await + .map_err(|e| { + write_error_expr(expr, &job_id); + e + }) + .context("failed to load module")?; - let script = js_runtime.execute_script( - "", - r#" + let script = js_runtime + .execute_script( + "", + r#" let args = Deno.core.ops.op_get_static_args().map(JSON.parse) import("file:///eval.ts").then((module) => module.main(...args)).then(JSON.stringify) "#, - )?; + ) + .map_err(|e| { + write_error_expr(expr, &job_id); + e + }) + .context("native script initialization")?; let fut = js_runtime.resolve(script); let global = js_runtime .with_event_loop_promise(fut, PollEventLoopOptions::default()) - .await?; + .await + .map_err(|e| { + write_error_expr(expr, &job_id); + e + }) + .context("native script event loop")?; let scope = &mut js_runtime.handle_scope(); let local = v8::Local::new(scope, global); diff --git a/backend/windmill-worker/src/mssql_executor.rs b/backend/windmill-worker/src/mssql_executor.rs index be5ea1e905..42d9c3aa8c 100644 --- a/backend/windmill-worker/src/mssql_executor.rs +++ b/backend/windmill-worker/src/mssql_executor.rs @@ -120,9 +120,11 @@ pub async fn do_mssql( let tcp = TcpStream::connect(config.get_addr()).await?; tcp.set_nodelay(true)?; - Client::connect(config, tcp.compat_write()).await.map_err(to_anyhow)? + Client::connect(config, tcp.compat_write()) + .await + .map_err(to_anyhow)? } - Err(e) => return Err(Error::Anyhow(to_anyhow(e))), + Err(e) => return Err(to_anyhow(e).into()), }; let sig = parse_mssql_sig(&query) diff --git a/backend/windmill-worker/src/mysql_executor.rs b/backend/windmill-worker/src/mysql_executor.rs index b98ec365ee..d733901f93 100644 --- a/backend/windmill-worker/src/mysql_executor.rs +++ b/backend/windmill-worker/src/mysql_executor.rs @@ -133,7 +133,7 @@ pub async fn do_mysql( .await?; let as_raw = serde_json::from_value(val).map_err(|e| { - Error::InternalErr(format!("Error while parsing inline resource: {e:#}")) + Error::internal_err(format!("Error while parsing inline resource: {e:#}")) })?; Some(as_raw) diff --git a/backend/windmill-worker/src/oracledb_executor.rs b/backend/windmill-worker/src/oracledb_executor.rs index f6e64a60a1..e6292181b2 100644 --- a/backend/windmill-worker/src/oracledb_executor.rs +++ b/backend/windmill-worker/src/oracledb_executor.rs @@ -328,7 +328,7 @@ pub async fn do_oracledb( .await?; let as_raw = serde_json::from_value(val).map_err(|e| { - Error::InternalErr(format!("Error while parsing inline resource: {e:#}")) + Error::internal_err(format!("Error while parsing inline resource: {e:#}")) })?; Some(as_raw) diff --git a/backend/windmill-worker/src/php_executor.rs b/backend/windmill-worker/src/php_executor.rs index 7eb0d95429..4f579a54a8 100644 --- a/backend/windmill-worker/src/php_executor.rs +++ b/backend/windmill-worker/src/php_executor.rs @@ -15,8 +15,8 @@ use windmill_queue::{append_logs, CanceledBy}; use crate::{ common::{ - check_executor_binary_exists, create_args_and_out_file, get_main_override, - get_reserved_variables, read_result, start_child_process, OccupancyMetrics, + check_executor_binary_exists, create_args_and_out_file, get_reserved_variables, + read_result, start_child_process, OccupancyMetrics, }, handle_child::handle_child, AuthedClientBackgroundTask, COMPOSER_CACHE_DIR, COMPOSER_PATH, DISABLE_NSJAIL, DISABLE_NUSER, @@ -190,11 +190,14 @@ pub async fn handle_php_job( let _ = write_file(job_dir, "main.php", inner_content)?; - let main_override = get_main_override(job.args.as_ref()); + let main_override = job.script_entrypoint_override.as_deref(); let write_wrapper_f = async { - let args = - windmill_parser_php::parse_php_signature(inner_content, main_override.clone())?.args; + let args = windmill_parser_php::parse_php_signature( + inner_content, + main_override.map(ToString::to_string), + )? + .args; let args_to_include = args .iter() @@ -220,7 +223,7 @@ pub async fn handle_php_job( .collect::>() .join("\n\n"); - let main_name = main_override.unwrap_or("main".to_string()); + let main_name = main_override.unwrap_or("main"); let wrapper_content: String = format!( r#" diff --git a/backend/windmill-worker/src/python_executor.rs b/backend/windmill-worker/src/python_executor.rs index a48e1cb396..d86c84dd0d 100644 --- a/backend/windmill-worker/src/python_executor.rs +++ b/backend/windmill-worker/src/python_executor.rs @@ -10,7 +10,7 @@ use anyhow::anyhow; use itertools::Itertools; use regex::Regex; use serde_json::value::RawValue; -use sqlx::{types::Json, Pool, Postgres}; +use sqlx::{Pool, Postgres}; use tokio::{ fs::{metadata, DirBuilder, File}, io::AsyncReadExt, @@ -26,7 +26,7 @@ use windmill_common::{ self, Error::{self}, }, - jobs::{QueuedJob, PREPROCESSOR_FAKE_ENTRYPOINT}, + jobs::QueuedJob, utils::calculate_hash, worker::{write_file, PythonAnnotations, WORKER_CONFIG}, DB, @@ -35,8 +35,8 @@ use windmill_common::{ #[cfg(feature = "enterprise")] use windmill_common::variables::get_secret_value_as_admin; -use windmill_queue::{append_logs, CanceledBy}; use std::env::var; +use windmill_queue::{append_logs, CanceledBy}; lazy_static::lazy_static! { static ref PYTHON_PATH: String = @@ -84,8 +84,8 @@ use windmill_common::s3_helpers::OBJECT_STORE_CACHE_SETTINGS; use crate::{ common::{ - create_args_and_out_file, get_main_override, get_reserved_variables, read_file, - read_result, start_child_process, OccupancyMetrics, + create_args_and_out_file, get_reserved_variables, read_file, read_result, + start_child_process, OccupancyMetrics, }, handle_child::handle_child, AuthedClientBackgroundTask, DISABLE_NSJAIL, DISABLE_NUSER, HOME_ENV, INSTANCE_PYTHON_VERSION, @@ -308,12 +308,26 @@ impl PyVersion { let mut child_cmd = Command::new(uv_cmd); child_cmd + .env_clear() + .env("HOME", HOME_ENV.to_string()) + .env("PATH", PATH_ENV.to_string()) .args(["python", "install", v, "--python-preference=only-managed"]) // TODO: Do we need these? .envs([("UV_PYTHON_INSTALL_DIR", PY_INSTALL_DIR)]) .stdout(Stdio::piped()) .stderr(Stdio::piped()); + #[cfg(windows)] + { + child_cmd + .env("SystemRoot", SYSTEM_ROOT.as_str()) + .env("USERPROFILE", crate::USERPROFILE_ENV.as_str()) + .env( + "TMP", + std::env::var("TMP").unwrap_or_else(|_| String::from("/tmp")), + ); + } + let child_process = start_child_process(child_cmd, "uv").await?; append_logs(&job_id, &w_id, logs, db).await; @@ -341,8 +355,23 @@ impl PyVersion { let uv_cmd = UV_PATH.as_str(); let mut child_cmd = Command::new(uv_cmd); + + #[cfg(windows)] + { + child_cmd + .env("SystemRoot", SYSTEM_ROOT.as_str()) + .env("USERPROFILE", crate::USERPROFILE_ENV.as_str()) + .env( + "TMP", + std::env::var("TMP").unwrap_or_else(|_| String::from("/tmp")), + ); + } + let output = child_cmd // .current_dir(job_dir) + .env_clear() + .env("HOME", HOME_ENV.to_string()) + .env("PATH", PATH_ENV.to_string()) .args([ "python", "find", @@ -902,8 +931,6 @@ pub async fn handle_python_job( tracing::debug!("Finished deps postinstall stage"); } - - if no_uv { append_logs( &job.id, @@ -937,10 +964,11 @@ pub async fn handle_python_job( pre_spread, ) = prepare_wrapper( job_dir, + job.is_flow_step, + job.preprocessed, + job.script_entrypoint_override.as_deref(), inner_content, &script_path, - job.args.as_ref(), - false, ) .await?; @@ -1057,7 +1085,7 @@ except BaseException as e: // Usefull if certain wheels needs to be preinstalled before execution. let global_site_packages_path = py_version.to_cache_dir() + "/global-site-packages"; let additional_python_paths_folders = { - let mut paths= additional_python_paths.clone(); + let mut paths = additional_python_paths.clone(); if std::fs::metadata(&global_site_packages_path).is_ok() { // We want global_site_packages_path to be included in additonal_python_paths_folders, but // we don't want it to be included in global_site_packages_path. @@ -1189,13 +1217,13 @@ mount {{ let args = read_file(&format!("{job_dir}/args.json")) .await .map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "error while reading args from preprocessing: {e:#}" )) })?; let args: HashMap> = serde_json::from_str(args.get()).map_err(|e| { - error::Error::InternalErr(format!( + error::Error::internal_err(format!( "error while deserializing args from preprocessing: {e:#}" )) })?; @@ -1207,10 +1235,11 @@ mount {{ async fn prepare_wrapper( job_dir: &str, + job_is_flow_step: bool, + job_preprocessed: Option, + job_script_entrypoint_override: Option<&str>, inner_content: &str, script_path: &str, - args: Option<&Json>>>, - skip_preprocessor: bool, ) -> error::Result<( &'static str, &'static str, @@ -1223,16 +1252,8 @@ async fn prepare_wrapper( Option, Option, )> { - let (main_override, apply_preprocessor) = match get_main_override(args) { - Some(main_override) => { - if !skip_preprocessor && main_override == PREPROCESSOR_FAKE_ENTRYPOINT { - (None, true) - } else { - (Some(main_override), false) - } - } - None => (None, false), - }; + let main_override = job_script_entrypoint_override.as_deref(); + let apply_preprocessor = !job_is_flow_step && job_preprocessed == Some(false); let relative_imports = RELATIVE_IMPORT_REGEX.is_match(&inner_content); @@ -1272,7 +1293,10 @@ async fn prepare_wrapper( let _ = write_file(job_dir, "loader.py", RELATIVE_PYTHON_LOADER)?; } - let sig = windmill_parser_py::parse_python_signature(inner_content, main_override.clone())?; + let sig = windmill_parser_py::parse_python_signature( + inner_content, + main_override.map(ToString::to_string), + )?; let pre_sig = if apply_preprocessor { Some(windmill_parser_py::parse_python_signature( @@ -1366,12 +1390,12 @@ async fn prepare_wrapper( } else { format!( r#"pre_args["{name}"] = kwargs.get("{name}") - if pre_args["{name}"] is None: - del pre_args["{name}"]"# + if pre_args["{name}"] is None: + del pre_args["{name}"]"# ) } }) - .join("\n ") + .join("\n ") }; Some(spread) } else { @@ -1389,7 +1413,7 @@ async fn prepare_wrapper( last, transforms, spread, - main_override, + main_override.map(ToString::to_string), pre_spread, )) } @@ -1409,7 +1433,7 @@ async fn replace_pip_secret( let capture = PIP_SECRET_VARIABLE.captures(req); let variable = capture.unwrap().get(1).unwrap().as_str(); if !variable.contains("/PIP_SECRET_") { - return Err(error::Error::InternalErr(format!( + return Err(error::Error::internal_err(format!( "invalid secret variable in pip requirements, (last part of path ma): {}", req ))); @@ -1586,6 +1610,7 @@ async fn spawn_uv_install( // If none, it is system python py_path: Option, no_uv_install: bool, + worker_dir: &str, ) -> Result { if !*DISABLE_NSJAIL { tracing::info!( @@ -1620,13 +1645,30 @@ async fn spawn_uv_install( vars.push(("REQ", &req)); vars.push(("TARGET", venv_p)); + std::fs::create_dir_all(venv_p)?; + let nsjail_proto = format!("{req}.config.proto"); + // Prepare NSJAIL + let _ = write_file( + job_dir, + &nsjail_proto, + &(if no_uv_install { + NSJAIL_CONFIG_DOWNLOAD_PY_CONTENT_FALLBACK + } else { + NSJAIL_CONFIG_DOWNLOAD_PY_CONTENT + }) + .replace("{WORKER_DIR}", worker_dir) + .replace("{PY_INSTALL_DIR}", &PY_INSTALL_DIR) + .replace("{TARGET_DIR}", &venv_p) + .replace("{CLONE_NEWUSER}", &(!*DISABLE_NUSER).to_string()), + )?; + let mut nsjail_cmd = Command::new(NSJAIL_PATH.as_str()); nsjail_cmd .current_dir(job_dir) .env_clear() .envs(vars) .envs(PROXY_ENVS.clone()) - .args(vec!["--config", "download.config.proto"]) + .args(vec!["--config", &nsjail_proto]) .stdout(Stdio::piped()) .stderr(Stdio::piped()); start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await @@ -1721,7 +1763,7 @@ async fn spawn_uv_install( // Track https://github.com/astral-sh/uv/issues/6715 if let Some(cert_path) = INDEX_CERT.as_ref() { // Once merged --cert can be used instead - // + // // command_args.extend(["--cert", cert_path]); envs.push(("SSL_CERT_FILE", cert_path)); } @@ -1812,6 +1854,8 @@ pub async fn handle_python_reqs( // TODO: Remove (Deprecated) mut no_uv_install: bool, ) -> error::Result> { + let worker_dir = worker_dir.to_string(); + let counter_arc = Arc::new(tokio::sync::Mutex::new(0)); // Append logs with line like this: // [9/21] + requests==2.32.3 << (S3) | in 57ms @@ -1895,30 +1939,6 @@ pub async fn handle_python_reqs( .map(handle_ephemeral_token), ); - // Prepare NSJAIL - if !*DISABLE_NSJAIL { - let _ = write_file( - job_dir, - "download.config.proto", - &(if no_uv_install { - NSJAIL_CONFIG_DOWNLOAD_PY_CONTENT_FALLBACK - } else { - NSJAIL_CONFIG_DOWNLOAD_PY_CONTENT - }) - .replace("{WORKER_DIR}", &worker_dir) - .replace("{PY_INSTALL_DIR}", &PY_INSTALL_DIR) - .replace( - "{CACHE_DIR}", - &(if no_uv_install { - PIP_CACHE_DIR.to_owned() - } else { - py_version.to_cache_dir() - }), - ) - .replace("{CLONE_NEWUSER}", &(!*DISABLE_NUSER).to_string()), - )?; - }; - // Cached paths let mut req_with_penv: Vec<(String, String)> = vec![]; // Requirements to pull (not cached) @@ -2020,29 +2040,26 @@ pub async fn handle_python_reqs( // Notify server that we are still alive // Detect if job has been canceled - let canceled = - sqlx::query_scalar::<_, bool> - (r#" - - UPDATE queue - SET last_ping = now() - , mem_peak = $1 - WHERE id = $2 - RETURNING canceled - - "#) - .bind(mem_peak_actual) - .bind(job_id_2) - .fetch_optional(&db_2) - .await - .unwrap_or_else(|e| { - tracing::error!(%e, "error updating job {job_id_2}: {e:#}"); - Some(false) - }) - .unwrap_or_else(|| { - // if the job is not in queue, it can only be in the completed_job so it is already complete - false - }); + let canceled = sqlx::query_scalar!( + "UPDATE v2_job_runtime r SET + memory_peak = $1, + ping = now() + FROM v2_job_queue q + WHERE r.id = $2 AND q.id = r.id + RETURNING canceled_by IS NOT NULL AS \"canceled!\"", + mem_peak_actual, + job_id_2 + ) + .fetch_optional(&db_2) + .await + .unwrap_or_else(|e| { + tracing::error!(%e, "error updating job {job_id_2}: {e:#}"); + Some(false) + }) + .unwrap_or_else(|| { + // if the job is not in queue, it can only be in the completed_job so it is already complete + false + }); if canceled { @@ -2155,7 +2172,7 @@ pub async fn handle_python_reqs( let pip_indexes = pip_indexes.clone(); let py_path = py_path.clone(); let pids = pids.clone(); - + let worker_dir = worker_dir.clone(); handles.push(task::spawn(async move { // permit will be dropped anyway if this thread exits at any point // so we dont have to drop it manually @@ -2223,7 +2240,8 @@ pub async fn handle_python_reqs( &job_dir, pip_indexes, py_path, - no_uv_install + no_uv_install, + &worker_dir ).await { Ok(r) => r, Err(e) => { @@ -2263,12 +2281,12 @@ pub async fn handle_python_reqs( uv_install_proccess.kill().await?; pids.lock().await.get_mut(i).and_then(|e| e.take()); return Err(anyhow::anyhow!("uv pip install was canceled")); - }, + }, (_, exitstatus) = async { // See tokio::process::Child::wait_with_output() for more context // Sometimes uv_install_proccess.wait() is not exiting if stderr is not awaited before it :/ (stderr_future.await, uv_install_proccess.wait().await) - } => match exitstatus { + } => match exitstatus { Ok(status) => if !status.success() { tracing::warn!( workspace_id = %w_id, @@ -2307,6 +2325,10 @@ pub async fn handle_python_reqs( #[cfg(not(all(feature = "enterprise", feature = "parquet", unix)))] let s3_push = false; + if !*DISABLE_NSJAIL { + let _ = std::fs::remove_file(format!("{job_dir}/{req}.config.proto")); + } + print_success( false, s3_push, @@ -2449,7 +2471,6 @@ pub async fn start_worker( ) .await?; - let _args = None; let ( import_loader, import_base64, @@ -2461,7 +2482,7 @@ pub async fn start_worker( spread, _, _, - ) = prepare_wrapper(job_dir, inner_content, script_path, _args.as_ref(), true).await?; + ) = prepare_wrapper(job_dir, false, None, None, inner_content, script_path).await?; { let indented_transforms = transforms diff --git a/backend/windmill-worker/src/result_processor.rs b/backend/windmill-worker/src/result_processor.rs index 5812b12175..dc99d1aae8 100644 --- a/backend/windmill-worker/src/result_processor.rs +++ b/backend/windmill-worker/src/result_processor.rs @@ -232,6 +232,7 @@ async fn send_job_completed( job_completed_tx: JobCompletedSender, job: Arc, result: Arc>, + result_columns: Option>, mem_peak: i32, canceled_by: Option, success: bool, @@ -242,6 +243,7 @@ async fn send_job_completed( let jc = JobCompleted { job, result, + result_columns, mem_peak, canceled_by, success, @@ -272,52 +274,22 @@ pub async fn process_result( ) -> error::Result { match result { Ok(r) => { - let job = if column_order.is_some() || new_args.is_some() { - let mut updated_job = (*job).clone(); - if let Some(column_order) = column_order { - match updated_job.flow_status { - Some(_) => { - tracing::warn!("flow_status was expected to be none"); - } - None => { - updated_job.flow_status = - Some(sqlx::types::Json(to_raw_value(&serde_json::json!({ - "_metadata": { - "column_order": column_order - } - })))); - } - } - } - if let Some(new_args) = new_args { - match updated_job.flow_status { - Some(_) => { - tracing::warn!("flow_status was expected to be none"); - } - None => { - // TODO save original args somewhere - // if let Some(args) = updated_job.args.as_mut() { - // args.0.remove(ENTRYPOINT_OVERRIDE); - // } - updated_job.flow_status = - Some(sqlx::types::Json(to_raw_value(&serde_json::json!({ - "_metadata": { - "preprocessed_args": true - } - })))); - } - } - updated_job.args = Some(Json(new_args)); - } - Arc::new(updated_job) - } else { - job - }; + // Update script args to preprocessed args + if let Some(preprocessed_args) = new_args { + sqlx::query!( + "UPDATE v2_job SET args = $1, preprocessed = TRUE WHERE id = $2", + Json(preprocessed_args) as Json>>, + job.id + ) + .execute(db) + .await?; + } send_job_completed( job_completed_tx, job, r, + column_order, mem_peak, canceled_by, true, @@ -331,7 +303,7 @@ pub async fn process_result( } Err(e) => { let error_value = match e { - Error::ExitStatus(i) => { + Error::ExitStatus(program, i) => { let res = read_result(job_dir).await.ok(); if res.as_ref().is_some_and(|x| !x.get().is_empty()) { @@ -348,11 +320,11 @@ pub async fn process_result( .last() .unwrap_or(&last_10_log_lines); - extract_error_value(log_lines, i, job.flow_step_id.clone()) + extract_error_value(&program, log_lines, i, job.flow_step_id.clone()) } } err @ _ => to_raw_value(&SerializedError { - message: format!("error during execution of the script:\n{}", err), + message: format!("error during execution of the script:\n{err:#}",), name: "ExecutionErr".to_string(), step_id: job.flow_step_id.clone(), exit_code: None, @@ -363,6 +335,7 @@ pub async fn process_result( job_completed_tx, job, Arc::new(to_raw_value(&error_value)), + None, mem_peak, canceled_by, false, @@ -435,7 +408,17 @@ pub async fn handle_receive_completed_job( } pub async fn process_completed_job( - JobCompleted { job, result, mem_peak, success, cached_res_path, canceled_by, duration, .. }: JobCompleted, + JobCompleted { + job, + result, + mem_peak, + success, + cached_res_path, + canceled_by, + duration, + result_columns, + .. + }: JobCompleted, client: &AuthedClient, db: &DB, worker_dir: &str, @@ -455,12 +438,32 @@ pub async fn process_completed_job( let job_id = job.id.clone(); let workspace_id = job.workspace_id.clone(); + if job.flow_step_id.as_deref() == Some("preprocessor") { + // Do this before inserting to `v2_job_completed` for backwards compatibility + // when we set `flow_status->_metadata->preprocessed_args` to true. + sqlx::query!( + r#"UPDATE v2_job SET + args = '{"reason":"PREPROCESSOR_ARGS_ARE_DISCARDED"}'::jsonb, + preprocessed = TRUE + WHERE id = $1 AND preprocessed = FALSE"#, + job.id + ) + .execute(db) + .await + .map_err(|e| { + Error::InternalErr(format!( + "error while deleting args of preprocessing step: {e:#}" + )) + })?; + } + add_completed_job( db, &job, true, false, Json(&result), + result_columns, mem_peak.to_owned(), canceled_by, false, @@ -662,10 +665,15 @@ pub struct SerializedError { #[serde(skip_serializing_if = "Option::is_none")] pub exit_code: Option, } -pub fn extract_error_value(log_lines: &str, i: i32, step_id: Option) -> Box { +pub fn extract_error_value( + program: &str, + log_lines: &str, + i: i32, + step_id: Option, +) -> Box { return to_raw_value(&SerializedError { message: format!( - "ExitCode: {i}, last log lines:\n{}", + "exit code for \"{program}\": {i}, last log lines:\n{}", ANSI_ESCAPE_RE.replace_all(log_lines.trim(), "").to_string() ), name: "ExecutionErr".to_string(), diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index 2c2aefe6b3..b1f2ad1f65 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -208,7 +208,7 @@ pub async fn create_token_for_owner( let jwt_secret = JWT_SECRET.read().await; if jwt_secret.is_empty() { - return Err(Error::InternalErr("No JWT secret found".to_string())); + return Err(Error::internal_err("No JWT secret found".to_string())); } let job_authed = match sqlx::query_as!( @@ -226,7 +226,7 @@ pub async fn create_token_for_owner( fetch_authed_from_permissioned_as(owner.to_string(), email.to_string(), w_id, db) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "Could not get permissions directly for job {job_id}: {e:#}" )) })? @@ -254,7 +254,7 @@ pub async fn create_token_for_owner( &jsonwebtoken::EncodingKey::from_secret(jwt_secret.as_bytes()), ) .map_err(|err| { - Error::InternalErr(format!( + Error::internal_err(format!( "Could not encode JWT token for job {job_id}: {:?}", err )) @@ -1278,7 +1278,7 @@ pub async fn run_worker( tokio::task::spawn( (async move { tracing::info!(worker = %worker_name, hostname = %hostname, "vacuuming queue"); - if let Err(e) = sqlx::query!("VACUUM (skip_locked) queue") + if let Err(e) = sqlx::query!("VACUUM (skip_locked) v2_job_queue, v2_job_runtime, v2_job_status") .execute(&db2) .await { @@ -1325,12 +1325,16 @@ pub async fn run_worker( same_worker_job.job_id ); let r = sqlx::query_as::<_, PulledJob>( - "UPDATE queue SET last_ping = now() WHERE id = $1 RETURNING *", + "WITH ping AS ( + UPDATE v2_job_runtime SET ping = NOW() WHERE id = $1 RETURNING id + ) SELECT * FROM v2_as_queue WHERE id = (SELECT id FROM ping)", ) .bind(same_worker_job.job_id) .fetch_optional(db) .await - .map_err(|_| Error::InternalErr("Impossible to fetch same_worker job".to_string())); + .map_err(|_| { + Error::internal_err("Impossible to fetch same_worker job".to_string()) + }); if r.is_err() && !same_worker_job.recoverable { tracing::error!( worker = %worker_name, hostname = %hostname, @@ -1484,6 +1488,7 @@ pub async fn run_worker( job: Arc::new(job.job), success: true, result: Arc::new(empty_result()), + result_columns: None, mem_peak: 0, cached_res_path: None, token: "".to_string(), @@ -1880,6 +1885,7 @@ pub enum SendResult { pub struct JobCompleted { pub job: Arc, pub result: Arc>, + pub result_columns: Option>, pub mem_peak: i32, pub success: bool, pub cached_res_path: Option, @@ -1994,21 +2000,31 @@ async fn handle_queued_job( db, &job.workspace_id, job.parent_job - .ok_or_else(|| Error::InternalErr(format!("expected parent job")))?, + .ok_or_else(|| Error::internal_err(format!("expected parent job")))?, job.id, ) .warn_after_seconds(5) .await?; } else if let Some(parent_job) = job.parent_job { if let Err(e) = sqlx::query_scalar!( - "UPDATE queue SET flow_status = jsonb_set(jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], COALESCE(flow_status->$1, '{}'::jsonb)), array[$1, 'started_at'], to_jsonb(now()::text)) WHERE id = $2 AND workspace_id = $3", + "UPDATE v2_job_status SET + flow_status = jsonb_set( + jsonb_set( + COALESCE(flow_status, '{}'::jsonb), + array[$1], + COALESCE(flow_status->$1, '{}'::jsonb) + ), + array[$1, 'started_at'], + to_jsonb(now()::text) + ) + WHERE id = $2", &job.id.to_string(), - parent_job, - &job.workspace_id + parent_job ) .execute(db) .warn_after_seconds(5) - .await { + .await + { tracing::error!("Could not update parent job started_at flow_status: {}", e); } } @@ -2056,6 +2072,7 @@ async fn handle_queued_job( .send(JobCompleted { job, result, + result_columns: None, mem_peak: 0, canceled_by: None, success: true, @@ -2280,7 +2297,7 @@ pub async fn get_hub_script_content_and_requirements( ) -> error::Result { let script_path = script_path .clone() - .ok_or_else(|| Error::InternalErr(format!("expected script path for hub script")))?; + .ok_or_else(|| Error::internal_err(format!("expected script path for hub script")))?; let script = get_full_hub_script_by_path(StripPath(script_path.to_string()), &HTTP_CLIENT, db).await?; @@ -2331,7 +2348,7 @@ async fn handle_code_execution_job( ) -> error::Result> { let script_hash = || { job.script_hash - .ok_or_else(|| Error::InternalErr("expected script hash".into())) + .ok_or_else(|| Error::internal_err("expected script hash")) }; let (arc_data, arc_metadata, data, metadata): ( Arc, @@ -2349,7 +2366,8 @@ async fn handle_code_execution_job( _ => None, }; - arc_data = preview.ok_or_else(|| Error::InternalErr("expected preview".to_string()))?; + arc_data = + preview.ok_or_else(|| Error::internal_err("expected preview".to_string()))?; metadata = ScriptMetadata { language: job.language, codebase, envs: None }; (arc_data.as_ref(), &metadata) } @@ -2378,7 +2396,7 @@ async fn handle_code_execution_job( let script_path = job .script_path .as_ref() - .ok_or_else(|| Error::InternalErr("expected script path".to_string()))?; + .ok_or_else(|| Error::internal_err("expected script path".to_string()))?; if script_path.starts_with("hub/") { let ContentReqLangEnvs { content, lockfile, language, envs, codebase } = get_hub_script_content_and_requirements(Some(script_path), Some(db)).await?; @@ -2394,7 +2412,7 @@ async fn handle_code_execution_job( ) .fetch_optional(db) .await? - .ok_or_else(|| Error::InternalErr("expected script hash".to_string()))?; + .ok_or_else(|| Error::internal_err("expected script hash".to_string()))?; (arc_data, arc_metadata) = cache::script::fetch(db, ScriptHash(hash)).await?; (arc_data.as_ref(), arc_metadata.as_ref()) @@ -2421,7 +2439,7 @@ async fn handle_code_execution_job( .await; } else if language == Some(ScriptLang::Mysql) { #[cfg(not(feature = "mysql"))] - return Err(Error::InternalErr( + return Err(Error::internal_err( "MySQL requires the mysql feature to be enabled".to_string(), )); @@ -2449,7 +2467,7 @@ async fn handle_code_execution_job( #[allow(unreachable_code)] #[cfg(not(feature = "bigquery"))] { - return Err(Error::InternalErr( + return Err(Error::internal_err( "Bigquery requires the bigquery feature to be enabled".to_string(), )); } @@ -2503,7 +2521,7 @@ async fn handle_code_execution_job( #[allow(unreachable_code)] #[cfg(not(feature = "mssql"))] { - return Err(Error::InternalErr( + return Err(Error::internal_err( "Microsoft SQL server requires the mssql feature to be enabled".to_string(), )); } @@ -2533,7 +2551,7 @@ async fn handle_code_execution_job( #[allow(unreachable_code)] #[cfg(not(feature = "oracledb"))] { - return Err(Error::InternalErr( + return Err(Error::internal_err( "Oracle DB requires the oracledb feature to be enabled".to_string(), )); } @@ -2644,7 +2662,7 @@ mount {{ } Some(ScriptLang::Python3) => { #[cfg(not(feature = "python"))] - return Err(Error::InternalErr( + return Err(Error::internal_err( "Python requires the python feature to be enabled".to_string(), )); @@ -2761,7 +2779,7 @@ mount {{ } Some(ScriptLang::Php) => { #[cfg(not(feature = "php"))] - return Err(Error::InternalErr( + return Err(Error::internal_err( "PHP requires the php feature to be enabled".to_string(), )); @@ -2785,7 +2803,7 @@ mount {{ } Some(ScriptLang::Rust) => { #[cfg(not(feature = "rust"))] - return Err(Error::InternalErr( + return Err(Error::internal_err( "Rust requires the rust feature to be enabled".to_string(), )); @@ -2809,7 +2827,7 @@ mount {{ } Some(ScriptLang::Ansible) => { #[cfg(not(feature = "python"))] - return Err(Error::InternalErr( + return Err(Error::internal_err( "Ansible requires the python feature to be enabled".to_string(), )); diff --git a/backend/windmill-worker/src/worker_flow.rs b/backend/windmill-worker/src/worker_flow.rs index cf24258b9e..97ffc30719 100644 --- a/backend/windmill-worker/src/worker_flow.rs +++ b/backend/windmill-worker/src/worker_flow.rs @@ -35,12 +35,12 @@ use windmill_common::bench::BenchmarkIter; use windmill_common::cache::{self, RawData}; use windmill_common::db::Authed; use windmill_common::flow_status::{ - ApprovalConditions, FlowStatusModuleWParent, Iterator, JobResult, + ApprovalConditions, FlowStatusModuleWParent, Iterator as FlowIterator, JobResult, }; use windmill_common::flows::{add_virtual_items_if_necessary, Branch, FlowNodeId}; use windmill_common::jobs::{ - script_hash_to_tag_and_limits, script_path_to_payload, BranchResults, JobKind, JobPayload, - OnBehalfOf, QueuedJob, RawCode, ENTRYPOINT_OVERRIDE, + script_hash_to_tag_and_limits, script_path_to_payload, JobKind, JobPayload, OnBehalfOf, + QueuedJob, RawCode, ENTRYPOINT_OVERRIDE, }; use windmill_common::scripts::ScriptHash; use windmill_common::users::username_to_permissioned_as; @@ -179,11 +179,6 @@ pub struct RecUpdateFlowStatusAfterJobCompletion { skip_error_handler: bool, } -#[derive(FromRow)] -pub struct RowArgs { - pub args: Option>>>, -} - #[derive(Deserialize)] struct RecoveryObject { recover: Option, @@ -222,18 +217,18 @@ pub async fn update_flow_status_after_job_completion_internal( let (job_kind, script_hash, old_status, raw_flow) = sqlx::query!( "SELECT - job_kind AS \"job_kind: JobKind\", + job_kind AS \"job_kind!: JobKind\", script_hash AS \"script_hash: ScriptHash\", flow_status AS \"flow_status!: Json>\", raw_flow AS \"raw_flow: Json>\" - FROM queue WHERE id = $1 AND workspace_id = $2 LIMIT 1", + FROM v2_as_queue WHERE id = $1 AND workspace_id = $2 LIMIT 1", flow, w_id ) .fetch_one(db) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "fetching flow status {flow} while reporting {success} {result:?}: {e:#}" )) }) @@ -242,7 +237,7 @@ pub async fn update_flow_status_after_job_completion_internal( record.job_kind, record.script_hash, serde_json::from_str::(record.flow_status.0.get()).map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "requiring current module to be parsable as FlowStatus: {e:?}" )) })?, @@ -264,12 +259,12 @@ pub async fn update_flow_status_after_job_completion_internal( Step::PreprocessorStep => old_status .preprocessor_module .as_ref() - .ok_or_else(|| Error::InternalErr(format!("preprocessor module not found")))?, + .ok_or_else(|| Error::internal_err(format!("preprocessor module not found")))?, Step::FailureStep => &old_status.failure_module.module_status, Step::Step(i) => old_status .modules .get(i as usize) - .ok_or_else(|| Error::InternalErr(format!("module {i} not found")))?, + .ok_or_else(|| Error::internal_err(format!("module {i} not found")))?, }; // tracing::debug!( @@ -355,22 +350,21 @@ pub async fn update_flow_status_after_job_completion_internal( )), _ => None, }; - let args = sqlx::query_as::<_, RowArgs>( + let args = sqlx::query_scalar!( "SELECT - args - FROM queue - WHERE id = $2", + args AS \"args: Json>>\" + FROM v2_job + WHERE id = $1", + flow ) - .bind(old_status.step) - .bind(flow) .fetch_one(db) .await .map_err(|e| { - Error::InternalErr(format!("retrieval of args from state: {e:#}")) + Error::internal_err(format!("retrieval of args from state: {e:#}")) })?; compute_bool_from_expr( &expr, - Marc::new(args.args.unwrap_or_default().0), + Marc::new(args.unwrap_or_default().0), result.clone(), all_iters, None, @@ -414,22 +408,18 @@ pub async fn update_flow_status_after_job_completion_internal( if matches!(module_step, Step::PreprocessorStep) { sqlx::query!( - "UPDATE queue SET args = (select result FROM completed_job WHERE id = $1) WHERE id = $2", + "UPDATE v2_job SET + args = (SELECT result FROM v2_job_completed WHERE id = $1), + preprocessed = TRUE + WHERE id = $2", job_id_for_status, flow - ).execute(db).await.map_err(|e| { - Error::InternalErr(format!("error while updating args in preprocessing step: {e:#}")) - })?; - - sqlx::query!( - r#"UPDATE completed_job SET args = '{"reason":"PREPROCESSOR_ARGS_ARE_DISCARDED"}'::jsonb WHERE id = $1"#, - job_id_for_status ) .execute(db) .await .map_err(|e| { - Error::InternalErr(format!( - "error while deleting args of preprocessing step: {e:#}" + Error::internal_err(format!( + "error while updating args in preprocessing step: {e:#}" )) })?; } @@ -448,7 +438,7 @@ pub async fn update_flow_status_after_job_completion_internal( .. } if *parallel => { let (nindex, len) = match (iterator, branchall) { - (Some(Iterator { itered, .. }), _) => { + (Some(FlowIterator { itered, .. }), _) => { let position = if flow_jobs_success.is_some() { find_flow_job_index(jobs, job_id_for_status) } else { @@ -457,24 +447,27 @@ pub async fn update_flow_status_after_job_completion_internal( let nindex = if let Some(position) = position { sqlx::query_scalar!( - "UPDATE queue - SET flow_status = JSONB_SET( - JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4), - ARRAY['modules', $1::TEXT, 'iterator', 'index'], - ((flow_status->'modules'->$1::int->'iterator'->>'index')::int + 1)::text::jsonb - ), - last_ping = NULL - WHERE id = $2 - RETURNING (flow_status->'modules'->$1::int->'iterator'->>'index')::int", - old_status.step, - flow, - position as i32, - json!(success) - )} else { + "UPDATE v2_job_status SET + flow_status = JSONB_SET( + JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4), + ARRAY['modules', $1::TEXT, 'iterator', 'index'], + ((flow_status->'modules'->$1::int->'iterator'->>'index')::int + 1)::text::jsonb + ) + WHERE id = $2 + RETURNING (flow_status->'modules'->$1::int->'iterator'->>'index')::int", + old_status.step, + flow, + position as i32, + json!(success) + ) + } else { sqlx::query_scalar!( - "UPDATE queue - SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'iterator', 'index'], ((flow_status->'modules'->$1::int->'iterator'->>'index')::int + 1)::text::jsonb), - last_ping = NULL + "UPDATE v2_job_status SET + flow_status = JSONB_SET( + flow_status, + ARRAY['modules', $1::TEXT, 'iterator', 'index'], + ((flow_status->'modules'->$1::int->'iterator'->>'index')::int + 1)::text::jsonb + ) WHERE id = $2 RETURNING (flow_status->'modules'->$1::int->'iterator'->>'index')::int", old_status.step, @@ -483,11 +476,11 @@ pub async fn update_flow_status_after_job_completion_internal( } .fetch_one(&mut *tx) .await.map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error while fetching iterator index: {e:#}" )) })? - .ok_or_else(|| Error::InternalErr(format!("requiring an index in InProgress")))?; + .ok_or_else(|| Error::internal_err(format!("requiring an index in InProgress")))?; tracing::info!( "parallel iteration {job_id_for_status} of flow {flow} update nindex: {nindex} len: {len}", nindex = nindex, @@ -504,11 +497,12 @@ pub async fn update_flow_status_after_job_completion_internal( let nindex = if let Some(position) = position { sqlx::query_scalar!( - "UPDATE queue - SET flow_status = JSONB_SET( - JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4), - ARRAY['modules', $1::TEXT, 'branchall', 'branch'], ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb), - last_ping = NULL + "UPDATE v2_job_status SET + flow_status = JSONB_SET( + JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4), + ARRAY['modules', $1::TEXT, 'branchall', 'branch'], + ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb + ) WHERE id = $2 RETURNING (flow_status->'modules'->$1::int->'branchall'->>'branch')::int", old_status.step, @@ -516,29 +510,38 @@ pub async fn update_flow_status_after_job_completion_internal( position as i32, json!(success) ) - } else { sqlx::query_scalar!( - "UPDATE queue - SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'branchall', 'branch'], ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb), - last_ping = NULL - WHERE id = $2 - RETURNING (flow_status->'modules'->$1::int->'branchall'->>'branch')::int", - old_status.step, - flow - )} + } else { + sqlx::query_scalar!( + "UPDATE v2_job_status SET + flow_status = JSONB_SET( + flow_status, + ARRAY['modules', $1::TEXT, 'branchall', 'branch'], + ((flow_status->'modules'->$1::int->'branchall'->>'branch')::int + 1)::text::jsonb + ) + WHERE id = $2 + RETURNING (flow_status->'modules'->$1::int->'branchall'->>'branch')::int", + old_status.step, + flow + ) + } .fetch_one(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error while fetching branchall index: {e:#}" )) })? - .ok_or_else(|| Error::InternalErr(format!("requiring an index in InProgress")))?; + .ok_or_else(|| Error::internal_err(format!("requiring an index in InProgress")))?; (nindex, *len as i32) } - _ => Err(Error::InternalErr(format!( + _ => Err(Error::internal_err(format!( "unexpected status for parallel module" )))?, }; + // reset ping after updating flow status: + let _ = sqlx::query!("UPDATE v2_job_runtime SET ping = NULL WHERE id = $1", flow) + .execute(&mut *tx) + .await?; if nindex == len { let mut flow_jobs_success = flow_jobs_success.clone(); if let Some(flow_job_success) = flow_jobs_success.as_mut() { @@ -552,13 +555,13 @@ pub async fn update_flow_status_after_job_completion_internal( let new_status = if skip_loop_failures || sqlx::query_scalar!( - "SELECT success FROM completed_job WHERE id = ANY($1)", + "SELECT success AS \"success!\" FROM v2_as_completed_job WHERE id = ANY($1)", jobs.as_slice() ) .fetch_all(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error while fetching sucess from completed_jobs: {e:#}" )) })? @@ -591,7 +594,7 @@ pub async fn update_flow_status_after_job_completion_internal( "DELETE FROM parallel_monitor_lock WHERE parent_flow_id = $1 RETURNING last_ping", flow, ).fetch_optional(db).await.map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error while deleting parallel_monitor_lock: {e:#}" )) })?; @@ -611,14 +614,18 @@ pub async fn update_flow_status_after_job_completion_internal( if parallelism.is_some() { sqlx::query!( - "UPDATE queue SET suspend = 0 WHERE parent_job = $1 AND suspend = $2 AND (flow_status->'step')::int = 0", + "UPDATE v2_job_queue q SET suspend = 0 + FROM v2_job j, v2_job_status f + WHERE parent_job = $1 + AND f.id = j.id AND q.id = j.id + AND suspend = $2 AND (f.flow_status->'step')::int = 0", flow, nindex ) .execute(db) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error resuming job at suspend {nindex} and parent {flow}: {e:#}" )) })?; @@ -629,7 +636,7 @@ pub async fn update_flow_status_after_job_completion_internal( flow, job_id_for_status ).fetch_optional(db).await.map_err(|e| { - Error::InternalErr(format!("error while removing parallel_monitor_lock: {e:#}")) + Error::internal_err(format!("error while removing parallel_monitor_lock: {e:#}")) })?; if r.is_some() { tracing::info!( @@ -642,7 +649,7 @@ pub async fn update_flow_status_after_job_completion_internal( } } FlowStatusModule::InProgress { - iterator: Some(windmill_common::flow_status::Iterator { index, itered, .. }), + iterator: Some(FlowIterator { index, itered, .. }), flow_jobs_success, flow_jobs, while_loop, @@ -715,12 +722,14 @@ pub async fn update_flow_status_after_job_completion_internal( let is_skipped = if current_module.as_ref().is_some_and(|m| m.skip_if.is_some()) { sqlx::query_scalar!( - "SELECT job_kind = 'identity' FROM completed_job WHERE id = $1", + "SELECT kind = 'identity' FROM v2_job WHERE id = $1", job_id_for_status ) .fetch_one(db) .await - .map_err(|e| Error::InternalErr(format!("error during skip check: {e:#}")))? + .map_err(|e| { + Error::internal_err(format!("error during skip check: {e:#}")) + })? .unwrap_or(false) } else { false @@ -768,7 +777,7 @@ pub async fn update_flow_status_after_job_completion_internal( let step_counter = if inc_step_counter { sqlx::query!( - "UPDATE queue + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['step'], $1) WHERE id = $2", json!(old_status.step + 1), @@ -777,7 +786,7 @@ pub async fn update_flow_status_after_job_completion_internal( .execute(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!("error while setting flow index for {flow}: {e:#}")) + Error::internal_err(format!("error while setting flow index for {flow}: {e:#}")) })?; old_status.step + 1 } else { @@ -792,18 +801,18 @@ pub async fn update_flow_status_after_job_completion_internal( if let Some(new_status) = new_status.as_ref() { if is_failure_step { let parent_module = sqlx::query_scalar!( - "SELECT flow_status->'failure_module'->>'parent_module' FROM queue WHERE id = $1", + "SELECT flow_status->'failure_module'->>'parent_module' FROM v2_job_status WHERE id = $1", flow ) .fetch_one(&mut *tx) .await.map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error while fetching failure module: {e:#}" )) })?; sqlx::query!( - "UPDATE queue + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['failure_module'], $1) WHERE id = $2", json!(FlowStatusModuleWParent { @@ -815,13 +824,13 @@ pub async fn update_flow_status_after_job_completion_internal( .execute(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error while setting flow status in failure step: {e:#}" )) })?; } else if matches!(module_step, Step::PreprocessorStep) { sqlx::query!( - "UPDATE queue + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['preprocessor_module'], $1) WHERE id = $2", json!(new_status), @@ -830,13 +839,13 @@ pub async fn update_flow_status_after_job_completion_internal( .execute(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error while setting flow status in preprocessing step: {e:#}" )) })?; } else { sqlx::query!( - "UPDATE queue + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2) WHERE id = $3", old_status.step.to_string(), @@ -846,21 +855,21 @@ pub async fn update_flow_status_after_job_completion_internal( .execute(&mut *tx) .await .map_err(|e| { - Error::InternalErr(format!("error while setting new flow status: {e:#}")) + Error::internal_err(format!("error while setting new flow status: {e:#}")) })?; if let Some(job_result) = new_status.job_result() { sqlx::query!( - "UPDATE queue - SET leaf_jobs = JSONB_SET(coalesce(leaf_jobs, '{}'::jsonb), ARRAY[$1::TEXT], $2) - WHERE COALESCE((SELECT root_job FROM queue WHERE id = $3), $3) = id", + "UPDATE v2_job_status + SET flow_leaf_jobs = JSONB_SET(coalesce(flow_leaf_jobs, '{}'::jsonb), ARRAY[$1::TEXT], $2) + WHERE COALESCE((SELECT flow_innermost_root_job FROM v2_job WHERE id = $3), $3) = id", new_status.id(), json!(job_result), flow ) .execute(&mut *tx) .await.map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error while setting leaf jobs: {e:#}" )) })?; @@ -882,23 +891,20 @@ pub async fn update_flow_status_after_job_completion_internal( .as_ref() .and_then(|m| m.stop_after_all_iters_if.as_ref().map(|x| x.expr.clone())) { - let args = sqlx::query_as::<_, RowArgs>( - "SELECT - args - FROM queue - WHERE id = $2", + let args = sqlx::query_scalar!( + "SELECT args AS \"args: Json>>\" + FROM v2_job WHERE id = $1", + flow ) - .bind(old_status.step) - .bind(flow) .fetch_one(db) .await .map_err(|e| { - Error::InternalErr(format!("retrieval of args from state: {e:#}")) + Error::internal_err(format!("retrieval of args from state: {e:#}")) })?; let should_stop = compute_bool_from_expr( &expr, - Marc::new(args.args.unwrap_or_default().0), + Marc::new(args.unwrap_or_default().0), nresult.clone(), None, None, @@ -927,27 +933,26 @@ pub async fn update_flow_status_after_job_completion_internal( if old_status.retry.fail_count > 0 && matches!(&new_status, Some(FlowStatusModule::Success { .. })) { - sqlx::query( - "UPDATE queue + sqlx::query!( + "UPDATE v2_job_status SET flow_status = flow_status - 'retry' - WHERE id = $1 - RETURNING flow_status", + WHERE id = $1", + flow ) - .bind(flow) .execute(&mut *tx) .await .context("remove flow status retry")?; } let flow_job = sqlx::query_as::<_, QueuedJob>( - "SELECT * FROM queue WHERE id = $1 AND workspace_id = $2", + "SELECT * FROM v2_as_queue WHERE id = $1 AND workspace_id = $2", ) .bind(flow) .bind(w_id) .fetch_optional(&mut *tx) .await .map_err(Into::::into)? - .ok_or_else(|| Error::InternalErr(format!("requiring flow to be in the queue")))?; + .ok_or_else(|| Error::internal_err(format!("requiring flow to be in the queue")))?; tx.commit().await?; let job_root = flow_job @@ -1036,15 +1041,22 @@ pub async fn update_flow_status_after_job_completion_internal( _cleanup_module.flow_jobs_to_clean ); sqlx::query!( - "UPDATE completed_job - SET logs = '##DELETED##', args = '{}'::jsonb, result = '{}'::jsonb - WHERE id = ANY($1)", + "UPDATE v2_job SET args = '{}'::jsonb WHERE id = ANY($1)", &_cleanup_module.flow_jobs_to_clean, ) .execute(db) .await .map_err(|e| { - Error::InternalErr(format!("error while cleaning up completed_job: {e:#}")) + Error::InternalErr(format!("error while cleaning up completed job: {e:#}")) + })?; + sqlx::query!( + "UPDATE v2_job_completed SET result = '{}'::jsonb WHERE id = ANY($1)", + &_cleanup_module.flow_jobs_to_clean, + ) + .execute(db) + .await + .map_err(|e| { + Error::internal_err(format!("error while cleaning up completed job: {e:#}")) })?; } } @@ -1086,6 +1098,7 @@ pub async fn update_flow_status_after_job_completion_internal( success, stop_early && skip_if_stop_early, Json(&nresult), + None, 0, None, true, @@ -1103,6 +1116,7 @@ pub async fn update_flow_status_after_job_completion_internal( |e| json!({"error": format!("Impossible to serialize error: {e:#}")}), ), ), + None, 0, None, true, @@ -1192,18 +1206,23 @@ async fn set_success_in_flow_job_success<'c>( let position = find_flow_job_index(flow_jobs, job_id_for_status); if let Some(position) = position { sqlx::query!( - "UPDATE queue SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], $4) WHERE id = $2", - old_status.step as i32, - flow, - position as i32, - json!(success) - ) - .execute(&mut **tx) - .await.map_err(|e| { - Error::InternalErr(format!( - "error while setting flow_jobs_success: {e:#}" - )) - })?; + "UPDATE v2_job_status SET + flow_status = JSONB_SET( + flow_status, + ARRAY['modules', $1::TEXT, 'flow_jobs_success', $3::TEXT], + $4 + ) + WHERE id = $2", + old_status.step as i32, + flow, + position as i32, + json!(success) + ) + .execute(&mut **tx) + .await + .map_err(|e| { + Error::internal_err(format!("error while setting flow_jobs_success: {e:#}")) + })?; } } Ok(()) @@ -1214,13 +1233,13 @@ async fn retrieve_flow_jobs_results( w_id: &str, job_uuids: &Vec, ) -> error::Result> { - let results = sqlx::query_as::<_, BranchResults>( + let results = sqlx::query!( "SELECT result, id - FROM completed_job + FROM v2_job_completed WHERE id = ANY($1) AND workspace_id = $2", + job_uuids.as_slice(), + w_id ) - .bind(job_uuids.as_slice()) - .bind(w_id) .fetch_all(db) .await? .into_iter() @@ -1232,7 +1251,7 @@ async fn retrieve_flow_jobs_results( .map(|j| { results .get(j) - .ok_or_else(|| Error::InternalErr(format!("missing job result for {}", j))) + .ok_or_else(|| Error::internal_err(format!("missing job result for {}", j))) }) .collect::, _>>()?; @@ -1248,23 +1267,23 @@ async fn compute_skip_branchall_failure<'c>( flow_module: Option<&FlowModule>, ) -> Result, Error> { let branch = if parallel { - sqlx::query_scalar!("SELECT script_path FROM completed_job WHERE id = $1", job) + sqlx::query_scalar!("SELECT runnable_path FROM v2_job WHERE id = $1", job) .fetch_one(db) .await .map_err(|e| { - Error::InternalErr(format!("error during retrieval of branchall index: {e:#}")) + Error::internal_err(format!("error during retrieval of branchall index: {e:#}")) })? .map(|p| { BRANCHALL_INDEX_RE .captures(&p) .map(|x| x.get(1).unwrap().as_str().parse::().ok()) .flatten() - .ok_or(Error::InternalErr(format!( + .ok_or(Error::internal_err(format!( "could not parse branchall index from path: {p}" ))) }) .ok_or_else(|| { - Error::InternalErr(format!("no branchall script path found for job {job}")) + Error::internal_err(format!("no branchall script path found for job {job}")) })?? } else { branch as i32 @@ -1288,12 +1307,12 @@ async fn compute_skip_branchall_failure<'c>( // ) // .fetch_one(db) // .await -// .map_err(|e| Error::InternalErr(format!("error during retrieval of cleanup module: {e:#}")))?; +// .map_err(|e| Error::internal_err(format!("error during retrieval of cleanup module: {e:#}")))?; // raw_value // .clone() // .and_then(|rv| serde_json::from_value::(rv).ok()) -// .ok_or(Error::InternalErr(format!( +// .ok_or(Error::internal_err(format!( // "Unable to parse flow cleanup module {:?}", // raw_value // ))) @@ -1350,48 +1369,55 @@ async fn compute_bool_from_expr( pub async fn update_flow_status_in_progress( db: &DB, - w_id: &str, + _w_id: &str, flow: Uuid, job_in_progress: Uuid, ) -> error::Result { let step = get_step_of_flow_status(db, flow).await?; match step { Step::Step(step) => { - sqlx::query(&format!( - "UPDATE queue - SET flow_status = jsonb_set(jsonb_set(flow_status, '{{modules, {step}, job}}', $1), '{{modules, {step}, type}}', $2) - WHERE id = $3 AND workspace_id = $4", - )) - .bind(json!(job_in_progress.to_string())) - .bind(json!("InProgress")) - .bind(flow) - .bind(w_id) + sqlx::query!( + "UPDATE v2_job_status SET + flow_status = jsonb_set( + jsonb_set(flow_status, ARRAY['modules', $3::INTEGER::TEXT, 'job'], to_jsonb($1::UUID::TEXT)), + ARRAY['modules', $3::INTEGER::TEXT, 'type'], + to_jsonb('InProgress'::text) + ) + WHERE id = $2", + job_in_progress, + flow, + step as i32 + ) .execute(db) .await?; } Step::PreprocessorStep => { - sqlx::query(&format!( - "UPDATE queue - SET flow_status = jsonb_set(jsonb_set(flow_status, '{{preprocessor_module, job}}', $1), '{{preprocessor_module, type}}', $2) - WHERE id = $3 AND workspace_id = $4", - )) - .bind(json!(job_in_progress.to_string())) - .bind(json!("InProgress")) - .bind(flow) - .bind(w_id) + sqlx::query!( + "UPDATE v2_job_status SET + flow_status = jsonb_set( + jsonb_set(flow_status, ARRAY['preprocessor_module', 'job'], to_jsonb($1::UUID::TEXT)), + ARRAY['preprocessor_module', 'type'], + to_jsonb('InProgress'::text) + ) + WHERE id = $2", + job_in_progress, + flow + ) .execute(db) .await?; } Step::FailureStep => { - sqlx::query(&format!( - "UPDATE queue - SET flow_status = jsonb_set(jsonb_set(flow_status, '{{failure_module, job}}', $1), '{{failure_module, type}}', $2) - WHERE id = $3 AND workspace_id = $4", - )) - .bind(json!(job_in_progress.to_string())) - .bind(json!("InProgress")) - .bind(flow) - .bind(w_id) + sqlx::query!( + "UPDATE v2_job_status SET + flow_status = jsonb_set( + jsonb_set(flow_status, ARRAY['failure_module', 'job'], to_jsonb($1::UUID::TEXT)), + ARRAY['failure_module', 'type'], + to_jsonb('InProgress'::text) + ) + WHERE id = $2", + job_in_progress, + flow + ) .execute(db) .await?; } @@ -1400,7 +1426,7 @@ pub async fn update_flow_status_in_progress( Ok(step) } -#[derive(Debug)] +#[derive(Debug, Copy, Clone)] pub enum Step { Step(usize), PreprocessorStep, @@ -1422,17 +1448,18 @@ impl Step { #[instrument(level = "trace", skip_all)] pub async fn get_step_of_flow_status(db: &DB, id: Uuid) -> error::Result { let r = sqlx::query!( - "SELECT (flow_status->'step')::integer as step, jsonb_array_length(flow_status->'modules') as len FROM queue WHERE id = $1", + "SELECT (flow_status->'step')::integer as step, jsonb_array_length(flow_status->'modules') as len + FROM v2_job_status WHERE id = $1", id ) .fetch_one(db) .await - .map_err(|e| Error::InternalErr(format!("fetching step flow status: {e:#}")))?; + .map_err(|e| Error::internal_err(format!("fetching step flow status: {e:#}")))?; if let Some(step) = r.step { Ok(Step::from_i32_and_len(step, r.len.unwrap_or(0) as usize)) } else { - Err(Error::InternalErr("step is null".to_string())) + Err(Error::internal_err("step is null".to_string())) } } @@ -1574,11 +1601,6 @@ pub struct ResumeRow { pub resume_id: i32, } -#[derive(FromRow)] -pub struct RawArgs { - pub args: Option>>>, -} - lazy_static::lazy_static! { static ref CRASH_FORCEFULLY_AT_STEP: Option = std::env::var("CRASH_FORCEFULLY_AT_STEP") .ok() @@ -1666,7 +1688,7 @@ async fn push_next_flow_job( }) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error sending update flow message to job completed channel: {e:#}" )) })?; @@ -1685,7 +1707,7 @@ async fn push_next_flow_job( .await?; if no_flow_overlap { let overlapping = sqlx::query_scalar!( - "SELECT id FROM queue WHERE schedule_path = $1 AND workspace_id = $2 AND id != $3 AND running = true", + "SELECT id AS \"id!\" FROM v2_as_queue WHERE schedule_path = $1 AND workspace_id = $2 AND id != $3 AND running = true", flow_job.schedule_path.as_ref().unwrap(), flow_job.workspace_id.as_str(), flow_job.id @@ -1711,7 +1733,7 @@ async fn push_next_flow_job( }) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error sending update flow message to job completed channel: {e:#}" )) })?; @@ -1748,7 +1770,7 @@ async fn push_next_flow_job( }) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error sending update flow message to job completed channel: {e:#}" )) })?; @@ -1798,7 +1820,7 @@ async fn push_next_flow_job( * * This only works because jobs::resume_job does the same thing. */ sqlx::query_scalar!( - "SELECT null FROM queue WHERE id = $1 FOR UPDATE", + "SELECT null FROM v2_job_queue WHERE id = $1 FOR UPDATE", flow_job.id ) .fetch_one(&mut *tx) @@ -1870,17 +1892,17 @@ async fn push_next_flow_job( } } let approval_conditions = ApprovalConditions { - user_auth_required: user_auth_required, - user_groups_required: user_groups_required, - self_approval_disabled: self_approval_disabled, + user_auth_required, + user_groups_required, + self_approval_disabled, }; - sqlx::query( - "UPDATE queue + sqlx::query!( + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['approval_conditions'], $1) WHERE id = $2", + json!(approval_conditions), + flow_job.id ) - .bind(json!(approval_conditions)) - .bind(flow_job.id) .execute(&mut *tx) .await?; } @@ -1897,7 +1919,10 @@ async fn push_next_flow_job( && suspend.continue_on_disapprove_timeout.unwrap_or(false); let audit_author = AuditAuthor { - username: flow_job.permissioned_as.trim_start_matches("u/").to_string(), + username: flow_job + .permissioned_as + .trim_start_matches("u/") + .to_string(), email: flow_job.email.clone(), username_override: None, }; @@ -1923,32 +1948,33 @@ async fn push_next_flow_job( .await?; } - sqlx::query( - "UPDATE queue + sqlx::query!( + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT, 'approvers'], $2) WHERE id = $3", + (status.step - 1).to_string(), + json!(resumes + .into_iter() + .map(|r| Approval { + resume_id: r.resume_id as u16, + approver: r + .approver.clone() + .unwrap_or_else(|| "unknown".to_string()) + }) + .collect::>() + ), + flow_job.id ) - .bind(status.step - 1) - .bind(json!(resumes - .into_iter() - .map(|r| Approval { - resume_id: r.resume_id as u16, - approver: r - .approver.clone() - .unwrap_or_else(|| "unknown".to_string()) - }) - .collect::>())) - .bind(flow_job.id) .execute(&mut *tx) .await?; // Remove the approval conditions from the flow status - sqlx::query( - "UPDATE queue + sqlx::query!( + "UPDATE v2_job_status SET flow_status = flow_status - 'approval_conditions' WHERE id = $1", + flow_job.id ) - .bind(flow_job.id) .execute(&mut *tx) .await?; @@ -1961,24 +1987,33 @@ async fn push_next_flow_job( FlowStatusModule::WaitingForPriorSteps { .. } ) && is_disapproved.is_none() { - sqlx::query( - "UPDATE queue SET - flow_status = JSONB_SET(flow_status, ARRAY['modules', flow_status->>'step'::text], $1), - suspend = $2, - suspend_until = now() + $3 - WHERE id = $4", + sqlx::query!( + "WITH suspend AS ( + UPDATE v2_job_queue SET suspend = $2, suspend_until = now() + $3 + WHERE id = $4 + RETURNING id + ) UPDATE v2_job_status SET flow_status = JSONB_SET( + flow_status, + ARRAY['modules', flow_status->>'step'::TEXT], + $1 + ) WHERE id = (SELECT id FROM suspend)", + json!(FlowStatusModule::WaitingForEvents { + id: status_module.id(), + count: required_events, + job: last + }), + (required_events - resume_messages.len() as u16) as i32, + Duration::from_secs( + suspend.timeout.map(|t| t.into()).unwrap_or_else(|| 30 * 60) + ) as Duration, + flow_job.id, ) - .bind(json!(FlowStatusModule::WaitingForEvents { id: status_module.id(), count: required_events, job: last })) - .bind((required_events - resume_messages.len() as u16) as i32) - .bind(Duration::from_secs(suspend.timeout.map(|t| t.into()).unwrap_or_else(|| 30 * 60))) - .bind(flow_job.id) .execute(&mut *tx) .await?; sqlx::query!( - "UPDATE queue - SET last_ping = null - WHERE id = $1 AND last_ping = $2", + "UPDATE v2_job_runtime SET ping = NULL + WHERE id = $1 AND ping = $2", flow_job.id, flow_job.last_ping ) @@ -2038,7 +2073,7 @@ async fn push_next_flow_job( }) .await .map_err(|e| { - Error::InternalErr(format!( + Error::internal_err(format!( "error sending update flow message to job completed channel: {e:#}" )) })?; @@ -2159,15 +2194,15 @@ async fn push_next_flow_job( scheduled_for_o = Some(from_now(retry_in)); status.retry.failed_jobs.push(job.clone()); - sqlx::query( - "UPDATE queue + sqlx::query!( + "UPDATE v2_job_status SET flow_status = JSONB_SET(JSONB_SET(flow_status, ARRAY['retry'], $1), ARRAY['modules', $3::TEXT, 'failed_retries'], $4) WHERE id = $2", + json!(RetryStatus { fail_count, ..status.retry.clone() }), + flow_job.id, + status.step.to_string(), + json!(status.retry.failed_jobs) ) - .bind(json!(RetryStatus { fail_count, ..status.retry.clone() })) - .bind(flow_job.id) - .bind(status.step) - .bind(json!(status.retry.failed_jobs)) .execute(db) .warn_after_seconds(2) .await @@ -2196,13 +2231,13 @@ async fn push_next_flow_job( status_module = status.failure_module.module_status.clone(); if module.retry.as_ref().is_some_and(|x| x.has_attempts()) { - sqlx::query( - "UPDATE queue + sqlx::query!( + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['retry'], $1) WHERE id = $2", + json!(RetryStatus { fail_count: 0, failed_jobs: vec![] }), + flow_job.id ) - .bind(json!(RetryStatus { fail_count: 0, failed_jobs: vec![] })) - .bind(flow_job.id) .execute(db) .await .context("update flow retry")?; @@ -2255,17 +2290,16 @@ async fn push_next_flow_job( ); Ok(Marc::new(hm)) } else if let Some(id) = get_args_from_id { - let row = sqlx::query_as::<_, RawArgs>( - "SELECT args FROM completed_job WHERE id = $1 AND workspace_id = $2", + let args = sqlx::query_scalar!( + "SELECT args AS \"args: Json>>\" + FROM v2_job WHERE id = $1 AND workspace_id = $2", + id, + &flow_job.workspace_id ) - .bind(id) - .bind(&flow_job.workspace_id) .fetch_optional(db) .await?; - if let Some(raw_args) = row { - Ok(Marc::new( - raw_args.args.map(|x| x.0).unwrap_or_else(HashMap::new), - )) + if let Some(args) = args { + Ok(Marc::new(args.map(|x| x.0).unwrap_or_else(HashMap::new))) } else { Ok(Marc::new(HashMap::new())) } @@ -2287,7 +2321,7 @@ async fn push_next_flow_job( .unwrap(), ) .map(Marc::new) - .map_err(|e| error::Error::InternalErr(format!("identity: {e:#}"))) + .map_err(|e| error::Error::internal_err(format!("identity: {e:#}"))) } Ok( FlowModuleValue::Script { input_transforms, .. } @@ -2313,7 +2347,7 @@ async fn push_next_flow_job( } Ok(_) => Ok(arc_flow_job_args.clone()), Err(e) => { - return Err(error::Error::InternalErr(format!( + return Err(error::Error::internal_err(format!( "module was not convertible to acceptable value {e:?}" ))) } @@ -2344,23 +2378,23 @@ async fn push_next_flow_job( let (job_payloads, next_status) = match next_flow_transform { NextFlowTransform::Continue(job_payload, next_state) => (job_payload, next_state), NextFlowTransform::EmptyInnerFlows => { - sqlx::query( - "UPDATE queue + sqlx::query!( + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2) WHERE id = $3", + status.step.to_string(), + json!(FlowStatusModule::Success { + id: status_module.id(), + job: Uuid::nil(), + flow_jobs: Some(vec![]), + flow_jobs_success: Some(vec![]), + branch_chosen: None, + approvers: vec![], + failed_retries: vec![], + skipped: false, + }), + flow_job.id ) - .bind(status.step) - .bind(json!(FlowStatusModule::Success { - id: status_module.id(), - job: Uuid::nil(), - flow_jobs: Some(vec![]), - flow_jobs_success: Some(vec![]), - branch_chosen: None, - approvers: vec![], - failed_retries: vec![], - skipped: false, - })) - .bind(flow_job.id) .execute(db) .await?; // flow is reprocessed by the worker in a state where the module has completed successfully. @@ -2396,9 +2430,7 @@ async fn push_next_flow_job( if i % 100 == 0 && i != 0 { tracing::info!(id = %flow_job.id, root_id = %job_root, "pushed (non-commited yet) first {i} subflows of {len}"); sqlx::query!( - "UPDATE queue - SET last_ping = now() - WHERE id = $1 AND last_ping < now()", + "UPDATE v2_job_runtime SET ping = now() WHERE id = $1 AND ping < now()", flow_job.id, ) .execute(db) @@ -2472,7 +2504,7 @@ async fn push_next_flow_job( } NextStatus::AllFlowJobs { branchall: None, - iterator: Some(Iterator { itered, .. }), + iterator: Some(FlowIterator { itered, .. }), simple_input_transforms, } => { if let Ok(args) = args.as_ref() { @@ -2622,9 +2654,11 @@ async fn push_next_flow_job( if i as u16 >= p { sqlx::query!( - "UPDATE queue - SET suspend = $1, suspend_until = now() + interval '14 day', running = true - WHERE id = $2", + "UPDATE v2_job_queue SET + suspend = $1, + suspend_until = now() + interval '14 day', + running = true + WHERE id = $2", (i as u16 - p + 1) as i32, uuid, ) @@ -2637,16 +2671,16 @@ async fn push_next_flow_job( if payload_tag.delete_after_use { let uuid_singleton_json = serde_json::to_value(&[uuid]).map_err(|e| { - error::Error::InternalErr(format!("Unable to serialize uuid: {e:#}")) + error::Error::internal_err(format!("Unable to serialize uuid: {e:#}")) })?; - sqlx::query( - "UPDATE queue + sqlx::query!( + "UPDATE v2_job_status SET flow_status = JSONB_SET(flow_status, ARRAY['cleanup_module', 'flow_jobs_to_clean'], COALESCE(flow_status->'cleanup_module'->'flow_jobs_to_clean', '[]'::jsonb) || $1) WHERE id = $2", + uuid_singleton_json, + root_job.unwrap_or(flow_job.id) ) - .bind(uuid_singleton_json) - .bind(root_job.unwrap_or(flow_job.id)) .execute(&mut *inner_tx) .await?; } @@ -2700,7 +2734,7 @@ async fn push_next_flow_job( } FlowStatusModule::InProgress { job: uuid, - iterator: Some(windmill_common::flow_status::Iterator { index, itered }), + iterator: Some(FlowIterator { index, itered }), flow_jobs: Some(flow_jobs), flow_jobs_success, branch_chosen: None, @@ -2770,9 +2804,12 @@ async fn push_next_flow_job( match step { Step::FailureStep => { sqlx::query!( - "UPDATE queue - SET flow_status = JSONB_SET( - JSONB_SET(flow_status, ARRAY['failure_module'], $1), ARRAY['step'], $2) + "UPDATE v2_job_status SET + flow_status = JSONB_SET( + JSONB_SET(flow_status, ARRAY['failure_module'], $1), + ARRAY['step'], + $2 + ) WHERE id = $3", json!(FlowStatusModuleWParent { parent_module: Some(current_id.clone()), @@ -2786,9 +2823,12 @@ async fn push_next_flow_job( } Step::PreprocessorStep => { sqlx::query!( - "UPDATE queue - SET flow_status = JSONB_SET( - JSONB_SET(flow_status, ARRAY['preprocessor_module'], $1), ARRAY['step'], $2) + "UPDATE v2_job_status SET + flow_status = JSONB_SET( + JSONB_SET(flow_status, ARRAY['preprocessor_module'], $1), + ARRAY['step'], + $2 + ) WHERE id = $3", json!(new_status), json!(-1), @@ -2799,9 +2839,12 @@ async fn push_next_flow_job( } Step::Step(i) => { sqlx::query!( - "UPDATE queue - SET flow_status = JSONB_SET( - JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2), ARRAY['step'], $3) + "UPDATE v2_job_status SET + flow_status = JSONB_SET( + JSONB_SET(flow_status, ARRAY['modules', $1::TEXT], $2), + ARRAY['step'], + $3 + ) WHERE id = $4", i as i32, json!(new_status), @@ -2816,9 +2859,7 @@ async fn push_next_flow_job( potentially_crash_for_testing(); sqlx::query!( - "UPDATE queue - SET last_ping = null - WHERE id = $1", + "UPDATE v2_job_runtime SET ping = null WHERE id = $1", flow_job.id ) .execute(&mut *tx) @@ -2941,7 +2982,7 @@ enum NextStatus { }, AllFlowJobs { branchall: Option, - iterator: Option, + iterator: Option, simple_input_transforms: Option>, }, } @@ -3284,10 +3325,7 @@ async fn compute_next_flow_transform( ContinuePayload::ParallelJobs(payloads), NextStatus::AllFlowJobs { branchall: None, - iterator: Some(windmill_common::flow_status::Iterator { - index: 0, - itered, - }), + iterator: Some(FlowIterator { index: 0, itered }), // we removed the is_simple_case for simple_input_transforms // if is_simple { // match value { @@ -3634,7 +3672,7 @@ async fn next_forloop_status( } FlowStatusModule::InProgress { - iterator: Some(windmill_common::flow_status::Iterator { itered, index }), + iterator: Some(FlowIterator { itered, index }), flow_jobs: Some(flow_jobs), flow_jobs_success, .. @@ -3978,11 +4016,12 @@ async fn get_previous_job_result( Ok(Some(retrieve_flow_jobs_results(db, w_id, flow_jobs).await?)) } Some(FlowStatusModule::Success { job, .. }) => Ok(Some( - sqlx::query_scalar::<_, Json>>( - "SELECT result FROM completed_job WHERE id = $1 AND workspace_id = $2", + sqlx::query_scalar!( + "SELECT result AS \"result!: Json>\" + FROM v2_job_completed WHERE id = $1 AND workspace_id = $2", + job, + w_id ) - .bind(job) - .bind(w_id) .fetch_one(db) .await? .0, diff --git a/backend/windmill-worker/src/worker_lockfiles.rs b/backend/windmill-worker/src/worker_lockfiles.rs index d4df729910..3888d8eb63 100644 --- a/backend/windmill-worker/src/worker_lockfiles.rs +++ b/backend/windmill-worker/src/worker_lockfiles.rs @@ -265,13 +265,13 @@ pub async fn handle_dependency_job( Some(hash) => &cache::script::fetch(db, hash).await?.0, _ => match preview_data { Some(RawData::Script(data)) => data, - _ => return Err(Error::InternalErr("expected script hash".into())), + _ => return Err(Error::internal_err("expected script hash")), }, }; let content = capture_dependency_job( &job.id, job.language.as_ref().map(|v| Ok(v)).unwrap_or_else(|| { - Err(Error::InternalErr( + Err(Error::internal_err( "Job Language required for dependency jobs".to_owned(), )) })?, @@ -551,7 +551,7 @@ pub async fn handle_flow_dependency_job( occupancy_metrics: &mut OccupancyMetrics, ) -> error::Result> { let job_path = job.script_path.clone().ok_or_else(|| { - error::Error::InternalErr( + error::Error::internal_err( "Cannot resolve flow dependencies for flow without path".to_string(), ) })?; @@ -574,7 +574,7 @@ pub async fn handle_flow_dependency_job( job.script_hash .clone() .ok_or_else(|| { - Error::InternalErr( + Error::internal_err( "Flow Dependency requires script hash (flow version)".to_owned(), ) })? @@ -602,7 +602,7 @@ pub async fn handle_flow_dependency_job( Some(ScriptHash(id)) => cache::flow::fetch_version(db, id).await?, _ => match preview_data { Some(RawData::Flow(data)) => data.clone(), - _ => return Err(Error::InternalErr("expected script hash".into())), + _ => return Err(Error::internal_err("expected script hash")), }, } .value() @@ -633,15 +633,17 @@ pub async fn handle_flow_dependency_job( let new_flow_value = Json(serde_json::value::to_raw_value(&flow).map_err(to_anyhow)?); // Re-check cancellation to ensure we don't accidentally override a flow. - if sqlx::query_scalar!("SELECT canceled FROM queue WHERE id = $1", job.id) - .fetch_optional(db) - .await - .map(|v| Some(true) == v) - .unwrap_or_else(|err| { - tracing::error!(%job.id, %err, "error checking cancellation for job {0}: {err}", job.id); - false - }) - { + if sqlx::query_scalar!( + "SELECT canceled_by IS NOT NULL AS \"canceled!\" FROM v2_job_queue WHERE id = $1", + job.id + ) + .fetch_optional(db) + .await + .map(|v| Some(true) == v) + .unwrap_or_else(|err| { + tracing::error!(%job.id, %err, "error checking cancellation for job {0}: {err}", job.id); + false + }) { return Ok(to_raw_value_owned(json!({ "status": "Flow lock generation was canceled", }))); @@ -649,7 +651,7 @@ pub async fn handle_flow_dependency_job( if !skip_flow_update { let version = version.ok_or_else(|| { - Error::InternalErr("Flow Dependency requires script hash (flow version)".to_owned()) + Error::internal_err("Flow Dependency requires script hash (flow version)".to_owned()) })?; sqlx::query!( @@ -1163,7 +1165,7 @@ async fn reduce_flow<'c>( for module in &mut *modules { let mut val = serde_json::from_str::(module.value.get()).map_err(|err| { - Error::InternalErr(format!( + Error::internal_err(format!( "reduce_flow: Failed to parse flow module value: {}", err )) @@ -1274,7 +1276,7 @@ async fn reduce_app(db: &sqlx::Pool, value: &mut Value, app: i64 // replace `content` with an empty string: let Some(Value::String(code)) = script.get_mut("content").map(std::mem::take) else { - return Err(error::Error::InternalErr( + return Err(error::Error::internal_err( "Missing `content` in inlineScript".to_string(), )); }; @@ -1477,7 +1479,7 @@ pub async fn handle_app_dependency_job( occupancy_metrics: &mut OccupancyMetrics, ) -> error::Result<()> { let job_path = job.script_path.clone().ok_or_else(|| { - error::Error::InternalErr( + error::Error::internal_err( "Cannot resolve app dependencies for app without path".to_string(), ) })?; @@ -1485,7 +1487,7 @@ pub async fn handle_app_dependency_job( let id = job .script_hash .clone() - .ok_or_else(|| Error::InternalErr("App Dependency requires script hash".to_owned()))? + .ok_or_else(|| Error::internal_err("App Dependency requires script hash".to_owned()))? .0; let record = sqlx::query!("SELECT app_id, value FROM app_version WHERE id = $1", id) .fetch_optional(db) @@ -1525,15 +1527,17 @@ pub async fn handle_app_dependency_job( .await?; // Re-check cancelation to ensure we don't accidentially override an app. - if sqlx::query_scalar!("SELECT canceled FROM queue WHERE id = $1", job.id) - .fetch_optional(db) - .await - .map(|v| Some(true) == v) - .unwrap_or_else(|err| { - tracing::error!(%job.id, %err, "error checking cancelation for job {0}: {err}", job.id); - false - }) - { + if sqlx::query_scalar!( + "SELECT canceled_by IS NOT NULL AS \"canceled!\" FROM v2_job_queue WHERE id = $1", + job.id + ) + .fetch_optional(db) + .await + .map(|v| Some(true) == v) + .unwrap_or_else(|err| { + tracing::error!(%job.id, %err, "error checking cancelation for job {0}: {err}", job.id); + false + }) { return Ok(()); } @@ -1572,7 +1576,7 @@ pub async fn handle_app_dependency_job( // match tx { // PushIsolationLevel::Transaction(tx) => tx.commit().await?, // _ => { - // return Err(Error::InternalErr( + // return Err(Error::internal_err( // "Expected a transaction here".to_string(), // )); // } @@ -1682,7 +1686,7 @@ async fn capture_dependency_job( match job_language { ScriptLang::Python3 => { #[cfg(not(feature = "python"))] - return Err(Error::InternalErr( + return Err(Error::internal_err( "Python requires the python feature to be enabled".to_string(), )); #[cfg(feature = "python")] @@ -1749,7 +1753,7 @@ async fn capture_dependency_job( } ScriptLang::Ansible => { #[cfg(not(feature = "python"))] - return Err(Error::InternalErr( + return Err(Error::internal_err( "Ansible requires the python feature to be enabled".to_string(), )); @@ -1887,7 +1891,7 @@ async fn capture_dependency_job( } ScriptLang::Php => { #[cfg(not(feature = "php"))] - return Err(Error::InternalErr( + return Err(Error::internal_err( "PHP requires the php feature to be enabled".to_string(), )); @@ -1929,7 +1933,7 @@ async fn capture_dependency_job( } #[cfg(not(feature = "rust"))] - return Err(Error::InternalErr( + return Err(Error::internal_err( "Rust requires the rust feature to be enabled".to_string(), )); diff --git a/benchmarks/lib.ts b/benchmarks/lib.ts index 47f2684855..1cdf245687 100644 --- a/benchmarks/lib.ts +++ b/benchmarks/lib.ts @@ -2,7 +2,7 @@ import { sleep } from "https://deno.land/x/sleep@v1.2.1/mod.ts"; import * as windmill from "https://deno.land/x/windmill@v1.174.0/mod.ts"; import * as api from "https://deno.land/x/windmill@v1.174.0/windmill-api/index.ts"; -export const VERSION = "v1.456.0"; +export const VERSION = "v1.457.1"; export async function login(email: string, password: string): Promise { return await windmill.UserService.login({ diff --git a/cli/gen/core/OpenAPI.ts b/cli/gen/core/OpenAPI.ts index f9debf88b1..38bbd34aac 100644 --- a/cli/gen/core/OpenAPI.ts +++ b/cli/gen/core/OpenAPI.ts @@ -54,7 +54,7 @@ export const OpenAPI: OpenAPIConfig = { PASSWORD: undefined, TOKEN: getEnv("WM_TOKEN"), USERNAME: undefined, - VERSION: '1.447.5', + VERSION: '1.454.1', WITH_CREDENTIALS: true, interceptors: { request: new Interceptors(), diff --git a/cli/gen/services.gen.ts b/cli/gen/services.gen.ts index 49b5e1482c..66481a2857 100644 --- a/cli/gen/services.gen.ts +++ b/cli/gen/services.gen.ts @@ -3,7 +3,7 @@ import type { CancelablePromise } from './core/CancelablePromise.ts'; import { OpenAPI } from './core/OpenAPI.ts'; import { request as __request } from './core/request.ts'; -import type { BackendVersionResponse, BackendUptodateResponse, GetLicenseIdResponse, GetOpenApiYamlResponse, GetAuditLogData, GetAuditLogResponse, ListAuditLogsData, ListAuditLogsResponse, LoginData, LoginResponse, LogoutResponse, GetUserData, GetUserResponse, UpdateUserData, UpdateUserResponse, IsOwnerOfPathData, IsOwnerOfPathResponse, SetPasswordData, SetPasswordResponse, SetPasswordForUserData, SetPasswordForUserResponse, SetLoginTypeForUserData, SetLoginTypeForUserResponse, CreateUserGloballyData, CreateUserGloballyResponse, GlobalUserUpdateData, GlobalUserUpdateResponse, GlobalUsernameInfoData, GlobalUsernameInfoResponse, GlobalUserRenameData, GlobalUserRenameResponse, GlobalUserDeleteData, GlobalUserDeleteResponse, GlobalUsersOverwriteData, GlobalUsersOverwriteResponse, GlobalUsersExportResponse, DeleteUserData, DeleteUserResponse, ListWorkspacesResponse, IsDomainAllowedResponse, ListUserWorkspacesResponse, ListWorkspacesAsSuperAdminData, ListWorkspacesAsSuperAdminResponse, CreateWorkspaceData, CreateWorkspaceResponse, ExistsWorkspaceData, ExistsWorkspaceResponse, ExistsUsernameData, ExistsUsernameResponse, GetGlobalData, GetGlobalResponse, SetGlobalData, SetGlobalResponse, GetLocalResponse, TestSmtpData, TestSmtpResponse, TestCriticalChannelsData, TestCriticalChannelsResponse, GetCriticalAlertsData, GetCriticalAlertsResponse, AcknowledgeCriticalAlertData, AcknowledgeCriticalAlertResponse, AcknowledgeAllCriticalAlertsResponse, TestLicenseKeyData, TestLicenseKeyResponse, TestObjectStorageConfigData, TestObjectStorageConfigResponse, SendStatsResponse, GetLatestKeyRenewalAttemptResponse, RenewLicenseKeyData, RenewLicenseKeyResponse, CreateCustomerPortalSessionData, CreateCustomerPortalSessionResponse, TestMetadataData, TestMetadataResponse, ListGlobalSettingsResponse, GetCurrentEmailResponse, RefreshUserTokenData, RefreshUserTokenResponse, GetTutorialProgressResponse, UpdateTutorialProgressData, UpdateTutorialProgressResponse, LeaveInstanceResponse, GetUsageResponse, GetRunnableResponse, GlobalWhoamiResponse, ListWorkspaceInvitesResponse, WhoamiData, WhoamiResponse, AcceptInviteData, AcceptInviteResponse, DeclineInviteData, DeclineInviteResponse, InviteUserData, InviteUserResponse, AddUserData, AddUserResponse, DeleteInviteData, DeleteInviteResponse, ArchiveWorkspaceData, ArchiveWorkspaceResponse, UnarchiveWorkspaceData, UnarchiveWorkspaceResponse, DeleteWorkspaceData, DeleteWorkspaceResponse, LeaveWorkspaceData, LeaveWorkspaceResponse, GetWorkspaceNameData, GetWorkspaceNameResponse, ChangeWorkspaceNameData, ChangeWorkspaceNameResponse, ChangeWorkspaceIdData, ChangeWorkspaceIdResponse, ChangeWorkspaceColorData, ChangeWorkspaceColorResponse, WhoisData, WhoisResponse, ExistsEmailData, ExistsEmailResponse, ListUsersAsSuperAdminData, ListUsersAsSuperAdminResponse, ListPendingInvitesData, ListPendingInvitesResponse, GetSettingsData, GetSettingsResponse, GetDeployToData, GetDeployToResponse, GetIsPremiumData, GetIsPremiumResponse, GetPremiumInfoData, GetPremiumInfoResponse, SetAutomaticBillingData, SetAutomaticBillingResponse, GetThresholdAlertData, GetThresholdAlertResponse, SetThresholdAlertData, SetThresholdAlertResponse, EditSlackCommandData, EditSlackCommandResponse, RunSlackMessageTestJobData, RunSlackMessageTestJobResponse, EditDeployToData, EditDeployToResponse, EditAutoInviteData, EditAutoInviteResponse, EditWebhookData, EditWebhookResponse, EditCopilotConfigData, EditCopilotConfigResponse, GetCopilotInfoData, GetCopilotInfoResponse, EditErrorHandlerData, EditErrorHandlerResponse, EditLargeFileStorageConfigData, EditLargeFileStorageConfigResponse, EditWorkspaceGitSyncConfigData, EditWorkspaceGitSyncConfigResponse, EditWorkspaceDeployUiSettingsData, EditWorkspaceDeployUiSettingsResponse, EditWorkspaceDefaultAppData, EditWorkspaceDefaultAppResponse, EditDefaultScriptsData, EditDefaultScriptsResponse, GetDefaultScriptsData, GetDefaultScriptsResponse, SetEnvironmentVariableData, SetEnvironmentVariableResponse, GetWorkspaceEncryptionKeyData, GetWorkspaceEncryptionKeyResponse, SetWorkspaceEncryptionKeyData, SetWorkspaceEncryptionKeyResponse, GetWorkspaceDefaultAppData, GetWorkspaceDefaultAppResponse, GetLargeFileStorageConfigData, GetLargeFileStorageConfigResponse, GetWorkspaceUsageData, GetWorkspaceUsageResponse, GetUsedTriggersData, GetUsedTriggersResponse, ListUsersData, ListUsersResponse, ListUsersUsageData, ListUsersUsageResponse, ListUsernamesData, ListUsernamesResponse, UsernameToEmailData, UsernameToEmailResponse, CreateTokenData, CreateTokenResponse, CreateTokenImpersonateData, CreateTokenImpersonateResponse, DeleteTokenData, DeleteTokenResponse, ListTokensData, ListTokensResponse, GetOidcTokenData, GetOidcTokenResponse, CreateVariableData, CreateVariableResponse, EncryptValueData, EncryptValueResponse, DeleteVariableData, DeleteVariableResponse, UpdateVariableData, UpdateVariableResponse, GetVariableData, GetVariableResponse, GetVariableValueData, GetVariableValueResponse, ExistsVariableData, ExistsVariableResponse, ListVariableData, ListVariableResponse, ListContextualVariablesData, ListContextualVariablesResponse, WorkspaceGetCriticalAlertsData, WorkspaceGetCriticalAlertsResponse, WorkspaceAcknowledgeCriticalAlertData, WorkspaceAcknowledgeCriticalAlertResponse, WorkspaceAcknowledgeAllCriticalAlertsData, WorkspaceAcknowledgeAllCriticalAlertsResponse, WorkspaceMuteCriticalAlertsUiData, WorkspaceMuteCriticalAlertsUiResponse, LoginWithOauthData, LoginWithOauthResponse, ConnectSlackCallbackData, ConnectSlackCallbackResponse, ConnectSlackCallbackInstanceData, ConnectSlackCallbackInstanceResponse, ConnectCallbackData, ConnectCallbackResponse, CreateAccountData, CreateAccountResponse, RefreshTokenData, RefreshTokenResponse, DisconnectAccountData, DisconnectAccountResponse, DisconnectSlackData, DisconnectSlackResponse, ListOauthLoginsResponse, ListOauthConnectsResponse, GetOauthConnectData, GetOauthConnectResponse, CreateResourceData, CreateResourceResponse, DeleteResourceData, DeleteResourceResponse, UpdateResourceData, UpdateResourceResponse, UpdateResourceValueData, UpdateResourceValueResponse, GetResourceData, GetResourceResponse, GetResourceValueInterpolatedData, GetResourceValueInterpolatedResponse, GetResourceValueData, GetResourceValueResponse, ExistsResourceData, ExistsResourceResponse, ListResourceData, ListResourceResponse, ListSearchResourceData, ListSearchResourceResponse, ListResourceNamesData, ListResourceNamesResponse, CreateResourceTypeData, CreateResourceTypeResponse, FileResourceTypeToFileExtMapData, FileResourceTypeToFileExtMapResponse, DeleteResourceTypeData, DeleteResourceTypeResponse, UpdateResourceTypeData, UpdateResourceTypeResponse, GetResourceTypeData, GetResourceTypeResponse, ExistsResourceTypeData, ExistsResourceTypeResponse, ListResourceTypeData, ListResourceTypeResponse, ListResourceTypeNamesData, ListResourceTypeNamesResponse, QueryResourceTypesData, QueryResourceTypesResponse, ListHubIntegrationsData, ListHubIntegrationsResponse, ListHubFlowsResponse, GetHubFlowByIdData, GetHubFlowByIdResponse, ListHubAppsResponse, GetHubAppByIdData, GetHubAppByIdResponse, GetPublicAppByCustomPathData, GetPublicAppByCustomPathResponse, GetHubScriptContentByPathData, GetHubScriptContentByPathResponse, GetHubScriptByPathData, GetHubScriptByPathResponse, GetTopHubScriptsData, GetTopHubScriptsResponse, QueryHubScriptsData, QueryHubScriptsResponse, ListSearchScriptData, ListSearchScriptResponse, ListScriptsData, ListScriptsResponse, ListScriptPathsData, ListScriptPathsResponse, CreateDraftData, CreateDraftResponse, DeleteDraftData, DeleteDraftResponse, CreateScriptData, CreateScriptResponse, ToggleWorkspaceErrorHandlerForScriptData, ToggleWorkspaceErrorHandlerForScriptResponse, GetCustomTagsData, GetCustomTagsResponse, GeDefaultTagsResponse, IsDefaultTagsPerWorkspaceResponse, ArchiveScriptByPathData, ArchiveScriptByPathResponse, ArchiveScriptByHashData, ArchiveScriptByHashResponse, DeleteScriptByHashData, DeleteScriptByHashResponse, DeleteScriptByPathData, DeleteScriptByPathResponse, GetScriptByPathData, GetScriptByPathResponse, GetTriggersCountOfScriptData, GetTriggersCountOfScriptResponse, ListTokensOfScriptData, ListTokensOfScriptResponse, GetScriptByPathWithDraftData, GetScriptByPathWithDraftResponse, GetScriptHistoryByPathData, GetScriptHistoryByPathResponse, GetScriptLatestVersionData, GetScriptLatestVersionResponse, UpdateScriptHistoryData, UpdateScriptHistoryResponse, RawScriptByPathData, RawScriptByPathResponse, RawScriptByPathTokenedData, RawScriptByPathTokenedResponse, ExistsScriptByPathData, ExistsScriptByPathResponse, GetScriptByHashData, GetScriptByHashResponse, RawScriptByHashData, RawScriptByHashResponse, GetScriptDeploymentStatusData, GetScriptDeploymentStatusResponse, RunScriptByPathData, RunScriptByPathResponse, OpenaiSyncScriptByPathData, OpenaiSyncScriptByPathResponse, RunWaitResultScriptByPathData, RunWaitResultScriptByPathResponse, RunWaitResultScriptByPathGetData, RunWaitResultScriptByPathGetResponse, OpenaiSyncFlowByPathData, OpenaiSyncFlowByPathResponse, RunWaitResultFlowByPathData, RunWaitResultFlowByPathResponse, ResultByIdData, ResultByIdResponse, ListFlowPathsData, ListFlowPathsResponse, ListSearchFlowData, ListSearchFlowResponse, ListFlowsData, ListFlowsResponse, GetFlowHistoryData, GetFlowHistoryResponse, GetFlowLatestVersionData, GetFlowLatestVersionResponse, GetFlowVersionData, GetFlowVersionResponse, UpdateFlowHistoryData, UpdateFlowHistoryResponse, GetFlowByPathData, GetFlowByPathResponse, GetTriggersCountOfFlowData, GetTriggersCountOfFlowResponse, ListTokensOfFlowData, ListTokensOfFlowResponse, ToggleWorkspaceErrorHandlerForFlowData, ToggleWorkspaceErrorHandlerForFlowResponse, GetFlowByPathWithDraftData, GetFlowByPathWithDraftResponse, ExistsFlowByPathData, ExistsFlowByPathResponse, CreateFlowData, CreateFlowResponse, UpdateFlowData, UpdateFlowResponse, ArchiveFlowByPathData, ArchiveFlowByPathResponse, DeleteFlowByPathData, DeleteFlowByPathResponse, ListRawAppsData, ListRawAppsResponse, ExistsRawAppData, ExistsRawAppResponse, GetRawAppDataData, GetRawAppDataResponse, ListSearchAppData, ListSearchAppResponse, ListAppsData, ListAppsResponse, CreateAppData, CreateAppResponse, ExistsAppData, ExistsAppResponse, GetAppByPathData, GetAppByPathResponse, GetAppLiteByPathData, GetAppLiteByPathResponse, GetAppByPathWithDraftData, GetAppByPathWithDraftResponse, GetAppHistoryByPathData, GetAppHistoryByPathResponse, GetAppLatestVersionData, GetAppLatestVersionResponse, UpdateAppHistoryData, UpdateAppHistoryResponse, GetPublicAppBySecretData, GetPublicAppBySecretResponse, GetPublicResourceData, GetPublicResourceResponse, GetPublicSecretOfAppData, GetPublicSecretOfAppResponse, GetAppByVersionData, GetAppByVersionResponse, CreateRawAppData, CreateRawAppResponse, UpdateRawAppData, UpdateRawAppResponse, DeleteRawAppData, DeleteRawAppResponse, DeleteAppData, DeleteAppResponse, UpdateAppData, UpdateAppResponse, CustomPathExistsData, CustomPathExistsResponse, ExecuteComponentData, ExecuteComponentResponse, RunFlowByPathData, RunFlowByPathResponse, RestartFlowAtStepData, RestartFlowAtStepResponse, RunScriptByHashData, RunScriptByHashResponse, RunScriptPreviewData, RunScriptPreviewResponse, RunCodeWorkflowTaskData, RunCodeWorkflowTaskResponse, RunRawScriptDependenciesData, RunRawScriptDependenciesResponse, RunFlowPreviewData, RunFlowPreviewResponse, ListQueueData, ListQueueResponse, GetQueueCountData, GetQueueCountResponse, GetCompletedCountData, GetCompletedCountResponse, CountCompletedJobsData, CountCompletedJobsResponse, ListFilteredUuidsData, ListFilteredUuidsResponse, CancelSelectionData, CancelSelectionResponse, ListCompletedJobsData, ListCompletedJobsResponse, ListJobsData, ListJobsResponse, GetDbClockResponse, CountJobsByTagData, CountJobsByTagResponse, GetJobData, GetJobResponse, GetRootJobIdData, GetRootJobIdResponse, GetJobLogsData, GetJobLogsResponse, GetJobArgsData, GetJobArgsResponse, GetJobUpdatesData, GetJobUpdatesResponse, GetLogFileFromStoreData, GetLogFileFromStoreResponse, GetFlowDebugInfoData, GetFlowDebugInfoResponse, GetCompletedJobData, GetCompletedJobResponse, GetCompletedJobResultData, GetCompletedJobResultResponse, GetCompletedJobResultMaybeData, GetCompletedJobResultMaybeResponse, DeleteCompletedJobData, DeleteCompletedJobResponse, CancelQueuedJobData, CancelQueuedJobResponse, CancelPersistentQueuedJobsData, CancelPersistentQueuedJobsResponse, ForceCancelQueuedJobData, ForceCancelQueuedJobResponse, CreateJobSignatureData, CreateJobSignatureResponse, GetResumeUrlsData, GetResumeUrlsResponse, GetSlackApprovalPayloadData, GetSlackApprovalPayloadResponse, ResumeSuspendedJobGetData, ResumeSuspendedJobGetResponse, ResumeSuspendedJobPostData, ResumeSuspendedJobPostResponse, SetFlowUserStateData, SetFlowUserStateResponse, GetFlowUserStateData, GetFlowUserStateResponse, ResumeSuspendedFlowAsOwnerData, ResumeSuspendedFlowAsOwnerResponse, CancelSuspendedJobGetData, CancelSuspendedJobGetResponse, CancelSuspendedJobPostData, CancelSuspendedJobPostResponse, GetSuspendedJobFlowData, GetSuspendedJobFlowResponse, PreviewScheduleData, PreviewScheduleResponse, CreateScheduleData, CreateScheduleResponse, UpdateScheduleData, UpdateScheduleResponse, SetScheduleEnabledData, SetScheduleEnabledResponse, DeleteScheduleData, DeleteScheduleResponse, GetScheduleData, GetScheduleResponse, ExistsScheduleData, ExistsScheduleResponse, ListSchedulesData, ListSchedulesResponse, ListSchedulesWithJobsData, ListSchedulesWithJobsResponse, SetDefaultErrorOrRecoveryHandlerData, SetDefaultErrorOrRecoveryHandlerResponse, CreateHttpTriggerData, CreateHttpTriggerResponse, UpdateHttpTriggerData, UpdateHttpTriggerResponse, DeleteHttpTriggerData, DeleteHttpTriggerResponse, GetHttpTriggerData, GetHttpTriggerResponse, ListHttpTriggersData, ListHttpTriggersResponse, ExistsHttpTriggerData, ExistsHttpTriggerResponse, ExistsRouteData, ExistsRouteResponse, CreateWebsocketTriggerData, CreateWebsocketTriggerResponse, UpdateWebsocketTriggerData, UpdateWebsocketTriggerResponse, DeleteWebsocketTriggerData, DeleteWebsocketTriggerResponse, GetWebsocketTriggerData, GetWebsocketTriggerResponse, ListWebsocketTriggersData, ListWebsocketTriggersResponse, ExistsWebsocketTriggerData, ExistsWebsocketTriggerResponse, SetWebsocketTriggerEnabledData, SetWebsocketTriggerEnabledResponse, CreateKafkaTriggerData, CreateKafkaTriggerResponse, UpdateKafkaTriggerData, UpdateKafkaTriggerResponse, DeleteKafkaTriggerData, DeleteKafkaTriggerResponse, GetKafkaTriggerData, GetKafkaTriggerResponse, ListKafkaTriggersData, ListKafkaTriggersResponse, ExistsKafkaTriggerData, ExistsKafkaTriggerResponse, SetKafkaTriggerEnabledData, SetKafkaTriggerEnabledResponse, CreateNatsTriggerData, CreateNatsTriggerResponse, UpdateNatsTriggerData, UpdateNatsTriggerResponse, DeleteNatsTriggerData, DeleteNatsTriggerResponse, GetNatsTriggerData, GetNatsTriggerResponse, ListNatsTriggersData, ListNatsTriggersResponse, ExistsNatsTriggerData, ExistsNatsTriggerResponse, SetNatsTriggerEnabledData, SetNatsTriggerEnabledResponse, ListInstanceGroupsResponse, GetInstanceGroupData, GetInstanceGroupResponse, CreateInstanceGroupData, CreateInstanceGroupResponse, UpdateInstanceGroupData, UpdateInstanceGroupResponse, DeleteInstanceGroupData, DeleteInstanceGroupResponse, AddUserToInstanceGroupData, AddUserToInstanceGroupResponse, RemoveUserFromInstanceGroupData, RemoveUserFromInstanceGroupResponse, ExportInstanceGroupsResponse, OverwriteInstanceGroupsData, OverwriteInstanceGroupsResponse, ListGroupsData, ListGroupsResponse, ListGroupNamesData, ListGroupNamesResponse, CreateGroupData, CreateGroupResponse, UpdateGroupData, UpdateGroupResponse, DeleteGroupData, DeleteGroupResponse, GetGroupData, GetGroupResponse, AddUserToGroupData, AddUserToGroupResponse, RemoveUserToGroupData, RemoveUserToGroupResponse, ListFoldersData, ListFoldersResponse, ListFolderNamesData, ListFolderNamesResponse, CreateFolderData, CreateFolderResponse, UpdateFolderData, UpdateFolderResponse, DeleteFolderData, DeleteFolderResponse, GetFolderData, GetFolderResponse, GetFolderUsageData, GetFolderUsageResponse, AddOwnerToFolderData, AddOwnerToFolderResponse, RemoveOwnerToFolderData, RemoveOwnerToFolderResponse, ListWorkersData, ListWorkersResponse, ExistsWorkerWithTagData, ExistsWorkerWithTagResponse, GetQueueMetricsResponse, GetCountsOfJobsWaitingPerTagResponse, ListWorkerGroupsResponse, GetConfigData, GetConfigResponse, UpdateConfigData, UpdateConfigResponse, DeleteConfigData, DeleteConfigResponse, ListConfigsResponse, ListAutoscalingEventsData, ListAutoscalingEventsResponse, GetGranularAclsData, GetGranularAclsResponse, AddGranularAclsData, AddGranularAclsResponse, RemoveGranularAclsData, RemoveGranularAclsResponse, SetCaptureConfigData, SetCaptureConfigResponse, PingCaptureConfigData, PingCaptureConfigResponse, GetCaptureConfigsData, GetCaptureConfigsResponse, ListCapturesData, ListCapturesResponse, DeleteCaptureData, DeleteCaptureResponse, StarData, StarResponse, UnstarData, UnstarResponse, GetInputHistoryData, GetInputHistoryResponse, GetArgsFromHistoryOrSavedInputData, GetArgsFromHistoryOrSavedInputResponse, ListInputsData, ListInputsResponse, CreateInputData, CreateInputResponse, UpdateInputData, UpdateInputResponse, DeleteInputData, DeleteInputResponse, DuckdbConnectionSettingsData, DuckdbConnectionSettingsResponse, DuckdbConnectionSettingsV2Data, DuckdbConnectionSettingsV2Response, PolarsConnectionSettingsData, PolarsConnectionSettingsResponse, PolarsConnectionSettingsV2Data, PolarsConnectionSettingsV2Response, S3ResourceInfoData, S3ResourceInfoResponse, DatasetStorageTestConnectionData, DatasetStorageTestConnectionResponse, ListStoredFilesData, ListStoredFilesResponse, LoadFileMetadataData, LoadFileMetadataResponse, LoadFilePreviewData, LoadFilePreviewResponse, LoadParquetPreviewData, LoadParquetPreviewResponse, LoadTableRowCountData, LoadTableRowCountResponse, LoadCsvPreviewData, LoadCsvPreviewResponse, DeleteS3FileData, DeleteS3FileResponse, MoveS3FileData, MoveS3FileResponse, FileUploadData, FileUploadResponse, FileDownloadData, FileDownloadResponse, FileDownloadParquetAsCsvData, FileDownloadParquetAsCsvResponse, GetJobMetricsData, GetJobMetricsResponse, SetJobProgressData, SetJobProgressResponse, GetJobProgressData, GetJobProgressResponse, ListLogFilesData, ListLogFilesResponse, GetLogFileData, GetLogFileResponse, ListConcurrencyGroupsResponse, DeleteConcurrencyGroupData, DeleteConcurrencyGroupResponse, GetConcurrencyKeyData, GetConcurrencyKeyResponse, ListExtendedJobsData, ListExtendedJobsResponse, SearchJobsIndexData, SearchJobsIndexResponse, SearchLogsIndexData, SearchLogsIndexResponse, CountSearchLogsIndexData, CountSearchLogsIndexResponse, ClearIndexData, ClearIndexResponse } from './types.gen.ts'; +import type { BackendVersionResponse, BackendUptodateResponse, GetLicenseIdResponse, GetOpenApiYamlResponse, GetAuditLogData, GetAuditLogResponse, ListAuditLogsData, ListAuditLogsResponse, LoginData, LoginResponse, LogoutResponse, GetUserData, GetUserResponse, UpdateUserData, UpdateUserResponse, IsOwnerOfPathData, IsOwnerOfPathResponse, SetPasswordData, SetPasswordResponse, SetPasswordForUserData, SetPasswordForUserResponse, SetLoginTypeForUserData, SetLoginTypeForUserResponse, CreateUserGloballyData, CreateUserGloballyResponse, GlobalUserUpdateData, GlobalUserUpdateResponse, GlobalUsernameInfoData, GlobalUsernameInfoResponse, GlobalUserRenameData, GlobalUserRenameResponse, GlobalUserDeleteData, GlobalUserDeleteResponse, GlobalUsersOverwriteData, GlobalUsersOverwriteResponse, GlobalUsersExportResponse, DeleteUserData, DeleteUserResponse, ListWorkspacesResponse, IsDomainAllowedResponse, ListUserWorkspacesResponse, ListWorkspacesAsSuperAdminData, ListWorkspacesAsSuperAdminResponse, CreateWorkspaceData, CreateWorkspaceResponse, ExistsWorkspaceData, ExistsWorkspaceResponse, ExistsUsernameData, ExistsUsernameResponse, GetGlobalData, GetGlobalResponse, SetGlobalData, SetGlobalResponse, GetLocalResponse, TestSmtpData, TestSmtpResponse, TestCriticalChannelsData, TestCriticalChannelsResponse, GetCriticalAlertsData, GetCriticalAlertsResponse, AcknowledgeCriticalAlertData, AcknowledgeCriticalAlertResponse, AcknowledgeAllCriticalAlertsResponse, TestLicenseKeyData, TestLicenseKeyResponse, TestObjectStorageConfigData, TestObjectStorageConfigResponse, SendStatsResponse, GetLatestKeyRenewalAttemptResponse, RenewLicenseKeyData, RenewLicenseKeyResponse, CreateCustomerPortalSessionData, CreateCustomerPortalSessionResponse, TestMetadataData, TestMetadataResponse, ListGlobalSettingsResponse, GetCurrentEmailResponse, RefreshUserTokenData, RefreshUserTokenResponse, GetTutorialProgressResponse, UpdateTutorialProgressData, UpdateTutorialProgressResponse, LeaveInstanceResponse, GetUsageResponse, GetRunnableResponse, GlobalWhoamiResponse, ListWorkspaceInvitesResponse, WhoamiData, WhoamiResponse, AcceptInviteData, AcceptInviteResponse, DeclineInviteData, DeclineInviteResponse, InviteUserData, InviteUserResponse, AddUserData, AddUserResponse, DeleteInviteData, DeleteInviteResponse, ArchiveWorkspaceData, ArchiveWorkspaceResponse, UnarchiveWorkspaceData, UnarchiveWorkspaceResponse, DeleteWorkspaceData, DeleteWorkspaceResponse, LeaveWorkspaceData, LeaveWorkspaceResponse, GetWorkspaceNameData, GetWorkspaceNameResponse, ChangeWorkspaceNameData, ChangeWorkspaceNameResponse, ChangeWorkspaceIdData, ChangeWorkspaceIdResponse, ChangeWorkspaceColorData, ChangeWorkspaceColorResponse, WhoisData, WhoisResponse, UpdateOperatorSettingsData, UpdateOperatorSettingsResponse, ExistsEmailData, ExistsEmailResponse, ListUsersAsSuperAdminData, ListUsersAsSuperAdminResponse, ListPendingInvitesData, ListPendingInvitesResponse, GetSettingsData, GetSettingsResponse, GetDeployToData, GetDeployToResponse, GetIsPremiumData, GetIsPremiumResponse, GetPremiumInfoData, GetPremiumInfoResponse, SetAutomaticBillingData, SetAutomaticBillingResponse, GetThresholdAlertData, GetThresholdAlertResponse, SetThresholdAlertData, SetThresholdAlertResponse, EditSlackCommandData, EditSlackCommandResponse, RunSlackMessageTestJobData, RunSlackMessageTestJobResponse, EditDeployToData, EditDeployToResponse, EditAutoInviteData, EditAutoInviteResponse, EditWebhookData, EditWebhookResponse, EditCopilotConfigData, EditCopilotConfigResponse, GetCopilotInfoData, GetCopilotInfoResponse, EditErrorHandlerData, EditErrorHandlerResponse, EditLargeFileStorageConfigData, EditLargeFileStorageConfigResponse, EditWorkspaceGitSyncConfigData, EditWorkspaceGitSyncConfigResponse, EditWorkspaceDeployUiSettingsData, EditWorkspaceDeployUiSettingsResponse, EditWorkspaceDefaultAppData, EditWorkspaceDefaultAppResponse, EditDefaultScriptsData, EditDefaultScriptsResponse, GetDefaultScriptsData, GetDefaultScriptsResponse, SetEnvironmentVariableData, SetEnvironmentVariableResponse, GetWorkspaceEncryptionKeyData, GetWorkspaceEncryptionKeyResponse, SetWorkspaceEncryptionKeyData, SetWorkspaceEncryptionKeyResponse, GetWorkspaceDefaultAppData, GetWorkspaceDefaultAppResponse, GetLargeFileStorageConfigData, GetLargeFileStorageConfigResponse, GetWorkspaceUsageData, GetWorkspaceUsageResponse, GetUsedTriggersData, GetUsedTriggersResponse, ListUsersData, ListUsersResponse, ListUsersUsageData, ListUsersUsageResponse, ListUsernamesData, ListUsernamesResponse, UsernameToEmailData, UsernameToEmailResponse, CreateTokenData, CreateTokenResponse, CreateTokenImpersonateData, CreateTokenImpersonateResponse, DeleteTokenData, DeleteTokenResponse, ListTokensData, ListTokensResponse, GetOidcTokenData, GetOidcTokenResponse, CreateVariableData, CreateVariableResponse, EncryptValueData, EncryptValueResponse, DeleteVariableData, DeleteVariableResponse, UpdateVariableData, UpdateVariableResponse, GetVariableData, GetVariableResponse, GetVariableValueData, GetVariableValueResponse, ExistsVariableData, ExistsVariableResponse, ListVariableData, ListVariableResponse, ListContextualVariablesData, ListContextualVariablesResponse, WorkspaceGetCriticalAlertsData, WorkspaceGetCriticalAlertsResponse, WorkspaceAcknowledgeCriticalAlertData, WorkspaceAcknowledgeCriticalAlertResponse, WorkspaceAcknowledgeAllCriticalAlertsData, WorkspaceAcknowledgeAllCriticalAlertsResponse, WorkspaceMuteCriticalAlertsUiData, WorkspaceMuteCriticalAlertsUiResponse, LoginWithOauthData, LoginWithOauthResponse, ConnectSlackCallbackData, ConnectSlackCallbackResponse, ConnectSlackCallbackInstanceData, ConnectSlackCallbackInstanceResponse, ConnectCallbackData, ConnectCallbackResponse, CreateAccountData, CreateAccountResponse, RefreshTokenData, RefreshTokenResponse, DisconnectAccountData, DisconnectAccountResponse, DisconnectSlackData, DisconnectSlackResponse, ListOauthLoginsResponse, ListOauthConnectsResponse, GetOauthConnectData, GetOauthConnectResponse, SyncTeamsResponse, CreateResourceData, CreateResourceResponse, DeleteResourceData, DeleteResourceResponse, UpdateResourceData, UpdateResourceResponse, UpdateResourceValueData, UpdateResourceValueResponse, GetResourceData, GetResourceResponse, GetResourceValueInterpolatedData, GetResourceValueInterpolatedResponse, GetResourceValueData, GetResourceValueResponse, ExistsResourceData, ExistsResourceResponse, ListResourceData, ListResourceResponse, ListSearchResourceData, ListSearchResourceResponse, ListResourceNamesData, ListResourceNamesResponse, CreateResourceTypeData, CreateResourceTypeResponse, FileResourceTypeToFileExtMapData, FileResourceTypeToFileExtMapResponse, DeleteResourceTypeData, DeleteResourceTypeResponse, UpdateResourceTypeData, UpdateResourceTypeResponse, GetResourceTypeData, GetResourceTypeResponse, ExistsResourceTypeData, ExistsResourceTypeResponse, ListResourceTypeData, ListResourceTypeResponse, ListResourceTypeNamesData, ListResourceTypeNamesResponse, QueryResourceTypesData, QueryResourceTypesResponse, ListHubIntegrationsData, ListHubIntegrationsResponse, ListHubFlowsResponse, GetHubFlowByIdData, GetHubFlowByIdResponse, ListHubAppsResponse, GetHubAppByIdData, GetHubAppByIdResponse, GetPublicAppByCustomPathData, GetPublicAppByCustomPathResponse, GetHubScriptContentByPathData, GetHubScriptContentByPathResponse, GetHubScriptByPathData, GetHubScriptByPathResponse, GetTopHubScriptsData, GetTopHubScriptsResponse, QueryHubScriptsData, QueryHubScriptsResponse, ListSearchScriptData, ListSearchScriptResponse, ListScriptsData, ListScriptsResponse, ListScriptPathsData, ListScriptPathsResponse, CreateDraftData, CreateDraftResponse, DeleteDraftData, DeleteDraftResponse, CreateScriptData, CreateScriptResponse, ToggleWorkspaceErrorHandlerForScriptData, ToggleWorkspaceErrorHandlerForScriptResponse, GetCustomTagsData, GetCustomTagsResponse, GeDefaultTagsResponse, IsDefaultTagsPerWorkspaceResponse, ArchiveScriptByPathData, ArchiveScriptByPathResponse, ArchiveScriptByHashData, ArchiveScriptByHashResponse, DeleteScriptByHashData, DeleteScriptByHashResponse, DeleteScriptByPathData, DeleteScriptByPathResponse, GetScriptByPathData, GetScriptByPathResponse, GetTriggersCountOfScriptData, GetTriggersCountOfScriptResponse, ListTokensOfScriptData, ListTokensOfScriptResponse, GetScriptByPathWithDraftData, GetScriptByPathWithDraftResponse, GetScriptHistoryByPathData, GetScriptHistoryByPathResponse, GetScriptLatestVersionData, GetScriptLatestVersionResponse, UpdateScriptHistoryData, UpdateScriptHistoryResponse, RawScriptByPathData, RawScriptByPathResponse, RawScriptByPathTokenedData, RawScriptByPathTokenedResponse, ExistsScriptByPathData, ExistsScriptByPathResponse, GetScriptByHashData, GetScriptByHashResponse, RawScriptByHashData, RawScriptByHashResponse, GetScriptDeploymentStatusData, GetScriptDeploymentStatusResponse, RunScriptByPathData, RunScriptByPathResponse, OpenaiSyncScriptByPathData, OpenaiSyncScriptByPathResponse, RunWaitResultScriptByPathData, RunWaitResultScriptByPathResponse, RunWaitResultScriptByPathGetData, RunWaitResultScriptByPathGetResponse, OpenaiSyncFlowByPathData, OpenaiSyncFlowByPathResponse, RunWaitResultFlowByPathData, RunWaitResultFlowByPathResponse, ResultByIdData, ResultByIdResponse, ListFlowPathsData, ListFlowPathsResponse, ListSearchFlowData, ListSearchFlowResponse, ListFlowsData, ListFlowsResponse, GetFlowHistoryData, GetFlowHistoryResponse, GetFlowLatestVersionData, GetFlowLatestVersionResponse, GetFlowVersionData, GetFlowVersionResponse, UpdateFlowHistoryData, UpdateFlowHistoryResponse, GetFlowByPathData, GetFlowByPathResponse, GetTriggersCountOfFlowData, GetTriggersCountOfFlowResponse, ListTokensOfFlowData, ListTokensOfFlowResponse, ToggleWorkspaceErrorHandlerForFlowData, ToggleWorkspaceErrorHandlerForFlowResponse, GetFlowByPathWithDraftData, GetFlowByPathWithDraftResponse, ExistsFlowByPathData, ExistsFlowByPathResponse, CreateFlowData, CreateFlowResponse, UpdateFlowData, UpdateFlowResponse, ArchiveFlowByPathData, ArchiveFlowByPathResponse, DeleteFlowByPathData, DeleteFlowByPathResponse, ListRawAppsData, ListRawAppsResponse, ExistsRawAppData, ExistsRawAppResponse, GetRawAppDataData, GetRawAppDataResponse, ListSearchAppData, ListSearchAppResponse, ListAppsData, ListAppsResponse, CreateAppData, CreateAppResponse, ExistsAppData, ExistsAppResponse, GetAppByPathData, GetAppByPathResponse, GetAppLiteByPathData, GetAppLiteByPathResponse, GetAppByPathWithDraftData, GetAppByPathWithDraftResponse, GetAppHistoryByPathData, GetAppHistoryByPathResponse, GetAppLatestVersionData, GetAppLatestVersionResponse, UpdateAppHistoryData, UpdateAppHistoryResponse, GetPublicAppBySecretData, GetPublicAppBySecretResponse, GetPublicResourceData, GetPublicResourceResponse, GetPublicSecretOfAppData, GetPublicSecretOfAppResponse, GetAppByVersionData, GetAppByVersionResponse, CreateRawAppData, CreateRawAppResponse, UpdateRawAppData, UpdateRawAppResponse, DeleteRawAppData, DeleteRawAppResponse, DeleteAppData, DeleteAppResponse, UpdateAppData, UpdateAppResponse, CustomPathExistsData, CustomPathExistsResponse, ExecuteComponentData, ExecuteComponentResponse, RunFlowByPathData, RunFlowByPathResponse, RestartFlowAtStepData, RestartFlowAtStepResponse, RunScriptByHashData, RunScriptByHashResponse, RunScriptPreviewData, RunScriptPreviewResponse, RunCodeWorkflowTaskData, RunCodeWorkflowTaskResponse, RunRawScriptDependenciesData, RunRawScriptDependenciesResponse, RunFlowPreviewData, RunFlowPreviewResponse, ListQueueData, ListQueueResponse, GetQueueCountData, GetQueueCountResponse, GetCompletedCountData, GetCompletedCountResponse, CountCompletedJobsData, CountCompletedJobsResponse, ListFilteredUuidsData, ListFilteredUuidsResponse, CancelSelectionData, CancelSelectionResponse, ListCompletedJobsData, ListCompletedJobsResponse, ListJobsData, ListJobsResponse, GetDbClockResponse, CountJobsByTagData, CountJobsByTagResponse, GetJobData, GetJobResponse, GetRootJobIdData, GetRootJobIdResponse, GetJobLogsData, GetJobLogsResponse, GetJobArgsData, GetJobArgsResponse, GetJobUpdatesData, GetJobUpdatesResponse, GetLogFileFromStoreData, GetLogFileFromStoreResponse, GetFlowDebugInfoData, GetFlowDebugInfoResponse, GetCompletedJobData, GetCompletedJobResponse, GetCompletedJobResultData, GetCompletedJobResultResponse, GetCompletedJobResultMaybeData, GetCompletedJobResultMaybeResponse, DeleteCompletedJobData, DeleteCompletedJobResponse, CancelQueuedJobData, CancelQueuedJobResponse, CancelPersistentQueuedJobsData, CancelPersistentQueuedJobsResponse, ForceCancelQueuedJobData, ForceCancelQueuedJobResponse, CreateJobSignatureData, CreateJobSignatureResponse, GetResumeUrlsData, GetResumeUrlsResponse, GetSlackApprovalPayloadData, GetSlackApprovalPayloadResponse, ResumeSuspendedJobGetData, ResumeSuspendedJobGetResponse, ResumeSuspendedJobPostData, ResumeSuspendedJobPostResponse, SetFlowUserStateData, SetFlowUserStateResponse, GetFlowUserStateData, GetFlowUserStateResponse, ResumeSuspendedFlowAsOwnerData, ResumeSuspendedFlowAsOwnerResponse, CancelSuspendedJobGetData, CancelSuspendedJobGetResponse, CancelSuspendedJobPostData, CancelSuspendedJobPostResponse, GetSuspendedJobFlowData, GetSuspendedJobFlowResponse, PreviewScheduleData, PreviewScheduleResponse, CreateScheduleData, CreateScheduleResponse, UpdateScheduleData, UpdateScheduleResponse, SetScheduleEnabledData, SetScheduleEnabledResponse, DeleteScheduleData, DeleteScheduleResponse, GetScheduleData, GetScheduleResponse, ExistsScheduleData, ExistsScheduleResponse, ListSchedulesData, ListSchedulesResponse, ListSchedulesWithJobsData, ListSchedulesWithJobsResponse, SetDefaultErrorOrRecoveryHandlerData, SetDefaultErrorOrRecoveryHandlerResponse, CreateHttpTriggerData, CreateHttpTriggerResponse, UpdateHttpTriggerData, UpdateHttpTriggerResponse, DeleteHttpTriggerData, DeleteHttpTriggerResponse, GetHttpTriggerData, GetHttpTriggerResponse, ListHttpTriggersData, ListHttpTriggersResponse, ExistsHttpTriggerData, ExistsHttpTriggerResponse, ExistsRouteData, ExistsRouteResponse, CreateWebsocketTriggerData, CreateWebsocketTriggerResponse, UpdateWebsocketTriggerData, UpdateWebsocketTriggerResponse, DeleteWebsocketTriggerData, DeleteWebsocketTriggerResponse, GetWebsocketTriggerData, GetWebsocketTriggerResponse, ListWebsocketTriggersData, ListWebsocketTriggersResponse, ExistsWebsocketTriggerData, ExistsWebsocketTriggerResponse, SetWebsocketTriggerEnabledData, SetWebsocketTriggerEnabledResponse, TestWebsocketConnectionData, TestWebsocketConnectionResponse, CreateKafkaTriggerData, CreateKafkaTriggerResponse, UpdateKafkaTriggerData, UpdateKafkaTriggerResponse, DeleteKafkaTriggerData, DeleteKafkaTriggerResponse, GetKafkaTriggerData, GetKafkaTriggerResponse, ListKafkaTriggersData, ListKafkaTriggersResponse, ExistsKafkaTriggerData, ExistsKafkaTriggerResponse, SetKafkaTriggerEnabledData, SetKafkaTriggerEnabledResponse, TestKafkaConnectionData, TestKafkaConnectionResponse, CreateNatsTriggerData, CreateNatsTriggerResponse, UpdateNatsTriggerData, UpdateNatsTriggerResponse, DeleteNatsTriggerData, DeleteNatsTriggerResponse, GetNatsTriggerData, GetNatsTriggerResponse, ListNatsTriggersData, ListNatsTriggersResponse, ExistsNatsTriggerData, ExistsNatsTriggerResponse, SetNatsTriggerEnabledData, SetNatsTriggerEnabledResponse, TestNatsConnectionData, TestNatsConnectionResponse, IsValidPostgresConfigurationData, IsValidPostgresConfigurationResponse, CreateTemplateScriptData, CreateTemplateScriptResponse, GetTemplateScriptData, GetTemplateScriptResponse, ListPostgresReplicationSlotData, ListPostgresReplicationSlotResponse, CreatePostgresReplicationSlotData, CreatePostgresReplicationSlotResponse, DeletePostgresReplicationSlotData, DeletePostgresReplicationSlotResponse, ListPostgresPublicationData, ListPostgresPublicationResponse, GetPostgresPublicationData, GetPostgresPublicationResponse, CreatePostgresPublicationData, CreatePostgresPublicationResponse, UpdatePostgresPublicationData, UpdatePostgresPublicationResponse, DeletePostgresPublicationData, DeletePostgresPublicationResponse, CreatePostgresTriggerData, CreatePostgresTriggerResponse, UpdatePostgresTriggerData, UpdatePostgresTriggerResponse, DeletePostgresTriggerData, DeletePostgresTriggerResponse, GetPostgresTriggerData, GetPostgresTriggerResponse, ListPostgresTriggersData, ListPostgresTriggersResponse, ExistsPostgresTriggerData, ExistsPostgresTriggerResponse, SetPostgresTriggerEnabledData, SetPostgresTriggerEnabledResponse, ListInstanceGroupsResponse, GetInstanceGroupData, GetInstanceGroupResponse, CreateInstanceGroupData, CreateInstanceGroupResponse, UpdateInstanceGroupData, UpdateInstanceGroupResponse, DeleteInstanceGroupData, DeleteInstanceGroupResponse, AddUserToInstanceGroupData, AddUserToInstanceGroupResponse, RemoveUserFromInstanceGroupData, RemoveUserFromInstanceGroupResponse, ExportInstanceGroupsResponse, OverwriteInstanceGroupsData, OverwriteInstanceGroupsResponse, ListGroupsData, ListGroupsResponse, ListGroupNamesData, ListGroupNamesResponse, CreateGroupData, CreateGroupResponse, UpdateGroupData, UpdateGroupResponse, DeleteGroupData, DeleteGroupResponse, GetGroupData, GetGroupResponse, AddUserToGroupData, AddUserToGroupResponse, RemoveUserToGroupData, RemoveUserToGroupResponse, ListFoldersData, ListFoldersResponse, ListFolderNamesData, ListFolderNamesResponse, CreateFolderData, CreateFolderResponse, UpdateFolderData, UpdateFolderResponse, DeleteFolderData, DeleteFolderResponse, GetFolderData, GetFolderResponse, GetFolderUsageData, GetFolderUsageResponse, AddOwnerToFolderData, AddOwnerToFolderResponse, RemoveOwnerToFolderData, RemoveOwnerToFolderResponse, ListWorkersData, ListWorkersResponse, ExistsWorkerWithTagData, ExistsWorkerWithTagResponse, GetQueueMetricsResponse, GetCountsOfJobsWaitingPerTagResponse, ListWorkerGroupsResponse, GetConfigData, GetConfigResponse, UpdateConfigData, UpdateConfigResponse, DeleteConfigData, DeleteConfigResponse, ListConfigsResponse, ListAutoscalingEventsData, ListAutoscalingEventsResponse, GetGranularAclsData, GetGranularAclsResponse, AddGranularAclsData, AddGranularAclsResponse, RemoveGranularAclsData, RemoveGranularAclsResponse, SetCaptureConfigData, SetCaptureConfigResponse, PingCaptureConfigData, PingCaptureConfigResponse, GetCaptureConfigsData, GetCaptureConfigsResponse, ListCapturesData, ListCapturesResponse, GetCaptureData, GetCaptureResponse, DeleteCaptureData, DeleteCaptureResponse, StarData, StarResponse, UnstarData, UnstarResponse, GetInputHistoryData, GetInputHistoryResponse, GetArgsFromHistoryOrSavedInputData, GetArgsFromHistoryOrSavedInputResponse, ListInputsData, ListInputsResponse, CreateInputData, CreateInputResponse, UpdateInputData, UpdateInputResponse, DeleteInputData, DeleteInputResponse, DuckdbConnectionSettingsData, DuckdbConnectionSettingsResponse, DuckdbConnectionSettingsV2Data, DuckdbConnectionSettingsV2Response, PolarsConnectionSettingsData, PolarsConnectionSettingsResponse, PolarsConnectionSettingsV2Data, PolarsConnectionSettingsV2Response, S3ResourceInfoData, S3ResourceInfoResponse, DatasetStorageTestConnectionData, DatasetStorageTestConnectionResponse, ListStoredFilesData, ListStoredFilesResponse, LoadFileMetadataData, LoadFileMetadataResponse, LoadFilePreviewData, LoadFilePreviewResponse, LoadParquetPreviewData, LoadParquetPreviewResponse, LoadTableRowCountData, LoadTableRowCountResponse, LoadCsvPreviewData, LoadCsvPreviewResponse, DeleteS3FileData, DeleteS3FileResponse, MoveS3FileData, MoveS3FileResponse, FileUploadData, FileUploadResponse, FileDownloadData, FileDownloadResponse, FileDownloadParquetAsCsvData, FileDownloadParquetAsCsvResponse, GetJobMetricsData, GetJobMetricsResponse, SetJobProgressData, SetJobProgressResponse, GetJobProgressData, GetJobProgressResponse, ListLogFilesData, ListLogFilesResponse, GetLogFileData, GetLogFileResponse, ListConcurrencyGroupsResponse, DeleteConcurrencyGroupData, DeleteConcurrencyGroupResponse, GetConcurrencyKeyData, GetConcurrencyKeyResponse, ListExtendedJobsData, ListExtendedJobsResponse, SearchJobsIndexData, SearchJobsIndexResponse, SearchLogsIndexData, SearchLogsIndexResponse, CountSearchLogsIndexData, CountSearchLogsIndexResponse, ClearIndexData, ClearIndexResponse } from './types.gen.ts'; /** * get backend version @@ -997,6 +997,25 @@ export const whois = (data: WhoisData): CancelablePromise => { re } }); }; +/** + * Update operator settings for a workspace + * Updates the operator settings for a specific workspace. Requires workspace admin privileges. + * @param data The data for the request. + * @param data.workspace + * @param data.requestBody + * @returns string Operator settings updated successfully + * @throws ApiError + */ +export const updateOperatorSettings = (data: UpdateOperatorSettingsData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/workspaces/operator_settings', + path: { + workspace: data.workspace + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + /** * exists email * @param data The data for the request. @@ -2081,6 +2100,16 @@ export const getOauthConnect = (data: GetOauthConnectData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/teams/sync' +}); }; + /** * create resource * @param data The data for the request. @@ -5736,6 +5765,24 @@ export const setWebsocketTriggerEnabled = (data: SetWebsocketTriggerEnabledData) mediaType: 'application/json' }); }; +/** + * test websocket connection + * @param data The data for the request. + * @param data.workspace + * @param data.requestBody test websocket connection + * @returns string successfuly connected to websocket + * @throws ApiError + */ +export const testWebsocketConnection = (data: TestWebsocketConnectionData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/websocket_triggers/test', + path: { + workspace: data.workspace + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + /** * create kafka trigger * @param data The data for the request. @@ -5872,6 +5919,24 @@ export const setKafkaTriggerEnabled = (data: SetKafkaTriggerEnabledData): Cancel mediaType: 'application/json' }); }; +/** + * test kafka connection + * @param data The data for the request. + * @param data.workspace + * @param data.requestBody test kafka connection + * @returns string successfuly connected to kafka brokers + * @throws ApiError + */ +export const testKafkaConnection = (data: TestKafkaConnectionData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/kafka_triggers/test', + path: { + workspace: data.workspace + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + /** * create nats trigger * @param data The data for the request. @@ -6008,6 +6073,368 @@ export const setNatsTriggerEnabled = (data: SetNatsTriggerEnabledData): Cancelab mediaType: 'application/json' }); }; +/** + * test NATS connection + * @param data The data for the request. + * @param data.workspace + * @param data.requestBody test nats connection + * @returns string successfuly connected to NATS servers + * @throws ApiError + */ +export const testNatsConnection = (data: TestNatsConnectionData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/nats_triggers/test', + path: { + workspace: data.workspace + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + +/** + * check if postgres configuration is set to logical + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @returns boolean boolean that indicates if postgres is set to logical level or not + * @throws ApiError + */ +export const isValidPostgresConfiguration = (data: IsValidPostgresConfigurationData): CancelablePromise => { return __request(OpenAPI, { + method: 'GET', + url: '/w/{workspace}/postgres_triggers/is_valid_postgres_configuration/{path}', + path: { + workspace: data.workspace, + path: data.path + } +}); }; + +/** + * create template script + * @param data The data for the request. + * @param data.workspace + * @param data.requestBody template script + * @returns string custom id to retrieve template script + * @throws ApiError + */ +export const createTemplateScript = (data: CreateTemplateScriptData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/postgres_triggers/create_template_script', + path: { + workspace: data.workspace + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + +/** + * get template script + * @param data The data for the request. + * @param data.workspace + * @param data.id + * @returns string template script + * @throws ApiError + */ +export const getTemplateScript = (data: GetTemplateScriptData): CancelablePromise => { return __request(OpenAPI, { + method: 'GET', + url: '/w/{workspace}/postgres_triggers/get_template_script/{id}', + path: { + workspace: data.workspace, + id: data.id + } +}); }; + +/** + * list postgres replication slot + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @returns SlotList list postgres slot + * @throws ApiError + */ +export const listPostgresReplicationSlot = (data: ListPostgresReplicationSlotData): CancelablePromise => { return __request(OpenAPI, { + method: 'GET', + url: '/w/{workspace}/postgres_triggers/slot/list/{path}', + path: { + workspace: data.workspace, + path: data.path + } +}); }; + +/** + * create replication slot for postgres + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @param data.requestBody new slot for postgres + * @returns string slot created + * @throws ApiError + */ +export const createPostgresReplicationSlot = (data: CreatePostgresReplicationSlotData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/postgres_triggers/slot/create/{path}', + path: { + workspace: data.workspace, + path: data.path + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + +/** + * delete postgres replication slot + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @param data.requestBody replication slot of postgres + * @returns string postgres replication slot deleted + * @throws ApiError + */ +export const deletePostgresReplicationSlot = (data: DeletePostgresReplicationSlotData): CancelablePromise => { return __request(OpenAPI, { + method: 'DELETE', + url: '/w/{workspace}/postgres_triggers/slot/delete/{path}', + path: { + workspace: data.workspace, + path: data.path + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + +/** + * list postgres publication + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @returns string database publication list + * @throws ApiError + */ +export const listPostgresPublication = (data: ListPostgresPublicationData): CancelablePromise => { return __request(OpenAPI, { + method: 'GET', + url: '/w/{workspace}/postgres_triggers/publication/list/{path}', + path: { + workspace: data.workspace, + path: data.path + } +}); }; + +/** + * get postgres publication + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @param data.publication + * @returns PublicationData postgres publication get + * @throws ApiError + */ +export const getPostgresPublication = (data: GetPostgresPublicationData): CancelablePromise => { return __request(OpenAPI, { + method: 'GET', + url: '/w/{workspace}/postgres_triggers/publication/get/{publication}/{path}', + path: { + workspace: data.workspace, + path: data.path, + publication: data.publication + } +}); }; + +/** + * create publication for postgres + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @param data.publication + * @param data.requestBody new publication for postgres + * @returns string publication created + * @throws ApiError + */ +export const createPostgresPublication = (data: CreatePostgresPublicationData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/postgres_triggers/publication/create/{publication}/{path}', + path: { + workspace: data.workspace, + path: data.path, + publication: data.publication + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + +/** + * update publication for postgres + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @param data.publication + * @param data.requestBody update publication for postgres + * @returns string publication updated + * @throws ApiError + */ +export const updatePostgresPublication = (data: UpdatePostgresPublicationData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/postgres_triggers/publication/update/{publication}/{path}', + path: { + workspace: data.workspace, + path: data.path, + publication: data.publication + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + +/** + * delete postgres publication + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @param data.publication + * @returns string postgres publication deleted + * @throws ApiError + */ +export const deletePostgresPublication = (data: DeletePostgresPublicationData): CancelablePromise => { return __request(OpenAPI, { + method: 'DELETE', + url: '/w/{workspace}/postgres_triggers/publication/delete/{publication}/{path}', + path: { + workspace: data.workspace, + path: data.path, + publication: data.publication + } +}); }; + +/** + * create postgres trigger + * @param data The data for the request. + * @param data.workspace + * @param data.requestBody new postgres trigger + * @returns string postgres trigger created + * @throws ApiError + */ +export const createPostgresTrigger = (data: CreatePostgresTriggerData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/postgres_triggers/create', + path: { + workspace: data.workspace + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + +/** + * update postgres trigger + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @param data.requestBody updated trigger + * @returns string postgres trigger updated + * @throws ApiError + */ +export const updatePostgresTrigger = (data: UpdatePostgresTriggerData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/postgres_triggers/update/{path}', + path: { + workspace: data.workspace, + path: data.path + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + +/** + * delete postgres trigger + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @returns string postgres trigger deleted + * @throws ApiError + */ +export const deletePostgresTrigger = (data: DeletePostgresTriggerData): CancelablePromise => { return __request(OpenAPI, { + method: 'DELETE', + url: '/w/{workspace}/postgres_triggers/delete/{path}', + path: { + workspace: data.workspace, + path: data.path + } +}); }; + +/** + * get postgres trigger + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @returns PostgresTrigger get postgres trigger + * @throws ApiError + */ +export const getPostgresTrigger = (data: GetPostgresTriggerData): CancelablePromise => { return __request(OpenAPI, { + method: 'GET', + url: '/w/{workspace}/postgres_triggers/get/{path}', + path: { + workspace: data.workspace, + path: data.path + } +}); }; + +/** + * list postgres triggers + * @param data The data for the request. + * @param data.workspace + * @param data.page which page to return (start at 1, default 1) + * @param data.perPage number of items to return for a given page (default 30, max 100) + * @param data.path filter by path + * @param data.isFlow + * @param data.pathStart + * @returns PostgresTrigger postgres trigger list + * @throws ApiError + */ +export const listPostgresTriggers = (data: ListPostgresTriggersData): CancelablePromise => { return __request(OpenAPI, { + method: 'GET', + url: '/w/{workspace}/postgres_triggers/list', + path: { + workspace: data.workspace + }, + query: { + page: data.page, + per_page: data.perPage, + path: data.path, + is_flow: data.isFlow, + path_start: data.pathStart + } +}); }; + +/** + * does postgres trigger exists + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @returns boolean postgres trigger exists + * @throws ApiError + */ +export const existsPostgresTrigger = (data: ExistsPostgresTriggerData): CancelablePromise => { return __request(OpenAPI, { + method: 'GET', + url: '/w/{workspace}/postgres_triggers/exists/{path}', + path: { + workspace: data.workspace, + path: data.path + } +}); }; + +/** + * set enabled postgres trigger + * @param data The data for the request. + * @param data.workspace + * @param data.path + * @param data.requestBody updated postgres trigger enable + * @returns string postgres trigger enabled set + * @throws ApiError + */ +export const setPostgresTriggerEnabled = (data: SetPostgresTriggerEnabledData): CancelablePromise => { return __request(OpenAPI, { + method: 'POST', + url: '/w/{workspace}/postgres_triggers/setenabled/{path}', + path: { + workspace: data.workspace, + path: data.path + }, + body: data.requestBody, + mediaType: 'application/json' +}); }; + /** * list instance groups * @returns InstanceGroup instance group list @@ -6746,6 +7173,23 @@ export const listCaptures = (data: ListCapturesData): CancelablePromise => { return __request(OpenAPI, { + method: 'GET', + url: '/w/{workspace}/capture/{id}', + path: { + workspace: data.workspace, + id: data.id + } +}); }; + /** * delete a capture * @param data The data for the request. diff --git a/cli/gen/types.gen.ts b/cli/gen/types.gen.ts index ee075449a9..4695b99980 100644 --- a/cli/gen/types.gen.ts +++ b/cli/gen/types.gen.ts @@ -1,8 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -export type AiResource = { +export type AIProvider = 'openai' | 'anthropic' | 'mistral' | 'deepseek' | 'customai'; + +export type AIResource = { path: string; - provider: string; + provider: AIProvider; }; export type Script = { @@ -30,7 +32,7 @@ export type Script = { }; lock?: string; lock_error_logs?: string; - language: 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp'; + language: ScriptLang; kind: 'script' | 'failure' | 'trigger' | 'command' | 'approval' | 'preprocessor'; starred: boolean; tag?: string; @@ -54,8 +56,6 @@ export type Script = { on_behalf_of_email?: string; }; -export type language = 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp'; - export type kind = 'script' | 'failure' | 'trigger' | 'command' | 'approval' | 'preprocessor'; export type NewScript = { @@ -69,7 +69,7 @@ export type NewScript = { }; is_template?: boolean; lock?: string; - language: 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp'; + language: ScriptLang; kind?: 'script' | 'failure' | 'trigger' | 'command' | 'approval' | 'preprocessor'; tag?: string; draft_only?: boolean; @@ -159,7 +159,7 @@ export type QueuedJob = { flow_status?: FlowStatus; raw_flow?: FlowValue; is_flow_step: boolean; - language?: 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp'; + language?: ScriptLang; email: string; visible_to_owner: boolean; mem_peak?: number; @@ -202,7 +202,7 @@ export type CompletedJob = { flow_status?: FlowStatus; raw_flow?: FlowValue; is_flow_step: boolean; - language?: 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp'; + language?: ScriptLang; is_skipped: boolean; email: string; visible_to_owner: boolean; @@ -372,11 +372,13 @@ export type MainArgSignature = { export type type2 = 'Valid' | 'Invalid'; +export type ScriptLang = 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp'; + export type Preview = { content?: string; path?: string; args: ScriptArgs; - language?: 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp'; + language?: ScriptLang; tag?: string; kind?: 'code' | 'identity' | 'http'; dedicated_worker?: boolean; @@ -550,10 +552,18 @@ export type EditSchedule = { cron_version?: string; }; -export type HttpTrigger = { - path: string; +export type TriggerExtraProperty = { + email: string; + extra_perms: { + [key: string]: (boolean); + }; + workspace_id: string; edited_by: string; edited_at: string; +}; + +export type HttpTrigger = TriggerExtraProperty & { + path: string; script_path: string; route_path: string; static_asset_config?: { @@ -562,11 +572,6 @@ export type HttpTrigger = { filename?: string; }; is_flow: boolean; - extra_perms: { - [key: string]: (boolean); - }; - email: string; - workspace_id: string; http_method: 'get' | 'post' | 'put' | 'delete' | 'patch'; is_async: boolean; requires_auth: boolean; @@ -613,22 +618,16 @@ export type TriggersCount = { webhook_count?: number; email_count?: number; websocket_count?: number; + postgres_count?: number; kafka_count?: number; nats_count?: number; }; -export type WebsocketTrigger = { +export type WebsocketTrigger = TriggerExtraProperty & { path: string; - edited_by: string; - edited_at: string; script_path: string; url: string; is_flow: boolean; - extra_perms: { - [key: string]: (boolean); - }; - email: string; - workspace_id: string; server_id?: string; last_server_ping?: string; error?: string; @@ -639,6 +638,7 @@ export type WebsocketTrigger = { }>; initial_messages?: Array; url_runnable_args?: ScriptArgs; + can_return_message: boolean; }; export type NewWebsocketTrigger = { @@ -653,6 +653,7 @@ export type NewWebsocketTrigger = { }>; initial_messages?: Array; url_runnable_args?: ScriptArgs; + can_return_message: boolean; }; export type EditWebsocketTrigger = { @@ -666,6 +667,7 @@ export type EditWebsocketTrigger = { }>; initial_messages?: Array; url_runnable_args?: ScriptArgs; + can_return_message: boolean; }; export type WebsocketTriggerInitialMessage = { @@ -678,6 +680,74 @@ export type WebsocketTriggerInitialMessage = { }; }; +export type Slot = { + name?: string; +}; + +export type SlotList = { + slot_name?: string; + active?: boolean; +}; + +export type PublicationData = { + table_to_track?: Array; + transaction_to_track: Array<(string)>; +}; + +export type TableToTrack = Array<{ + table_name: string; + columns_name?: Array<(string)>; + where_clause?: string; +}>; + +export type Relations = { + schema_name: string; + table_to_track: TableToTrack; +}; + +export type Language = 'Typescript'; + +export type TemplateScript = { + postgres_resource_path: string; + relations: Array; + language: Language; +}; + +export type PostgresTrigger = TriggerExtraProperty & { + path: string; + script_path: string; + is_flow: boolean; + enabled: boolean; + postgres_resource_path: string; + publication_name: string; + server_id?: string; + replication_slot_name: string; + error?: string; + last_server_ping?: string; +}; + +export type NewPostgresTrigger = { + replication_slot_name?: string; + publication_name?: string; + path: string; + script_path: string; + is_flow: boolean; + enabled: boolean; + postgres_resource_path: string; + publication?: PublicationData; +}; + +export type EditPostgresTrigger = { + replication_slot_name: string; + publication_name: string; + path: string; + script_path: string; + is_flow: boolean; + enabled: boolean; + postgres_resource_path: string; + publication?: PublicationData; +}; + export type KafkaTrigger = { path: string; edited_by: string; @@ -817,6 +887,7 @@ export type UserWorkspaceList = { name: string; username: string; color: string; + operator_settings?: OperatorSettings; }>; }; @@ -1111,7 +1182,7 @@ export type MetricDataPoint = { export type RawScriptForDependencies = { raw_code: string; path: string; - language: 'python3' | 'deno' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'bun' | 'php' | 'rust' | 'ansible' | 'csharp'; + language: ScriptLang; }; export type ConcurrencyGroup = { @@ -1223,6 +1294,79 @@ export type CaptureConfig = { last_server_ping?: string; }; +export type OperatorSettings = { + /** + * Whether operators can view runs + */ + runs: boolean; + /** + * Whether operators can view schedules + */ + schedules: boolean; + /** + * Whether operators can view resources + */ + resources: boolean; + /** + * Whether operators can view variables + */ + variables: boolean; + /** + * Whether operators can view audit logs + */ + audit_logs: boolean; + /** + * Whether operators can view triggers + */ + triggers: boolean; + /** + * Whether operators can view groups page + */ + groups: boolean; + /** + * Whether operators can view folders page + */ + folders: boolean; + /** + * Whether operators can view workers page + */ + workers: boolean; +} | null; + +export type TeamInfo = { + /** + * The unique identifier of the Microsoft Teams team + */ + team_id: string; + /** + * The display name of the Microsoft Teams team + */ + team_name: string; + /** + * List of channels within the team + */ + channels: Array; +}; + +export type ChannelInfo = { + /** + * The unique identifier of the channel + */ + channel_id: string; + /** + * The display name of the channel + */ + channel_name: string; + /** + * The Microsoft Teams tenant identifier + */ + tenant_id: string; + /** + * The service URL for the channel + */ + service_url: string; +}; + export type OpenFlow = { summary: string; description?: string; @@ -1331,7 +1475,7 @@ export type RawScript = { is_trigger?: boolean; }; -export type language2 = 'deno' | 'bun' | 'python3' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'php'; +export type language = 'deno' | 'bun' | 'python3' | 'go' | 'bash' | 'powershell' | 'postgresql' | 'mysql' | 'bigquery' | 'snowflake' | 'mssql' | 'oracledb' | 'graphql' | 'nativets' | 'php'; export type PathScript = { input_transforms: { @@ -1441,10 +1585,14 @@ export type FlowStatusModule = { export type type4 = 'WaitingForPriorSteps' | 'WaitingForEvents' | 'WaitingForExecutor' | 'InProgress' | 'Success' | 'Failure'; +export type ParameterId = string; + export type ParameterKey = string; export type ParameterWorkspaceId = string; +export type ParameterPublicationName = string; + export type ParameterVersionId = number; export type ParameterToken = string; @@ -2239,6 +2387,13 @@ export type WhoisData = { export type WhoisResponse = (User); +export type UpdateOperatorSettingsData = { + requestBody: OperatorSettings; + workspace: string; +}; + +export type UpdateOperatorSettingsResponse = (string); + export type ExistsEmailData = { email: string; }; @@ -2285,8 +2440,9 @@ export type GetSettingsResponse = ({ customer_id?: string; webhook?: string; deploy_to?: string; - ai_resource?: AiResource; - code_completion_enabled: boolean; + ai_resource?: AIResource; + code_completion_model?: string; + ai_models: Array<(string)>; error_handler?: string; error_handler_extra_args?: ScriptArgs; error_handler_muted_on_cancel: boolean; @@ -2297,6 +2453,7 @@ export type GetSettingsResponse = ({ default_scripts?: WorkspaceDefaultScripts; mute_critical_alerts?: boolean; color?: string; + operator_settings?: OperatorSettings; }); export type GetDeployToData = { @@ -2427,8 +2584,9 @@ export type EditCopilotConfigData = { * WorkspaceCopilotConfig */ requestBody: { - ai_resource?: AiResource; - code_completion_enabled: boolean; + ai_resource?: AIResource; + code_completion_model?: string; + ai_models: Array<(string)>; }; workspace: string; }; @@ -2440,9 +2598,10 @@ export type GetCopilotInfoData = { }; export type GetCopilotInfoResponse = ({ - ai_provider: string; + ai_provider: AIProvider; exists_ai_resource: boolean; - code_completion_enabled: boolean; + code_completion_model?: string; + ai_models: Array<(string)>; }); export type EditErrorHandlerData = { @@ -2586,6 +2745,7 @@ export type GetUsedTriggersResponse = ({ websocket_used: boolean; kafka_used: boolean; nats_used: boolean; + postgres_used: boolean; }); export type ListUsersData = { @@ -2916,6 +3076,8 @@ export type GetOauthConnectResponse = ({ scopes?: Array<(string)>; }); +export type SyncTeamsResponse = (Array); + export type CreateResourceData = { /** * new resource @@ -5490,6 +5652,20 @@ export type SetWebsocketTriggerEnabledData = { export type SetWebsocketTriggerEnabledResponse = (string); +export type TestWebsocketConnectionData = { + /** + * test websocket connection + */ + requestBody: { + url: string; + url_runnable_args?: ScriptArgs; + can_return_message: boolean; + }; + workspace: string; +}; + +export type TestWebsocketConnectionResponse = (string); + export type CreateKafkaTriggerData = { /** * new kafka trigger @@ -5565,6 +5741,20 @@ export type SetKafkaTriggerEnabledData = { export type SetKafkaTriggerEnabledResponse = (string); +export type TestKafkaConnectionData = { + /** + * test kafka connection + */ + requestBody: { + connection: { + [key: string]: unknown; + }; + }; + workspace: string; +}; + +export type TestKafkaConnectionResponse = (string); + export type CreateNatsTriggerData = { /** * new nats trigger @@ -5640,6 +5830,195 @@ export type SetNatsTriggerEnabledData = { export type SetNatsTriggerEnabledResponse = (string); +export type TestNatsConnectionData = { + /** + * test nats connection + */ + requestBody: { + connection: { + [key: string]: unknown; + }; + }; + workspace: string; +}; + +export type TestNatsConnectionResponse = (string); + +export type IsValidPostgresConfigurationData = { + path: string; + workspace: string; +}; + +export type IsValidPostgresConfigurationResponse = (boolean); + +export type CreateTemplateScriptData = { + /** + * template script + */ + requestBody: TemplateScript; + workspace: string; +}; + +export type CreateTemplateScriptResponse = (string); + +export type GetTemplateScriptData = { + id: string; + workspace: string; +}; + +export type GetTemplateScriptResponse = (string); + +export type ListPostgresReplicationSlotData = { + path: string; + workspace: string; +}; + +export type ListPostgresReplicationSlotResponse = (Array); + +export type CreatePostgresReplicationSlotData = { + path: string; + /** + * new slot for postgres + */ + requestBody: Slot; + workspace: string; +}; + +export type CreatePostgresReplicationSlotResponse = (string); + +export type DeletePostgresReplicationSlotData = { + path: string; + /** + * replication slot of postgres + */ + requestBody: Slot; + workspace: string; +}; + +export type DeletePostgresReplicationSlotResponse = (string); + +export type ListPostgresPublicationData = { + path: string; + workspace: string; +}; + +export type ListPostgresPublicationResponse = (Array<(string)>); + +export type GetPostgresPublicationData = { + path: string; + publication: string; + workspace: string; +}; + +export type GetPostgresPublicationResponse = (PublicationData); + +export type CreatePostgresPublicationData = { + path: string; + publication: string; + /** + * new publication for postgres + */ + requestBody: PublicationData; + workspace: string; +}; + +export type CreatePostgresPublicationResponse = (string); + +export type UpdatePostgresPublicationData = { + path: string; + publication: string; + /** + * update publication for postgres + */ + requestBody: PublicationData; + workspace: string; +}; + +export type UpdatePostgresPublicationResponse = (string); + +export type DeletePostgresPublicationData = { + path: string; + publication: string; + workspace: string; +}; + +export type DeletePostgresPublicationResponse = (string); + +export type CreatePostgresTriggerData = { + /** + * new postgres trigger + */ + requestBody: NewPostgresTrigger; + workspace: string; +}; + +export type CreatePostgresTriggerResponse = (string); + +export type UpdatePostgresTriggerData = { + path: string; + /** + * updated trigger + */ + requestBody: EditPostgresTrigger; + workspace: string; +}; + +export type UpdatePostgresTriggerResponse = (string); + +export type DeletePostgresTriggerData = { + path: string; + workspace: string; +}; + +export type DeletePostgresTriggerResponse = (string); + +export type GetPostgresTriggerData = { + path: string; + workspace: string; +}; + +export type GetPostgresTriggerResponse = (PostgresTrigger); + +export type ListPostgresTriggersData = { + isFlow?: boolean; + /** + * which page to return (start at 1, default 1) + */ + page?: number; + /** + * filter by path + */ + path?: string; + pathStart?: string; + /** + * number of items to return for a given page (default 30, max 100) + */ + perPage?: number; + workspace: string; +}; + +export type ListPostgresTriggersResponse = (Array); + +export type ExistsPostgresTriggerData = { + path: string; + workspace: string; +}; + +export type ExistsPostgresTriggerResponse = (boolean); + +export type SetPostgresTriggerEnabledData = { + path: string; + /** + * updated postgres trigger enable + */ + requestBody: { + enabled: boolean; + }; + workspace: string; +}; + +export type SetPostgresTriggerEnabledResponse = (string); + export type ListInstanceGroupsResponse = (Array); export type GetInstanceGroupData = { @@ -5987,7 +6366,7 @@ export type ListAutoscalingEventsData = { export type ListAutoscalingEventsResponse = (Array); export type GetGranularAclsData = { - kind: 'script' | 'group_' | 'resource' | 'schedule' | 'variable' | 'flow' | 'folder' | 'app' | 'raw_app' | 'http_trigger' | 'websocket_trigger' | 'kafka_trigger' | 'nats_trigger'; + kind: 'script' | 'group_' | 'resource' | 'schedule' | 'variable' | 'flow' | 'folder' | 'app' | 'raw_app' | 'http_trigger' | 'websocket_trigger' | 'kafka_trigger' | 'nats_trigger' | 'postgres_trigger'; path: string; workspace: string; }; @@ -5997,7 +6376,7 @@ export type GetGranularAclsResponse = ({ }); export type AddGranularAclsData = { - kind: 'script' | 'group_' | 'resource' | 'schedule' | 'variable' | 'flow' | 'folder' | 'app' | 'raw_app' | 'http_trigger' | 'websocket_trigger' | 'kafka_trigger' | 'nats_trigger'; + kind: 'script' | 'group_' | 'resource' | 'schedule' | 'variable' | 'flow' | 'folder' | 'app' | 'raw_app' | 'http_trigger' | 'websocket_trigger' | 'kafka_trigger' | 'nats_trigger' | 'postgres_trigger'; path: string; /** * acl to add @@ -6012,7 +6391,7 @@ export type AddGranularAclsData = { export type AddGranularAclsResponse = (string); export type RemoveGranularAclsData = { - kind: 'script' | 'group_' | 'resource' | 'schedule' | 'variable' | 'flow' | 'folder' | 'app' | 'raw_app' | 'http_trigger' | 'websocket_trigger' | 'kafka_trigger' | 'nats_trigger'; + kind: 'script' | 'group_' | 'resource' | 'schedule' | 'variable' | 'flow' | 'folder' | 'app' | 'raw_app' | 'http_trigger' | 'websocket_trigger' | 'kafka_trigger' | 'nats_trigger' | 'postgres_trigger'; path: string; /** * acl to add @@ -6076,6 +6455,13 @@ export type ListCapturesData = { export type ListCapturesResponse = (Array); +export type GetCaptureData = { + id: number; + workspace: string; +}; + +export type GetCaptureResponse = (Capture); + export type DeleteCaptureData = { id: number; workspace: string; @@ -6200,6 +6586,7 @@ export type DuckdbConnectionSettingsV2Data = { export type DuckdbConnectionSettingsV2Response = ({ connection_settings_str: string; + azure_container_path?: string; }); export type PolarsConnectionSettingsData = { diff --git a/cli/main.ts b/cli/main.ts index f02dbbe841..20008cd9d1 100644 --- a/cli/main.ts +++ b/cli/main.ts @@ -60,7 +60,7 @@ export { // } // }); -export const VERSION = "1.456.0"; +export const VERSION = "1.457.1"; const command = new Command() .name("wmill") diff --git a/cli/settings.ts b/cli/settings.ts index 4952b7ac7a..1cfe0b9bf0 100644 --- a/cli/settings.ts +++ b/cli/settings.ts @@ -1,15 +1,11 @@ -import { yamlStringify } from "./deps.ts"; -import { Confirm } from "./deps.ts"; -import { colors } from "./deps.ts"; -import { yamlParseFile } from "./deps.ts"; -import { log } from "./deps.ts"; +import process from "node:process"; +import { colors, Confirm, log, yamlParseFile, yamlStringify } from "./deps.ts"; +import * as wmill from "./gen/services.gen.ts"; +import { AiResource, Config, GlobalSetting } from "./gen/types.gen.ts"; import { compareInstanceObjects, InstanceSyncOptions } from "./instance.ts"; import { isSuperset } from "./types.ts"; import { deepEqual } from "./utils.ts"; -import * as wmill from "./gen/services.gen.ts"; -import { AiResource, Config, GlobalSetting } from "./gen/types.gen.ts"; import { removeWorkerPrefix } from "./worker_groups.ts"; -import process from "node:process"; export interface SimplifiedSettings { // slack_team_id?: string; @@ -25,7 +21,8 @@ export interface SimplifiedSettings { error_handler_extra_args?: any; error_handler_muted_on_cancel?: boolean; ai_resource?: AiResource; - code_completion_enabled: boolean; + code_completion_model?: string; + ai_models: string[]; large_file_storage?: any; git_sync?: any; default_app?: string; @@ -81,7 +78,8 @@ export async function pushWorkspaceSettings( error_handler_muted_on_cancel: remoteSettings.error_handler_muted_on_cancel, ai_resource: remoteSettings.ai_resource, - code_completion_enabled: remoteSettings.code_completion_enabled, + code_completion_model: remoteSettings.code_completion_model, + ai_models: remoteSettings.ai_models, large_file_storage: remoteSettings.large_file_storage, git_sync: remoteSettings.git_sync, default_app: remoteSettings.default_app, @@ -153,15 +151,17 @@ export async function pushWorkspaceSettings( } } if ( - localSettings.ai_resource !== settings.ai_resource || - localSettings.code_completion_enabled !== settings.code_completion_enabled + localSettings.ai_resource != settings.ai_resource || + localSettings.code_completion_model != settings.code_completion_model || + !deepEqual(localSettings.ai_models, settings.ai_models) ) { - log.debug(`Updating openai settings...`); + log.debug(`Updating copilot settings...`); await wmill.editCopilotConfig({ workspace, requestBody: { ai_resource: localSettings.ai_resource, - code_completion_enabled: localSettings.code_completion_enabled, + code_completion_model: localSettings.code_completion_model, + ai_models: localSettings.ai_models, }, }); } @@ -282,7 +282,9 @@ export async function readInstanceSettings(opts: InstanceSyncOptions) { await checkInstanceSettingsPath(opts); try { - localSettings = (await yamlParseFile(instanceSettingsPath)) as GlobalSetting[]; + localSettings = (await yamlParseFile( + instanceSettingsPath + )) as GlobalSetting[]; } catch { log.warn(`No ${instanceSettingsPath} found`); } @@ -445,9 +447,7 @@ export async function pushInstanceSettings( } } -export async function readLocalConfigs( - opts: InstanceSyncOptions -) { +export async function readLocalConfigs(opts: InstanceSyncOptions) { let localConfigs: Config[] = []; await checkInstanceConfigPath(opts); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 95f0c35a97..8bc52010f7 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "windmill-components", - "version": "1.456.0", + "version": "1.457.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "windmill-components", - "version": "1.456.0", + "version": "1.457.1", "license": "AGPL-3.0", "dependencies": { "@anthropic-ai/sdk": "^0.32.1", diff --git a/frontend/package.json b/frontend/package.json index 3ea5fd90b8..dbea2551a5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "windmill-components", - "version": "1.456.0", + "version": "1.457.1", "scripts": { "dev": "vite dev", "build": "vite build", diff --git a/frontend/src/lib/components/Dev.svelte b/frontend/src/lib/components/Dev.svelte index ccdda7524e..e53d49eb72 100644 --- a/frontend/src/lib/components/Dev.svelte +++ b/frontend/src/lib/components/Dev.svelte @@ -48,7 +48,7 @@ } from '$lib/relative_imports' import Tooltip from './Tooltip.svelte' import type { ScheduleTrigger, TriggerContext } from './triggers' - import { initAllAiWorkspace } from './copilot/lib' + import { workspaceAIClients } from './copilot/lib' import type { FlowPropPickerConfig, PropPickerContext } from './prop_picker' import type { PickableProperties } from './flows/previousResults' $: token = $page.url.searchParams.get('wm_token') ?? undefined @@ -110,14 +110,19 @@ async function setCopilotInfo() { if (workspace) { - initAllAiWorkspace(workspace) + workspaceAIClients.init(workspace) try { - copilotInfo.set(await WorkspaceService.getCopilotInfo({ workspace })) + const info = await WorkspaceService.getCopilotInfo({ workspace }) + copilotInfo.set({ + ...info, + ai_provider: info.ai_provider ?? 'openai' + }) } catch (err) { copilotInfo.set({ - ai_provider: '', + ai_provider: 'openai', exists_ai_resource: false, - code_completion_enabled: false + code_completion_model: undefined, + ai_models: [] }) console.error('Could not get copilot info') diff --git a/frontend/src/lib/components/Editor.svelte b/frontend/src/lib/components/Editor.svelte index 350d26b643..b5f6565362 100644 --- a/frontend/src/lib/components/Editor.svelte +++ b/frontend/src/lib/components/Editor.svelte @@ -172,7 +172,6 @@ import { initVim } from './monaco_keybindings' import { buildWorkerDefinition } from '$lib/monaco_workers/build_workers' import { parseTypescriptDeps } from '$lib/relative_imports' - import type { AiProviderTypes } from './copilot/lib' // import EditorTheme from './EditorTheme.svelte' @@ -640,7 +639,7 @@ textAfterPosition, lang, abortController, - aiProvider as AiProviderTypes + aiProvider ) if (insertText) { items = [ @@ -668,7 +667,7 @@ } $: $copilotInfo.exists_ai_resource && - $copilotInfo.code_completion_enabled && + $copilotInfo.code_completion_model && $codeCompletionSessionEnabled && initialized && addCopilotSuggestions() diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index 3db9804bb8..a713835829 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -86,7 +86,6 @@ import type { FlowBuilderWhitelabelCustomUi } from './custom_ui' import FlowYamlEditor from './flows/header/FlowYamlEditor.svelte' import { type TriggerContext, type ScheduleTrigger } from './triggers' - import type { AiProviderTypes } from './copilot/lib' export let initialPath: string = '' export let pathStoreInit: string | undefined = undefined @@ -821,7 +820,7 @@ try { push(history, $flowStore) let module = stepOnly ? $copilotModulesStore[0] : $copilotModulesStore[idx] - const aiProvider = $copilotInfo.ai_provider as AiProviderTypes + const aiProvider = $copilotInfo.ai_provider copilotLoading = true copilotStatus = "Generating code for step '" + module.id + "'..." diff --git a/frontend/src/lib/components/copilot/CodeCompletionStatus.svelte b/frontend/src/lib/components/copilot/CodeCompletionStatus.svelte index 8a77a8df9f..920f2d137e 100644 --- a/frontend/src/lib/components/copilot/CodeCompletionStatus.svelte +++ b/frontend/src/lib/components/copilot/CodeCompletionStatus.svelte @@ -12,7 +12,7 @@ } -{#if $copilotInfo.exists_ai_resource && $copilotInfo.code_completion_enabled} +{#if $copilotInfo.exists_ai_resource && $copilotInfo.code_completion_model} import { ExternalLink, Wand2 } from 'lucide-svelte' import Button from '../common/button/Button.svelte' - import { getNonStreamingCompletion, type AiProviderTypes } from './lib' + import { getNonStreamingCompletion } from './lib' import Popup from '../common/popup/Popup.svelte' import { sendUserToast } from '$lib/toast' import { copilotInfo } from '$lib/stores' import { base } from '$lib/base' import type { ChatCompletionMessageParam } from 'openai/resources/index.mjs' + import type { AIProvider } from '$lib/gen' export let schedule: string export let cronVersion: string @@ -56,7 +57,7 @@ const response = await getNonStreamingCompletion( messages, abortController, - aiProvider as AiProviderTypes + aiProvider as AIProvider ) if (response.startsWith('ERROR:')) { diff --git a/frontend/src/lib/components/copilot/IteratorGen.svelte b/frontend/src/lib/components/copilot/IteratorGen.svelte index 361a6a5c1a..a53423670b 100644 --- a/frontend/src/lib/components/copilot/IteratorGen.svelte +++ b/frontend/src/lib/components/copilot/IteratorGen.svelte @@ -1,7 +1,7 @@ @@ -21,8 +24,10 @@ setTimeout(() => { abortController.abort() }, 10000) + await testKey({ apiKey, + resourcePath, messages: [ { role: 'user', @@ -30,7 +35,8 @@ } ], abortController, - aiProvider + aiProvider, + model }) sendUserToast('Valid key') } catch (err) { @@ -42,5 +48,11 @@ } finally { loading = false } - }}>Test key + {#if apiKey} + Test key + {:else} + Test + {/if} + diff --git a/frontend/src/lib/components/copilot/completion.ts b/frontend/src/lib/components/copilot/completion.ts index b30a3fe7e0..01c90035c6 100644 --- a/frontend/src/lib/components/copilot/completion.ts +++ b/frontend/src/lib/components/copilot/completion.ts @@ -1,6 +1,7 @@ -import type { ChatCompletionMessageParam } from 'openai/resources/chat/index.mjs' -import { getNonStreamingCompletion, type AiProviderTypes } from './lib' +import type { AIProvider } from '$lib/gen' import { codeCompletionLoading } from '$lib/stores' +import type { ChatCompletionMessageParam } from 'openai/resources/chat/index.mjs' +import { getNonStreamingCompletion } from './lib' const systemPrompt = `You are a code completion assistant, return the code that should go instead of the . @@ -74,7 +75,7 @@ export async function editorCodeCompletion( after: string, lang: string, abortController: AbortController, - aiProvider: AiProviderTypes + aiProvider: AIProvider ) { codeCompletionLoading.set(true) const messages: ChatCompletionMessageParam[] = [ diff --git a/frontend/src/lib/components/copilot/flow.ts b/frontend/src/lib/components/copilot/flow.ts index 7867a2f2d5..1c5f8685bd 100644 --- a/frontend/src/lib/components/copilot/flow.ts +++ b/frontend/src/lib/components/copilot/flow.ts @@ -1,21 +1,17 @@ import { - type FlowModule, ScriptService, - type RawScript, - type PathScript, + type AIProvider, + type FlowModule, type InputTransform, + type PathScript, + type RawScript, type Script } from '$lib/gen' -import { - addResourceTypes, - deltaCodeCompletion, - getNonStreamingCompletion, - type AiProviderTypes -} from './lib' +import { scriptLangToEditorLang } from '$lib/scripts' import type { Writable } from 'svelte/store' import type Editor from '../Editor.svelte' import type { Drawer } from '../common' -import { scriptLangToEditorLang } from '$lib/scripts' +import { addResourceTypes, deltaCodeCompletion, getNonStreamingCompletion } from './lib' export type FlowCopilotModule = { id: string @@ -259,7 +255,7 @@ export async function stepCopilot( | undefined, isFirstInLoop: boolean, abortController: AbortController, - aiProvider: AiProviderTypes + aiProvider: AIProvider ) { if (module.source !== 'custom') { throw new Error('Not a custom module') @@ -328,7 +324,7 @@ export async function glueCopilot( }, isFirstInLoop: boolean, abortController: AbortController, - aiProvider: AiProviderTypes + aiProvider: AIProvider ) { const { prevCode, prevLang } = await getPreviousStepContent(pastModule, workspace) diff --git a/frontend/src/lib/components/copilot/lib.ts b/frontend/src/lib/components/copilot/lib.ts index fe7028dc1e..69d5ac9b7d 100644 --- a/frontend/src/lib/components/copilot/lib.ts +++ b/frontend/src/lib/components/copilot/lib.ts @@ -1,56 +1,130 @@ -import { OpenAI } from 'openai' -import { OpenAPI, ResourceService, type Script } from '../../gen' -import type { Writable } from 'svelte/store' +import type { AIProvider } from '$lib/gen' +import { + copilotInfo, + copilotSessionModel, + type DBSchema, + type GraphqlSchema, + type SQLSchema +} from '$lib/stores' import { Anthropic } from '@anthropic-ai/sdk' -import type { DBSchema, GraphqlSchema, SQLSchema } from '$lib/stores' -import { formatResourceTypes } from './utils' -import { EDIT_CONFIG, FIX_CONFIG, GEN_CONFIG } from './prompts' import { Mistral } from '@mistralai/mistralai' import { buildClientSchema, printSchema } from 'graphql' +import { OpenAI } from 'openai' import type { ChatCompletionCreateParamsStreaming, ChatCompletionMessageParam } from 'openai/resources/index.mjs' +import { get, type Writable } from 'svelte/store' +import { OpenAPI, ResourceService, type Script } from '../../gen' +import { EDIT_CONFIG, FIX_CONFIG, GEN_CONFIG } from './prompts' +import { formatResourceTypes } from './utils' import type { MessageCreateParams, MessageParam } from '@anthropic-ai/sdk/resources/messages.mjs' -import type { ChatCompletionRequest } from '@mistralai/mistralai/models/components/chatcompletionrequest' import type { - SystemMessage, - UserMessage, AssistantMessage, - ToolMessage, CompletionEvent, - ContentChunk + ContentChunk, + SystemMessage, + ToolMessage, + UserMessage } from '@mistralai/mistralai/models/components' +import type { ChatCompletionRequest } from '@mistralai/mistralai/models/components/chatcompletionrequest' export const SUPPORTED_LANGUAGES = new Set(Object.keys(GEN_CONFIG.prompts)) -export type AiProviderTypes = 'openai' | 'anthropic' | 'mistral' - -interface AiProvider { - init: (workspace: string, updateClient: boolean, token?: string) => void +export const AI_DEFAULT_MODELS: Record = { + openai: ['gpt-4o', 'gpt-4o-mini'], + anthropic: ['claude-3-5-sonnet-latest', 'claude-3-5-haiku-latest'], + mistral: ['codestral-latest'], + deepseek: ['deepseek-chat', 'deepseek-reasoner'], + groq: ['llama-3.3-70b-versatile', 'llama-3.1-8b-instant'], + openrouter: ['meta-llama/llama-3.2-3b-instruct:free'], + customai: [] } -class WorkspacedMistral implements AiProvider { - private client: Mistral | undefined +export const OPENAI_COMPATIBLE_BASE_URLS = { + groq: 'https://api.groq.com/openai/v1', + openrouter: 'https://openrouter.ai/api/v1', + deepseek: 'https://api.deepseek.com/v1' +} as const - init(workspace: string, updateClient: boolean, token?: string) { - if (!this.client || updateClient) { - this.client = initWorkspaceAiProvider(workspace, 'mistral', token) as unknown as Mistral - } +class WorkspacedAIClients { + private openaiClient: OpenAI | undefined + private anthropicClient: Anthropic | undefined + private mistralClient: Mistral | undefined + + init(workspace: string) { + this.initOpenai(workspace) + this.initAnthropic(workspace) + this.initMistral(workspace) } - getClient() { - if (!this.client) { - throw new Error('AnthropicAi not initialized') + private getBaseURL(workspace: string) { + return `${location.origin}${OpenAPI.BASE}/w/${workspace}/ai/proxy` + } + + private initOpenai(workspace: string) { + const baseURL = this.getBaseURL(workspace) + this.openaiClient = new OpenAI({ + baseURL, + apiKey: 'fake-key', + defaultHeaders: { + Authorization: '' // a non empty string will be unable to access Windmill backend proxy + }, + dangerouslyAllowBrowser: true + }) + } + + private initAnthropic(workspace: string) { + const baseURL = this.getBaseURL(workspace) + this.anthropicClient = new Anthropic({ + baseURL, + apiKey: 'fake-key', + dangerouslyAllowBrowser: true + }) + } + + private initMistral(workspace: string) { + const baseURL = this.getBaseURL(workspace) + this.mistralClient = new Mistral({ + serverURL: baseURL + }) + } + + getOpenaiClient() { + if (!this.openaiClient) { + throw new Error('OpenAI not initialized') } - return this.client + return this.openaiClient + } + + getAnthropicClient() { + if (!this.anthropicClient) { + throw new Error('Anthropic not initialized') + } + return this.anthropicClient + } + + getMistralClient() { + if (!this.mistralClient) { + throw new Error('Mistral not initialized') + } + return this.mistralClient } } -export namespace MistralAi { - export let workspace = new WorkspacedMistral() +export const workspaceAIClients = new WorkspacedAIClients() +const DEFAULT_COMPLETION_CONFIG: ChatCompletionCreateParamsStreaming = { + model: '', + max_tokens: 8000, //TODO: make this dynamic + temperature: 0, + seed: 42, + stream: true, + messages: [] +} + +namespace MistralAI { export const mistralConfig: ChatCompletionRequest = { temperature: 0, model: null, @@ -78,30 +152,11 @@ export namespace MistralAi { } } -class WorkspacedAnthropic implements AiProvider { - private client: Anthropic | undefined - - init(workspace: string, updateClient: boolean, token: string | undefined = undefined) { - if (!this.client || updateClient) { - this.client = initWorkspaceAiProvider(workspace, 'anthropic', token) as unknown as Anthropic - } - } - - getClient() { - if (!this.client) { - throw new Error('AnthropicAi not initialized') - } - return this.client - } -} - -export namespace AnthropicAi { - export let workspace = new WorkspacedAnthropic() - +export namespace AnthropicAI { export const config: MessageCreateParams = { temperature: 0, max_tokens: 8192, - model: 'claude-3-5-sonnet-20241022', + model: '', messages: [] } @@ -135,30 +190,11 @@ export namespace AnthropicAi { } } -class WorkspacedOpenai implements AiProvider { - private client: OpenAI | undefined - - init(workspace: string, updateClient: boolean, token: string | undefined = undefined) { - if (!this.client || updateClient) { - this.client = initWorkspaceAiProvider(workspace, 'openai', token) as unknown as OpenAI - } - } - - getClient() { - if (!this.client) { - throw new Error('OpenAI not initialized') - } - return this.client - } -} - -export namespace OpenAi { - export let workspace = new WorkspacedOpenai() - +namespace OpenAi { export const openaiConfig: ChatCompletionCreateParamsStreaming = { temperature: 0, max_tokens: 16384, - model: 'gpt-4o-2024-08-06', + model: '', seed: 42, stream: true, messages: [] @@ -169,125 +205,38 @@ export namespace OpenAi { } } -export function initAllAiWorkspace(workspace: string, updateClient: boolean = false) { - OpenAi.workspace.init(workspace, updateClient) - AnthropicAi.workspace.init(workspace, updateClient) - MistralAi.workspace.init(workspace, updateClient) -} - -function initWorkspaceAiProvider( - workspace: string, - aiProvider: AiProviderTypes, - token: string | undefined = undefined -): Anthropic | OpenAI | Mistral { - const baseURL = `${location.origin}${OpenAPI.BASE}/w/${workspace}/ai/proxy` - let client - switch (aiProvider) { - case 'openai': { - client = new OpenAI({ - baseURL, - apiKey: 'fake-key', - defaultHeaders: { - Authorization: token ? `Bearer ${token}` : '' - }, - dangerouslyAllowBrowser: true - }) - break - } - case 'anthropic': { - client = new Anthropic({ - baseURL, - apiKey: 'fake-key', - defaultHeaders: { - Authorization: token ? `Bearer ${token}` : '' - }, - dangerouslyAllowBrowser: true - }) - break - } - case 'mistral': { - client = new Mistral({ - serverURL: baseURL - }) - } - } - return client -} - export async function testKey({ apiKey, + resourcePath, + model, abortController, messages, aiProvider }: { apiKey?: string + resourcePath?: string + model: string | undefined messages: ChatCompletionMessageParam[] abortController: AbortController - aiProvider: AiProviderTypes + aiProvider: AIProvider }) { - if (apiKey) { - switch (aiProvider) { - case 'openai': { - const openai = new OpenAI({ - apiKey, - dangerouslyAllowBrowser: true - }) - await openai.chat.completions.create( - { - ...OpenAi.openaiConfig, - messages, - stream: false - }, - { - signal: abortController.signal - } - ) - break - } - case 'anthropic': { - const anthropic = new Anthropic({ - apiKey, - dangerouslyAllowBrowser: true - }) - const [, anthropicMessages] = AnthropicAi.getSystemPromptAndArrayMessages(messages) - await anthropic.messages.create( - { - ...AnthropicAi.config, - messages: anthropicMessages, - stream: false - }, - { - signal: abortController.signal - } - ) - break - } - case 'mistral': { - const mistral = new Mistral({ - apiKey - }) - await mistral.chat.complete( - { - ...MistralAi.mistralConfig, - model: 'codestral-latest', - stream: false, - messages: messages as MistralAi.MistralParamsMessage[] - }, - { - fetchOptions: { - signal: abortController.signal, - headers: { - 'content-type': 'application/json' - } - } - } - ) - break - } - } - } else { - await getNonStreamingCompletion(messages, abortController, aiProvider, undefined, true) + if (!apiKey && !resourcePath) { + throw new Error('API key or resource path is required') } + const modelToTest = model ?? AI_DEFAULT_MODELS[aiProvider][0] + + if (!modelToTest) { + throw new Error('Missing a model to test') + } + + await getNonStreamingCompletion( + messages, + abortController, + aiProvider, + apiKey, + resourcePath, + modelToTest + ) } interface BaseOptions { @@ -410,7 +359,9 @@ function addDBSChema(scriptOptions: CopilotOptions, prompt: string) { const { dbSchema, language } = scriptOptions if ( dbSchema && - ['postgresql', 'mysql', 'snowflake', 'bigquery', 'mssql', 'graphql', 'oracledb'].includes(language) && // make sure we are using a SQL/query language + ['postgresql', 'mysql', 'snowflake', 'bigquery', 'mssql', 'graphql', 'oracledb'].includes( + language + ) && // make sure we are using a SQL/query language language === dbSchema.lang // make sure we are using the same language as the schema ) { let { stringified } = dbSchema @@ -467,66 +418,109 @@ const PROMPTS_CONFIGS = { export async function getNonStreamingCompletion( messages: ChatCompletionMessageParam[], abortController: AbortController, - aiProvider: AiProviderTypes, - model = OpenAi.openaiConfig.model, - noCache?: boolean + aiProvider: AIProvider, + apiKey?: string, // testing API KEY directly from the frontend + resourcePath?: string, // testing resource path passed as a header to the backend proxy + forceModel?: string ) { let response: string | undefined = '' - const queryOptions = { - query: { - no_cache: noCache - }, + let model = forceModel + + if (!model) { + model = get(copilotSessionModel) + let info = get(copilotInfo) + const { ai_models: aiModels } = info + + if (!model || !aiModels.includes(model)) { + console.warn('Invalid model, using default model:', aiModels[0]) + model = aiModels[0] + } + } + + if (!model) { + throw new Error('No model found') + } + + const fetchOptions: { + signal: AbortSignal + headers?: Record + } = { signal: abortController.signal } - switch (aiProvider) { - case 'openai': { - const openaiClient = OpenAi.workspace.getClient() - const completion = await openaiClient.chat.completions.create( - { - ...OpenAi.openaiConfig, - messages, - stream: false, - model - }, - queryOptions - ) - response = completion.choices[0]?.message.content || '' - break + if (resourcePath) { + fetchOptions.headers = { + 'X-Resource-Path': resourcePath } + } + switch (aiProvider) { case 'anthropic': { - const anthropicClient = AnthropicAi.workspace.getClient() - const [system, anthropicMessages] = AnthropicAi.getSystemPromptAndArrayMessages(messages) + const anthropicClient = apiKey + ? new Anthropic({ + apiKey, + dangerouslyAllowBrowser: true + }) + : workspaceAIClients.getAnthropicClient() + const [system, anthropicMessages] = AnthropicAI.getSystemPromptAndArrayMessages(messages) const message = await anthropicClient.messages.create( { - ...AnthropicAi.config, + ...AnthropicAI.config, system, + model, messages: anthropicMessages, stream: false }, - queryOptions + fetchOptions ) response = message.content[0].type === 'text' ? message.content[0].text : '' break } case 'mistral': { - const mistralClient = MistralAi.workspace.getClient() + const mistralClient = apiKey + ? new Mistral({ + apiKey + }) + : workspaceAIClients.getMistralClient() const message = await mistralClient.chat.complete( { - ...MistralAi.mistralConfig, - model: 'codestral-latest', + ...MistralAI.mistralConfig, + model, stream: false, - messages: messages as MistralAi.MistralParamsMessage[] + messages: messages as MistralAI.MistralParamsMessage[] }, { - fetchOptions: { - signal: abortController.signal, - cache: 'no-store' - } + fetchOptions: fetchOptions } ) - response = MistralAi.retrieveTextValue(message.choices && message.choices[0].message.content) + response = MistralAI.retrieveTextValue(message.choices && message.choices[0].message.content) break } + default: { + if (aiProvider === 'customai' && apiKey) { + throw new Error('Cannot test API key for Custom AI, only resource path is supported') + } + const baseURL = OPENAI_COMPATIBLE_BASE_URLS[aiProvider] + + if (apiKey && aiProvider !== 'openai' && !baseURL) { + throw new Error('No base URL for this provider: ' + aiProvider) + } + const openaiClient = apiKey + ? new OpenAI({ + apiKey, + baseURL, + dangerouslyAllowBrowser: true + }) + : workspaceAIClients.getOpenaiClient() + const completion = await openaiClient.chat.completions.create( + { + ...(aiProvider === 'openai' ? OpenAi.openaiConfig : DEFAULT_COMPLETION_CONFIG), + messages, + model, + stream: false + }, + fetchOptions + ) + response = completion.choices[0]?.message.content || '' + } } return response } @@ -534,17 +528,30 @@ export async function getNonStreamingCompletion( export async function getCompletion( messages: ChatCompletionMessageParam[], abortController: AbortController, - aiProvider: AiProviderTypes, - model = OpenAi.openaiConfig.model + aiProvider: AIProvider ) { + let model = get(copilotSessionModel) + let info = get(copilotInfo) + const { ai_models: aiModels } = info + + if (!model || !aiModels.includes(model)) { + console.warn('Invalid model, using default model:', aiModels[0]) + model = aiModels[0] + } + + if (!model) { + throw new Error('No model found') + } + switch (aiProvider) { case 'anthropic': { - const anthropicClient = AnthropicAi.workspace.getClient() - const [system, anthropicMessages] = AnthropicAi.getSystemPromptAndArrayMessages(messages) + const anthropicClient = workspaceAIClients.getAnthropicClient() + const [system, anthropicMessages] = AnthropicAI.getSystemPromptAndArrayMessages(messages) const completion = await anthropicClient.messages.create( { - ...AnthropicAi.config, + ...AnthropicAI.config, + model, system, messages: anthropicMessages, stream: true @@ -553,13 +560,29 @@ export async function getCompletion( ) return completion } - case 'openai': { - const openaiClient = OpenAi.workspace.getClient() + case 'mistral': { + const mistralClient = workspaceAIClients.getMistralClient() + const message = await mistralClient.chat.stream( + { + ...MistralAI.mistralConfig, + model, + messages: messages as MistralAI.MistralParamsMessage[] + }, + { + fetchOptions: { + signal: abortController.signal + } + } + ) + return message + } + default: { + const openaiClient = workspaceAIClients.getOpenaiClient() const completion = await openaiClient.chat.completions.create( { - ...OpenAi.openaiConfig, - messages, - model + ...(aiProvider === 'openai' ? OpenAi.openaiConfig : DEFAULT_COMPLETION_CONFIG), + model, + messages }, { signal: abortController.signal @@ -567,23 +590,6 @@ export async function getCompletion( ) return completion } - case 'mistral': { - const mistralClient = MistralAi.workspace.getClient() - const message = await mistralClient.chat.stream( - { - ...MistralAi.mistralConfig, - model: 'codestral-latest', - messages: messages as MistralAi.MistralParamsMessage[] - }, - { - fetchOptions: { - signal: abortController.signal, - cache: 'no-store' - } - } - ) - return message - } } } @@ -592,21 +598,20 @@ export function getResponseFromEvent( | Anthropic.Messages.RawMessageStreamEvent | OpenAI.Chat.Completions.ChatCompletionChunk | CompletionEvent, - aiProvider: AiProviderTypes + aiProvider: AIProvider ): string { switch (aiProvider) { - case 'openai': { - const messages = part as OpenAI.Chat.Completions.ChatCompletionChunk - return OpenAi.retrieveTextValue(messages) - } case 'anthropic': { const messages = part as Anthropic.Messages.RawMessageStreamEvent - return AnthropicAi.retrieveTextValue(messages) + return AnthropicAI.retrieveTextValue(messages) } case 'mistral': { const messages = part as CompletionEvent - return MistralAi.retrieveTextValue(messages.data.choices[0].delta.content) + return MistralAI.retrieveTextValue(messages.data.choices[0].delta.content) } + default: + const messages = part as OpenAI.Chat.Completions.ChatCompletionChunk + return OpenAi.retrieveTextValue(messages) } } @@ -614,7 +619,7 @@ export async function copilot( scriptOptions: CopilotOptions, generatedCode: Writable, abortController: AbortController, - aiProvider: AiProviderTypes, + aiProvider: AIProvider, generatedExplanation?: Writable ) { const { prompt, systemPrompt } = await getPrompts(scriptOptions) @@ -704,7 +709,7 @@ export async function deltaCodeCompletion( messages: ChatCompletionMessageParam[], generatedCodeDelta: Writable, abortController: AbortController, - aiProvider: AiProviderTypes + aiProvider: AIProvider ) { const completion = await getCompletion(messages, abortController, aiProvider) diff --git a/frontend/src/lib/components/graph/FlowGraphV2.svelte b/frontend/src/lib/components/graph/FlowGraphV2.svelte index 48f7fc9430..9b142927b2 100644 --- a/frontend/src/lib/components/graph/FlowGraphV2.svelte +++ b/frontend/src/lib/components/graph/FlowGraphV2.svelte @@ -1,7 +1,7 @@ @@ -198,11 +204,23 @@ @@ -230,9 +248,12 @@
- + + + +
@@ -243,7 +264,12 @@ bind:value={aiKey} on:keyup={handleKeyUp} /> - + {#if aiKey} { - // in JS, an empty string is also falsy - aiResourceInitialPath = aiResourcePath - aiResourceInitialProvider = aiProvider + async function editCopilotConfig(): Promise { if (aiResourcePath) { await WorkspaceService.editCopilotConfig({ workspace: $workspaceStore!, @@ -227,26 +231,30 @@ path: aiResourcePath, provider: aiProvider }, - code_completion_enabled: codeCompletionEnabled + code_completion_model: codeCompletionModel, + ai_models: aiModels } }) copilotInfo.set({ ai_provider: aiProvider, exists_ai_resource: true, - code_completion_enabled: codeCompletionEnabled + code_completion_model: codeCompletionModel, + ai_models: aiModels }) } else { await WorkspaceService.editCopilotConfig({ workspace: $workspaceStore!, requestBody: { ai_resource: undefined, - code_completion_enabled: codeCompletionEnabled + code_completion_model: codeCompletionModel, + ai_models: [] } }) copilotInfo.set({ - ai_provider: '', + ai_provider: 'openai', exists_ai_resource: false, - code_completion_enabled: codeCompletionEnabled + code_completion_model: codeCompletionModel, + ai_models: [] }) } sendUserToast(`Copilot settings updated`) @@ -406,6 +414,7 @@ }, 1000 - (timeEnd - timeStart)) } + let loadedSettings = false async function loadSettings(): Promise { const settings = await WorkspaceService.getSettings({ workspace: $workspaceStore! }) slack_team_name = settings.slack_name @@ -425,9 +434,12 @@ customer_id = settings.customer_id workspaceToDeployTo = settings.deploy_to webhook = settings.webhook - aiResourceInitialPath = settings.ai_resource?.path - aiResourceInitialProvider = settings.ai_resource?.provider - selected = (aiResourceInitialProvider as AiProviderTypes) ?? 'openai' + + aiResourcePath = settings.ai_resource?.path + aiProvider = settings.ai_resource?.provider ?? 'openai' + codeCompletionModel = settings.code_completion_model + aiModels = settings.ai_models + errorHandlerItemKind = settings.error_handler?.split('/')[0] as 'flow' | 'script' errorHandlerScriptPath = (settings.error_handler ?? '').split('/').slice(1).join('/') errorHandlerInitialScriptPath = errorHandlerScriptPath @@ -444,7 +456,6 @@ 'custom' } errorHandlerExtraArgs = settings.error_handler_extra_args ?? {} - codeCompletionEnabled = settings.code_completion_enabled workspaceDefaultAppPath = settings.default_app s3ResourceSettings = convertBackendSettingsToFrontendSettings(settings.large_file_storage) @@ -537,6 +548,8 @@ workspace: $workspaceStore!, path: 'openai_client_credentials_oauth' }) + + loadedSettings = true } let deployUiSettings: { @@ -727,7 +740,9 @@ - {#if tab == 'users'} + {#if !loadedSettings} + + {:else if tab == 'users'} {:else if tab == 'deploy_to'}
@@ -1047,43 +1062,104 @@
- { - aiResourceInitialPath = '' - aiResourceInitialProvider = '' - }} - > - - - - -
- {#key [aiResourceInitialPath, aiResourceInitialProvider, usingOpenaiClientCredentialsOauth, selected]} - { - editCopilotConfig(ev.detail, selected) - }} - /> - - {/key} -
-
- { - editCopilotConfig(aiResourceInitialPath || '', aiResourceInitialProvider || '') + +
+ { + aiResourcePath = '' + aiModels = [] + codeCompletionModel = undefined }} - /> + > + + + + + + + + +
+ {#key aiProvider} + { + if (aiResourcePath && aiModels.length === 0) { + if (aiProvider !== 'customai') { + aiModels = AI_DEFAULT_MODELS[aiProvider].slice(0, 1) + } + } + }} + /> + + {/key} +
+ + {#if aiResourcePath} + + +
+ { + if (codeCompletionModel != undefined) { + codeCompletionModel = undefined + } else { + codeCompletionModel = AI_DEFAULT_MODELS[aiProvider][0] ?? '' + } + }} + checked={codeCompletionModel != undefined} + options={{ + right: 'Code completion' + }} + /> + + {#if codeCompletionModel != undefined} + + {/if} +
+ {/if} +
{:else if tab == 'windmill_lfs'}
diff --git a/lsp/Pipfile b/lsp/Pipfile index 940df30fff..1d3455f2d3 100644 --- a/lsp/Pipfile +++ b/lsp/Pipfile @@ -4,8 +4,8 @@ verify_ssl = true name = "pypi" [packages] -wmill = ">=1.456.0" -wmill_pg = ">=1.456.0" +wmill = ">=1.457.1" +wmill_pg = ">=1.457.1" sendgrid = "*" mysql-connector-python = "*" pymongo = "*" diff --git a/openflow.openapi.yaml b/openflow.openapi.yaml index 2198173813..d97e836e13 100644 --- a/openflow.openapi.yaml +++ b/openflow.openapi.yaml @@ -1,7 +1,7 @@ openapi: "3.0.3" info: - version: 1.456.0 + version: 1.457.1 title: OpenFlow Spec contact: name: Ruben Fiszel diff --git a/powershell-client/WindmillClient/WindmillClient.psd1 b/powershell-client/WindmillClient/WindmillClient.psd1 index aac05daa78..e054d66015 100644 --- a/powershell-client/WindmillClient/WindmillClient.psd1 +++ b/powershell-client/WindmillClient/WindmillClient.psd1 @@ -12,7 +12,7 @@ RootModule = 'WindmillClient.psm1' # Version number of this module. - ModuleVersion = '1.456.0' + ModuleVersion = '1.457.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/python-client/wmill/pyproject.toml b/python-client/wmill/pyproject.toml index 0ee4ed7b5b..cceed926f8 100644 --- a/python-client/wmill/pyproject.toml +++ b/python-client/wmill/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wmill" -version = "1.456.0" +version = "1.457.1" description = "A client library for accessing Windmill server wrapping the Windmill client API" license = "Apache-2.0" homepage = "https://windmill.dev" diff --git a/python-client/wmill_pg/pyproject.toml b/python-client/wmill_pg/pyproject.toml index 2c213d557c..fba1ddaf2a 100644 --- a/python-client/wmill_pg/pyproject.toml +++ b/python-client/wmill_pg/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wmill-pg" -version = "1.456.0" +version = "1.457.1" description = "An extension client for the wmill client library focused on pg" license = "Apache-2.0" homepage = "https://windmill.dev" diff --git a/typescript-client/jsr.json b/typescript-client/jsr.json index 0947f2c0ad..51472921d2 100644 --- a/typescript-client/jsr.json +++ b/typescript-client/jsr.json @@ -1,6 +1,6 @@ { "name": "@windmill/windmill", - "version": "1.456.0", + "version": "1.457.1", "exports": "./src/index.ts", "publish": { "exclude": ["!src", "./s3Types.ts", "./client.ts"] diff --git a/typescript-client/package.json b/typescript-client/package.json index 347362bc92..e4e9f2dcf5 100644 --- a/typescript-client/package.json +++ b/typescript-client/package.json @@ -1,7 +1,7 @@ { "name": "windmill-client", "description": "Windmill SDK client for browsers and Node.js", - "version": "1.456.0", + "version": "1.457.1", "author": "Ruben Fiszel", "license": "Apache 2.0", "devDependencies": { diff --git a/version.txt b/version.txt index aaa526a611..fd1d44e234 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.456.0 +1.457.1