diff --git a/.eslintrc.json b/.eslintrc.json index a94ea87704..4e6a169dae 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -27,9 +27,8 @@ "extends": "plugin:svelte/recommended", "parser": "svelte-eslint-parser", "parserOptions": { - "parser": "@babel/eslint-parser", + "parser": "@typescript-eslint/parser", "ecmaVersion": 2019, - "sourceType": "module", "allowImportExportEverywhere": true } }, diff --git a/charts/budibase/templates/secrets.yaml b/charts/budibase/templates/secrets.yaml index a44d2c0d9b..20701d4125 100644 --- a/charts/budibase/templates/secrets.yaml +++ b/charts/budibase/templates/secrets.yaml @@ -12,12 +12,12 @@ metadata: type: Opaque data: {{- if $existingSecret }} - internalApiKey: {{ index $existingSecret.data "internalApiKey" }} - jwtSecret: {{ index $existingSecret.data "jwtSecret" }} - objectStoreAccess: {{ index $existingSecret.data "objectStoreAccess" }} - objectStoreSecret: {{ index $existingSecret.data "objectStoreSecret" }} - bbEncryptionKey: {{ index $existingSecret.data "bbEncryptionKey" }} - apiEncryptionKey: {{ index $existingSecret.data "apiEncryptionKey" }} + internalApiKey: {{ index $existingSecret.data "internalApiKey" | quote }} + jwtSecret: {{ index $existingSecret.data "jwtSecret" | quote }} + objectStoreAccess: {{ index $existingSecret.data "objectStoreAccess" | quote }} + objectStoreSecret: {{ index $existingSecret.data "objectStoreSecret" | quote }} + bbEncryptionKey: {{ index $existingSecret.data "bbEncryptionKey" | quote }} + apiEncryptionKey: {{ index $existingSecret.data "apiEncryptionKey" | quote }} {{- else }} internalApiKey: {{ template "budibase.defaultsecret" .Values.globals.internalApiKey }} jwtSecret: {{ template "budibase.defaultsecret" .Values.globals.jwtSecret }} diff --git a/packages/bbui/src/Button/Button.svelte b/packages/bbui/src/Button/Button.svelte index 0a8917c3c1..77653d0c42 100644 --- a/packages/bbui/src/Button/Button.svelte +++ b/packages/bbui/src/Button/Button.svelte @@ -3,7 +3,7 @@ import AbsTooltip from "../Tooltip/AbsTooltip.svelte" import { createEventDispatcher } from "svelte" - export let type + export let type = undefined export let disabled = false export let size = "M" export let cta = false @@ -16,8 +16,8 @@ export let active = false export let tooltip = undefined export let newStyles = true - export let id - export let ref + export let id = undefined + export let ref = undefined export let reverse = false const dispatch = createEventDispatcher() diff --git a/packages/bbui/src/Form/Core/DateRangePicker.svelte b/packages/bbui/src/Form/Core/DateRangePicker.svelte index 9084942ba7..72180a98d6 100644 --- a/packages/bbui/src/Form/Core/DateRangePicker.svelte +++ b/packages/bbui/src/Form/Core/DateRangePicker.svelte @@ -2,13 +2,6 @@ import CoreDatePicker from "./DatePicker/DatePicker.svelte" import Icon from "../../Icon/Icon.svelte" - export let value = null - export let disabled = false - export let readonly = false - export let error = null - export let appendTo = undefined - export let ignoreTimezones = false - let fromDate let toDate diff --git a/packages/bbui/src/Form/Search.svelte b/packages/bbui/src/Form/Search.svelte index 2fbda275eb..a085986d3e 100644 --- a/packages/bbui/src/Form/Search.svelte +++ b/packages/bbui/src/Form/Search.svelte @@ -10,7 +10,7 @@ export let disabled = false export let updateOnChange = true export let quiet = false - export let inputRef + export let inputRef = undefined export let helpText = null const dispatch = createEventDispatcher() diff --git a/packages/bbui/src/Form/Select.svelte b/packages/bbui/src/Form/Select.svelte index 260090c7b7..0e67a1f532 100644 --- a/packages/bbui/src/Form/Select.svelte +++ b/packages/bbui/src/Form/Select.svelte @@ -17,18 +17,18 @@ export let getOptionIcon = option => option?.icon export let getOptionColour = option => option?.colour export let useOptionIconImage = false - export let isOptionEnabled + export let isOptionEnabled = undefined export let quiet = false export let autoWidth = false export let sort = false export let tooltip = "" export let autocomplete = false - export let customPopoverHeight - export let align + export let customPopoverHeight = undefined + export let align = undefined export let footer = null export let tag = null export let helpText = null - export let compare + export let compare = undefined export let onOptionMouseenter = () => {} export let onOptionMouseleave = () => {} diff --git a/packages/bbui/src/Table/Table.svelte b/packages/bbui/src/Table/Table.svelte index 3916bec738..228838e477 100644 --- a/packages/bbui/src/Table/Table.svelte +++ b/packages/bbui/src/Table/Table.svelte @@ -43,7 +43,7 @@ export let showHeaderBorder = true export let placeholderText = "No rows found" export let snippets = [] - export let defaultSortColumn + export let defaultSortColumn = undefined export let defaultSortOrder = "Ascending" const dispatch = createEventDispatcher() diff --git a/packages/bbui/src/Typography/Heading.svelte b/packages/bbui/src/Typography/Heading.svelte index 50522fffc3..90d53fb208 100644 --- a/packages/bbui/src/Typography/Heading.svelte +++ b/packages/bbui/src/Typography/Heading.svelte @@ -1,9 +1,9 @@ - diff --git a/packages/builder/.gitignore b/packages/builder/.gitignore index abc5671984..41411ea16c 100644 --- a/packages/builder/.gitignore +++ b/packages/builder/.gitignore @@ -6,4 +6,4 @@ release/ dist/ routify .routify/ -svelte.config.js \ No newline at end of file +.rollup.cache \ No newline at end of file diff --git a/packages/builder/package.json b/packages/builder/package.json index 46e454f5b9..c98e817486 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -4,13 +4,14 @@ "license": "GPL-3.0", "private": true, "scripts": { - "build": "routify -b && vite build --emptyOutDir", + "build": "routify -b && NODE_OPTIONS=\"--max_old_space_size=4096\" vite build --emptyOutDir", "start": "routify -c rollup", "dev": "routify -c dev:vite", "dev:vite": "vite --host 0.0.0.0", "rollup": "rollup -c -w", "test": "vitest run", - "test:watch": "vitest" + "test:watch": "vitest", + "check:types": "yarn svelte-check" }, "jest": { "globals": { @@ -88,6 +89,7 @@ "@babel/plugin-transform-runtime": "^7.13.10", "@babel/preset-env": "^7.13.12", "@rollup/plugin-replace": "^5.0.3", + "@rollup/plugin-typescript": "8.3.0", "@roxi/routify": "2.18.12", "@sveltejs/vite-plugin-svelte": "1.4.0", "@testing-library/jest-dom": "6.4.2", @@ -97,6 +99,7 @@ "jest": "29.7.0", "jsdom": "^21.1.1", "resize-observer-polyfill": "^1.5.1", + "svelte-check": "^4.1.0", "svelte-jester": "^1.3.2", "vite": "^4.5.0", "vite-plugin-static-copy": "^0.17.0", diff --git a/packages/builder/src/api.js b/packages/builder/src/api.ts similarity index 87% rename from packages/builder/src/api.js rename to packages/builder/src/api.ts index 6441b4ff48..5d1a0beaeb 100644 --- a/packages/builder/src/api.js +++ b/packages/builder/src/api.ts @@ -8,7 +8,7 @@ import { get } from "svelte/store" import { auth, navigation } from "./stores/portal" export const API = createAPIClient({ - attachHeaders: headers => { + attachHeaders: (headers: Record) => { // Attach app ID header from store let appId = get(appStore).appId if (appId) { @@ -16,13 +16,13 @@ export const API = createAPIClient({ } // Add csrf token if authenticated - const user = get(auth).user + const user: any = get(auth).user if (user?.csrfToken) { headers["x-csrf-token"] = user.csrfToken } }, - onError: error => { + onError: (error: any) => { const { url, message, status, method, handled } = error || {} // Log any errors that we haven't manually handled @@ -45,14 +45,14 @@ export const API = createAPIClient({ } } }, - onMigrationDetected: appId => { + onMigrationDetected: (appId: string) => { const updatingUrl = `/builder/app/updating/${appId}` if (window.location.pathname === updatingUrl) { return } - get(navigation).goto( + get(navigation)?.goto( `${updatingUrl}?returnUrl=${encodeURIComponent(window.location.pathname)}` ) }, diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index b16533c2ca..b901d21a6d 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -114,7 +114,7 @@ $: schemaFields = search.getFields( $tables.list, Object.values(schema || {}), - { allowLinks: true } + { allowLinks: false } ) $: queryLimit = tableId?.includes("datasource") ? "∞" : "1000" $: isTrigger = $memoBlock?.type === AutomationStepType.TRIGGER diff --git a/packages/builder/src/dataBinding.js b/packages/builder/src/dataBinding.js index 8adc27ee59..c89221f163 100644 --- a/packages/builder/src/dataBinding.js +++ b/packages/builder/src/dataBinding.js @@ -1141,10 +1141,11 @@ export const buildFormSchema = (component, asset) => { const fieldSetting = settings.find( setting => setting.key === "field" && setting.type.startsWith("field/") ) - if (fieldSetting && component.field) { + if (fieldSetting) { const type = fieldSetting.type.split("field/")[1] - if (type) { - schema[component.field] = { type } + const key = component.field || component._instanceName + if (type && key) { + schema[key] = { type } } } component._children?.forEach(child => { diff --git a/packages/builder/src/index.d.ts b/packages/builder/src/index.d.ts new file mode 100644 index 0000000000..1cbad4f12c --- /dev/null +++ b/packages/builder/src/index.d.ts @@ -0,0 +1,8 @@ +declare module "api" { + const API: { + getPlugins: () => Promise + createPlugin: (plugin: object) => Promise + uploadPlugin: (plugin: FormData) => Promise + deletePlugin: (id: string) => Promise + } +} diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte index b723788695..3757ed7dee 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte @@ -117,7 +117,4 @@ align-items: center; margin-bottom: 12px; } - - .tabs { - } diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ComponentList/DNDPositionIndicator.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ComponentList/DNDPositionIndicator.svelte index 4612440a2c..45185d8e2d 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ComponentList/DNDPositionIndicator.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ComponentList/DNDPositionIndicator.svelte @@ -50,8 +50,6 @@ border-radius: 4px; pointer-events: none; } - .indicator.above { - } .indicator.below { margin-top: 32px; } diff --git a/packages/builder/src/pages/builder/portal/plugins/index.svelte b/packages/builder/src/pages/builder/portal/plugins/index.svelte index d8dd4eae11..e16da42e10 100644 --- a/packages/builder/src/pages/builder/portal/plugins/index.svelte +++ b/packages/builder/src/pages/builder/portal/plugins/index.svelte @@ -1,4 +1,4 @@ - -
- {#key $component.editing} - - {/key} -
- {#if !formContext} - - {:else if !fieldState} - - {:else if schemaType && schemaType !== type && !["options", "longform"].includes(type)} - - {:else} - - {#if fieldState.error} -
- - {fieldState.error} -
- {:else if helpText} -
- {helpText} -
- {/if} - {/if} -
-
+ + + + + {:else} +
+ {#key $component.editing} + + {/key} +
+ {#if !fieldState} + + {:else if schemaType && schemaType !== type && !["options", "longform"].includes(type)} + + {:else} + + {#if fieldState.error} +
+ + {fieldState.error} +
+ {:else if helpText} +
+ {helpText} +
+ {/if} + {/if} +
+
+ {/if} +