Merge branch 'master' into feat/row-actions

This commit is contained in:
Adria Navarro 2024-07-24 09:51:47 +02:00 committed by GitHub
commit 2d9da6b7d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 148 additions and 172 deletions

View File

@ -64,11 +64,6 @@ RUN mkdir -p /var/log/nginx && \
touch /var/run/nginx.pid && \
usermod -a -G tty www-data
WORKDIR /
RUN mkdir -p scripts/integrations/oracle
COPY packages/server/scripts/integrations/oracle scripts/integrations/oracle
RUN /bin/bash -e ./scripts/integrations/oracle/instantclient/linux/install.sh
# setup minio
WORKDIR /minio
COPY scripts/install-minio.sh ./install.sh

View File

@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "2.29.22",
"version": "2.29.24",
"npmClient": "yarn",
"packages": [
"packages/*",

View File

@ -435,6 +435,11 @@ class InternalBuilder {
)} = ? THEN 1 ELSE 0 END = 1`,
[value]
)
} else if (this.client === SqlClient.ORACLE) {
query = query[fnc](
`COALESCE(${quotedIdentifier(this.client, key)}, -1) = ?`,
[value]
)
} else {
query = query[fnc](
`COALESCE(${quotedIdentifier(this.client, key)} = ?, FALSE)`,
@ -454,6 +459,11 @@ class InternalBuilder {
)} = ? THEN 1 ELSE 0 END = 0`,
[value]
)
} else if (this.client === SqlClient.ORACLE) {
query = query[fnc](
`COALESCE(${quotedIdentifier(this.client, key)}, -1) != ?`,
[value]
)
} else {
query = query[fnc](
`COALESCE(${quotedIdentifier(this.client, key)} != ?, TRUE)`,

View File

@ -12,7 +12,6 @@
export let listItemKey
export let draggable = true
export let focus
export let bindings = []
let zoneType = generate()
@ -127,7 +126,6 @@
anchor={anchors[draggableItem.id]}
item={draggableItem.item}
{...listTypeProps}
{bindings}
on:change={onItemChanged}
/>
</div>

View File

@ -64,7 +64,9 @@
items={columns.sortable}
listItemKey={"_id"}
listType={FieldSetting}
{bindings}
listTypeProps={{
bindings,
}}
/>
<style>

View File

@ -106,12 +106,24 @@
}
const handleHashChange = () => {
const { open: sidePanelOpen } = $sidePanelStore
if (sidePanelOpen) {
// only close if the sidepanel is open and theres no onload side panel actions on the screen.
if (
sidePanelOpen &&
!$screenStore.activeScreen.onLoad?.some(
item => item["##eventHandlerType"] === "Open Side Panel"
)
) {
sidePanelStore.actions.close()
}
const { open: modalOpen } = $modalStore
if (modalOpen) {
// only close if the modal is open and theres onload modals actions on the screen.
if (
modalOpen &&
!$screenStore.activeScreen.onLoad?.some(
item => item["##eventHandlerType"] === "Open Modal"
)
) {
modalStore.actions.close()
}
}

View File

@ -21,11 +21,6 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends g++ make python3 jq
RUN yarn global add pm2
# Install client for oracle datasource
RUN apt-get install unzip libaio1
COPY packages/server/scripts/integrations/oracle/ scripts/integrations/oracle/
RUN /bin/bash -e scripts/integrations/oracle/instantclient/linux/x86-64/install.sh
# Install postgres client for pg_dump utils
RUN apt update && apt upgrade -y \
&& apt install software-properties-common apt-transport-https curl gpg -y \

View File

@ -101,6 +101,7 @@
"object-sizeof": "2.6.1",
"openai": "^4.52.1",
"openapi-types": "9.3.1",
"oracledb": "6.5.1",
"pg": "8.10.0",
"pouchdb": "7.3.0",
"pouchdb-all-dbs": "1.1.1",
@ -111,12 +112,12 @@
"snowflake-promise": "^4.5.0",
"socket.io": "4.7.5",
"tar": "6.2.1",
"tmp": "0.2.3",
"to-json-schema": "0.2.5",
"uuid": "^8.3.2",
"validate.js": "0.13.1",
"worker-farm": "1.7.0",
"xml2js": "0.5.0",
"tmp": "0.2.3"
"xml2js": "0.5.0"
},
"devDependencies": {
"@babel/preset-env": "7.16.11",
@ -131,13 +132,13 @@
"@types/lodash": "4.14.200",
"@types/mssql": "9.1.4",
"@types/node-fetch": "2.6.4",
"@types/oracledb": "5.2.2",
"@types/oracledb": "6.5.1",
"@types/pg": "8.6.6",
"@types/server-destroy": "1.0.1",
"@types/supertest": "2.0.14",
"@types/tar": "6.1.5",
"@types/uuid": "8.3.4",
"@types/tmp": "0.2.6",
"@types/uuid": "8.3.4",
"copyfiles": "2.4.1",
"docker-compose": "0.23.17",
"jest": "29.7.0",
@ -156,9 +157,6 @@
"update-dotenv": "1.1.1",
"yargs": "13.2.4"
},
"optionalDependencies": {
"oracledb": "5.3.0"
},
"nx": {
"targets": {
"dev": {

View File

@ -1,23 +0,0 @@
#!/bin/bash
# Must be root to continue
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
# Allow for re-runs
rm -rf /opt/oracle
echo "Installing oracle instant client"
# copy and unzip package
mkdir -p /opt/oracle
cp scripts/integrations/oracle/instantclient/linux/arm64/basiclite-19.10.zip /opt/oracle
cd /opt/oracle
unzip -qq basiclite-19.10.zip -d .
rm *.zip
mv instantclient* instantclient
# update runtime link path
sh -c "echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf"
ldconfig /etc/ld.so.conf.d
echo "Installation complete"

View File

@ -1,10 +0,0 @@
#!/bin/bash
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"
if [[ $TARGETARCH == arm* ]] ;
then
echo "Installing ARM Oracle instant client..."
$SCRIPT_DIR/arm64/install.sh
else
echo "Installing x86-64 Oracle instant client..."
$SCRIPT_DIR/x86-64/install.sh
fi

View File

@ -1,23 +0,0 @@
#!/bin/bash
# Must be root to continue
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
# Allow for re-runs
rm -rf /opt/oracle
echo "Installing oracle instant client"
# copy and unzip package
mkdir -p /opt/oracle
cp scripts/integrations/oracle/instantclient/linux/x86-64/basiclite-21.4.zip /opt/oracle
cd /opt/oracle
unzip -qq basiclite-21.4.zip -d .
rm *.zip
mv instantclient* instantclient
# update runtime link path
sh -c "echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf"
ldconfig /etc/ld.so.conf.d
echo "Installation complete"

View File

@ -10,7 +10,7 @@ To install oracle express edition simply run `docker-compose up`
- A single instance pluggable database (PDB) will be created named `xepdb1`
- The default password is configured in the compose file as `oracle`
- The `system` and `pdbadmin` users share this password
- The `system` and `pdbadmin` users share this password
## Instant Client
@ -87,4 +87,3 @@ ALTER USER hr ACCOUNT UNLOCK;
ALTER USER hr IDENTIFIED BY hr;
```
You should now be able to connect to the hr schema using the credentials hr/hr

View File

@ -41,7 +41,7 @@ const DEFINITIONS: Record<SourceName, Integration | undefined> = {
[SourceName.GOOGLE_SHEETS]: googlesheets.schema,
[SourceName.REDIS]: redis.schema,
[SourceName.SNOWFLAKE]: snowflake.schema,
[SourceName.ORACLE]: undefined,
[SourceName.ORACLE]: oracle.schema,
[SourceName.BUDIBASE]: undefined,
}
@ -64,20 +64,10 @@ const INTEGRATIONS: Record<SourceName, IntegrationBaseConstructor | undefined> =
[SourceName.GOOGLE_SHEETS]: googlesheets.integration,
[SourceName.REDIS]: redis.integration,
[SourceName.SNOWFLAKE]: snowflake.integration,
[SourceName.ORACLE]: undefined,
[SourceName.ORACLE]: oracle.integration,
[SourceName.BUDIBASE]: undefined,
}
// optionally add oracle integration if the oracle binary can be installed
if (
process.arch &&
!process.arch.startsWith("arm") &&
oracle.integration.isInstalled()
) {
DEFINITIONS[SourceName.ORACLE] = oracle.schema
INTEGRATIONS[SourceName.ORACLE] = oracle.integration
}
export async function getDefinition(
source: SourceName
): Promise<Integration | undefined> {

View File

@ -24,7 +24,7 @@ import {
getSqlQuery,
HOST_ADDRESS,
} from "./utils"
import {
import oracledb, {
BindParameters,
Connection,
ConnectionAttributes,
@ -36,13 +36,7 @@ import { sql } from "@budibase/backend-core"
const Sql = sql.Sql
let oracledb: any
try {
oracledb = require("oracledb")
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT
} catch (err) {
console.log("ORACLEDB is not installed")
}
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT
interface OracleConfig {
host: string
@ -158,10 +152,6 @@ class OracleIntegration extends Sql implements DatasourcePlus {
return parts.join(" || ")
}
static isInstalled() {
return oracledb != null
}
/**
* Map the flat tabular columns and constraints data into a nested object
*/

View File

@ -208,4 +208,38 @@ describe("SQL query builder", () => {
sql: `select * from (select * from (select * from (select * from "test" where LOWER("test"."name") LIKE :1 order by "test"."id" asc) where rownum <= :2) "test" order by "test"."id" asc) where rownum <= :3`,
})
})
it("should use an oracle compatible coalesce query for oracle when using the equals filter", () => {
let query = new Sql(SqlClient.ORACLE, limit)._query(
generateReadJson({
filters: {
equal: {
name: "John",
},
},
})
)
expect(query).toEqual({
bindings: ["John", limit, 5000],
sql: `select * from (select * from (select * from (select * from "test" where COALESCE("test"."name", -1) = :1 order by "test"."id" asc) where rownum <= :2) "test" order by "test"."id" asc) where rownum <= :3`,
})
})
it("should use an oracle compatible coalesce query for oracle when using the not equals filter", () => {
let query = new Sql(SqlClient.ORACLE, limit)._query(
generateReadJson({
filters: {
notEqual: {
name: "John",
},
},
})
)
expect(query).toEqual({
bindings: ["John", limit, 5000],
sql: `select * from (select * from (select * from (select * from "test" where COALESCE("test"."name", -1) != :1 order by "test"."id" asc) where rownum <= :2) "test" order by "test"."id" asc) where rownum <= :3`,
})
})
})

View File

@ -1,4 +1,7 @@
import { HelperFunctionBuiltin } from "../src/helpers/constants"
import {
HelperFunctionBuiltin,
EXTERNAL_FUNCTION_COLLECTIONS,
} from "../src/helpers/constants"
import { readFileSync, writeFileSync } from "fs"
import { marked } from "marked"
import { join, dirname } from "path"
@ -14,21 +17,6 @@ type HelperInfo = {
tags?: any[]
}
/**
* full list of supported helpers can be found here:
* https://github.com/budibase/handlebars-helpers
*/
const COLLECTIONS = [
"math",
"array",
"number",
"url",
"string",
"comparison",
"object",
"uuid",
]
const FILENAME = join(__dirname, "..", "src", "manifest.json")
const outputJSON: any = {}
const ADDED_HELPERS = {
@ -140,7 +128,7 @@ const excludeFunctions: Record<string, string[]> = { string: ["raw"] }
*/
function run() {
const foundNames: string[] = []
for (let collection of COLLECTIONS) {
for (let collection of EXTERNAL_FUNCTION_COLLECTIONS) {
const collectionFile = readFileSync(
`${dirname(
require.resolve("@budibase/handlebars-helpers")

View File

@ -58,7 +58,7 @@ function buildList(parts: string[], value: any) {
if (!value) {
return parts.length > 1 ? `${build()}` : build()
} else {
return parts.length === 0 ? value : `${value}, ${build()}`
return parts.length === 0 ? value : `${build()}, ${value}`
}
}

View File

@ -15,6 +15,22 @@ export const HelperFunctionBuiltin = [
"with",
]
/**
* full list of supported helpers can be found here:
* https://github.com/Budibase/handlebars-helpers
*/
export const EXTERNAL_FUNCTION_COLLECTIONS = [
"math",
"array",
"number",
"url",
"string",
"comparison",
"object",
"regex",
"uuid",
]
export const HelperFunctionNames = {
OBJECT: "object",
ALL: "all",

View File

@ -2,26 +2,12 @@
import helpers from "@budibase/handlebars-helpers"
import { date, duration } from "./date"
import { HelperFunctionBuiltin } from "./constants"
import {
HelperFunctionBuiltin,
EXTERNAL_FUNCTION_COLLECTIONS,
} from "./constants"
import Handlebars from "handlebars"
/**
* full list of supported helpers can be found here:
* https://github.com/Budibase/handlebars-helpers
*/
const EXTERNAL_FUNCTION_COLLECTIONS = [
"math",
"array",
"number",
"url",
"string",
"comparison",
"object",
"regex",
"uuid",
]
const ADDED_HELPERS = {
date: date,
duration: duration,
@ -40,7 +26,7 @@ export function registerAll(handlebars: typeof Handlebars) {
let hbsHelperInfo = helpers[collection]()
for (let entry of Object.entries(hbsHelperInfo)) {
const name = entry[0]
// skip built in functions and ones seen already
// skip built-in functions and ones seen already
if (
HelperFunctionBuiltin.indexOf(name) !== -1 ||
externalNames.indexOf(name) !== -1

View File

@ -1312,6 +1312,26 @@
"requiresBlock": false
}
},
"regex": {
"toRegex": {
"args": [
"str"
],
"numArgs": 1,
"example": "{{toRegex 'foo'}} -> /foo/",
"description": "<p>Convert the given string to a regular expression.</p>\n",
"requiresBlock": false
},
"test": {
"args": [
"str"
],
"numArgs": 1,
"example": "{{test 'foobar' (toRegex 'foo')}} -> true",
"description": "<p>Returns true if the given <code>str</code> matches the given regex. A regex can be passed on the context, or using the <a href=\"#toregex\">toRegex</a> helper as a subexpression.</p>\n",
"requiresBlock": false
}
},
"uuid": {
"uuid": {
"args": [],

View File

@ -93,10 +93,10 @@ describe("Test that the string processing works correctly", () => {
it("should handle a complex statement", () => {
const response = convertToJS(
"This is the average: {{ join ( avg val1 val2 val3 ) val4 }}"
"This is the average: {{ join val1 ( avg val2 val3 val4 ) }}"
)
checkLines(response, [
'const var1 = helpers.join(helpers.avg($("val1"), $("val2"), $("val3")), $("val4"));',
'const var1 = helpers.join($("val1"), helpers.avg($("val2"), $("val3"), $("val4")));',
"return `This is the average: ${var1}`;",
])
})
@ -119,10 +119,10 @@ describe("Test that the string processing works correctly", () => {
it("should handle multiple complex statements", () => {
const response = convertToJS(
"average: {{ avg ( abs val1 ) val2 }} add: {{ add 1 2 }}"
"average: {{ avg val1 ( abs val2 ) }} add: {{ add 1 2 }}"
)
checkLines(response, [
'const var1 = helpers.avg(helpers.abs($("val1")), $("val2"));',
'const var1 = helpers.avg($("val1"), helpers.abs($("val2")));',
"const var2 = helpers.add(1, 2);",
"return `average: ${var1} add: ${var2}`;",
])

View File

@ -2038,7 +2038,7 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.23.12":
"@budibase/backend-core@2.29.22":
version "0.0.0"
dependencies:
"@budibase/nano" "10.1.5"
@ -2119,14 +2119,14 @@
through2 "^2.0.0"
"@budibase/pro@npm:@budibase/pro@latest":
version "2.23.12"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.23.12.tgz#b2e813c547a5ed22b5bd86b1158159fe4b918260"
integrity sha512-DMtfkrJDSIF9V7AL6brpuWWw7Ot5XxO4YQ32ggmr0264uU9KYsTFvlFXFP3MSF2H+247ZYUouSJU76+XeC13qQ==
version "2.29.22"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.29.22.tgz#2608b2a76be0426879068e5a61100d6b8dde6f3a"
integrity sha512-flMVIpWQb9w3f4aiBSM73aLcYmfoPIf+kP8JXgRWO0k3nGrUGaMQNBKzXwC7soTkTrJCZjBh8uaY75AxTP2RdA==
dependencies:
"@budibase/backend-core" "2.23.12"
"@budibase/shared-core" "2.23.12"
"@budibase/string-templates" "2.23.12"
"@budibase/types" "2.23.12"
"@budibase/backend-core" "2.29.22"
"@budibase/shared-core" "2.29.22"
"@budibase/string-templates" "2.29.22"
"@budibase/types" "2.29.22"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"
@ -2137,13 +2137,13 @@
scim-patch "^0.8.1"
scim2-parse-filter "^0.2.8"
"@budibase/shared-core@2.23.12":
"@budibase/shared-core@2.29.22":
version "0.0.0"
dependencies:
"@budibase/types" "0.0.0"
cron-validate "1.4.5"
"@budibase/string-templates@2.23.12":
"@budibase/string-templates@2.29.22":
version "0.0.0"
dependencies:
"@budibase/handlebars-helpers" "^0.13.2"
@ -2151,7 +2151,7 @@
handlebars "^4.7.8"
lodash.clonedeep "^4.5.0"
"@budibase/types@2.23.12":
"@budibase/types@2.29.22":
version "0.0.0"
dependencies:
scim-patch "^0.8.1"
@ -5731,13 +5731,12 @@
dependencies:
"@types/node" "*"
"@types/oracledb@5.2.2":
version "5.2.2"
resolved "https://registry.yarnpkg.com/@types/oracledb/-/oracledb-5.2.2.tgz#ae7ba795969e3bbd8d57ab141873a1aa012b86cd"
integrity sha512-aYb2DdZOQVIgSCSXjXNikQuyiHAY09SkRA4cjwoj+F/mhLJDahdjNeBmvQvfFojyChCKLuupSJHqoAXPExgV5w==
"@types/oracledb@6.5.1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@types/oracledb/-/oracledb-6.5.1.tgz#17d021cabc9d216dfa6d3d65ae3ee585c33baab3"
integrity sha512-Ll0bKGXmCZVngBL3juSaytA8Jeocx0VghDHTt+FEC2bs8fdl9pzoaBXYWXjBUxCCT8Y/69m5AzuTgBd79j24WA==
dependencies:
"@types/node" "*"
dotenv "^8.2.0"
"@types/passport-google-oauth@^1.0.42":
version "1.0.45"
@ -16660,10 +16659,10 @@ ora@^5.4.1:
strip-ansi "^6.0.0"
wcwidth "^1.0.1"
oracledb@5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/oracledb/-/oracledb-5.3.0.tgz#a15e6cd16757d8711a2c006a28bd7ecd3b8466f7"
integrity sha512-HMJzQ6lCf287ztvvehTEmjCWA21FQ3RMvM+mgoqd4i8pkREuqFWO+y3ovsGR9moJUg4T0xjcwS8rl4mggWPxmg==
oracledb@6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/oracledb/-/oracledb-6.5.1.tgz#814d985035acdb1a6470b1152af0ca3767569ede"
integrity sha512-JzoSGei1wnvmqgKnAZK1W650mzHTZXx+7hClV4mwsbY/ZjUtrpnojNJMYJ2jkOhj7XG5oJPfXc4GqDKaNzkxqg==
os-locale@^3.1.0:
version "3.1.0"