From 1d0807f54238c8d8d242e3e5534c6d0868b3172b Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 13 Aug 2024 16:17:20 +0200 Subject: [PATCH 01/17] fix(apps): improve tanstack table handling of objects --- .../components/apps/components/display/table/AppCell.svelte | 6 +++++- .../apps/components/display/table/AppTableFooter.svelte | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/apps/components/display/table/AppCell.svelte b/frontend/src/lib/components/apps/components/display/table/AppCell.svelte index 97eaea3635..f4abc40ade 100644 --- a/frontend/src/lib/components/apps/components/display/table/AppCell.svelte +++ b/frontend/src/lib/components/apps/components/display/table/AppCell.svelte @@ -80,7 +80,11 @@ {:else}
- {value} + {#if typeof value == 'object'} + {JSON.stringify(value)} + {:else} + {value} + {/if}
{/if} diff --git a/frontend/src/lib/components/apps/components/display/table/AppTableFooter.svelte b/frontend/src/lib/components/apps/components/display/table/AppTableFooter.svelte index b3dcbb33d3..e0ab15a500 100644 --- a/frontend/src/lib/components/apps/components/display/table/AppTableFooter.svelte +++ b/frontend/src/lib/components/apps/components/display/table/AppTableFooter.svelte @@ -28,8 +28,11 @@ for (let i = 0; i < objArray.length; i++) { let line = '' for (let j = 0; j < headers.length; j++) { - const value = objArray[i][headers[j]] + let value = objArray[i][headers[j]] line += j ? ',' : '' + if (typeof value != 'string') { + value = JSON.stringify(value) + } line += /[\",\n]/.test(value) ? '"' + value.replace(/"/g, '""') + '"' : value } str += line + '\r\n' From 95a898a5d52468c255ce336d7d1b6a6ad24f3d1b Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 13 Aug 2024 17:06:51 +0200 Subject: [PATCH 02/17] fix compile --- ...52f42d315eabb34c96133b69542b01232295c26cc9e093c372f9.json} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename backend/.sqlx/{query-44d0c89afbc472165d80ca7a14b391bc2e5c44e0953103790dfe9375f605ee65.json => query-28a878c59b6d52f42d315eabb34c96133b69542b01232295c26cc9e093c372f9.json} (55%) diff --git a/backend/.sqlx/query-44d0c89afbc472165d80ca7a14b391bc2e5c44e0953103790dfe9375f605ee65.json b/backend/.sqlx/query-28a878c59b6d52f42d315eabb34c96133b69542b01232295c26cc9e093c372f9.json similarity index 55% rename from backend/.sqlx/query-44d0c89afbc472165d80ca7a14b391bc2e5c44e0953103790dfe9375f605ee65.json rename to backend/.sqlx/query-28a878c59b6d52f42d315eabb34c96133b69542b01232295c26cc9e093c372f9.json index 4005465103..fcdf2ac38d 100644 --- a/backend/.sqlx/query-44d0c89afbc472165d80ca7a14b391bc2e5c44e0953103790dfe9375f605ee65.json +++ b/backend/.sqlx/query-28a878c59b6d52f42d315eabb34c96133b69542b01232295c26cc9e093c372f9.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT coalesce(COUNT(*) FILTER(WHERE suspend = 0), 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() AND running = false", + "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 queue WHERE (workspace_id = $1 OR $2) AND scheduled_for <= now()", "describe": { "columns": [ { @@ -25,5 +25,5 @@ null ] }, - "hash": "44d0c89afbc472165d80ca7a14b391bc2e5c44e0953103790dfe9375f605ee65" + "hash": "28a878c59b6d52f42d315eabb34c96133b69542b01232295c26cc9e093c372f9" } From f00545f1691c5107d1103f89bf68fdc3915ddd82 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 13 Aug 2024 18:00:50 +0200 Subject: [PATCH 03/17] fix: add an option to disable bundling globally --- backend/windmill-common/src/worker.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/windmill-common/src/worker.rs b/backend/windmill-common/src/worker.rs index 4e6e7d7d50..292a4aef2e 100644 --- a/backend/windmill-common/src/worker.rs +++ b/backend/windmill-common/src/worker.rs @@ -78,6 +78,11 @@ lazy_static::lazy_static! { static ref CUSTOM_TAG_REGEX: Regex = Regex::new(r"^(\w+)\(((?:\w+)\+?)+\)$").unwrap(); + pub static ref DISABLE_BUNDLING: bool = std::env::var("DISABLE_BUNDLING") + .ok() + .and_then(|x| x.parse::().ok()) + .unwrap_or(false); + } pub async fn make_suspended_pull_query(wc: &WorkerConfig) { @@ -232,7 +237,8 @@ pub fn get_annotation(inner_content: &str) -> Annotations { let native_mode: bool = annotations.contains(&"native".to_string()); //TODO: remove || npm_mode when bun build is more powerful - let nobundling: bool = annotations.contains(&"nobundling".to_string()) || nodejs_mode; + let nobundling: bool = + annotations.contains(&"nobundling".to_string()) || nodejs_mode || *DISABLE_BUNDLING; Annotations { npm_mode, nodejs_mode, native_mode, nobundling } } From 41bf933fb73b4aafd7f9c9a0be10543e39227004 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 13 Aug 2024 18:04:08 +0200 Subject: [PATCH 04/17] chore(main): release 1.379.1 (#4231) * chore(main): release 1.379.1 * Apply automatic changes --------- Co-authored-by: rubenfiszel --- CHANGELOG.md | 8 ++++ backend/Cargo.lock | 40 +++++++++---------- backend/Cargo.toml | 4 +- backend/windmill-api/openapi.yaml | 2 +- benchmarks/lib.ts | 2 +- cli/main.ts | 2 +- frontend/package-lock.json | 4 +- frontend/package.json | 2 +- lsp/Pipfile | 4 +- openflow.openapi.yaml | 2 +- .../WindmillClient/WindmillClient.psd1 | 2 +- python-client/wmill/pyproject.toml | 2 +- python-client/wmill_pg/pyproject.toml | 2 +- typescript-client/jsr.json | 2 +- typescript-client/package.json | 2 +- version.txt | 2 +- 16 files changed, 45 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfcd62c85f..6dccae9fea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [1.379.1](https://github.com/windmill-labs/windmill/compare/v1.379.0...v1.379.1) (2024-08-13) + + +### Bug Fixes + +* add an option to disable bundling globally ([f00545f](https://github.com/windmill-labs/windmill/commit/f00545f1691c5107d1103f89bf68fdc3915ddd82)) +* **apps:** improve tanstack table handling of objects ([1d0807f](https://github.com/windmill-labs/windmill/commit/1d0807f54238c8d8d242e3e5534c6d0868b3172b)) + ## [1.379.0](https://github.com/windmill-labs/windmill/compare/v1.378.0...v1.379.0) (2024-08-13) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index ecd7f3495b..38c653792b 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -10398,7 +10398,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windmill" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "axum", @@ -10438,7 +10438,7 @@ dependencies = [ [[package]] name = "windmill-api" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "argon2", @@ -10522,7 +10522,7 @@ dependencies = [ [[package]] name = "windmill-api-client" -version = "1.379.0" +version = "1.379.1" dependencies = [ "base64 0.21.7", "chrono", @@ -10540,7 +10540,7 @@ dependencies = [ [[package]] name = "windmill-audit" -version = "1.379.0" +version = "1.379.1" dependencies = [ "chrono", "serde", @@ -10553,7 +10553,7 @@ dependencies = [ [[package]] name = "windmill-common" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "async-stream", @@ -10594,7 +10594,7 @@ dependencies = [ [[package]] name = "windmill-git-sync" -version = "1.379.0" +version = "1.379.1" dependencies = [ "regex", "rsmq_async", @@ -10609,7 +10609,7 @@ dependencies = [ [[package]] name = "windmill-indexer" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "bytes", @@ -10630,7 +10630,7 @@ dependencies = [ [[package]] name = "windmill-parser" -version = "1.379.0" +version = "1.379.1" dependencies = [ "serde", "serde_json", @@ -10638,7 +10638,7 @@ dependencies = [ [[package]] name = "windmill-parser-bash" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "lazy_static", @@ -10649,7 +10649,7 @@ dependencies = [ [[package]] name = "windmill-parser-go" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "gosyn", @@ -10661,7 +10661,7 @@ dependencies = [ [[package]] name = "windmill-parser-graphql" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "lazy_static", @@ -10672,7 +10672,7 @@ dependencies = [ [[package]] name = "windmill-parser-php" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -10686,7 +10686,7 @@ dependencies = [ [[package]] name = "windmill-parser-py" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "itertools 0.13.0", @@ -10697,7 +10697,7 @@ dependencies = [ [[package]] name = "windmill-parser-py-imports" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "async-recursion", @@ -10714,7 +10714,7 @@ dependencies = [ [[package]] name = "windmill-parser-sql" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "lazy_static", @@ -10725,7 +10725,7 @@ dependencies = [ [[package]] name = "windmill-parser-ts" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -10744,7 +10744,7 @@ dependencies = [ [[package]] name = "windmill-parser-wasm" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "getrandom 0.2.15", @@ -10763,7 +10763,7 @@ dependencies = [ [[package]] name = "windmill-queue" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "async-recursion", @@ -10796,7 +10796,7 @@ dependencies = [ [[package]] name = "windmill-sql-datatype-parser-wasm" -version = "1.379.0" +version = "1.379.1" dependencies = [ "wasm-bindgen", "wasm-bindgen-test", @@ -10806,7 +10806,7 @@ dependencies = [ [[package]] name = "windmill-worker" -version = "1.379.0" +version = "1.379.1" dependencies = [ "anyhow", "async-recursion", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index f55145399e..a8e6d052f9 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windmill" -version = "1.379.0" +version = "1.379.1" authors.workspace = true edition.workspace = true @@ -25,7 +25,7 @@ members = [ ] [workspace.package] -version = "1.379.0" +version = "1.379.1" authors = ["Ruben Fiszel "] edition = "2021" diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index f1710b526f..fc798eb170 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -1,7 +1,7 @@ openapi: "3.0.3" info: - version: 1.379.0 + version: 1.379.1 title: Windmill API contact: diff --git a/benchmarks/lib.ts b/benchmarks/lib.ts index 458aa1f44c..ba2018904b 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.379.0"; +export const VERSION = "v1.379.1"; export async function login(email: string, password: string): Promise { return await windmill.UserService.login({ diff --git a/cli/main.ts b/cli/main.ts index 4fb7e6a3a5..0426a554a1 100644 --- a/cli/main.ts +++ b/cli/main.ts @@ -34,7 +34,7 @@ addEventListener("error", (event) => { } }); -export const VERSION = "v1.379.0"; +export const VERSION = "v1.379.1"; let command: any = new Command() .name("wmill") diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 67b8ce8c0a..cf7c437ab6 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "windmill-components", - "version": "1.379.0", + "version": "1.379.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "windmill-components", - "version": "1.379.0", + "version": "1.379.1", "license": "AGPL-3.0", "dependencies": { "@aws-crypto/sha256-js": "^4.0.0", diff --git a/frontend/package.json b/frontend/package.json index 3839c0f933..737f6e340d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "windmill-components", - "version": "1.379.0", + "version": "1.379.1", "scripts": { "dev": "vite dev", "build": "vite build", diff --git a/lsp/Pipfile b/lsp/Pipfile index 3c596f0e9c..192ae66cc8 100644 --- a/lsp/Pipfile +++ b/lsp/Pipfile @@ -4,8 +4,8 @@ verify_ssl = true name = "pypi" [packages] -wmill = ">=1.379.0" -wmill_pg = ">=1.379.0" +wmill = ">=1.379.1" +wmill_pg = ">=1.379.1" sendgrid = "*" mysql-connector-python = "*" pymongo = "*" diff --git a/openflow.openapi.yaml b/openflow.openapi.yaml index 8db518f604..beb69a0fbc 100644 --- a/openflow.openapi.yaml +++ b/openflow.openapi.yaml @@ -1,7 +1,7 @@ openapi: "3.0.3" info: - version: 1.379.0 + version: 1.379.1 title: OpenFlow Spec contact: name: Ruben Fiszel diff --git a/powershell-client/WindmillClient/WindmillClient.psd1 b/powershell-client/WindmillClient/WindmillClient.psd1 index cf3c84b38b..9400c36174 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.379.0' +ModuleVersion = '1.379.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/python-client/wmill/pyproject.toml b/python-client/wmill/pyproject.toml index c7c4d88a04..84cb8f609e 100644 --- a/python-client/wmill/pyproject.toml +++ b/python-client/wmill/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wmill" -version = "1.379.0" +version = "1.379.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 eb69306e25..a3c3bc0485 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.379.0" +version = "1.379.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 901967a9f7..9d67e686c9 100644 --- a/typescript-client/jsr.json +++ b/typescript-client/jsr.json @@ -1,6 +1,6 @@ { "name": "@windmill/windmill", - "version": "1.379.0", + "version": "1.379.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 f6bc81f22e..16e21f990c 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.379.0", + "version": "1.379.1", "author": "Ruben Fiszel", "license": "Apache 2.0", "devDependencies": { diff --git a/version.txt b/version.txt index 0c1fce71d6..e9be85d464 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.379.0 +1.379.1 From b424c61e95e3cc9213d4d3efbe4173857d4e80fd Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 13 Aug 2024 18:45:55 +0200 Subject: [PATCH 05/17] fix(frontend): date input is more flexible and accept default html format as a fallback --- frontend/src/lib/components/DateInput.svelte | 27 ++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/frontend/src/lib/components/DateInput.svelte b/frontend/src/lib/components/DateInput.svelte index ad4c17c2d7..eb4b650c76 100644 --- a/frontend/src/lib/components/DateInput.svelte +++ b/frontend/src/lib/components/DateInput.svelte @@ -1,6 +1,7 @@ { let { job } = detail if (job.script_path != lastScriptPath && job.script_path) { diff --git a/frontend/src/lib/components/FlowStatusViewerInner.svelte b/frontend/src/lib/components/FlowStatusViewerInner.svelte index bc4fe65e62..c875fd1e30 100644 --- a/frontend/src/lib/components/FlowStatusViewerInner.svelte +++ b/frontend/src/lib/components/FlowStatusViewerInner.svelte @@ -69,6 +69,7 @@ export let reducedPolling = false export let wideResults = false + export let hideFlowResult = false let jobResults: any[] = flowJobIds?.flowJobs?.map((x, id) => `iter #${id + 1} not loaded by frontend yet`) ?? [] @@ -642,16 +643,18 @@ {:else if `result` in job} -
- -
+ {#if !hideFlowResult} +
+ +
+ {/if} {:else if job.flow_status?.modules?.[job?.flow_status?.step]?.type === 'WaitingForEvents'} {:else if $suspendStatus && Object.keys($suspendStatus).length > 0} diff --git a/frontend/src/lib/components/common/table/AppRow.svelte b/frontend/src/lib/components/common/table/AppRow.svelte index 93afe04815..1ec6540b85 100644 --- a/frontend/src/lib/components/common/table/AppRow.svelte +++ b/frontend/src/lib/components/common/table/AppRow.svelte @@ -33,9 +33,10 @@ import { goto as gotoUrl } from '$app/navigation' import { page } from '$app/stores' import type DeployWorkspaceDrawer from '$lib/components/DeployWorkspaceDrawer.svelte' - import { DELETE, copyToClipboard, isDeployable } from '$lib/utils' + import { DELETE, copyToClipboard } from '$lib/utils' import AppDeploymentHistory from '$lib/components/apps/editor/AppDeploymentHistory.svelte' import AppJsonEditor from '$lib/components/apps/editor/AppJsonEditor.svelte' + import { isDeployable } from '$lib/utils_deployable' export let app: ListableApp & { has_draft?: boolean; draft_only?: boolean; canWrite: boolean } export let marked: string | undefined diff --git a/frontend/src/lib/components/common/table/FlowRow.svelte b/frontend/src/lib/components/common/table/FlowRow.svelte index ab73ba060e..6e96465f02 100644 --- a/frontend/src/lib/components/common/table/FlowRow.svelte +++ b/frontend/src/lib/components/common/table/FlowRow.svelte @@ -14,7 +14,9 @@ import Row from './Row.svelte' import DraftBadge from '$lib/components/DraftBadge.svelte' import { sendUserToast } from '$lib/toast' - import { DELETE, copyToClipboard, isDeployable, isOwner } from '$lib/utils' + import { DELETE, copyToClipboard, isOwner } from '$lib/utils' + import { isDeployable } from '$lib/utils_deployable' + import type DeployWorkspaceDrawer from '$lib/components/DeployWorkspaceDrawer.svelte' import { Pen, diff --git a/frontend/src/lib/components/common/table/RawAppRow.svelte b/frontend/src/lib/components/common/table/RawAppRow.svelte index 615de50e64..e40f59a76f 100644 --- a/frontend/src/lib/components/common/table/RawAppRow.svelte +++ b/frontend/src/lib/components/common/table/RawAppRow.svelte @@ -15,7 +15,7 @@ import { goto } from '$lib/navigation' import type DeployWorkspaceDrawer from '$lib/components/DeployWorkspaceDrawer.svelte' import { FileUp, Globe, Pen, Share, Trash } from 'lucide-svelte' - import { isDeployable } from '$lib/utils' + import { isDeployable } from '$lib/utils_deployable' export let app: ListableRawApp & { canWrite: boolean } export let marked: string | undefined diff --git a/frontend/src/lib/components/common/table/ScriptRow.svelte b/frontend/src/lib/components/common/table/ScriptRow.svelte index 12acd2774c..a962e17c32 100644 --- a/frontend/src/lib/components/common/table/ScriptRow.svelte +++ b/frontend/src/lib/components/common/table/ScriptRow.svelte @@ -21,7 +21,9 @@ import Row from './Row.svelte' import DraftBadge from '$lib/components/DraftBadge.svelte' import { sendUserToast } from '$lib/toast' - import { copyToClipboard, DELETE, isDeployable, isOwner } from '$lib/utils' + import { copyToClipboard, DELETE, isOwner } from '$lib/utils' + import { isDeployable } from '$lib/utils_deployable' + import type DeployWorkspaceDrawer from '$lib/components/DeployWorkspaceDrawer.svelte' import { LanguageIcon } from '../languageIcons' import { diff --git a/frontend/src/lib/components/home/Item.svelte b/frontend/src/lib/components/home/Item.svelte index 2e7b3c6967..ccaabb68b0 100644 --- a/frontend/src/lib/components/home/Item.svelte +++ b/frontend/src/lib/components/home/Item.svelte @@ -12,7 +12,7 @@ import { ArrowBigUp } from 'lucide-svelte' import { enterpriseLicense, workspaceStore } from '$lib/stores' import { WorkspaceService, type WorkspaceDeployUISettings } from '$lib/gen' - import { ALL_DEPLOYABLE } from '$lib/utils' + import { ALL_DEPLOYABLE } from '$lib/utils_deployable' export let item export let depth: number = 0 diff --git a/frontend/src/lib/forLater.ts b/frontend/src/lib/forLater.ts index ecbf221545..ea290e2a53 100644 --- a/frontend/src/lib/forLater.ts +++ b/frontend/src/lib/forLater.ts @@ -1,6 +1,7 @@ import { get } from 'svelte/store' import { dbClockDrift } from './stores' import { JobService } from './gen' +import pLimit from 'p-limit' function subtractSeconds(date: Date, seconds: number): Date { date.setSeconds(date.getSeconds() - seconds) @@ -12,19 +13,22 @@ function adjustDate(drift: number): Date { } export async function computeDrift() { - const now = Date.now() - const dbClock = await JobService.getDbClock() - dbClockDrift.set(dbClock - now) + if (get(dbClockDrift) == undefined) { + const now = Date.now() + const dbClock = await JobService.getDbClock() + dbClockDrift.set(dbClock - now) + } } export function forLater(scheduledString: string): boolean { return getDbClockNow() < subtractSeconds(new Date(scheduledString), 5) } +const limit = pLimit(1) export function getDbClockNow() { let drift = get(dbClockDrift) if (drift == undefined) { - computeDrift() + limit(() => computeDrift()) drift = 0 } return adjustDate(drift) diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 896e3a73a4..1a278c9c79 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -14,7 +14,6 @@ import { sendUserToast } from './toast' import type { Script, WorkspaceDeployUISettings } from './gen' import type { EnumType, SchemaProperty } from './common' import type { Schema } from './common' -import { minimatch } from 'minimatch' export { sendUserToast } export function validateUsername(username: string): string { @@ -941,34 +940,3 @@ export function getSchemaFromProperties(properties: { [name: string]: SchemaProp order: Object.keys(properties).filter((k) => k !== 'label') } } - -type DeployUIType = 'script' | 'flow' | 'app' | 'resource' | 'variable' | 'secret' - -export function isDeployable( - type: DeployUIType, - path: string, - deployUiSettings: WorkspaceDeployUISettings | undefined -) { - if (deployUiSettings == undefined) { - return false - } - - if (deployUiSettings.include_type != undefined && !deployUiSettings.include_type.includes(type)) { - return false - } - - if ( - deployUiSettings.include_path != undefined && - deployUiSettings.include_path.length != 0 && - deployUiSettings.include_path.every((x) => !minimatch(path, x)) - ) { - return false - } - - return true -} - -export const ALL_DEPLOYABLE: WorkspaceDeployUISettings = { - include_path: [], - include_type: ['script', 'flow', 'app', 'resource', 'variable', 'secret'] -} diff --git a/frontend/src/lib/utils_deployable.ts b/frontend/src/lib/utils_deployable.ts new file mode 100644 index 0000000000..9a8efc6ef8 --- /dev/null +++ b/frontend/src/lib/utils_deployable.ts @@ -0,0 +1,33 @@ +import { minimatch } from 'minimatch' +import type { WorkspaceDeployUISettings } from './gen' + +type DeployUIType = 'script' | 'flow' | 'app' | 'resource' | 'variable' | 'secret' + +export function isDeployable( + type: DeployUIType, + path: string, + deployUiSettings: WorkspaceDeployUISettings | undefined +) { + if (deployUiSettings == undefined) { + return false + } + + if (deployUiSettings.include_type != undefined && !deployUiSettings.include_type.includes(type)) { + return false + } + + if ( + deployUiSettings.include_path != undefined && + deployUiSettings.include_path.length != 0 && + deployUiSettings.include_path.every((x) => !minimatch(path, x)) + ) { + return false + } + + return true +} + +export const ALL_DEPLOYABLE: WorkspaceDeployUISettings = { + include_path: [], + include_type: ['script', 'flow', 'app', 'resource', 'variable', 'secret'] +} diff --git a/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte index 76973ddeac..eeea7c7ff7 100644 --- a/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte @@ -8,7 +8,8 @@ type FlowModule, type WorkspaceDeployUISettings } from '$lib/gen' - import { ALL_DEPLOYABLE, canWrite, defaultIfEmptyString, emptyString, isDeployable } from '$lib/utils' + import { canWrite, defaultIfEmptyString, emptyString } from '$lib/utils' + import { isDeployable, ALL_DEPLOYABLE } from '$lib/utils_deployable' import DetailPageLayout from '$lib/components/details/DetailPageLayout.svelte' import { goto } from '$lib/navigation' diff --git a/frontend/src/routes/(root)/(logged)/resources/+page.svelte b/frontend/src/routes/(root)/(logged)/resources/+page.svelte index 14cf5166a8..87b5b0cd4b 100644 --- a/frontend/src/routes/(root)/(logged)/resources/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/resources/+page.svelte @@ -31,7 +31,9 @@ import { OauthService, ResourceService, WorkspaceService, type ListableResource } from '$lib/gen' import { enterpriseLicense, userStore, workspaceStore } from '$lib/stores' import { sendUserToast } from '$lib/toast' - import { ALL_DEPLOYABLE, canWrite, classNames, emptySchema, isDeployable, removeMarkdown, truncate } from '$lib/utils' + import { canWrite, classNames, emptySchema, removeMarkdown, truncate } from '$lib/utils' + import { isDeployable, ALL_DEPLOYABLE } from '$lib/utils_deployable' + import { convert } from '@redocly/json-to-json-schema' import { Braces, diff --git a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte index bdf1ffca5a..0b7229d65f 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte @@ -1,20 +1,19 @@