diff --git a/lerna.json b/lerna.json index 12a3de8166..dd50fdf909 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.148-alpha.1", + "version": "1.0.151-alpha.2", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 3ef5607e96..858588c0ee 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.0.148-alpha.1", + "version": "1.0.151-alpha.2", "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 3acf509550..9cd9f2cbba 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.148-alpha.1", + "version": "1.0.151-alpha.2", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "^1.0.148-alpha.1", + "@budibase/string-templates": "^1.0.151-alpha.2", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index f5cb896c7a..5a58f2066e 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.148-alpha.1", + "version": "1.0.151-alpha.2", "license": "GPL-3.0", "private": true, "scripts": { @@ -67,10 +67,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.148-alpha.1", - "@budibase/client": "^1.0.148-alpha.1", - "@budibase/frontend-core": "^1.0.148-alpha.1", - "@budibase/string-templates": "^1.0.148-alpha.1", + "@budibase/bbui": "^1.0.151-alpha.2", + "@budibase/client": "^1.0.151-alpha.2", + "@budibase/frontend-core": "^1.0.151-alpha.2", + "@budibase/string-templates": "^1.0.151-alpha.2", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 1af40694a3..7b189ad109 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -53,6 +53,7 @@ : { schema: {} } $: schema = getSchemaForTable(tableId, { searchableSchema: true }).schema $: schemaFields = Object.values(schema || {}) + $: queryLimit = tableId?.includes("datasource") ? "∞" : "1000" const onChange = Utils.sequential(async (e, key) => { try { @@ -330,6 +331,7 @@ on:change={e => onChange(e, key)} {bindings} updateOnChange={false} + placeholder={value.customType === "queryLimit" ? queryLimit : ""} /> {/if} diff --git a/packages/builder/src/components/start/AppRow.svelte b/packages/builder/src/components/start/AppRow.svelte index f197c76fdd..d7ebbf63ef 100644 --- a/packages/builder/src/components/start/AppRow.svelte +++ b/packages/builder/src/components/start/AppRow.svelte @@ -12,6 +12,7 @@ export let appOverview export let releaseLock export let editIcon + export let copyAppId
@@ -75,6 +76,9 @@ unpublishApp(app)} icon="GlobeRemove"> Unpublish + copyAppId(app)} icon="Copy"> + Copy App ID + {/if} {#if !app.deployed} updateApp(app)} icon="Edit">Edit diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte index 291eef0821..2869db42ff 100644 --- a/packages/builder/src/pages/builder/portal/apps/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/index.svelte @@ -11,6 +11,7 @@ Body, Search, Divider, + Helpers, } from "@budibase/bbui" import TemplateDisplay from "components/common/TemplateDisplay.svelte" import Spinner from "components/common/Spinner.svelte" @@ -264,6 +265,11 @@ } } + const copyAppId = async app => { + await Helpers.copyToClipboard(app.prodId) + notifications.success("App ID copied to clipboard.") + } + function createAppFromTemplateUrl(templateKey) { // validate the template key just to make sure const templateParts = templateKey.split("/") @@ -412,6 +418,7 @@
{#each filteredApps as app (app.appId)} { let val = row[header] val = - typeof val === "object" + typeof val === "object" && !(val instanceof Date) ? `"${JSON.stringify(val).replace(/"/g, "'")}"` : `"${val}"` return val.trim() diff --git a/packages/server/src/automations/steps/queryRows.js b/packages/server/src/automations/steps/queryRows.js index 62f7659589..d4bc5fe076 100644 --- a/packages/server/src/automations/steps/queryRows.js +++ b/packages/server/src/automations/steps/queryRows.js @@ -50,6 +50,7 @@ exports.definition = { limit: { type: "number", title: "Limit", + customType: "queryLimit", }, }, required: ["tableId"], diff --git a/packages/server/src/integrations/postgres.ts b/packages/server/src/integrations/postgres.ts index 1da0ab31af..430a3f3461 100644 --- a/packages/server/src/integrations/postgres.ts +++ b/packages/server/src/integrations/postgres.ts @@ -147,7 +147,7 @@ module PostgresModule { return parts.join(" || ") } - async internalQuery(query: SqlQuery) { + async internalQuery(query: SqlQuery, close: boolean = true) { const client = this.client this.index = 1 // need to handle a specific issue with json data types in postgres, @@ -164,10 +164,11 @@ module PostgresModule { try { return await client.query(query.sql, query.bindings || []) } catch (err) { + await this.client.end() // @ts-ignore throw new Error(err) } finally { - await this.client.end() + if (close) await this.client.end() } } @@ -204,48 +205,54 @@ module PostgresModule { } } catch (err) { tableKeys = {} - } finally { - await this.client.close() } - const columnsResponse = await this.client.query(this.COLUMNS_SQL) - const tables: { [key: string]: Table } = {} + try { + const columnsResponse = await this.client.query(this.COLUMNS_SQL) - for (let column of columnsResponse.rows) { - const tableName: string = column.table_name - const columnName: string = column.column_name + const tables: { [key: string]: Table } = {} - // table key doesn't exist yet - if (!tables[tableName] || !tables[tableName].schema) { - tables[tableName] = { - _id: buildExternalTableId(datasourceId, tableName), - primary: tableKeys[tableName] || [], - name: tableName, - schema: {}, + for (let column of columnsResponse.rows) { + const tableName: string = column.table_name + const columnName: string = column.column_name + + // table key doesn't exist yet + if (!tables[tableName] || !tables[tableName].schema) { + tables[tableName] = { + _id: buildExternalTableId(datasourceId, tableName), + primary: tableKeys[tableName] || [], + name: tableName, + schema: {}, + } + } + + const identity = !!( + column.identity_generation || + column.identity_start || + column.identity_increment + ) + const hasDefault = + typeof column.column_default === "string" && + column.column_default.startsWith("nextval") + const isGenerated = + column.is_generated && column.is_generated !== "NEVER" + const isAuto: boolean = hasDefault || identity || isGenerated + tables[tableName].schema[columnName] = { + autocolumn: isAuto, + name: columnName, + ...convertSqlType(column.data_type), } } - const identity = !!( - column.identity_generation || - column.identity_start || - column.identity_increment - ) - const hasDefault = - typeof column.column_default === "string" && - column.column_default.startsWith("nextval") - const isGenerated = - column.is_generated && column.is_generated !== "NEVER" - const isAuto: boolean = hasDefault || identity || isGenerated - tables[tableName].schema[columnName] = { - autocolumn: isAuto, - name: columnName, - ...convertSqlType(column.data_type), - } + const final = finaliseExternalTables(tables, entities) + this.tables = final.tables + this.schemaErrors = final.errors + } catch (err) { + // @ts-ignore + throw new Error(err) + } finally { + await this.client.end() } - - const final = finaliseExternalTables(tables, entities) - this.tables = final.tables - this.schemaErrors = final.errors } async create(query: SqlQuery | string) { @@ -274,8 +281,9 @@ module PostgresModule { if (Array.isArray(input)) { const responses = [] for (let query of input) { - responses.push(await this.internalQuery(query)) + responses.push(await this.internalQuery(query, false)) } + await this.client.end() return responses } else { const response = await this.internalQuery(input) diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 30cd8dbba7..fccfec87e2 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.148-alpha.1", + "version": "1.0.151-alpha.2", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index 066009589e..75a464f1c3 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.148-alpha.1", + "version": "1.0.151-alpha.2", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -31,9 +31,9 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.0.148-alpha.1", - "@budibase/pro": "1.0.148-alpha.1", - "@budibase/string-templates": "^1.0.148-alpha.1", + "@budibase/backend-core": "^1.0.151-alpha.2", + "@budibase/pro": "1.0.151-alpha.2", + "@budibase/string-templates": "^1.0.151-alpha.2", "@koa/router": "^8.0.0", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "^0.3.0",