better integration API, parse JSON by default
This commit is contained in:
commit
6f57c1d22d
|
@ -68,5 +68,6 @@ jobs:
|
|||
env:
|
||||
DOCKER_USER: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_API_KEY }}
|
||||
run: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
|
||||
run: yarn build:docker
|
||||
run: |
|
||||
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
|
||||
yarn build:docker
|
||||
|
|
|
@ -9,7 +9,6 @@ services:
|
|||
SELF_HOSTED: 1
|
||||
COUCH_DB_URL: http://${COUCH_DB_USER}:${COUCH_DB_PASSWORD}@couchdb-service:5984
|
||||
BUDIBASE_ENVIRONMENT: ${BUDIBASE_ENVIRONMENT}
|
||||
LOGO_URL: ${LOGO_URL}
|
||||
PORT: 4002
|
||||
JWT_SECRET: ${JWT_SECRET}
|
||||
depends_on:
|
||||
|
@ -43,6 +42,7 @@ services:
|
|||
environment:
|
||||
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
|
||||
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
|
||||
MINIO_BROWSER: "off"
|
||||
command: server /data
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||||
|
|
|
@ -5,9 +5,6 @@ MAIN_PORT=10000
|
|||
# This should be updated
|
||||
HOSTING_KEY=budibase
|
||||
|
||||
# This section contains customisation options
|
||||
LOGO_URL=https://logoipsum.com/logo/logo-15.svg
|
||||
|
||||
# This section contains all secrets pertaining to the system
|
||||
# These should be updated
|
||||
JWT_SECRET=testsecret
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "0.4.3",
|
||||
"version": "0.5.3",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/builder",
|
||||
"version": "0.4.3",
|
||||
"version": "0.5.3",
|
||||
"license": "AGPL-3.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
@ -64,7 +64,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@budibase/bbui": "^1.52.4",
|
||||
"@budibase/client": "^0.4.3",
|
||||
"@budibase/client": "^0.5.3",
|
||||
"@budibase/colorpicker": "^1.0.1",
|
||||
"@budibase/svelte-ag-grid": "^0.0.16",
|
||||
"@fortawesome/fontawesome-free": "^5.14.0",
|
||||
|
|
|
@ -56,4 +56,13 @@ export default class Automation {
|
|||
steps.splice(stepIdx, 1)
|
||||
this.automation.definition.steps = steps
|
||||
}
|
||||
|
||||
constructBlock(type, stepId, blockDefinition) {
|
||||
return {
|
||||
...blockDefinition,
|
||||
inputs: blockDefinition.inputs || {},
|
||||
stepId,
|
||||
type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { writable } from "svelte/store"
|
|||
import api from "../../api"
|
||||
import Automation from "./Automation"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import analytics from "analytics"
|
||||
|
||||
const automationActions = store => ({
|
||||
fetch: async () => {
|
||||
|
@ -93,6 +94,9 @@ const automationActions = store => ({
|
|||
state.selectedBlock = newBlock
|
||||
return state
|
||||
})
|
||||
analytics.captureEvent("Added Automation Block", {
|
||||
name: block.name,
|
||||
})
|
||||
},
|
||||
deleteAutomationBlock: block => {
|
||||
store.update(state => {
|
||||
|
|
|
@ -49,16 +49,9 @@
|
|||
}
|
||||
|
||||
function addBlockToAutomation(stepId, blockDefinition) {
|
||||
const newBlock = {
|
||||
...blockDefinition,
|
||||
inputs: blockDefinition.inputs || {},
|
||||
stepId,
|
||||
type: selectedTab,
|
||||
}
|
||||
const newBlock = $automationStore.selectedAutomation.constructBlock(
|
||||
selectedTab, stepId, blockDefinition)
|
||||
automationStore.actions.addBlockToAutomation(newBlock)
|
||||
analytics.captureEvent("Added Automation Block", {
|
||||
name: blockDefinition.name,
|
||||
})
|
||||
closePopover()
|
||||
if (stepId === "WEBHOOK") {
|
||||
webhookModal.show()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<script>
|
||||
import TableSelector from "./TableSelector.svelte"
|
||||
import RowSelector from "./RowSelector.svelte"
|
||||
import SchemaSetup from "./SchemaSetup.svelte"
|
||||
import { Button, Input, Select, Label } from "@budibase/bbui"
|
||||
import { automationStore } from "builderStore"
|
||||
import WebhookDisplay from "../Shared/WebhookDisplay.svelte"
|
||||
|
@ -70,6 +71,8 @@
|
|||
<RowSelector bind:value={block.inputs[key]} {bindings} />
|
||||
{:else if value.customType === 'webhookUrl'}
|
||||
<WebhookDisplay value={block.inputs[key]} />
|
||||
{:else if value.customType === 'triggerSchema'}
|
||||
<SchemaSetup bind:value={block.inputs[key]} />
|
||||
{:else if value.type === 'string' || value.type === 'number'}
|
||||
<BindableInput
|
||||
type="string"
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
<script>
|
||||
import { Input, Select } from "@budibase/bbui"
|
||||
|
||||
export let value = {}
|
||||
$: fieldsArray = Object.entries(value).map(([name, type]) => ({
|
||||
name,
|
||||
type,
|
||||
}))
|
||||
|
||||
function addField() {
|
||||
const newValue = { ...value }
|
||||
newValue[""] = "string"
|
||||
value = newValue
|
||||
}
|
||||
|
||||
function removeField(name) {
|
||||
const newValues = { ...value }
|
||||
delete newValues[name]
|
||||
value = newValues
|
||||
}
|
||||
|
||||
const fieldNameChanged = originalName => e => {
|
||||
// reconstruct using fieldsArray, so field order is preserved
|
||||
let entries = [...fieldsArray]
|
||||
const newName = e.target.value
|
||||
if (newName) {
|
||||
entries.find(f => f.name === originalName).name = newName
|
||||
} else {
|
||||
entries = entries.filter(f => f.name !== originalName)
|
||||
}
|
||||
value = entries.reduce((newVals, current) => {
|
||||
newVals[current.name] = current.type
|
||||
return newVals
|
||||
}, {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="root">
|
||||
<div class="add-field">
|
||||
<i class="ri-add-line" on:click={addField} />
|
||||
</div>
|
||||
<div class="spacer" />
|
||||
{#each fieldsArray as field}
|
||||
<div class="field">
|
||||
<Input
|
||||
value={field.name}
|
||||
secondary
|
||||
on:change={fieldNameChanged(field.name)} />
|
||||
<Select
|
||||
secondary
|
||||
extraThin
|
||||
value={field.type}
|
||||
on:blur={e => (value[field.name] = e.target.value)}>
|
||||
<option>string</option>
|
||||
<option>number</option>
|
||||
<option>boolean</option>
|
||||
<option>datetime</option>
|
||||
</Select>
|
||||
|
||||
<i class="remove-field ri-delete-bin-line"
|
||||
on:click={() => removeField(field.name)} />
|
||||
|
||||
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.root {
|
||||
position: relative;
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
/* so we can show the "+" button beside the "fields" label*/
|
||||
top: -26px;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
height: var(--spacing-s);
|
||||
}
|
||||
|
||||
.field {
|
||||
max-width: 100%;
|
||||
background-color: var(--grey-2);
|
||||
margin-bottom: var(--spacing-m);
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
border-color: var(--grey-4);
|
||||
display: grid;
|
||||
/*grid-template-rows: auto auto;
|
||||
grid-template-columns: auto;*/
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.field :global(select) {
|
||||
padding: var(--spacing-xs) 2rem var(--spacing-m) var(--spacing-s) !important;
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--grey-7);
|
||||
}
|
||||
|
||||
.field :global(.pointer) {
|
||||
padding-bottom: var(--spacing-m) !important;
|
||||
color: var(--grey-2);
|
||||
}
|
||||
|
||||
.field :global(input) {
|
||||
padding: var(--spacing-m) var(--spacing-xl) var(--spacing-xs) var(--spacing-m);
|
||||
font-size: var(--font-size-s);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.remove-field {
|
||||
cursor: pointer;
|
||||
color: var(--grey-6);
|
||||
position: absolute;
|
||||
top: var(--spacing-m);
|
||||
right: 3px;
|
||||
}
|
||||
|
||||
.remove-field:hover {
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
.add-field {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.add-field > i {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -7,6 +7,7 @@
|
|||
Heading,
|
||||
Select
|
||||
} from "@budibase/bbui"
|
||||
import Editor from "./QueryEditor.svelte"
|
||||
|
||||
export let fields = {}
|
||||
export let schema
|
||||
|
@ -17,23 +18,8 @@
|
|||
$: fieldKeys = Object.keys(fields)
|
||||
$: schemaKeys = Object.keys(schema.fields)
|
||||
|
||||
$: console.log({ fields, schema })
|
||||
|
||||
function addField() {
|
||||
// Add the new field to custom fields for the query
|
||||
schema.fields[draftField.name] = {
|
||||
type: draftField.type
|
||||
}
|
||||
// reset the draft field
|
||||
draftField = {}
|
||||
}
|
||||
|
||||
function removeField(field) {
|
||||
delete fields[field]
|
||||
fields = fields
|
||||
|
||||
delete schema.fields[field]
|
||||
schema = schema
|
||||
function updateCustomFields({ detail }) {
|
||||
fields.customData = detail.value
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -46,38 +32,21 @@
|
|||
type={schema.fields[field]?.type}
|
||||
required={schema.fields[field]?.required}
|
||||
bind:value={fields[field]} />
|
||||
{#if !schema.fields[field]?.required}
|
||||
<i class="ri-close-circle-line" on:click={() => removeField(field)} />
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</form>
|
||||
{#if schema.customisable && editable}
|
||||
<div>
|
||||
<Label>Add Custom Field</Label>
|
||||
<div class="new-field">
|
||||
<Label extraSmall grey>Name</Label>
|
||||
<Label extraSmall grey>Type</Label>
|
||||
<Input thin bind:value={draftField.name} />
|
||||
<Select thin secondary bind:value={draftField.type}>
|
||||
<option value={"text"}>String</option>
|
||||
<option value={"number"}>Number</option>
|
||||
</Select>
|
||||
</div>
|
||||
<Button small thin secondary on:click={addField}>Add Field</Button>
|
||||
</div>
|
||||
<Label extraSmall grey>Data</Label>
|
||||
{#if schema.customisable}
|
||||
<Editor
|
||||
label="Query"
|
||||
mode="json"
|
||||
on:change={updateCustomFields}
|
||||
readOnly={!editable}
|
||||
value={fields.customData} />
|
||||
{/if}
|
||||
|
||||
|
||||
<style>
|
||||
.new-field {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: var(--spacing-m);
|
||||
margin-top: var(--spacing-m);
|
||||
margin-bottom: var(--spacing-m);
|
||||
}
|
||||
|
||||
.field {
|
||||
margin-bottom: var(--spacing-m);
|
||||
display: grid;
|
||||
|
@ -85,15 +54,4 @@
|
|||
grid-gap: var(--spacing-m);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
i {
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
i:hover {
|
||||
transform: scale(1.1);
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -47,5 +47,5 @@
|
|||
value={query.fields.json} />
|
||||
{:else if schema.type === QueryTypes.FIELDS}
|
||||
<FieldsBuilder bind:fields={query.fields} {schema} {editable} />
|
||||
{:else if schema.type === QueryTypes.LIST}LIST STUFF{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
} from "@budibase/bbui"
|
||||
import { AddIcon, ArrowDownIcon } from "components/common/Icons/"
|
||||
import actionTypes from "./actions"
|
||||
import { createEventDispatcher } from "svelte"
|
||||
import { automationStore } from "builderStore"
|
||||
|
||||
const eventTypeKey = "##eventHandlerType"
|
||||
const EVENT_TYPE_KEY = "##eventHandlerType"
|
||||
|
||||
export let event
|
||||
|
||||
|
@ -17,16 +19,10 @@
|
|||
let addActionDropdown
|
||||
let selectedAction
|
||||
|
||||
let draftEventHandler = { parameters: [] }
|
||||
|
||||
$: actions = event || []
|
||||
$: selectedActionComponent =
|
||||
selectedAction &&
|
||||
actionTypes.find(t => t.name === selectedAction[eventTypeKey]).component
|
||||
|
||||
const updateEventHandler = (updatedHandler, index) => {
|
||||
actions[index] = updatedHandler
|
||||
}
|
||||
actionTypes.find(t => t.name === selectedAction[EVENT_TYPE_KEY]).component
|
||||
|
||||
const deleteAction = index => {
|
||||
actions.splice(index, 1)
|
||||
|
@ -36,7 +32,7 @@
|
|||
const addAction = actionType => () => {
|
||||
const newAction = {
|
||||
parameters: {},
|
||||
[eventTypeKey]: actionType.name,
|
||||
[EVENT_TYPE_KEY]: actionType.name,
|
||||
}
|
||||
actions.push(newAction)
|
||||
selectedAction = newAction
|
||||
|
@ -79,7 +75,7 @@
|
|||
<div class="action-container">
|
||||
<div class="action-header" on:click={selectAction(action)}>
|
||||
<span class:selected={action === selectedAction}>
|
||||
{index + 1}. {action[eventTypeKey]}
|
||||
{index + 1}. {action[EVENT_TYPE_KEY]}
|
||||
</span>
|
||||
</div>
|
||||
<i
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import { notifier } from "builderStore/store/notifications"
|
||||
import EventEditor from "./EventEditor.svelte"
|
||||
import BottomDrawer from "components/common/BottomDrawer.svelte"
|
||||
import { automationStore } from "builderStore"
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
|
@ -17,10 +18,48 @@
|
|||
drawerVisible = true
|
||||
}
|
||||
|
||||
const saveEventData = () => {
|
||||
const saveEventData = async () => {
|
||||
// any automations that need created from event triggers
|
||||
const automationsToCreate = value.filter(
|
||||
action => action["##eventHandlerType"] === "Trigger Automation"
|
||||
)
|
||||
automationsToCreate.forEach(action => createAutomation(action.parameters))
|
||||
|
||||
dispatch("change", value)
|
||||
notifier.success("Component actions saved.")
|
||||
}
|
||||
|
||||
// called by the parent modal when actions are saved
|
||||
const createAutomation = async parameters => {
|
||||
if (parameters.automationId || !parameters.newAutomationName) return
|
||||
|
||||
await automationStore.actions.create({ name: parameters.newAutomationName })
|
||||
|
||||
const appActionDefinition = $automationStore.blockDefinitions.TRIGGER.APP
|
||||
|
||||
const newBlock = $automationStore.selectedAutomation.constructBlock(
|
||||
"TRIGGER",
|
||||
"APP",
|
||||
appActionDefinition
|
||||
)
|
||||
|
||||
newBlock.inputs = {
|
||||
fields: Object.entries(parameters.fields).reduce(
|
||||
(fields, [key, value]) => {
|
||||
fields[key] = value.type
|
||||
return fields
|
||||
},
|
||||
{}
|
||||
),
|
||||
}
|
||||
|
||||
automationStore.actions.addBlockToAutomation(newBlock)
|
||||
|
||||
await automationStore.actions.save($automationStore.selectedAutomation)
|
||||
|
||||
parameters.automationId = $automationStore.selectedAutomation.automation._id
|
||||
delete parameters.newAutomationName
|
||||
}
|
||||
</script>
|
||||
|
||||
<Button secondary small on:click={showDrawer}>Define Actions</Button>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
// accepts an array of field names, and outputs an object of { FieldName: value }
|
||||
import { DataList, Label, TextButton, Spacer, Select } from "@budibase/bbui"
|
||||
import { DataList, Label, TextButton, Spacer, Select, Input } from "@budibase/bbui"
|
||||
import { store, backendUiStore, currentAsset } from "builderStore"
|
||||
import fetchBindableProperties from "builderStore/fetchBindableProperties"
|
||||
import { CloseCircleIcon, AddIcon } from "components/common/Icons"
|
||||
|
@ -14,6 +14,7 @@
|
|||
|
||||
export let parameterFields
|
||||
export let schemaFields
|
||||
export let fieldLabel="Column"
|
||||
|
||||
const emptyField = () => ({ name: "", value: "" })
|
||||
|
||||
|
@ -59,7 +60,7 @@
|
|||
// value and type is needed by the client, so it can parse
|
||||
// a string into a correct type
|
||||
newParameterFields[field.name] = {
|
||||
type: schemaFields.find(f => f.name === field.name).type,
|
||||
type: schemaFields ? schemaFields.find(f => f.name === field.name).type : "string",
|
||||
value: readableToRuntimeBinding(bindableProperties, field.value),
|
||||
}
|
||||
}
|
||||
|
@ -73,13 +74,17 @@
|
|||
|
||||
{#if fields}
|
||||
{#each fields as field}
|
||||
<Label size="m" color="dark">Column</Label>
|
||||
<Label size="m" color="dark">{fieldLabel}</Label>
|
||||
{#if schemaFields}
|
||||
<Select secondary bind:value={field.name} on:blur={rebuildParameters}>
|
||||
<option value="" />
|
||||
{#each schemaFields as schemaField}
|
||||
<option value={schemaField.name}>{schemaField.name}</option>
|
||||
{/each}
|
||||
</Select>
|
||||
{:else}
|
||||
<Input secondary bind:value={field.name} on:blur={rebuildParameters}/>
|
||||
{/if}
|
||||
<Label size="m" color="dark">Value</Label>
|
||||
<DataList secondary bind:value={field.value} on:blur={rebuildParameters}>
|
||||
<option value="" />
|
||||
|
@ -100,7 +105,7 @@
|
|||
<Spacer small />
|
||||
|
||||
<TextButton text small blue on:click={addField}>
|
||||
Add Field
|
||||
Add {fieldLabel}
|
||||
<div style="height: 20px; width: 20px;">
|
||||
<AddIcon />
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
<script>
|
||||
import { Select, Label, Input } from "@budibase/bbui"
|
||||
import { automationStore } from "builderStore"
|
||||
import SaveFields from "./SaveFields.svelte"
|
||||
|
||||
const AUTOMATION_STATUS = {
|
||||
NEW: "new",
|
||||
EXISTING: "existing"
|
||||
}
|
||||
|
||||
export let parameters = {}
|
||||
|
||||
let automationStatus = parameters.automationId ? AUTOMATION_STATUS.EXISTING : AUTOMATION_STATUS.NEW
|
||||
|
||||
$: automations = $automationStore.automations
|
||||
.filter(a => a.definition.trigger?.stepId === "APP")
|
||||
.map(automation => {
|
||||
const schema = Object.entries(
|
||||
automation.definition.trigger.inputs.fields
|
||||
).map(([name, type]) => ({ name, type }))
|
||||
|
||||
return {
|
||||
name: automation.name,
|
||||
_id: automation._id,
|
||||
schema,
|
||||
}
|
||||
})
|
||||
|
||||
$: hasAutomations = automations && automations.length > 0
|
||||
|
||||
$: selectedAutomation =
|
||||
parameters &&
|
||||
parameters.automationId &&
|
||||
automations.find(a => a._id === parameters.automationId)
|
||||
|
||||
const onFieldsChanged = e => {
|
||||
parameters.fields = e.detail
|
||||
}
|
||||
|
||||
const setNew = () => {
|
||||
automationStatus = AUTOMATION_STATUS.NEW
|
||||
parameters.automationId = undefined
|
||||
}
|
||||
|
||||
const setExisting = () => {
|
||||
automationStatus = AUTOMATION_STATUS.EXISTING
|
||||
parameters.newAutomationName = ""
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="root">
|
||||
|
||||
<div class="radio-container" on:click={setNew}>
|
||||
<input
|
||||
type="radio"
|
||||
value={AUTOMATION_STATUS.NEW}
|
||||
bind:group={automationStatus}
|
||||
disabled={!hasAutomations}>
|
||||
|
||||
<Label disabled={!hasAutomations}>Create a new automation </Label>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="radio-container" on:click={setExisting}>
|
||||
|
||||
<input
|
||||
type="radio"
|
||||
value={AUTOMATION_STATUS.EXISTING}
|
||||
bind:group={automationStatus}
|
||||
disabled={!hasAutomations}>
|
||||
|
||||
<Label disabled={!hasAutomations}>Use an existing automation </Label>
|
||||
|
||||
</div>
|
||||
|
||||
<Label size="m" color="dark">Automation</Label>
|
||||
|
||||
{#if automationStatus === AUTOMATION_STATUS.EXISTING}
|
||||
<Select secondary bind:value={parameters.automationId} placeholder="Choose automation">
|
||||
<option value="" />
|
||||
{#each automations as automation}
|
||||
<option value={automation._id}>{automation.name}</option>
|
||||
{/each}
|
||||
</Select>
|
||||
{:else}
|
||||
<Input secondary bind:value={parameters.newAutomationName} placeholder="Enter automation name" />
|
||||
{/if}
|
||||
|
||||
<SaveFields
|
||||
parameterFields={parameters.fields}
|
||||
schemaFields={automationStatus === AUTOMATION_STATUS.EXISTING && selectedAutomation && selectedAutomation.schema}
|
||||
fieldLabel="Field"
|
||||
on:fieldschanged={onFieldsChanged} />
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.root {
|
||||
display: grid;
|
||||
column-gap: var(--spacing-s);
|
||||
row-gap: var(--spacing-s);
|
||||
grid-template-columns: auto 1fr auto 1fr auto;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.root :global(> div:nth-child(4)) {
|
||||
grid-column: 2 / span 4;
|
||||
}
|
||||
|
||||
.radio-container {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
}
|
||||
|
||||
.radio-container:nth-child(1) {
|
||||
grid-column: 1 / span 2;
|
||||
}
|
||||
|
||||
.radio-container:nth-child(2) {
|
||||
grid-column: 3 / span 3;
|
||||
}
|
||||
|
||||
.radio-container :global(> label) {
|
||||
margin-left: var(--spacing-m);
|
||||
}
|
||||
|
||||
.radio-container > input {
|
||||
margin-bottom: var(--spacing-s);
|
||||
}
|
||||
|
||||
.radio-container > input:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -2,6 +2,7 @@ import NavigateTo from "./NavigateTo.svelte"
|
|||
import SaveRow from "./SaveRow.svelte"
|
||||
import DeleteRow from "./DeleteRow.svelte"
|
||||
import ExecuteQuery from "./ExecuteQuery.svelte"
|
||||
import TriggerAutomation from "./TriggerAutomation.svelte"
|
||||
|
||||
// defines what actions are available, when adding a new one
|
||||
// the component is the setup panel for the action
|
||||
|
@ -25,4 +26,8 @@ export default [
|
|||
name: "Execute Query",
|
||||
component: ExecuteQuery,
|
||||
},
|
||||
{
|
||||
name: "Trigger Automation",
|
||||
component: TriggerAutomation,
|
||||
},
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/client",
|
||||
"version": "0.4.3",
|
||||
"version": "0.5.3",
|
||||
"license": "MPL-2.0",
|
||||
"main": "dist/budibase-client.js",
|
||||
"module": "dist/budibase-client.js",
|
||||
|
@ -15,7 +15,7 @@
|
|||
"svelte-spa-router": "^3.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@budibase/standard-components": "^0.4.3",
|
||||
"@budibase/standard-components": "^0.5.3",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
"fs-extra": "^8.1.0",
|
||||
|
@ -29,5 +29,5 @@
|
|||
"svelte": "^3.30.0",
|
||||
"svelte-jester": "^1.0.6"
|
||||
},
|
||||
"gitHead": "e4e053cb6ff9a0ddc7115b44ccaa24b8ec41fb9a"
|
||||
"gitHead": "62ebf3cedcd7e9b2494b4f8cbcfb90927609b491"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import API from "./api"
|
||||
/**
|
||||
* Executes an automation. Must have "App Action" trigger.
|
||||
*/
|
||||
export const triggerAutomation = async (automationId, fields) => {
|
||||
return await API.post({
|
||||
url: `/api/automations/${automationId}/trigger`,
|
||||
body: { fields },
|
||||
})
|
||||
}
|
|
@ -8,3 +8,4 @@ export * from "./relationships"
|
|||
export * from "./routes"
|
||||
export * from "./queries"
|
||||
export * from "./app"
|
||||
export * from "./automations"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { enrichDataBinding, enrichDataBindings } from "./enrichDataBinding"
|
||||
import { routeStore } from "../store"
|
||||
import { saveRow, deleteRow, executeQuery } from "../api"
|
||||
import { saveRow, deleteRow, executeQuery, triggerAutomation } from "../api"
|
||||
|
||||
const saveRowHandler = async (action, context) => {
|
||||
let draft = context[`${action.parameters.contextPath}_draft`]
|
||||
|
@ -21,6 +21,17 @@ const deleteRowHandler = async (action, context) => {
|
|||
})
|
||||
}
|
||||
|
||||
const triggerAutomationHandler = async (action, context) => {
|
||||
const params = {}
|
||||
for (let field in action.parameters.fields) {
|
||||
params[field] = enrichDataBinding(
|
||||
action.parameters.fields[field].value,
|
||||
context
|
||||
)
|
||||
}
|
||||
await triggerAutomation(action.parameters.automationId, params)
|
||||
}
|
||||
|
||||
const navigationHandler = action => {
|
||||
routeStore.actions.navigate(action.parameters.url)
|
||||
}
|
||||
|
@ -42,6 +53,7 @@ const handlerMap = {
|
|||
["Delete Row"]: deleteRowHandler,
|
||||
["Navigate To"]: navigationHandler,
|
||||
["Execute Query"]: queryExecutionHandler,
|
||||
["Trigger Automation"]: triggerAutomationHandler,
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@budibase/server",
|
||||
"email": "hi@budibase.com",
|
||||
"version": "0.4.3",
|
||||
"version": "0.5.3",
|
||||
"description": "Budibase Web Server",
|
||||
"main": "src/electron.js",
|
||||
"repository": {
|
||||
|
@ -49,8 +49,8 @@
|
|||
"author": "Budibase",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@budibase/client": "^0.4.3",
|
||||
"@elastic/elasticsearch": "^7.10.0",
|
||||
"@budibase/client": "^0.5.3",
|
||||
"@koa/router": "^8.0.0",
|
||||
"@sendgrid/mail": "^7.1.1",
|
||||
"@sentry/node": "^5.19.2",
|
||||
|
@ -118,5 +118,5 @@
|
|||
"./scripts/jestSetup.js"
|
||||
]
|
||||
},
|
||||
"gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691"
|
||||
"gitHead": "62ebf3cedcd7e9b2494b4f8cbcfb90927609b491"
|
||||
}
|
||||
|
|
|
@ -31,11 +31,18 @@ exports.save = async function(ctx) {
|
|||
|
||||
function enrichQueryFields(fields, parameters) {
|
||||
const enrichedQuery = {}
|
||||
|
||||
// enrich the fields with dynamic parameters
|
||||
for (let key in fields) {
|
||||
const template = handlebars.compile(fields[key])
|
||||
enrichedQuery[key] = template(parameters)
|
||||
}
|
||||
|
||||
if (fields.json || fields.customData) {
|
||||
enrichedQuery.json = JSON.parse(fields.json || fields.customData)
|
||||
delete enrichedQuery.customData
|
||||
}
|
||||
|
||||
return enrichedQuery
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ const CouchDB = require("../db")
|
|||
const emitter = require("../events/index")
|
||||
const InMemoryQueue = require("../utilities/queue/inMemoryQueue")
|
||||
const { getAutomationParams } = require("../db/utils")
|
||||
const { coerceValue } = require("../utilities")
|
||||
|
||||
let automationQueue = new InMemoryQueue("automationQueue")
|
||||
|
||||
|
@ -119,6 +120,37 @@ const BUILTIN_DEFINITIONS = {
|
|||
},
|
||||
type: "TRIGGER",
|
||||
},
|
||||
APP: {
|
||||
name: "App Action",
|
||||
event: "app:trigger",
|
||||
icon: "ri-window-fill",
|
||||
tagline: "Automation fired from the frontend",
|
||||
description: "Trigger an automation from an action inside your app",
|
||||
stepId: "APP",
|
||||
inputs: {},
|
||||
schema: {
|
||||
inputs: {
|
||||
properties: {
|
||||
fields: {
|
||||
type: "object",
|
||||
customType: "triggerSchema",
|
||||
title: "Fields",
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
},
|
||||
outputs: {
|
||||
properties: {
|
||||
fields: {
|
||||
type: "object",
|
||||
description: "Fields submitted from the app frontend",
|
||||
},
|
||||
},
|
||||
required: ["fields"],
|
||||
},
|
||||
},
|
||||
type: "TRIGGER",
|
||||
},
|
||||
}
|
||||
|
||||
async function queueRelevantRowAutomations(event, eventType) {
|
||||
|
@ -200,13 +232,20 @@ async function fillRowOutput(automation, params) {
|
|||
|
||||
module.exports.externalTrigger = async function(automation, params) {
|
||||
// TODO: replace this with allowing user in builder to input values in future
|
||||
if (
|
||||
automation.definition != null &&
|
||||
automation.definition.trigger != null &&
|
||||
automation.definition.trigger.inputs.tableId != null
|
||||
) {
|
||||
if (automation.definition != null && automation.definition.trigger != null) {
|
||||
if (automation.definition.trigger.inputs.tableId != null) {
|
||||
params = await fillRowOutput(automation, params)
|
||||
}
|
||||
if (automation.definition.trigger.stepId === "APP") {
|
||||
// values are likely to be submitted as strings, so we shall convert to correct type
|
||||
const coercedFields = {}
|
||||
const fields = automation.definition.trigger.inputs.fields
|
||||
for (let key in fields) {
|
||||
coercedFields[key] = coerceValue(params.fields[key], fields[key])
|
||||
}
|
||||
params.fields = coercedFields
|
||||
}
|
||||
}
|
||||
|
||||
automationQueue.add({ automation, event: params })
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ module.exports = {
|
|||
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
||||
DEPLOYMENT_DB_URL: process.env.DEPLOYMENT_DB_URL,
|
||||
LOCAL_TEMPLATES: process.env.LOCAL_TEMPLATES,
|
||||
// self hosting features
|
||||
LOGO_URL: process.env.LOGO_URL,
|
||||
_set(key, value) {
|
||||
process.env[key] = value
|
||||
module.exports[key] = value
|
||||
|
|
|
@ -56,7 +56,7 @@ const SCHEMA = {
|
|||
},
|
||||
delete: {
|
||||
"Airtable Ids": {
|
||||
type: FIELD_TYPES.LIST,
|
||||
type: FIELD_TYPES.JSON,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -69,12 +69,12 @@ class AirtableIntegration {
|
|||
}
|
||||
|
||||
async create(query) {
|
||||
const { table, ...rest } = query
|
||||
const { table, json } = query
|
||||
|
||||
try {
|
||||
const records = await this.client(table).create([
|
||||
{
|
||||
fields: rest,
|
||||
fields: json,
|
||||
},
|
||||
])
|
||||
return records
|
||||
|
@ -87,7 +87,7 @@ class AirtableIntegration {
|
|||
async read(query) {
|
||||
try {
|
||||
const records = await this.client(query.table)
|
||||
.select({ maxRecords: 10, view: query.view })
|
||||
.select({ maxRecords: query.numRecords || 10, view: query.view })
|
||||
.firstPage()
|
||||
return records.map(({ fields }) => fields)
|
||||
} catch (err) {
|
||||
|
@ -97,13 +97,13 @@ class AirtableIntegration {
|
|||
}
|
||||
|
||||
async update(query) {
|
||||
const { table, id, ...rest } = query
|
||||
const { table, id, json } = query
|
||||
|
||||
try {
|
||||
const records = await this.client(table).update([
|
||||
{
|
||||
id,
|
||||
fields: rest,
|
||||
fields: json,
|
||||
},
|
||||
])
|
||||
return records
|
||||
|
|
|
@ -6,21 +6,39 @@ const SCHEMA = {
|
|||
url: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
required: true,
|
||||
default: "localhost",
|
||||
default: "http://localhost:5984",
|
||||
},
|
||||
database: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
required: true,
|
||||
},
|
||||
view: {
|
||||
},
|
||||
query: {
|
||||
create: {
|
||||
"CouchDB DSL": {
|
||||
type: QUERY_TYPES.JSON,
|
||||
},
|
||||
},
|
||||
read: {
|
||||
"CouchDB DSL": {
|
||||
type: QUERY_TYPES.JSON,
|
||||
},
|
||||
},
|
||||
update: {
|
||||
"CouchDB Document": {
|
||||
type: QUERY_TYPES.JSON,
|
||||
},
|
||||
},
|
||||
delete: {
|
||||
"Document ID": {
|
||||
type: QUERY_TYPES.FIELDS,
|
||||
fields: {
|
||||
id: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
json: {
|
||||
type: QUERY_TYPES.JSON,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -31,10 +49,21 @@ class CouchDBIntegration {
|
|||
this.client = new PouchDB(`${config.url}/${config.database}`)
|
||||
}
|
||||
|
||||
async read() {
|
||||
async create(query) {
|
||||
try {
|
||||
const result = await this.client.post(query.json)
|
||||
return result
|
||||
} catch (err) {
|
||||
console.error("Error writing to couchDB", err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
async read(query) {
|
||||
try {
|
||||
const result = await this.client.allDocs({
|
||||
include_docs: true,
|
||||
...query.json,
|
||||
})
|
||||
return result.rows.map(row => row.doc)
|
||||
} catch (err) {
|
||||
|
@ -42,6 +71,26 @@ class CouchDBIntegration {
|
|||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
async update(query) {
|
||||
try {
|
||||
const result = await this.client.put(query.json)
|
||||
return result
|
||||
} catch (err) {
|
||||
console.error("Error updating couchDB document", err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
async delete(query) {
|
||||
try {
|
||||
const result = await this.client.remove(query.id)
|
||||
return result
|
||||
} catch (err) {
|
||||
console.error("Error deleting couchDB document", err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -1,23 +1,71 @@
|
|||
const { Client } = require("@elastic/elasticsearch")
|
||||
const { QUERY_TYPES, FIELD_TYPES } = require("./Integration")
|
||||
|
||||
const SCHEMA = {
|
||||
datasource: {
|
||||
url: {
|
||||
type: "string",
|
||||
required: true,
|
||||
default: "localhost",
|
||||
},
|
||||
index: {
|
||||
type: "string",
|
||||
required: true,
|
||||
default: "http://localhost:9200",
|
||||
},
|
||||
},
|
||||
query: {
|
||||
json: {
|
||||
type: "json",
|
||||
create: {
|
||||
"ES Query DSL": {
|
||||
type: QUERY_TYPES.FIELDS,
|
||||
customisable: true,
|
||||
fields: {
|
||||
index: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
read: {
|
||||
"ES Query DSL": {
|
||||
type: QUERY_TYPES.FIELDS,
|
||||
customisable: true,
|
||||
fields: {
|
||||
index: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
update: {
|
||||
"ES Query DSL": {
|
||||
type: QUERY_TYPES.FIELDS,
|
||||
customisable: true,
|
||||
fields: {
|
||||
id: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
required: true,
|
||||
},
|
||||
index: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
delete: {
|
||||
"Document ID": {
|
||||
type: QUERY_TYPES.FIELDS,
|
||||
fields: {
|
||||
index: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
required: true,
|
||||
},
|
||||
id: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
class ElasticSearchIntegration {
|
||||
|
@ -27,12 +75,14 @@ class ElasticSearchIntegration {
|
|||
}
|
||||
|
||||
async create(query) {
|
||||
const { index, json } = query
|
||||
|
||||
try {
|
||||
const result = await this.client.index({
|
||||
index: this.config.index,
|
||||
body: JSON.parse(query.json),
|
||||
index,
|
||||
body: json,
|
||||
})
|
||||
return [result]
|
||||
return result.body
|
||||
} catch (err) {
|
||||
console.error("Error writing to elasticsearch", err)
|
||||
throw err
|
||||
|
@ -42,10 +92,11 @@ class ElasticSearchIntegration {
|
|||
}
|
||||
|
||||
async read(query) {
|
||||
const { index, json } = query
|
||||
try {
|
||||
const result = await this.client.search({
|
||||
index: this.config.index,
|
||||
body: JSON.parse(query.json),
|
||||
index: index,
|
||||
body: json,
|
||||
})
|
||||
return result.body.hits.hits.map(({ _source }) => _source)
|
||||
} catch (err) {
|
||||
|
@ -55,6 +106,35 @@ class ElasticSearchIntegration {
|
|||
await this.client.close()
|
||||
}
|
||||
}
|
||||
|
||||
async update(query) {
|
||||
const { id, index, json } = query
|
||||
try {
|
||||
const result = await this.client.update({
|
||||
id,
|
||||
index,
|
||||
body: json,
|
||||
})
|
||||
return result.body
|
||||
} catch (err) {
|
||||
console.error("Error querying elasticsearch", err)
|
||||
throw err
|
||||
} finally {
|
||||
await this.client.close()
|
||||
}
|
||||
}
|
||||
|
||||
async delete(query) {
|
||||
try {
|
||||
const result = await this.client.delete(query)
|
||||
return result.body
|
||||
} catch (err) {
|
||||
console.error("Error deleting from elasticsearch", err)
|
||||
throw err
|
||||
} finally {
|
||||
await this.client.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -43,14 +43,13 @@ class MongoIntegration {
|
|||
|
||||
async create(query) {
|
||||
try {
|
||||
const mongoQuery = query.json ? JSON.parse(query.json) : {}
|
||||
await this.connect()
|
||||
const db = this.client.db(this.config.db)
|
||||
const collection = db.collection(this.config.collection)
|
||||
const result = await collection.insertOne(mongoQuery)
|
||||
const result = await collection.insertOne(query.json)
|
||||
return result
|
||||
} catch (err) {
|
||||
console.error("Error querying mongodb", err)
|
||||
console.error("Error writing to mongodb", err)
|
||||
throw err
|
||||
} finally {
|
||||
await this.client.close()
|
||||
|
@ -59,11 +58,10 @@ class MongoIntegration {
|
|||
|
||||
async read(query) {
|
||||
try {
|
||||
const mongoQuery = query.json ? JSON.parse(query.json) : {}
|
||||
await this.connect()
|
||||
const db = this.client.db(this.config.db)
|
||||
const collection = db.collection(this.config.collection)
|
||||
const result = await collection.find(mongoQuery).toArray()
|
||||
const result = await collection.find(query.json).toArray()
|
||||
return result
|
||||
} catch (err) {
|
||||
console.error("Error querying mongodb", err)
|
||||
|
|
|
@ -144,6 +144,23 @@ exports.walkDir = (dirPath, callback) => {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This will coerce a value to the correct types based on the type transform map
|
||||
* @param {object} row The value to coerce
|
||||
* @param {object} type The type fo coerce to
|
||||
* @returns {object} The coerced value
|
||||
*/
|
||||
exports.coerceValue = (value, type) => {
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (TYPE_TRANSFORM_MAP[type].hasOwnProperty(value)) {
|
||||
return TYPE_TRANSFORM_MAP[type][value]
|
||||
} else if (TYPE_TRANSFORM_MAP[type].parse) {
|
||||
return TYPE_TRANSFORM_MAP[type].parse(value)
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* This will coerce the values in a row to the correct types based on the type transform map and the
|
||||
* table schema.
|
||||
|
@ -159,25 +176,11 @@ exports.coerceRowValues = (row, table) => {
|
|||
const field = table.schema[key]
|
||||
if (!field) continue
|
||||
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (TYPE_TRANSFORM_MAP[field.type].hasOwnProperty(value)) {
|
||||
clonedRow[key] = TYPE_TRANSFORM_MAP[field.type][value]
|
||||
} else if (TYPE_TRANSFORM_MAP[field.type].parse) {
|
||||
clonedRow[key] = TYPE_TRANSFORM_MAP[field.type].parse(value)
|
||||
}
|
||||
clonedRow[key] = exports.coerceValue(value, field.type)
|
||||
}
|
||||
return clonedRow
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the correct link to the logo URL depending on if running in Cloud or if running in self hosting.
|
||||
* @returns {string} A URL which links to the correct default logo for new apps.
|
||||
*/
|
||||
exports.getLogoUrl = () => {
|
||||
const BB_LOGO_URL =
|
||||
"https://d33wubrfki0l68.cloudfront.net/aac32159d7207b5085e74a7ef67afbb7027786c5/2b1fd/img/logo/bb-emblem.svg"
|
||||
if (env.SELF_HOSTED) {
|
||||
return env.LOGO_URL || BB_LOGO_URL
|
||||
}
|
||||
return BB_LOGO_URL
|
||||
return "https://d33wubrfki0l68.cloudfront.net/aac32159d7207b5085e74a7ef67afbb7027786c5/2b1fd/img/logo/bb-emblem.svg"
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
"keywords": [
|
||||
"svelte"
|
||||
],
|
||||
"version": "0.4.3",
|
||||
"version": "0.5.3",
|
||||
"license": "MIT",
|
||||
"gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691",
|
||||
"gitHead": "62ebf3cedcd7e9b2494b4f8cbcfb90927609b491",
|
||||
"dependencies": {
|
||||
"@budibase/bbui": "^1.52.4",
|
||||
"@budibase/svelte-ag-grid": "^0.0.16",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@budibase/deployment",
|
||||
"email": "hi@budibase.com",
|
||||
"version": "0.3.8",
|
||||
"version": "0.5.3",
|
||||
"description": "Budibase Deployment Server",
|
||||
"main": "src/index.js",
|
||||
"repository": {
|
||||
|
@ -30,5 +30,6 @@
|
|||
"koa-static": "^5.0.0",
|
||||
"pino-pretty": "^4.0.0",
|
||||
"server-destroy": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"gitHead": "62ebf3cedcd7e9b2494b4f8cbcfb90927609b491"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue