From d9378e76f706e3951e68d4e80ce459bdd816d2fb Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 14 Sep 2021 17:49:01 +0100 Subject: [PATCH 1/5] Backbone of query definition. --- .../server/src/automations/steps/queryRows.js | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 packages/server/src/automations/steps/queryRows.js diff --git a/packages/server/src/automations/steps/queryRows.js b/packages/server/src/automations/steps/queryRows.js new file mode 100644 index 0000000000..8b01bd9755 --- /dev/null +++ b/packages/server/src/automations/steps/queryRows.js @@ -0,0 +1,74 @@ +//const rowController = require("../../api/controllers/row") + +const SortOrders = { + ASCENDING: "ascending", + DESCENDING: "descending", +} + +const SortOrdersPretty = { + [SortOrders.ASCENDING]: "Ascending", + [SortOrders.DESCENDING]: "Descending", +} + +exports.definition = { + description: "Query rows from the database", + icon: "ri-search-line", + name: "Query rows", + tagline: "Query rows from {{inputs.enriched.table.name}} table", + type: "ACTION", + stepId: "QUERY_ROWS", + internal: true, + inputs: {}, + schema: { + inputs: { + properties: { + tableId: { + type: "string", + customType: "table", + title: "Table", + }, + filters: { + type: "object", + customType: "filters", + title: "Filtering", + }, + sortColumn: { + type: "string", + title: "Sort Column", + customType: "column", + }, + sortOrder: { + type: "string", + title: "Sort Order", + enum: Object.values(SortOrders), + pretty: Object.values(SortOrdersPretty), + }, + limit: { + type: "number", + title: "Limit", + }, + }, + required: ["tableId", "filters"], + }, + outputs: { + properties: { + row: { + type: "array", + customType: "rows", + description: "The rows that were found", + }, + success: { + type: "boolean", + description: "Whether the deletion was successful", + }, + }, + required: ["rows", "success"], + }, + }, +} + +exports.run = async function ({ inputs, appId }) { + console.log(inputs) + console.log(appId) + // TODO: use the search controller +} From 73e7875c5075ee380718f1af5fb44b2cca5bc56e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Sep 2021 13:45:38 +0100 Subject: [PATCH 2/5] Fixing issues with shared -> Shared directory. --- .../FlowChart/FlowItem.svelte | 2 +- .../app/[application]/automate/_layout.svelte | 2 +- packages/client/yarn.lock | 258 +++++++++++++++++- packages/server/yarn.lock | 9 +- 4 files changed, 258 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 5e34dd7d55..5beb101beb 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -11,7 +11,7 @@ StatusLight, } from "@budibase/bbui" import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte" - import CreateWebhookModal from "components/automation/shared/CreateWebhookModal.svelte" + import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" import ResultsModal from "./ResultsModal.svelte" import ActionModal from "./ActionModal.svelte" import { database } from "stores/backend" diff --git a/packages/builder/src/pages/builder/app/[application]/automate/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/automate/_layout.svelte index 8dbfd72761..22a49e04d2 100644 --- a/packages/builder/src/pages/builder/app/[application]/automate/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/automate/_layout.svelte @@ -3,7 +3,7 @@ import { automationStore } from "builderStore" import AutomationPanel from "components/automation/AutomationPanel/AutomationPanel.svelte" import CreateAutomationModal from "components/automation/AutomationPanel/CreateAutomationModal.svelte" - import CreateWebhookModal from "components/automation/shared/CreateWebhookModal.svelte" + import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" $: automation = $automationStore.automations[0] let modal let webhookModal diff --git a/packages/client/yarn.lock b/packages/client/yarn.lock index 27c542cf09..c0631eaa8e 100644 --- a/packages/client/yarn.lock +++ b/packages/client/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@adobe/spectrum-css-workflow-icons@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@adobe/spectrum-css-workflow-icons/-/spectrum-css-workflow-icons-1.2.1.tgz#7e2cb3fcfb5c8b12d7275afafbb6ec44913551b4" + integrity sha512-uVgekyBXnOVkxp+CUssjN/gefARtudZC8duEn1vm0lBQFwGRZFlDEzU1QC+aIRWCrD1Z8OgRpmBYlSZ7QS003w== + "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4": version "7.12.13" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.13.tgz#dcfc826beef65e75c50e21d3837d7d95798dd658" @@ -23,6 +28,73 @@ chalk "^2.0.0" js-tokens "^4.0.0" +"@budibase/bbui@^0.9.129": + version "0.9.129" + resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-0.9.129.tgz#989bf60d404772d4b308382faba7adac6518ec3e" + integrity sha512-U3uO9K3m7Ph5RQpzXx5IIy94s/KdU9Q8eJXFQwH6neYIKQk3OFo8br5px5C7lE38mtazqq9XvQy0f+MUarKk4A== + dependencies: + "@adobe/spectrum-css-workflow-icons" "^1.2.1" + "@spectrum-css/actionbutton" "^1.0.1" + "@spectrum-css/actiongroup" "^1.0.1" + "@spectrum-css/avatar" "^3.0.2" + "@spectrum-css/button" "^3.0.1" + "@spectrum-css/buttongroup" "^3.0.2" + "@spectrum-css/checkbox" "^3.0.2" + "@spectrum-css/dialog" "^3.0.1" + "@spectrum-css/divider" "^1.0.3" + "@spectrum-css/dropzone" "^3.0.2" + "@spectrum-css/fieldgroup" "^3.0.2" + "@spectrum-css/fieldlabel" "^3.0.1" + "@spectrum-css/icon" "^3.0.1" + "@spectrum-css/illustratedmessage" "^3.0.2" + "@spectrum-css/inputgroup" "^3.0.2" + "@spectrum-css/label" "^2.0.10" + "@spectrum-css/link" "^3.1.1" + "@spectrum-css/menu" "^3.0.1" + "@spectrum-css/modal" "^3.0.1" + "@spectrum-css/pagination" "^3.0.3" + "@spectrum-css/picker" "^1.0.1" + "@spectrum-css/popover" "^3.0.1" + "@spectrum-css/progressbar" "^1.0.2" + "@spectrum-css/progresscircle" "^1.0.2" + "@spectrum-css/radio" "^3.0.2" + "@spectrum-css/search" "^3.0.2" + "@spectrum-css/sidenav" "^3.0.2" + "@spectrum-css/statuslight" "^3.0.2" + "@spectrum-css/stepper" "^3.0.3" + "@spectrum-css/switch" "^1.0.2" + "@spectrum-css/table" "^3.0.1" + "@spectrum-css/tabs" "^3.0.1" + "@spectrum-css/tags" "^3.0.2" + "@spectrum-css/textfield" "^3.0.1" + "@spectrum-css/toast" "^3.0.1" + "@spectrum-css/tooltip" "^3.0.3" + "@spectrum-css/treeview" "^3.0.2" + "@spectrum-css/typography" "^3.0.1" + "@spectrum-css/underlay" "^2.0.9" + "@spectrum-css/vars" "^3.0.1" + dayjs "^1.10.4" + svelte-flatpickr "^3.1.0" + svelte-portal "^1.0.0" + +"@budibase/standard-components@^0.9.124": + version "0.9.129" + resolved "https://registry.yarnpkg.com/@budibase/standard-components/-/standard-components-0.9.129.tgz#f2cdead99b8f25177c4c291be3032fb9ffd1dac3" + integrity sha512-RYWBcrz4MGICg9neIPQ4CbU3WTTJoTofi2D4pwA+qvvN3uhqOCcFIZ3+yadZ5Akz2qwMztQ8WDvetowm2srZcA== + dependencies: + "@budibase/bbui" "^0.9.129" + "@spectrum-css/button" "^3.0.3" + "@spectrum-css/card" "^3.0.3" + "@spectrum-css/divider" "^1.0.3" + "@spectrum-css/link" "^3.1.3" + "@spectrum-css/page" "^3.0.1" + "@spectrum-css/typography" "^3.0.2" + "@spectrum-css/vars" "^3.0.1" + apexcharts "^3.22.1" + dayjs "^1.10.5" + svelte-apexcharts "^1.0.2" + svelte-flatpickr "^3.1.0" + "@rollup/plugin-alias@^3.1.5": version "3.1.5" resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-3.1.5.tgz#73356a3a1eab2e1e2fd952f9f53cd89fc740d952" @@ -64,16 +136,46 @@ estree-walker "^1.0.1" picomatch "^2.2.2" -"@spectrum-css/button@^3.0.3": +"@spectrum-css/actionbutton@^1.0.1": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/actionbutton/-/actionbutton-1.0.3.tgz#8f7342a69b303c5acdcfa0a59f5e9267b9f3cb30" + integrity sha512-P9qoCPSiZ1SB6ZYqK5hub0vGty00YYqonQE0KTjtb1i+T1nYR/87vWqVPERx9j63uhgZncjwFYaThTvRqye7eQ== + +"@spectrum-css/actiongroup@^1.0.1": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/actiongroup/-/actiongroup-1.0.3.tgz#4713ce65e6f5c72c404a7b638fbc3b4fd7e3874f" + integrity sha512-NlB9Q4ZlWixXxymoPIYG6g2hkwAGKFodHWPFfxHD8ddkjXWRB9G2akUP7cfsJ4DcYn4VisUORCOYQwqDiSmboQ== + +"@spectrum-css/avatar@^3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@spectrum-css/avatar/-/avatar-3.0.2.tgz#4f1826223eae330e64b6d3cc899e9bc2e98dac95" + integrity sha512-wEczvSqxttTWSiL3cOvXV/RmGRwSkw2w6+slcHhnf0kb7ovymMM+9oz8vvEpEsSeo5u598bc+7ktrKFpAd6soQ== + +"@spectrum-css/button@^3.0.1", "@spectrum-css/button@^3.0.3": version "3.0.3" resolved "https://registry.yarnpkg.com/@spectrum-css/button/-/button-3.0.3.tgz#2df1efaab6c7e0b3b06cb4b59e1eae59c7f1fc84" integrity sha512-6CnLPqqtaU/PcSSIGeGRi0iFIIxIUByYLKFO6zn5NEUc12KQ28dJ4PLwB6WBa0L8vRoAGlnWWH2ZZweTijbXgg== +"@spectrum-css/buttongroup@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/buttongroup/-/buttongroup-3.0.3.tgz#719d868845ac9d2c4f939c1b9f6044507902d5aa" + integrity sha512-eXl8U4QWMWXqyTu654FdQdEGnmczgOYlpIFSHyCMVjhtPqZp2xwnLFiGh6LKw+bLio6eeOZ0L+vpk1GcoYqgkw== + "@spectrum-css/card@^3.0.3": version "3.0.3" resolved "https://registry.yarnpkg.com/@spectrum-css/card/-/card-3.0.3.tgz#56b2e2da6b80c1583228baa279de7407383bfb6b" integrity sha512-+oKLUI2a0QmQP9EzySeq/G4FpUkkdaDNbuEbqCj2IkPMc/2v/nwzsPhh1fj2UIghGAiiUwXfPpzax1e8fyhQUg== +"@spectrum-css/checkbox@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/checkbox/-/checkbox-3.0.3.tgz#8577067fc8b97e4609f92bd242364937a533a7bb" + integrity sha512-QVG9uMHq+lh70Dh6mDNnY+vEvNz2p7VC6xgLfDYfijp2qeiqYPq72fQK6p/SiyqPk96ZACzNRwgeROU6Xf6Wgg== + +"@spectrum-css/dialog@^3.0.1": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/dialog/-/dialog-3.0.3.tgz#7715a4ea435e753afb623d99ca5917ed1bcd6f34" + integrity sha512-AhmKgfRIVyTe3ABiJ8lLUQL34VB/H6fN16na2LlbDRJvyRMzkdN1Xf2i6U3f4OMd3qQ8Gm5xat4BvMxIQPBAUQ== + "@spectrum-css/divider@^1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@spectrum-css/divider/-/divider-1.0.3.tgz#639e2ebaa0834efa40f42397668bbd5c153ea385" @@ -81,11 +183,56 @@ dependencies: "@spectrum-css/vars" "^3.0.2" -"@spectrum-css/link@^3.1.3": +"@spectrum-css/dropzone@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/dropzone/-/dropzone-3.0.3.tgz#aee71697a2c195947599d7541b858c3c198741dc" + integrity sha512-ujrswdtB6bHigklyHsm6zomFd6rUnKJ3xVVRjroVF4+ouK4DxK5tX0iVd0EW6AOfOjx4Cc28uyFot3fpxp+MQw== + +"@spectrum-css/fieldgroup@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/fieldgroup/-/fieldgroup-3.0.3.tgz#85d85da048d08200f25ceab378026dd2b11e0bb2" + integrity sha512-wXUXTXN1CPnR7M4Ltd+3uh7BfcNGUV1+Xe0/h0tCpq/j+S2Sd4xo7/pUMdU19sIDrAAtpEFp1tt+nouHcU5HGQ== + +"@spectrum-css/fieldlabel@^3.0.1": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/fieldlabel/-/fieldlabel-3.0.3.tgz#f73c04d20734d4718ffb620dc46458904685b449" + integrity sha512-nEvIkEXCD5n4fW67Unq6Iu7VXoauEd/JGpfTY02VsC5p4FJLnwKfPDbJUuUsqClAxqw7nAsmXVKtn4zQFf5yPQ== + +"@spectrum-css/icon@^3.0.1": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/icon/-/icon-3.0.3.tgz#5c612822380927087aebd526855d82ed2c3e2cba" + integrity sha512-hyloKOejPCXhP3MBNsm3SjR9j8xT1R1S19p32KW/0Qhj+VMUtfyEPmevyFptpn7wcovQccdl/vZVIVDuML/imw== + +"@spectrum-css/illustratedmessage@^3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@spectrum-css/illustratedmessage/-/illustratedmessage-3.0.2.tgz#6a480be98b027e050b086e7899e40d87adb0a8c0" + integrity sha512-dqnE8X27bGcO0HN8+dYx8O4o0dNNIAqeivOzDHhe2El+V4dTzMrNIerF6G0NLm3GjVf6XliwmitsZK+K6FmbtA== + +"@spectrum-css/inputgroup@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/inputgroup/-/inputgroup-3.0.3.tgz#00c9a370ddc2c55cf0f37dd6069faa9501fd7eb5" + integrity sha512-FqRJTiLL7jiGfzDVXWUGVLqHryJjCcqQIrqAi+Tq0oenapzsBe2qc/zIrKgh2wtMI+NTIBLXTECvij3L1HlqAg== + +"@spectrum-css/label@^2.0.10": + version "2.0.10" + resolved "https://registry.yarnpkg.com/@spectrum-css/label/-/label-2.0.10.tgz#2368651d7636a19385b5d300cdf6272db1916001" + integrity sha512-xCbtEiQkZIlLdWFikuw7ifDCC21DOC/KMgVrrVJHXFc4KRQe9LTZSqmGF3tovm+CSq1adE59mYoTbojVQ9YuEQ== + +"@spectrum-css/link@^3.1.1", "@spectrum-css/link@^3.1.3": version "3.1.3" resolved "https://registry.yarnpkg.com/@spectrum-css/link/-/link-3.1.3.tgz#b0e560a7e0acdb4a2b329b6669696aa3438f5993" integrity sha512-8Pmy5d73MwKcATTPaj+fSrZYnIw7GmfX40AvpC1xx5LauOxsbUb4AVNp1kn2H8rrOBmxF7czyhoBBhEiv66QUg== +"@spectrum-css/menu@^3.0.1": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/menu/-/menu-3.0.3.tgz#46a9b221bb5f470a2f8a934bdfd512d84d2fdc4d" + integrity sha512-qKA9J/MrikNKIpCEHsAazG2vY3im5tjGCmo6p9Pdnu8/aQMsiuZDHZayukeCttJUZkrb9guDVL9OIHlK5RZvcQ== + +"@spectrum-css/modal@^3.0.1": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@spectrum-css/modal/-/modal-3.0.2.tgz#58b6621cab65f90788d310374f40df1f7090473f" + integrity sha512-YnIivJhoaao7Otu+HV7sgebPyFbO6sd/oMvTN/Rb2wwgnaMnIIuIRdGandSrcgotN2uNgs+P0knG6mv/xA1/dg== + "@spectrum-css/page@^3.0.1": version "3.0.2" resolved "https://registry.yarnpkg.com/@spectrum-css/page/-/page-3.0.2.tgz#8f0c03d25f5565fb13115541a8fcaf0e1d3a8ee0" @@ -93,11 +240,106 @@ dependencies: "@spectrum-css/vars" "^3.0.2" -"@spectrum-css/typography@^3.0.2": +"@spectrum-css/pagination@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/pagination/-/pagination-3.0.3.tgz#b204c3ada384c4af751a354bc428346d82eeea65" + integrity sha512-OJ/v9GeNXJOZ9Yr9LDBYPrR2NCiLOWP9wANT/a5sqFuugRnQbn/HYMnRp9TBxwpDY6ihaPo0T/wi7kLiAJFdDw== + +"@spectrum-css/picker@^1.0.1": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/picker/-/picker-1.0.3.tgz#21379bcf8ae94277deeb6ad65dcd9e2bbfacb487" + integrity sha512-oHLGxBx5BwVCSGo7/T1C9PTHX1+/5AmVjyLiTJ4UoIdSJmOERw9YcRZbcGZgBJNWbxcjr4TyGtwj1EcSjEy97w== + +"@spectrum-css/popover@^3.0.1": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/popover/-/popover-3.0.3.tgz#6fb69873474fb968afb738eacb9e121f93e83a09" + integrity sha512-KvmXv4TV19FBx39KfmgVlDYtvtBqv/8RRK7RRLDDHGViTxZtShjVsVpwIgfkfgn4iJztCnXpWzFqRXWUu2XCpQ== + +"@spectrum-css/progressbar@^1.0.2": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/progressbar/-/progressbar-1.0.3.tgz#f70bcc38a2a21cff2f422ec825724ebbb9455e67" + integrity sha512-vJHplefUuy8+NjCw1X7fLbqHVGNVBpvGFXNAeaIj4SFf4ygxiUq/5c9iRhhsCQixEsJlfD/b7BnGXU7BUDkr6Q== + +"@spectrum-css/progresscircle@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@spectrum-css/progresscircle/-/progresscircle-1.0.2.tgz#258ea9170fb70f795edda03e38a61d93bef4487c" + integrity sha512-JLULpyzjIY95lzlWR1yE1gv4l1K6p+scQ+edmuZZUHBzwM3pUtkvHJmUlA9TYdResUYW6Uka60VRdY6lZ8gnFQ== + +"@spectrum-css/radio@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/radio/-/radio-3.0.3.tgz#25c3bc5e9c30a8a8ae728717b7c7fb736cdae640" + integrity sha512-LaLGfz/eGNR2iyqouXYILIA+pKRqF769iPdwM0REm5RpWvMQDD7rPZ/kWlg18owjaFsyllEp25gEjmhRJIIVOw== + +"@spectrum-css/search@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/search/-/search-3.0.3.tgz#3415dc106aca0d5dd996e87084a1b47c2b95a882" + integrity sha512-kdLpKTt0obljuhS1q1tukujRlvSs8sBwij76D4Qp8KpMzwePfZyvv1kYzuWPNZfTeISxWsmyZ6Wxd1uvzjn+UA== + +"@spectrum-css/sidenav@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/sidenav/-/sidenav-3.0.3.tgz#132141fbd2500a927c312fa4e1d712c438b3d597" + integrity sha512-cQ+CgwjxGftrcc79i1XnGd66QTl7H7zopSU0UTV4Qq7hvqfrjjWxfZ6b+3tezrrhNlDope1ff9o8sm67PsPXtg== + +"@spectrum-css/statuslight@^3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@spectrum-css/statuslight/-/statuslight-3.0.2.tgz#dc54b6cd113413dcdb909c486b5d7bae60db65c5" + integrity sha512-xodB8g8vGJH20XmUj9ZsPlM1jHrGeRbvmVXkz0q7YvQrYAhim8pP3W+XKKZAletPFAuu8cmUOc6SWn6i4X4z6w== + +"@spectrum-css/stepper@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/stepper/-/stepper-3.0.3.tgz#ae89846886431e3edeee060207b8f81540f73a34" + integrity sha512-prAD61ImlOTs9b6PfB3cB08x4lAfxtvnW+RZiTYky0E8GgZdrc/MfCkL5/oqQaIQUtyQv/3Lb7ELAf/0K8QTXw== + +"@spectrum-css/switch@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@spectrum-css/switch/-/switch-1.0.2.tgz#f0b4c69271964573e02b08e90998096e49e1de44" + integrity sha512-zqmHpgWPNg1gEwdUNFYV3CBX5JaeALfIqcJIxE0FLZqr9d1C4+oLE0ItIFzt1bwr4bFAOmkEpvtiY+amluzGxQ== + +"@spectrum-css/table@^3.0.1": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/table/-/table-3.0.3.tgz#7f7f19905ef3275cbf907ce3a5818e63c30b2caf" + integrity sha512-nxwzVjLPsXoY/v4sdxOVYLcC+cEbGgJyLcLclT5LT9MGSbngFeUMJzzVR4EvehzuN4dH7hrATG7Mbuq29Mf0Hg== + +"@spectrum-css/tabs@^3.0.1": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/tabs/-/tabs-3.0.3.tgz#51dd6f168c897b0fdc3a7e9f901df7bd2288b4fc" + integrity sha512-iLP1I72bJWz9APdQB1jiw+pOv5a7N+hYOCJvRoc56Us/hJKVzowkyGRe3uH+8v36nCG9bHxiAQNLoU8eXisVrg== + +"@spectrum-css/tags@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/tags/-/tags-3.0.3.tgz#fc76d2735cdc442de91b7eb3bee49a928c0767ac" + integrity sha512-SL8vPxVDfWcY5VdIuyl0TImEXcOU1I7yCyXkk7MudMwfnYs81FaIyY32hFV9OHj0Tz/36UzRzc7AVMSuRQ53pw== + +"@spectrum-css/textfield@^3.0.1": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@spectrum-css/textfield/-/textfield-3.0.2.tgz#907f62d2dc82852dd6236a820be99e252b531631" + integrity sha512-nkFgAb0cP4jUodkUBErMNfyF78jJLtgL1Mrr9/rvGpGobo10IAbb8zZY4CkZ64o8XmMy/85+wZTKcx+KHatqpg== + +"@spectrum-css/toast@^3.0.1": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/toast/-/toast-3.0.3.tgz#97c1527384707600832ecda35643ed304615250f" + integrity sha512-CjLeaMs+cjUXojCCRtbj0YkD2BoZW16kjj2o5omkEpUTjA34IJ8xJ1a+CCtDILWekhXvN0MBN4sbumcnwcnx8w== + +"@spectrum-css/tooltip@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/tooltip/-/tooltip-3.0.3.tgz#26b8ca3b3d30e29630244d85eb4fc11d0c841281" + integrity sha512-ztRF7WW1FzyNavXBRc+80z67UoOrY9wl3cMYsVD3MpDnyxdzP8cjza1pCcolKBaFqRTcQKkxKw3GWtGICRKR5A== + +"@spectrum-css/treeview@^3.0.2": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@spectrum-css/treeview/-/treeview-3.0.3.tgz#aeda5175158b9f8d7529cb2b394428eb2a428046" + integrity sha512-D5gGzZC/KtRArdx86Mesc9+99W9nTbUOeyYGqoJoAfJSOttoT6Tk5CrDvlCmAqjKf5rajemAkGri1ChqvUIwkw== + +"@spectrum-css/typography@^3.0.1", "@spectrum-css/typography@^3.0.2": version "3.0.2" resolved "https://registry.yarnpkg.com/@spectrum-css/typography/-/typography-3.0.2.tgz#ea3ca0a60e18064527819d48c8c4364cab4fcd38" integrity sha512-5ZOLmQe0edzsDMyhghUd4hBb5uxGsFrxzf+WasfcUw9klSfTsRZ09n1BsaaWbgrLjlMQ+EEHS46v5VNo0Ms2CA== +"@spectrum-css/underlay@^2.0.9": + version "2.0.10" + resolved "https://registry.yarnpkg.com/@spectrum-css/underlay/-/underlay-2.0.10.tgz#8b75b646605a311850f6620caa18d4996cd64ed7" + integrity sha512-PmsmkzeGD/rY4pp3ILXHt9w8BW7uaEqXe08hQRS7rGki7wqCpG4mE0/8N3yEcA3QxWQclmG9gdkg5uz6wMmYzA== + "@spectrum-css/vars@^3.0.1", "@spectrum-css/vars@^3.0.2": version "3.0.2" resolved "https://registry.yarnpkg.com/@spectrum-css/vars/-/vars-3.0.2.tgz#ea9062c3c98dfc6ba59e5df14a03025ad8969999" @@ -817,6 +1059,11 @@ data-urls@^2.0.0: whatwg-mimetype "^2.3.0" whatwg-url "^8.0.0" +dayjs@^1.10.4: + version "1.10.7" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.7.tgz#2cf5f91add28116748440866a0a1d26f3a6ce468" + integrity sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig== + dayjs@^1.10.5: version "1.10.6" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.6.tgz#288b2aa82f2d8418a6c9d4df5898c0737ad02a63" @@ -2953,6 +3200,11 @@ svelte-flatpickr@^3.1.0: dependencies: flatpickr "^4.5.2" +svelte-portal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/svelte-portal/-/svelte-portal-1.0.0.tgz#36a47c5578b1a4d9b4dc60fa32a904640ec4cdd3" + integrity sha512-nHf+DS/jZ6jjnZSleBMSaZua9JlG5rZv9lOGKgJuaZStfevtjIlUJrkLc3vbV8QdBvPPVmvcjTlazAzfKu0v3Q== + svelte-spa-router@^3.0.5: version "3.0.5" resolved "https://registry.yarnpkg.com/svelte-spa-router/-/svelte-spa-router-3.0.5.tgz#097506578ac2371c9556b9789bd397d408968d92" diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 3944d0a9e9..ef54091251 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -4226,7 +4226,7 @@ end-stream@~0.1.0: dependencies: write-stream "~0.4.3" -errno@~0.1.1, errno@~0.1.7: +errno@~0.1.1: version "0.1.8" resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f" integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A== @@ -11068,13 +11068,6 @@ word-wrap@~1.2.3: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== -worker-farm@1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.7.0.tgz#26a94c5391bbca926152002f69b84a4bf772e5a8" - integrity sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw== - dependencies: - errno "~0.1.7" - wrap-ansi@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" From 96f0f9b4fd5047a4b6dbdc7659f7dec7a70a4dca Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Sep 2021 19:02:44 +0100 Subject: [PATCH 3/5] Adding in backend implementation of the query step, as well as some front-end work to support the filter drawer within automations. --- .../SetupPanel/AutomationBlockSetup.svelte | 70 ++++++++++- .../FilterEditor/FilterDrawer.svelte | 25 ++-- .../server/src/api/controllers/row/index.js | 1 + packages/server/src/automations/actions.js | 3 + .../server/src/automations/steps/queryRows.js | 61 ++++++++-- packages/string-templates/manifest.json | 109 ++++++++++++++++++ .../scripts/gen-collection-info.js | 10 +- 7 files changed, 257 insertions(+), 22 deletions(-) diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index c16260779e..eceb2420dc 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -2,8 +2,16 @@ import TableSelector from "./TableSelector.svelte" import RowSelector from "./RowSelector.svelte" import SchemaSetup from "./SchemaSetup.svelte" - import { Button, Input, Select, Label } from "@budibase/bbui" + import { + Button, + Input, + Select, + Label, + ActionButton, + Drawer, + } from "@budibase/bbui" import { automationStore } from "builderStore" + import { tables } from "stores/backend" import WebhookDisplay from "../Shared/WebhookDisplay.svelte" import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte" import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte" @@ -15,11 +23,17 @@ import { database } from "stores/backend" import { debounce } from "lodash" import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte" + import FilterDrawer from "components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte" + // need the client lucene builder to convert to the structure API expects + import { buildLuceneQuery } from "../../../../../client/src/utils/lucene" export let block export let webhookModal export let testData export let schemaProperties + let drawer + let tempFilters = lookForFilters(schemaProperties) || [] + $: stepId = block.stepId $: bindings = getAvailableBindings( block || $automationStore.selectedBlock, @@ -28,6 +42,11 @@ $: instanceId = $database._id $: inputData = testData ? testData : block.inputs + $: tableId = inputData ? inputData.tableId : null + $: table = tableId + ? $tables.list.find(table => table._id === inputData.tableId) + : { schema: {} } + $: schemaFields = table ? Object.values(table.schema) : [] const onChange = debounce(async function (e, key) { if (testData) { @@ -71,6 +90,35 @@ } return bindings } + + function lookForFilters(properties) { + console.log("testing") + if (!properties) { + return [] + } + let filters + const inputs = testData ? testData : block.inputs + for (let [key, field] of properties) { + // need to look for the builder definition (keyed separately, see saveFilters) + const defKey = `${key}-def` + if (field.customType === "filters" && inputs?.[defKey]) { + filters = inputs[defKey] + break + } + } + return filters || [] + } + + function saveFilters(key) { + const filters = buildLuceneQuery(tempFilters) + const defKey = `${key}-def` + inputData[key] = filters + inputData[defKey] = tempFilters + onChange({ detail: filters }, key) + // need to store the builder definition in the automation + onChange({ detail: tempFilters }, defKey) + drawer.hide() + }
@@ -84,6 +132,26 @@ options={value.enum} getOptionLabel={(x, idx) => (value.pretty ? value.pretty[idx] : x)} /> + {:else if value.customType === "column"} + import { - DatePicker, - Icon, - Button, - Select, - Combobox, - Input, - DrawerContent, - Layout, Body, + Button, + Combobox, + DatePicker, + DrawerContent, + Icon, + Input, + Layout, + Select, } from "@budibase/bbui" import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" + import BindingPanel from "components/common/bindings/BindingPanel.svelte" import { generate } from "shortid" - import { OperatorOptions, getValidOperatorsForType } from "helpers/lucene" + import { getValidOperatorsForType, OperatorOptions } from "helpers/lucene" export let schemaFields export let filters = [] export let bindings = [] + export let panel = BindingPanel const BannedTypes = ["link", "attachment", "formula"] @@ -82,9 +84,7 @@ const getFieldOptions = field => { const schema = schemaFields.find(x => x.name === field) - const opt = schema?.constraints?.inclusion || [] - - return opt + return schema?.constraints?.inclusion || [] } @@ -127,6 +127,7 @@ title={`Value for "${filter.field}"`} value={filter.value} placeholder="Value" + {panel} {bindings} on:change={event => (filter.value = event.detail)} /> diff --git a/packages/server/src/api/controllers/row/index.js b/packages/server/src/api/controllers/row/index.js index a50afa77ea..1d003ebd18 100644 --- a/packages/server/src/api/controllers/row/index.js +++ b/packages/server/src/api/controllers/row/index.js @@ -113,6 +113,7 @@ exports.destroy = async function (ctx) { exports.search = async ctx => { const tableId = getTableId(ctx) try { + ctx.status = 200 ctx.body = await pickApi(tableId).search(ctx) } catch (err) { ctx.throw(400, err) diff --git a/packages/server/src/automations/actions.js b/packages/server/src/automations/actions.js index ef77387a40..13f7c487c1 100644 --- a/packages/server/src/automations/actions.js +++ b/packages/server/src/automations/actions.js @@ -13,6 +13,7 @@ const zapier = require("./steps/zapier") const integromat = require("./steps/integromat") let filter = require("./steps/filter") let delay = require("./steps/delay") +let queryRow = require("./steps/queryRows") const ACTION_IMPLS = { SEND_EMAIL_SMTP: sendSmtpEmail.run, @@ -26,6 +27,7 @@ const ACTION_IMPLS = { SERVER_LOG: serverLog.run, DELAY: delay.run, FILTER: filter.run, + QUERY_ROWS: queryRow.run, // these used to be lowercase step IDs, maintain for backwards compat discord: discord.run, slack: slack.run, @@ -44,6 +46,7 @@ const ACTION_DEFINITIONS = { SERVER_LOG: serverLog.definition, DELAY: delay.definition, FILTER: filter.definition, + QUERY_ROWS: queryRow.definition, // these used to be lowercase step IDs, maintain for backwards compat discord: discord.definition, slack: slack.definition, diff --git a/packages/server/src/automations/steps/queryRows.js b/packages/server/src/automations/steps/queryRows.js index 8b01bd9755..64b757418e 100644 --- a/packages/server/src/automations/steps/queryRows.js +++ b/packages/server/src/automations/steps/queryRows.js @@ -1,4 +1,6 @@ -//const rowController = require("../../api/controllers/row") +const rowController = require("../../api/controllers/row") +const tableController = require("../../api/controllers/table") +const { FieldTypes } = require("../../constants") const SortOrders = { ASCENDING: "ascending", @@ -12,7 +14,7 @@ const SortOrdersPretty = { exports.definition = { description: "Query rows from the database", - icon: "ri-search-line", + icon: "Search", name: "Query rows", tagline: "Query rows from {{inputs.enriched.table.name}} table", type: "ACTION", @@ -48,11 +50,11 @@ exports.definition = { title: "Limit", }, }, - required: ["tableId", "filters"], + required: ["tableId"], }, outputs: { properties: { - row: { + rows: { type: "array", customType: "rows", description: "The rows that were found", @@ -67,8 +69,51 @@ exports.definition = { }, } -exports.run = async function ({ inputs, appId }) { - console.log(inputs) - console.log(appId) - // TODO: use the search controller +async function getTable(appId, tableId) { + const ctx = { + params: { + id: tableId, + }, + appId, + } + await tableController.find(ctx) + return ctx.body +} + +exports.run = async function ({ inputs, appId }) { + const { tableId, filters, sortColumn, sortOrder, limit } = inputs + const table = await getTable(appId, tableId) + let sortType = FieldTypes.STRING + if (table && table.schema && sortColumn) { + const fieldType = table.schema[sortColumn].type + sortType = + fieldType === FieldTypes.NUMBER ? FieldTypes.NUMBER : FieldTypes.STRING + } + const ctx = { + params: { + tableId, + }, + request: { + body: { + sortOrder, + sortType, + sort: sortColumn, + query: filters || {}, + limit, + }, + }, + appId, + } + try { + await rowController.search(ctx) + return { + rows: ctx.body ? ctx.body.rows : [], + success: ctx.status === 200, + } + } catch (err) { + return { + success: false, + response: err, + } + } } diff --git a/packages/string-templates/manifest.json b/packages/string-templates/manifest.json index 02bd7f8a64..629bb2ebe3 100644 --- a/packages/string-templates/manifest.json +++ b/packages/string-templates/manifest.json @@ -1090,6 +1090,115 @@ "description": "

Block helper that always renders the inverse block unless a is less than or equal to b.

\n" } }, + "object": { + "extend": { + "args": [ + "objects" + ], + "numArgs": 1, + "description": "

Extend the context with the properties of other objects. A shallow merge is performed to avoid mutating the context.

\n" + }, + "forIn": { + "args": [ + "context", + "options" + ], + "numArgs": 2, + "description": "

Block helper that iterates over the properties of an object, exposing each key and value on the context.

\n" + }, + "forOwn": { + "args": [ + "obj", + "options" + ], + "numArgs": 2, + "description": "

Block helper that iterates over the own properties of an object, exposing each key and value on the context.

\n" + }, + "toPath": { + "args": [ + "prop" + ], + "numArgs": 1, + "description": "

Take arguments and, if they are string or number, convert them to a dot-delineated object property path.

\n" + }, + "get": { + "args": [ + "prop", + "context", + "options" + ], + "numArgs": 3, + "description": "

Use property paths (a.b.c) to get a value or nested value from the context. Works as a regular helper or block helper.

\n" + }, + "getObject": { + "args": [ + "prop", + "context" + ], + "numArgs": 2, + "description": "

Use property paths (a.b.c) to get an object from the context. Differs from the get helper in that this helper will return the actual object, including the given property key. Also, this helper does not work as a block helper.

\n" + }, + "hasOwn": { + "args": [ + "key", + "context" + ], + "numArgs": 2, + "description": "

Return true if key is an own, enumerable property of the given context object.

\n" + }, + "isObject": { + "args": [ + "value" + ], + "numArgs": 1, + "description": "

Return true if value is an object.

\n" + }, + "JSONparse": { + "args": [ + "string" + ], + "numArgs": 1, + "description": "

Parses the given string using JSON.parse.

\n" + }, + "JSONstringify": { + "args": [ + "obj" + ], + "numArgs": 1, + "description": "

Stringify an object using JSON.stringify.

\n" + }, + "merge": { + "args": [ + "object", + "objects" + ], + "numArgs": 2, + "description": "

Deeply merge the properties of the given objects with the context object.

\n" + }, + "parseJSON": { + "args": [ + "string" + ], + "numArgs": 1, + "description": "

Parses the given string using JSON.parse.

\n" + }, + "pick": { + "args": [ + "properties", + "context", + "options" + ], + "numArgs": 3, + "description": "

Pick properties from the context object.

\n" + }, + "stringify": { + "args": [ + "obj" + ], + "numArgs": 1, + "description": "

Stringify an object using JSON.stringify.

\n" + } + }, "date": { "date": { "args": [ diff --git a/packages/string-templates/scripts/gen-collection-info.js b/packages/string-templates/scripts/gen-collection-info.js index fcd3cb4923..29df10423f 100644 --- a/packages/string-templates/scripts/gen-collection-info.js +++ b/packages/string-templates/scripts/gen-collection-info.js @@ -11,7 +11,15 @@ const marked = require("marked") */ const DIRECTORY = fs.existsSync("node_modules") ? "." : ".." -const COLLECTIONS = ["math", "array", "number", "url", "string", "comparison"] +const COLLECTIONS = [ + "math", + "array", + "number", + "url", + "string", + "comparison", + "object", +] const FILENAME = `${DIRECTORY}/manifest.json` const outputJSON = {} const ADDED_HELPERS = { From 94d5ff895a25d95bcb617762b2f7de60b760a3a5 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 16 Sep 2021 12:43:08 +0100 Subject: [PATCH 4/5] Adding test case for new query rows step. --- packages/server/package.json | 3 +- .../src/automations/tests/queryRows.spec.js | 51 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 packages/server/src/automations/tests/queryRows.spec.js diff --git a/packages/server/package.json b/packages/server/package.json index c564e00d6e..f805fea051 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -49,7 +49,8 @@ "!src/automations/tests/**/*", "!src/utilities/fileProcessor.js", "!src/utilities/fileSystem/**/*", - "!src/utilities/redis.js" + "!src/utilities/redis.js", + "!src/api/controllers/row/internalSearch.js" ], "coverageReporters": [ "lcov", diff --git a/packages/server/src/automations/tests/queryRows.spec.js b/packages/server/src/automations/tests/queryRows.spec.js new file mode 100644 index 0000000000..fca03f4e3b --- /dev/null +++ b/packages/server/src/automations/tests/queryRows.spec.js @@ -0,0 +1,51 @@ +// lucene searching not supported in test due to use of PouchDB +let rows = [] +jest.mock("../../api/controllers/row/internalSearch", () => ({ + fullSearch: jest.fn(() => { + return { + rows, + } + }), + paginatedSearch: jest.fn(), +})) +const setup = require("./utilities") + +const NAME = "Test" + +describe("Test a query step automation", () => { + let table + let config = setup.getConfig() + + beforeEach(async () => { + await config.init() + table = await config.createTable() + const row = { + name: NAME, + description: "original description", + tableId: table._id, + } + rows.push(await config.createRow(row)) + rows.push(await config.createRow(row)) + }) + + afterAll(setup.afterAll) + + it("should be able to run the query step", async () => { + const inputs = { + tableId: table._id, + filters: { + equal: { + name: NAME, + }, + }, + sortColumn: "name", + sortOrder: "ascending", + limit: 10, + } + const res = await setup.runStep(setup.actions.QUERY_ROWS.stepId, inputs) + expect(res.success).toBe(true) + expect(res.rows).toBeDefined() + expect(res.rows.length).toBe(2) + expect(res.rows[0].name).toBe(NAME) + }) +}) \ No newline at end of file From 3113368c263624a8da273dfcefa4356c2687ef8c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 16 Sep 2021 13:45:22 +0100 Subject: [PATCH 5/5] Making filter drawer in automations full width. --- .../automation/SetupPanel/AutomationBlockSetup.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 7c420c5f02..ff61c8345d 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -33,6 +33,7 @@ export let schemaProperties let drawer let tempFilters = lookForFilters(schemaProperties) || [] + let fillWidth = true $: stepId = block.stepId $: bindings = getAvailableBindings( @@ -140,7 +141,7 @@ /> {:else if value.customType === "filters"} Define filters - +