Merge remote-tracking branch 'origin/develop' into feat/user-groups-tab

This commit is contained in:
Peter Clement 2022-07-21 11:47:08 +01:00
commit ad1cf0726f
27 changed files with 3345 additions and 190 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*" "packages/*"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/backend-core", "name": "@budibase/backend-core",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"description": "Budibase backend core libraries used in server and worker", "description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js", "main": "dist/src/index.js",
"types": "dist/src/index.d.ts", "types": "dist/src/index.d.ts",
@ -20,7 +20,7 @@
"test:watch": "jest --watchAll" "test:watch": "jest --watchAll"
}, },
"dependencies": { "dependencies": {
"@budibase/types": "^1.1.18-alpha.0", "@budibase/types": "^1.1.18-alpha.4",
"@techpass/passport-openidconnect": "0.3.2", "@techpass/passport-openidconnect": "0.3.2",
"aws-sdk": "2.1030.0", "aws-sdk": "2.1030.0",
"bcrypt": "5.0.1", "bcrypt": "5.0.1",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/bbui", "name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.", "description": "A UI solution used in the different Budibase projects.",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"license": "MPL-2.0", "license": "MPL-2.0",
"svelte": "src/index.js", "svelte": "src/index.js",
"module": "dist/bbui.es.js", "module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
], ],
"dependencies": { "dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.2.1", "@adobe/spectrum-css-workflow-icons": "^1.2.1",
"@budibase/string-templates": "^1.1.18-alpha.0", "@budibase/string-templates": "^1.1.18-alpha.4",
"@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2", "@spectrum-css/avatar": "^3.0.2",

View File

@ -53,10 +53,10 @@
to-gfm-code-block "^0.1.1" to-gfm-code-block "^0.1.1"
year "^0.2.1" year "^0.2.1"
"@budibase/string-templates@^1.1.15-alpha.1": "@budibase/string-templates@^1.1.18-alpha.0":
version "1.1.15" version "1.1.18-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.1.15.tgz#14e7e0c84f08c091049fa6bed1cd527b8c199975" resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.1.18-alpha.0.tgz#7b1c7fe4c2b0deedde8d0cd05668adb661e60016"
integrity sha512-hXMIohvVlpj/l/jrWIlNb1Hqyjmbi95yvOiFigTq9Js6xfV7ugmuP0c4IOQB8hb4zYhud4A+WqhxC5WVUebYiA== integrity sha512-7xmBfDlMqsGNtPu/P7+ljaRwHpMeegJjN4JDSCezvfrrKUzgfDKLKP2PsK8hoCUvxfRAt8/uT7JIBxKoJeCNvg==
dependencies: dependencies:
"@budibase/handlebars-helpers" "^0.11.8" "@budibase/handlebars-helpers" "^0.11.8"
dayjs "^1.10.4" dayjs "^1.10.4"
@ -65,6 +65,46 @@
lodash "^4.17.20" lodash "^4.17.20"
vm2 "^3.9.4" vm2 "^3.9.4"
"@jridgewell/gen-mapping@^0.3.0":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9"
integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==
dependencies:
"@jridgewell/set-array" "^1.0.1"
"@jridgewell/sourcemap-codec" "^1.4.10"
"@jridgewell/trace-mapping" "^0.3.9"
"@jridgewell/resolve-uri@^3.0.3":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78"
integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==
"@jridgewell/set-array@^1.0.1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==
"@jridgewell/source-map@^0.3.2":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb"
integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==
dependencies:
"@jridgewell/gen-mapping" "^0.3.0"
"@jridgewell/trace-mapping" "^0.3.9"
"@jridgewell/sourcemap-codec@^1.4.10":
version "1.4.14"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==
"@jridgewell/trace-mapping@^0.3.9":
version "0.3.14"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed"
integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==
dependencies:
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"
"@rollup/plugin-commonjs@^16.0.0": "@rollup/plugin-commonjs@^16.0.0":
version "16.0.0" version "16.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-16.0.0.tgz#169004d56cd0f0a1d0f35915d31a036b0efe281f" resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-16.0.0.tgz#169004d56cd0f0a1d0f35915d31a036b0efe281f"
@ -382,7 +422,7 @@ acorn@^7.3.1:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
acorn@^8.7.0: acorn@^8.5.0, acorn@^8.7.0:
version "8.7.1" version "8.7.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30"
integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==
@ -569,9 +609,9 @@ browserslist@^4.0.0:
node-releases "^1.1.71" node-releases "^1.1.71"
buffer-from@^1.0.0: buffer-from@^1.0.0:
version "1.1.1" version "1.1.2"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
builtin-modules@^3.1.0: builtin-modules@^3.1.0:
version "3.2.0" version "3.2.0"
@ -3151,8 +3191,7 @@ snapdragon@^0.8.1:
source-map-resolve "^0.5.0" source-map-resolve "^0.5.0"
use "^3.1.0" use "^3.1.0"
"source-map-fast@npm:source-map@0.7.3", source-map@~0.7.2: "source-map-fast@npm:source-map@0.7.3":
name source-map-fast
version "0.7.3" version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
@ -3168,10 +3207,10 @@ source-map-resolve@^0.5.0:
source-map-url "^0.4.0" source-map-url "^0.4.0"
urix "^0.1.0" urix "^0.1.0"
source-map-support@~0.5.19: source-map-support@~0.5.20:
version "0.5.19" version "0.5.21"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
dependencies: dependencies:
buffer-from "^1.0.0" buffer-from "^1.0.0"
source-map "^0.6.0" source-map "^0.6.0"
@ -3331,13 +3370,14 @@ svgo@^1.0.0:
util.promisify "~1.0.0" util.promisify "~1.0.0"
terser@^5.0.0: terser@^5.0.0:
version "5.6.1" version "5.14.2"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.6.1.tgz#a48eeac5300c0a09b36854bf90d9c26fb201973c" resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10"
integrity sha512-yv9YLFQQ+3ZqgWCUk+pvNJwgUTdlIxUk1WTN+RnaFJe2L7ipG2csPT0ra2XRm7Cs8cxN7QXmK1rFzEwYEQkzXw== integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA==
dependencies: dependencies:
"@jridgewell/source-map" "^0.3.2"
acorn "^8.5.0"
commander "^2.20.0" commander "^2.20.0"
source-map "~0.7.2" source-map-support "~0.5.20"
source-map-support "~0.5.19"
through2@^2.0.0: through2@^2.0.0:
version "2.0.5" version "2.0.5"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/builder", "name": "@budibase/builder",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"license": "GPL-3.0", "license": "GPL-3.0",
"private": true, "private": true,
"scripts": { "scripts": {
@ -69,10 +69,10 @@
} }
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.1.18-alpha.0", "@budibase/bbui": "^1.1.18-alpha.4",
"@budibase/client": "^1.1.18-alpha.0", "@budibase/client": "^1.1.18-alpha.4",
"@budibase/frontend-core": "^1.1.18-alpha.0", "@budibase/frontend-core": "^1.1.18-alpha.4",
"@budibase/string-templates": "^1.1.18-alpha.0", "@budibase/string-templates": "^1.1.18-alpha.4",
"@sentry/browser": "5.19.1", "@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1", "@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1", "@spectrum-css/vars": "^3.0.1",

View File

@ -246,6 +246,7 @@
{bindings} {bindings}
allowJS={false} allowJS={false}
updateOnChange={false} updateOnChange={false}
drawerLeft="260px"
/> />
{/if} {/if}
{:else if value.customType === "query"} {:else if value.customType === "query"}
@ -335,6 +336,7 @@
{bindings} {bindings}
updateOnChange={false} updateOnChange={false}
placeholder={value.customType === "queryLimit" ? queryLimit : ""} placeholder={value.customType === "queryLimit" ? queryLimit : ""}
drawerLeft="260px"
/> />
</div> </div>
{/if} {/if}

View File

@ -18,6 +18,7 @@
export let fillWidth export let fillWidth
export let allowJS = true export let allowJS = true
export let updateOnChange = true export let updateOnChange = true
export let drawerLeft
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
let bindingDrawer let bindingDrawer
@ -53,7 +54,7 @@
</div> </div>
{/if} {/if}
</div> </div>
<Drawer {fillWidth} bind:this={bindingDrawer} {title}> <Drawer {fillWidth} bind:this={bindingDrawer} {title} left={drawerLeft}>
<svelte:fragment slot="description"> <svelte:fragment slot="description">
Add the objects on the left to enrich your text. Add the objects on the left to enrich your text.
</svelte:fragment> </svelte:fragment>

View File

@ -32,6 +32,7 @@
export let menuItems export let menuItems
export let showMenu = false export let showMenu = false
export let bindings = [] export let bindings = []
export let bindingDrawerLeft
let fields = Object.entries(object || {}).map(([name, value]) => ({ let fields = Object.entries(object || {}).map(([name, value]) => ({
name, name,
@ -119,6 +120,7 @@
value={field.value} value={field.value}
allowJS={false} allowJS={false}
fillWidth={true} fillWidth={true}
drawerLeft={bindingDrawerLeft}
/> />
{:else} {:else}
<Input <Input

View File

@ -440,6 +440,7 @@
...dynamicRequestBindings, ...dynamicRequestBindings,
...dataSourceStaticBindings, ...dataSourceStaticBindings,
]} ]}
bindingDrawerLeft="260px"
/> />
</Tab> </Tab>
<Tab title="Params"> <Tab title="Params">
@ -448,6 +449,7 @@
name="param" name="param"
headings headings
bindings={mergedBindings} bindings={mergedBindings}
bindingDrawerLeft="260px"
/> />
</Tab> </Tab>
<Tab title="Headers"> <Tab title="Headers">
@ -458,6 +460,7 @@
name="header" name="header"
headings headings
bindings={mergedBindings} bindings={mergedBindings}
bindingDrawerLeft="260px"
/> />
</Tab> </Tab>
<Tab title="Body"> <Tab title="Body">

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"description": "Budibase CLI, for developers, self hosting and migrations.", "description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js", "main": "src/index.js",
"bin": { "bin": {
@ -26,8 +26,8 @@
"outputPath": "build" "outputPath": "build"
}, },
"dependencies": { "dependencies": {
"@budibase/backend-core": "^1.1.18-alpha.0", "@budibase/backend-core": "^1.1.18-alpha.4",
"axios": "0.21.1", "axios": "0.21.2",
"chalk": "4.1.0", "chalk": "4.1.0",
"cli-progress": "3.11.2", "cli-progress": "3.11.2",
"commander": "7.1.0", "commander": "7.1.0",

File diff suppressed because it is too large Load Diff

View File

@ -3509,17 +3509,18 @@
}, },
{ {
"type": "boolean", "type": "boolean",
"label": "Show button", "label": "Use button for click action",
"key": "showButton" "key": "showButton"
}, },
{ {
"type": "text", "type": "text",
"key": "buttonText", "key": "buttonText",
"label": "Button text" "label": "Button text",
"dependsOn": "showButton"
}, },
{ {
"type": "event", "type": "event",
"label": "Button action", "label": "Click action",
"key": "buttonOnClick" "key": "buttonOnClick"
} }
] ]
@ -3841,18 +3842,19 @@
}, },
{ {
"type": "boolean", "type": "boolean",
"label": "Show button", "label": "Use button for click action",
"key": "showCardButton" "key": "showCardButton"
}, },
{ {
"type": "text", "type": "text",
"key": "cardButtonText", "key": "cardButtonText",
"label": "Button text", "label": "Button text",
"nested": true "nested": true,
"dependsOn": "showCardButton"
}, },
{ {
"type": "event", "type": "event",
"label": "Button action", "label": "Click action",
"key": "cardButtonOnClick", "key": "cardButtonOnClick",
"nested": true "nested": true
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/client", "name": "@budibase/client",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"license": "MPL-2.0", "license": "MPL-2.0",
"module": "dist/budibase-client.js", "module": "dist/budibase-client.js",
"main": "dist/budibase-client.js", "main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw" "dev:builder": "rollup -cw"
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.1.18-alpha.0", "@budibase/bbui": "^1.1.18-alpha.4",
"@budibase/frontend-core": "^1.1.18-alpha.0", "@budibase/frontend-core": "^1.1.18-alpha.4",
"@budibase/string-templates": "^1.1.18-alpha.0", "@budibase/string-templates": "^1.1.18-alpha.4",
"@spectrum-css/button": "^3.0.3", "@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3", "@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3", "@spectrum-css/divider": "^1.0.3",

View File

@ -19,9 +19,10 @@
const handleLink = e => { const handleLink = e => {
if (!linkURL) { if (!linkURL) {
return return false
} }
e.preventDefault() e.preventDefault()
e.stopPropagation()
routeStore.actions.navigate(linkURL, linkPeek) routeStore.actions.navigate(linkURL, linkPeek)
} }
</script> </script>
@ -32,6 +33,8 @@
tabindex="0" tabindex="0"
role="figure" role="figure"
class:horizontal class:horizontal
class:clickable={buttonOnClick && !showButton}
on:click={showButton ? null : buttonOnClick}
> >
{#if imageURL} {#if imageURL}
<div <div
@ -67,7 +70,9 @@
{/if} {/if}
{#if showButton} {#if showButton}
<div class="spectrum-Card-footer button-container"> <div class="spectrum-Card-footer button-container">
<Button on:click={buttonOnClick} secondary>{buttonText || ""}</Button> <Button on:click={buttonOnClick} secondary>
{buttonText || "Click me"}
</Button>
</div> </div>
{/if} {/if}
</div> </div>
@ -81,6 +86,11 @@
flex-direction: column; flex-direction: column;
justify-content: flex-start; justify-content: flex-start;
align-items: stretch; align-items: stretch;
transition: border-color 130ms ease-out;
}
.spectrum-Card.clickable:hover {
cursor: pointer;
border-color: var(--spectrum-global-color-gray-500) !important;
} }
.spectrum-Card.horizontal { .spectrum-Card.horizontal {
flex-direction: row; flex-direction: row;
@ -90,7 +100,7 @@
padding: var(--spectrum-global-dimension-size-50) 0; padding: var(--spectrum-global-dimension-size-50) 0;
} }
.spectrum-Card-title.link { .spectrum-Card-title.link {
transition: color 130ms ease-in-out; transition: color 130ms ease-out;
} }
.spectrum-Card-title.link:hover { .spectrum-Card-title.link:hover {
cursor: pointer; cursor: pointer;

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
{ {
"name": "@budibase/frontend-core", "name": "@budibase/frontend-core",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"description": "Budibase frontend core libraries used in builder and client", "description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase", "author": "Budibase",
"license": "MPL-2.0", "license": "MPL-2.0",
"svelte": "src/index.js", "svelte": "src/index.js",
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.1.18-alpha.0", "@budibase/bbui": "^1.1.18-alpha.4",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"svelte": "^3.46.2" "svelte": "^3.46.2"
} }

View File

@ -35,7 +35,7 @@ export const OperatorOptions = {
label: "Less than", label: "Less than",
}, },
Contains: { Contains: {
value: "equal", value: "contains",
label: "Contains", label: "Contains",
}, },
NotContains: { NotContains: {

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/server", "name": "@budibase/server",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"description": "Budibase Web Server", "description": "Budibase Web Server",
"main": "src/index.ts", "main": "src/index.ts",
"repository": { "repository": {
@ -77,11 +77,11 @@
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@apidevtools/swagger-parser": "10.0.3", "@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "^1.1.18-alpha.0", "@budibase/backend-core": "^1.1.18-alpha.4",
"@budibase/client": "^1.1.18-alpha.0", "@budibase/client": "^1.1.18-alpha.4",
"@budibase/pro": "1.1.18-alpha.0", "@budibase/pro": "1.1.18-alpha.4",
"@budibase/string-templates": "^1.1.18-alpha.0", "@budibase/string-templates": "^1.1.18-alpha.4",
"@budibase/types": "^1.1.18-alpha.0", "@budibase/types": "^1.1.18-alpha.4",
"@bull-board/api": "3.7.0", "@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4", "@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0", "@elastic/elasticsearch": "7.10.0",

View File

@ -19,6 +19,7 @@ class QueryBuilder {
empty: {}, empty: {},
notEmpty: {}, notEmpty: {},
oneOf: {}, oneOf: {},
contains: {},
...base, ...base,
} }
this.limit = 50 this.limit = 50
@ -119,6 +120,11 @@ class QueryBuilder {
return this return this
} }
addContains(key, value) {
this.query.contains[key] = value
return this
}
/** /**
* Preprocesses a value before going into a lucene search. * Preprocesses a value before going into a lucene search.
* Transforms strings to lowercase and wraps strings and bools in quotes. * Transforms strings to lowercase and wraps strings and bools in quotes.
@ -164,6 +170,31 @@ class QueryBuilder {
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}` return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`
} }
const contains = (key, value) => {
if (!value && value !== 0) {
return null
}
return `${key}:${builder.preprocess(value, { escape: true })}`
}
const oneOf = (key, value) => {
if (!Array.isArray(value)) {
if (typeof value === "string") {
value = value.split(",")
} else {
return ""
}
}
let orStatement = `${builder.preprocess(value[0], allPreProcessingOpts)}`
for (let i = 1; i < value.length; i++) {
orStatement += ` OR ${builder.preprocess(
value[i],
allPreProcessingOpts
)}`
}
return `${key}:(${orStatement})`
}
function build(structure, queryFn) { function build(structure, queryFn) {
for (let [key, value] of Object.entries(structure)) { for (let [key, value] of Object.entries(structure)) {
key = builder.preprocess(key.replace(/ /g, "_"), { key = builder.preprocess(key.replace(/ /g, "_"), {
@ -239,26 +270,10 @@ class QueryBuilder {
build(this.query.notEmpty, key => `${key}:["" TO *]`) build(this.query.notEmpty, key => `${key}:["" TO *]`)
} }
if (this.query.oneOf) { if (this.query.oneOf) {
build(this.query.oneOf, (key, value) => { build(this.query.oneOf, oneOf)
if (!Array.isArray(value)) { }
if (typeof value === "string") { if (this.query.contains) {
value = value.split(",") build(this.query.contains, contains)
} else {
return ""
}
}
let orStatement = `${builder.preprocess(
value[0],
allPreProcessingOpts
)}`
for (let i = 1; i < value.length; i++) {
orStatement += ` OR ${builder.preprocess(
value[i],
allPreProcessingOpts
)}`
}
return `${key}:(${orStatement})`
})
} }
// make sure table ID is always added as an AND // make sure table ID is always added as an AND
if (tableId) { if (tableId) {

View File

@ -131,6 +131,9 @@ export interface SearchFilters {
oneOf?: { oneOf?: {
[key: string]: any[] [key: string]: any[]
} }
contains?: {
[key: string]: any
}
} }
export interface SortJson { export interface SortJson {

View File

@ -142,6 +142,21 @@ class InternalBuilder {
} }
} }
} }
const like = (key: string, value: any) => {
const fnc = allOr ? "orWhere" : "where"
// postgres supports ilike, nothing else does
if (this.client === SqlClients.POSTGRES) {
query = query[fnc](key, "ilike", `%${value}%`)
} else {
const rawFnc = `${fnc}Raw`
// @ts-ignore
query = query[rawFnc](`LOWER(${likeKey(this.client, key)}) LIKE ?`, [
`%${value}%`,
])
}
}
if (!filters) { if (!filters) {
return query return query
} }
@ -168,19 +183,7 @@ class InternalBuilder {
}) })
} }
if (filters.fuzzy) { if (filters.fuzzy) {
iterate(filters.fuzzy, (key, value) => { iterate(filters.fuzzy, like)
const fnc = allOr ? "orWhere" : "where"
// postgres supports ilike, nothing else does
if (this.client === SqlClients.POSTGRES) {
query = query[fnc](key, "ilike", `%${value}%`)
} else {
const rawFnc = `${fnc}Raw`
// @ts-ignore
query = query[rawFnc](`LOWER(${likeKey(this.client, key)}) LIKE ?`, [
`%${value}%`,
])
}
})
} }
if (filters.range) { if (filters.range) {
iterate(filters.range, (key, value) => { iterate(filters.range, (key, value) => {
@ -223,6 +226,34 @@ class InternalBuilder {
query = query[fnc](key) query = query[fnc](key)
}) })
} }
if (filters.contains) {
const fnc = allOr ? "orWhere" : "where"
const rawFnc = `${fnc}Raw`
if (this.client === SqlClients.POSTGRES) {
iterate(filters.contains, (key: string, value: any) => {
const fieldNames = key.split(/\./g)
const tableName = fieldNames[0]
const columnName = fieldNames[1]
if (typeof value === "string") {
value = `"${value}"`
}
// @ts-ignore
query = query[rawFnc](
`"${tableName}"."${columnName}"::jsonb @> '[${value}]'`
)
})
} else if (this.client === SqlClients.MY_SQL) {
iterate(filters.contains, (key: string, value: any) => {
if (typeof value === "string") {
value = `"${value}"`
}
// @ts-ignore
query = query[rawFnc](`JSON_CONTAINS(${key}, '${value}')`)
})
} else {
iterate(filters.contains, like)
}
}
return query return query
} }

View File

@ -1,4 +1,5 @@
const Sql = require("../base/sql") const Sql = require("../base/sql")
const { SqlClients } = require("../utils")
const TABLE_NAME = "test" const TABLE_NAME = "test"
@ -46,7 +47,7 @@ function generateDeleteJson(table = TABLE_NAME, filters = {}) {
describe("SQL query builder", () => { describe("SQL query builder", () => {
const limit = 500 const limit = 500
const client = "pg" const client = SqlClients.POSTGRES
let sql let sql
beforeEach(() => { beforeEach(() => {
@ -173,15 +174,15 @@ describe("SQL query builder", () => {
}) })
it("should work with MS-SQL", () => { it("should work with MS-SQL", () => {
const query = new Sql("mssql", 10)._query(generateReadJson()) const query = new Sql(SqlClients.MS_SQL, 10)._query(generateReadJson())
expect(query).toEqual({ expect(query).toEqual({
bindings: [10], bindings: [10],
sql: `select * from (select top (@p0) * from [${TABLE_NAME}]) as [${TABLE_NAME}]` sql: `select * from (select top (@p0) * from [${TABLE_NAME}]) as [${TABLE_NAME}]`
}) })
}) })
it("should work with mySQL", () => { it("should work with MySQL", () => {
const query = new Sql("mysql", 10)._query(generateReadJson()) const query = new Sql(SqlClients.MY_SQL, 10)._query(generateReadJson())
expect(query).toEqual({ expect(query).toEqual({
bindings: [10], bindings: [10],
sql: `select * from (select * from \`${TABLE_NAME}\` limit ?) as \`${TABLE_NAME}\`` sql: `select * from (select * from \`${TABLE_NAME}\` limit ?) as \`${TABLE_NAME}\``
@ -238,4 +239,49 @@ describe("SQL query builder", () => {
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"` sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"`
}) })
}) })
it("should use like expression for MS-SQL when filter is contains", () => {
const query = new Sql(SqlClients.MS_SQL, 10)._query(generateReadJson({
filters: {
contains: {
age: 20,
name: "John"
}
}
}))
expect(query).toEqual({
bindings: [10, "%20%", "%John%"],
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where LOWER(${TABLE_NAME}.age) LIKE @p1 and LOWER(${TABLE_NAME}.name) LIKE @p2) as [${TABLE_NAME}]`
})
})
it("should use JSON_CONTAINS expression for MySQL when filter is contains", () => {
const query = new Sql(SqlClients.MY_SQL, 10)._query(generateReadJson({
filters: {
contains: {
age: 20,
name: "John"
}
}
}))
expect(query).toEqual({
bindings: [10],
sql: `select * from (select * from \`${TABLE_NAME}\` where JSON_CONTAINS(${TABLE_NAME}.age, '20') and JSON_CONTAINS(${TABLE_NAME}.name, '"John"') limit ?) as \`${TABLE_NAME}\``
})
})
it("should use jsonb operator expression for PostgreSQL when filter is contains", () => {
const query = new Sql(SqlClients.POSTGRES, 10)._query(generateReadJson({
filters: {
contains: {
age: 20,
name: "John"
}
}
}))
expect(query).toEqual({
bindings: [10],
sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"`
})
})
}) })

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"description": "Handlebars wrapper for Budibase templating.", "description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs", "main": "src/index.cjs",
"module": "dist/bundle.mjs", "module": "dist/bundle.mjs",

View File

@ -515,6 +515,46 @@
"@types/yargs" "^15.0.0" "@types/yargs" "^15.0.0"
chalk "^4.0.0" chalk "^4.0.0"
"@jridgewell/gen-mapping@^0.3.0":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9"
integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==
dependencies:
"@jridgewell/set-array" "^1.0.1"
"@jridgewell/sourcemap-codec" "^1.4.10"
"@jridgewell/trace-mapping" "^0.3.9"
"@jridgewell/resolve-uri@^3.0.3":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78"
integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==
"@jridgewell/set-array@^1.0.1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==
"@jridgewell/source-map@^0.3.2":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb"
integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==
dependencies:
"@jridgewell/gen-mapping" "^0.3.0"
"@jridgewell/trace-mapping" "^0.3.9"
"@jridgewell/sourcemap-codec@^1.4.10":
version "1.4.14"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==
"@jridgewell/trace-mapping@^0.3.9":
version "0.3.14"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed"
integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==
dependencies:
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"
"@rollup/plugin-commonjs@^17.1.0": "@rollup/plugin-commonjs@^17.1.0":
version "17.1.0" version "17.1.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-17.1.0.tgz#757ec88737dffa8aa913eb392fade2e45aef2a2d" resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-17.1.0.tgz#757ec88737dffa8aa913eb392fade2e45aef2a2d"
@ -711,10 +751,10 @@ acorn@^7.1.1:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
acorn@^8.2.4, acorn@^8.7.0: acorn@^8.2.4, acorn@^8.5.0, acorn@^8.7.0:
version "8.7.0" version "8.7.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30"
integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ== integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==
agent-base@6: agent-base@6:
version "6.0.2" version "6.0.2"
@ -3956,9 +3996,9 @@ source-map-resolve@^0.5.0:
urix "^0.1.0" urix "^0.1.0"
source-map-support@^0.5.6, source-map-support@~0.5.20: source-map-support@^0.5.6, source-map-support@~0.5.20:
version "0.5.20" version "0.5.21"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.20.tgz#12166089f8f5e5e8c56926b377633392dd2cb6c9" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
integrity sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw== integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
dependencies: dependencies:
buffer-from "^1.0.0" buffer-from "^1.0.0"
source-map "^0.6.0" source-map "^0.6.0"
@ -3978,7 +4018,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
source-map@^0.7.3, source-map@~0.7.2: source-map@^0.7.3:
version "0.7.3" version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
@ -4145,12 +4185,13 @@ terminal-link@^2.0.0:
supports-hyperlinks "^2.0.0" supports-hyperlinks "^2.0.0"
terser@^5.0.0: terser@^5.0.0:
version "5.10.0" version "5.14.2"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.10.0.tgz#b86390809c0389105eb0a0b62397563096ddafcc" resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10"
integrity sha512-AMmF99DMfEDiRJfxfY5jj5wNH/bYO09cniSqhfoyxc8sFoYIgkJy86G04UoZU5VjlpnplVu0K6Tx6E9b5+DlHA== integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA==
dependencies: dependencies:
"@jridgewell/source-map" "^0.3.2"
acorn "^8.5.0"
commander "^2.20.0" commander "^2.20.0"
source-map "~0.7.2"
source-map-support "~0.5.20" source-map-support "~0.5.20"
test-exclude@^6.0.0: test-exclude@^6.0.0:

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/types", "name": "@budibase/types",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"description": "Budibase types", "description": "Budibase types",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/worker", "name": "@budibase/worker",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.1.18-alpha.0", "version": "1.1.18-alpha.4",
"description": "Budibase background service", "description": "Budibase background service",
"main": "src/index.ts", "main": "src/index.ts",
"repository": { "repository": {
@ -35,10 +35,10 @@
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@budibase/backend-core": "^1.1.18-alpha.0", "@budibase/backend-core": "^1.1.18-alpha.4",
"@budibase/pro": "1.1.18-alpha.0", "@budibase/pro": "1.1.18-alpha.4",
"@budibase/string-templates": "^1.1.18-alpha.0", "@budibase/string-templates": "^1.1.18-alpha.4",
"@budibase/types": "^1.1.18-alpha.0", "@budibase/types": "^1.1.18-alpha.4",
"@koa/router": "8.0.8", "@koa/router": "8.0.8",
"@sentry/node": "6.17.7", "@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2", "@techpass/passport-openidconnect": "0.3.2",