Merge branch 'master' of github.com:Budibase/budibase into labday/sqs
This commit is contained in:
commit
37b4b756ea
|
@ -107,3 +107,4 @@ budibase-component
|
|||
budibase-datasource
|
||||
|
||||
*.iml
|
||||
.nx
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "2.22.9",
|
||||
"version": "2.22.12",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*",
|
||||
|
|
|
@ -79,7 +79,8 @@ const removeHandler = id => {
|
|||
export default (element, opts) => {
|
||||
const id = Math.random()
|
||||
const update = newOpts => {
|
||||
const callback = newOpts?.callback || newOpts
|
||||
const callback =
|
||||
newOpts?.callback || (typeof newOpts === "function" ? newOpts : null)
|
||||
const anchor = newOpts?.anchor || element
|
||||
const allowedType = newOpts?.allowedType || "click"
|
||||
updateHandler(id, element, anchor, callback, allowedType)
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
.main {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.padding .main {
|
||||
padding: var(--spacing-xl);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
export let schema
|
||||
export let value
|
||||
export let customRenderers = []
|
||||
export let snippets
|
||||
|
||||
let renderer
|
||||
const typeMap = {
|
||||
|
@ -44,7 +45,7 @@
|
|||
if (!template) {
|
||||
return value
|
||||
}
|
||||
return processStringSync(template, { value })
|
||||
return processStringSync(template, { value, snippets })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
export let customPlaceholder = false
|
||||
export let showHeaderBorder = true
|
||||
export let placeholderText = "No rows found"
|
||||
export let snippets = []
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
|
@ -425,6 +426,7 @@
|
|||
<CellRenderer
|
||||
{customRenderers}
|
||||
{row}
|
||||
{snippets}
|
||||
schema={schema[field]}
|
||||
value={deepGet(row, field)}
|
||||
on:clickrelationship
|
||||
|
|
|
@ -34,12 +34,7 @@
|
|||
import { getBindings } from "components/backend/DataTable/formula"
|
||||
import JSONSchemaModal from "./JSONSchemaModal.svelte"
|
||||
import { ValidColumnNameRegex } from "@budibase/shared-core"
|
||||
import {
|
||||
FieldType,
|
||||
FieldSubtype,
|
||||
SourceName,
|
||||
FieldTypeSubtypes,
|
||||
} from "@budibase/types"
|
||||
import { FieldType, FieldSubtype, SourceName } from "@budibase/types"
|
||||
import RelationshipSelector from "components/common/RelationshipSelector.svelte"
|
||||
import { RowUtils } from "@budibase/frontend-core"
|
||||
import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte"
|
||||
|
@ -710,21 +705,6 @@
|
|||
thin
|
||||
text="Allow multiple users"
|
||||
/>
|
||||
{:else if editableColumn.type === FieldType.ATTACHMENT}
|
||||
<Toggle
|
||||
value={editableColumn.subtype !== FieldTypeSubtypes.ATTACHMENT.SINGLE &&
|
||||
// Checking config before the subtype was added
|
||||
editableColumn.constraints?.length?.maximum !== 1}
|
||||
on:change={e => {
|
||||
if (!e.detail) {
|
||||
editableColumn.subtype = FieldTypeSubtypes.ATTACHMENT.SINGLE
|
||||
} else {
|
||||
delete editableColumn.subtype
|
||||
}
|
||||
}}
|
||||
thin
|
||||
text="Allow multiple"
|
||||
/>
|
||||
{/if}
|
||||
{#if editableColumn.type === AUTO_TYPE || editableColumn.autocolumn}
|
||||
<Select
|
||||
|
|
|
@ -313,7 +313,7 @@ export const bindingsToCompletions = (bindings, mode) => {
|
|||
...bindingByCategory[catKey].reduce((acc, binding) => {
|
||||
let displayType = binding.fieldSchema?.type || binding.display?.type
|
||||
acc.push({
|
||||
label: binding.display?.name || "NO NAME",
|
||||
label: binding.display?.name || binding.readableBinding || "NO NAME",
|
||||
info: completion => {
|
||||
return buildBindingInfoNode(completion, binding)
|
||||
},
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
export let allowJS = false
|
||||
export let allowHelpers = true
|
||||
export let autofocusEditor = false
|
||||
export let context = null
|
||||
|
||||
$: enrichedBindings = enrichBindings(bindings)
|
||||
|
||||
|
@ -27,7 +28,7 @@
|
|||
|
||||
<BindingPanel
|
||||
bindings={enrichedBindings}
|
||||
context={$previewStore.selectedComponentContext}
|
||||
context={{ ...$previewStore.selectedComponentContext, ...context }}
|
||||
snippets={$snippets}
|
||||
{value}
|
||||
{allowJS}
|
||||
|
|
|
@ -32,10 +32,14 @@
|
|||
import TourWrap from "components/portal/onboarding/TourWrap.svelte"
|
||||
import { TOUR_STEP_KEYS } from "components/portal/onboarding/tours.js"
|
||||
import { goto } from "@roxi/routify"
|
||||
import { onMount } from "svelte"
|
||||
import PosthogClient from "../../analytics/PosthogClient"
|
||||
|
||||
export let application
|
||||
export let loaded
|
||||
|
||||
const posthog = new PosthogClient(process.env.POSTHOG_TOKEN)
|
||||
|
||||
let unpublishModal
|
||||
let updateAppModal
|
||||
let revertModal
|
||||
|
@ -44,6 +48,8 @@
|
|||
let appActionPopoverOpen = false
|
||||
let appActionPopoverAnchor
|
||||
let publishing = false
|
||||
let showNpsSurvey = false
|
||||
let lastOpened
|
||||
|
||||
$: filteredApps = $appsStore.apps.filter(app => app.devId === application)
|
||||
$: selectedApp = filteredApps?.length ? filteredApps[0] : null
|
||||
|
@ -57,7 +63,7 @@
|
|||
$appStore.version &&
|
||||
$appStore.upgradableVersion !== $appStore.version
|
||||
$: canPublish = !publishing && loaded && $sortedScreens.length > 0
|
||||
$: lastDeployed = getLastDeployedString($deploymentStore)
|
||||
$: lastDeployed = getLastDeployedString($deploymentStore, lastOpened)
|
||||
|
||||
const initialiseApp = async () => {
|
||||
const applicationPkg = await API.fetchAppPackage($appStore.devId)
|
||||
|
@ -97,6 +103,7 @@
|
|||
type: "success",
|
||||
icon: "GlobeCheck",
|
||||
})
|
||||
showNpsSurvey = true
|
||||
await completePublish()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
@ -147,6 +154,10 @@
|
|||
notifications.error("Error refreshing app")
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
posthog.init()
|
||||
})
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
|
@ -201,6 +212,7 @@
|
|||
class="app-action-button publish app-action-popover"
|
||||
on:click={() => {
|
||||
if (!appActionPopoverOpen) {
|
||||
lastOpened = new Date()
|
||||
appActionPopover.show()
|
||||
} else {
|
||||
appActionPopover.hide()
|
||||
|
@ -343,6 +355,10 @@
|
|||
<RevertModal bind:this={revertModal} />
|
||||
<VersionModal hideIcon bind:this={versionModal} />
|
||||
|
||||
{#if showNpsSurvey}
|
||||
<div class="nps-survey" />
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.app-action-popover-content {
|
||||
padding: var(--spacing-xl);
|
||||
|
|
|
@ -7,10 +7,13 @@
|
|||
Layout,
|
||||
Label,
|
||||
} from "@budibase/bbui"
|
||||
import { themeStore } from "stores/builder"
|
||||
import { themeStore, previewStore } from "stores/builder"
|
||||
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||
|
||||
export let column
|
||||
|
||||
$: columnValue =
|
||||
$previewStore.selectedComponentContext?.eventContext?.row?.[column.name]
|
||||
</script>
|
||||
|
||||
<DrawerContent>
|
||||
|
@ -41,6 +44,9 @@
|
|||
icon: "TableColumnMerge",
|
||||
},
|
||||
]}
|
||||
context={{
|
||||
value: columnValue,
|
||||
}}
|
||||
/>
|
||||
<Layout noPadding gap="XS">
|
||||
<Label>Background color</Label>
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
"name": "Blocks",
|
||||
"icon": "Article",
|
||||
"children": [
|
||||
"gridblock",
|
||||
"tableblock",
|
||||
"cardsblock",
|
||||
"repeaterblock",
|
||||
"formblock",
|
||||
|
@ -16,7 +14,7 @@
|
|||
{
|
||||
"name": "Layout",
|
||||
"icon": "ClassicGridView",
|
||||
"children": ["container", "section", "grid", "sidepanel"]
|
||||
"children": ["container", "section", "sidepanel"]
|
||||
},
|
||||
{
|
||||
"name": "Data",
|
||||
|
@ -24,7 +22,7 @@
|
|||
"children": [
|
||||
"dataprovider",
|
||||
"repeater",
|
||||
"table",
|
||||
"gridblock",
|
||||
"spreadsheet",
|
||||
"dynamicfilter",
|
||||
"daterangepicker"
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
import { goto } from "@roxi/routify"
|
||||
import { TOUR_KEYS } from "components/portal/onboarding/tours.js"
|
||||
import formScreen from "templates/formScreen"
|
||||
import rowListScreen from "templates/rowListScreen"
|
||||
import gridListScreen from "templates/gridListScreen"
|
||||
import gridDetailsScreen from "templates/gridDetailsScreen"
|
||||
|
||||
let mode
|
||||
let pendingScreen
|
||||
|
@ -127,7 +128,7 @@
|
|||
screenAccessRole = Roles.BASIC
|
||||
formType = null
|
||||
|
||||
if (mode === "table" || mode === "grid" || mode === "form") {
|
||||
if (mode === "grid" || mode === "gridDetails" || mode === "form") {
|
||||
datasourceModal.show()
|
||||
} else if (mode === "blank") {
|
||||
let templates = getTemplates($tables.list)
|
||||
|
@ -153,7 +154,10 @@
|
|||
|
||||
// Handler for Datasource Screen Creation
|
||||
const completeDatasourceScreenCreation = async () => {
|
||||
templates = rowListScreen(selectedDatasources, mode)
|
||||
templates =
|
||||
mode === "grid"
|
||||
? gridListScreen(selectedDatasources)
|
||||
: gridDetailsScreen(selectedDatasources)
|
||||
|
||||
const screens = templates.map(template => {
|
||||
let screenTemplate = template.create()
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
|
@ -2,8 +2,8 @@
|
|||
import { Body } from "@budibase/bbui"
|
||||
import CreationPage from "components/common/CreationPage.svelte"
|
||||
import blankImage from "./images/blank.png"
|
||||
import tableImage from "./images/table.png"
|
||||
import gridImage from "./images/grid.png"
|
||||
import tableInline from "./images/tableInline.png"
|
||||
import tableDetails from "./images/tableDetails.png"
|
||||
import formImage from "./images/form.png"
|
||||
import CreateScreenModal from "./CreateScreenModal.svelte"
|
||||
import { screenStore } from "stores/builder"
|
||||
|
@ -38,23 +38,23 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" on:click={() => createScreenModal.show("table")}>
|
||||
<div class="card" on:click={() => createScreenModal.show("grid")}>
|
||||
<div class="image">
|
||||
<img alt="" src={tableImage} />
|
||||
<img alt="" src={tableInline} />
|
||||
</div>
|
||||
<div class="text">
|
||||
<Body size="S">Table</Body>
|
||||
<Body size="XS">View, edit and delete rows on a table</Body>
|
||||
<Body size="S">Table with inline editing</Body>
|
||||
<Body size="XS">View, edit and delete rows inline</Body>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" on:click={() => createScreenModal.show("grid")}>
|
||||
<div class="card" on:click={() => createScreenModal.show("gridDetails")}>
|
||||
<div class="image">
|
||||
<img alt="" src={gridImage} />
|
||||
<img alt="" src={tableDetails} />
|
||||
</div>
|
||||
<div class="text">
|
||||
<Body size="S">Grid</Body>
|
||||
<Body size="XS">View and manipulate rows on a grid</Body>
|
||||
<Body size="S">Table with details panel</Body>
|
||||
<Body size="XS">Manage your row details in a side panel</Body>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -113,6 +113,11 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.card .image {
|
||||
min-height: 130px;
|
||||
min-width: 235px;
|
||||
}
|
||||
|
||||
.text {
|
||||
border: 1px solid var(--grey-4);
|
||||
border-radius: 0 0 4px 4px;
|
||||
|
|
|
@ -279,12 +279,10 @@ export class ComponentStore extends BudiStore {
|
|||
else {
|
||||
if (setting.type === "dataProvider") {
|
||||
// Validate data provider exists, or else clear it
|
||||
const treeId = parent?._id || component._id
|
||||
const path = findComponentPath(screen?.props, treeId)
|
||||
const providers = path.filter(component =>
|
||||
component._component?.endsWith("/dataprovider")
|
||||
const providers = findAllMatchingComponents(
|
||||
screen?.props,
|
||||
x => x._component === "@budibase/standard-components/dataprovider"
|
||||
)
|
||||
// Validate non-empty values
|
||||
const valid = providers?.some(dp => value.includes?.(dp._id))
|
||||
if (!valid) {
|
||||
if (providers.length) {
|
||||
|
|
|
@ -7,12 +7,25 @@ export const INITIAL_HOVER_STATE = {
|
|||
}
|
||||
|
||||
export class HoverStore extends BudiStore {
|
||||
hoverTimeout
|
||||
|
||||
constructor() {
|
||||
super({ ...INITIAL_HOVER_STATE })
|
||||
this.hover = this.hover.bind(this)
|
||||
}
|
||||
|
||||
hover(componentId, notifyClient = true) {
|
||||
clearTimeout(this.hoverTimeout)
|
||||
if (componentId) {
|
||||
this.processHover(componentId, notifyClient)
|
||||
} else {
|
||||
this.hoverTimeout = setTimeout(() => {
|
||||
this.processHover(componentId, notifyClient)
|
||||
}, 10)
|
||||
}
|
||||
}
|
||||
|
||||
processHover(componentId, notifyClient) {
|
||||
if (componentId === get(this.store).componentId) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
import sanitizeUrl from "helpers/sanitizeUrl"
|
||||
import { Screen } from "./Screen"
|
||||
import { Component } from "./Component"
|
||||
import { generate } from "shortid"
|
||||
import { makePropSafe as safe } from "@budibase/string-templates"
|
||||
import { Utils } from "@budibase/frontend-core"
|
||||
|
||||
export default function (datasources) {
|
||||
if (!Array.isArray(datasources)) {
|
||||
return []
|
||||
}
|
||||
return datasources.map(datasource => {
|
||||
return {
|
||||
name: `${datasource.label} - List with panel`,
|
||||
create: () => createScreen(datasource),
|
||||
id: GRID_DETAILS_TEMPLATE,
|
||||
resourceId: datasource.resourceId,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const GRID_DETAILS_TEMPLATE = "GRID_DETAILS_TEMPLATE"
|
||||
export const gridDetailsUrl = datasource => sanitizeUrl(`/${datasource.label}`)
|
||||
|
||||
const createScreen = datasource => {
|
||||
/*
|
||||
Create Row
|
||||
*/
|
||||
const createRowSidePanel = new Component(
|
||||
"@budibase/standard-components/sidepanel"
|
||||
).instanceName("New row side panel")
|
||||
|
||||
const buttonGroup = new Component("@budibase/standard-components/buttongroup")
|
||||
const createButton = new Component("@budibase/standard-components/button")
|
||||
|
||||
createButton.customProps({
|
||||
onClick: [
|
||||
{
|
||||
id: 0,
|
||||
"##eventHandlerType": "Open Side Panel",
|
||||
parameters: {
|
||||
id: createRowSidePanel._json._id,
|
||||
},
|
||||
},
|
||||
],
|
||||
text: "Create row",
|
||||
type: "cta",
|
||||
})
|
||||
|
||||
buttonGroup.instanceName(`${datasource.label} - Create`).customProps({
|
||||
hAlign: "right",
|
||||
buttons: [createButton.json()],
|
||||
})
|
||||
|
||||
const gridHeader = new Component("@budibase/standard-components/container")
|
||||
.instanceName("Heading container")
|
||||
.customProps({
|
||||
direction: "row",
|
||||
hAlign: "stretch",
|
||||
})
|
||||
|
||||
const heading = new Component("@budibase/standard-components/heading")
|
||||
.instanceName("Table heading")
|
||||
.customProps({
|
||||
text: datasource?.label,
|
||||
})
|
||||
|
||||
gridHeader.addChild(heading)
|
||||
gridHeader.addChild(buttonGroup)
|
||||
|
||||
const createFormBlock = new Component(
|
||||
"@budibase/standard-components/formblock"
|
||||
)
|
||||
createFormBlock.instanceName("Create row form block").customProps({
|
||||
dataSource: datasource,
|
||||
labelPosition: "left",
|
||||
buttonPosition: "top",
|
||||
actionType: "Create",
|
||||
title: "Create row",
|
||||
buttons: Utils.buildFormBlockButtonConfig({
|
||||
_id: createFormBlock._json._id,
|
||||
showDeleteButton: false,
|
||||
showSaveButton: true,
|
||||
saveButtonLabel: "Save",
|
||||
actionType: "Create",
|
||||
dataSource: datasource,
|
||||
}),
|
||||
})
|
||||
|
||||
createRowSidePanel.addChild(createFormBlock)
|
||||
|
||||
/*
|
||||
Edit Row
|
||||
*/
|
||||
const stateKey = `ID_${generate()}`
|
||||
const detailsSidePanel = new Component(
|
||||
"@budibase/standard-components/sidepanel"
|
||||
).instanceName("Edit row side panel")
|
||||
|
||||
const editFormBlock = new Component("@budibase/standard-components/formblock")
|
||||
editFormBlock.instanceName("Edit row form block").customProps({
|
||||
dataSource: datasource,
|
||||
labelPosition: "left",
|
||||
buttonPosition: "top",
|
||||
actionType: "Update",
|
||||
title: "Edit",
|
||||
rowId: `{{ ${safe("state")}.${safe(stateKey)} }}`,
|
||||
buttons: Utils.buildFormBlockButtonConfig({
|
||||
_id: editFormBlock._json._id,
|
||||
showDeleteButton: true,
|
||||
showSaveButton: true,
|
||||
saveButtonLabel: "Save",
|
||||
deleteButtonLabel: "Delete",
|
||||
actionType: "Update",
|
||||
dataSource: datasource,
|
||||
}),
|
||||
})
|
||||
|
||||
detailsSidePanel.addChild(editFormBlock)
|
||||
|
||||
const gridBlock = new Component("@budibase/standard-components/gridblock")
|
||||
gridBlock
|
||||
.customProps({
|
||||
table: datasource,
|
||||
allowAddRows: false,
|
||||
allowEditRows: false,
|
||||
allowDeleteRows: false,
|
||||
onRowClick: [
|
||||
{
|
||||
id: 0,
|
||||
"##eventHandlerType": "Update State",
|
||||
parameters: {
|
||||
key: stateKey,
|
||||
type: "set",
|
||||
persist: false,
|
||||
value: `{{ ${safe("eventContext")}.${safe("row")}._id }}`,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
"##eventHandlerType": "Open Side Panel",
|
||||
parameters: {
|
||||
id: detailsSidePanel._json._id,
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
.instanceName(`${datasource.label} - Table`)
|
||||
|
||||
return new Screen()
|
||||
.route(gridDetailsUrl(datasource))
|
||||
.instanceName(`${datasource.label} - List and details`)
|
||||
.addChild(gridHeader)
|
||||
.addChild(gridBlock)
|
||||
.addChild(createRowSidePanel)
|
||||
.addChild(detailsSidePanel)
|
||||
.json()
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
import sanitizeUrl from "helpers/sanitizeUrl"
|
||||
import { Screen } from "./Screen"
|
||||
import { Component } from "./Component"
|
||||
|
||||
export default function (datasources) {
|
||||
if (!Array.isArray(datasources)) {
|
||||
return []
|
||||
}
|
||||
return datasources.map(datasource => {
|
||||
return {
|
||||
name: `${datasource.label} - List`,
|
||||
create: () => createScreen(datasource),
|
||||
id: GRID_LIST_TEMPLATE,
|
||||
resourceId: datasource.resourceId,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const GRID_LIST_TEMPLATE = "GRID_LIST_TEMPLATE"
|
||||
export const gridListUrl = datasource => sanitizeUrl(`/${datasource.label}`)
|
||||
|
||||
const createScreen = datasource => {
|
||||
const heading = new Component("@budibase/standard-components/heading")
|
||||
.instanceName("Table heading")
|
||||
.customProps({
|
||||
text: datasource?.label,
|
||||
})
|
||||
|
||||
const gridBlock = new Component("@budibase/standard-components/gridblock")
|
||||
.instanceName(`${datasource.label} - Table`)
|
||||
.customProps({
|
||||
table: datasource,
|
||||
})
|
||||
|
||||
return new Screen()
|
||||
.route(gridListUrl(datasource))
|
||||
.instanceName(`${datasource.label} - List`)
|
||||
.addChild(heading)
|
||||
.addChild(gridBlock)
|
||||
.json()
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
import rowListScreen from "./rowListScreen"
|
||||
import gridListScreen from "./gridListScreen"
|
||||
import gridDetailsScreen from "./gridDetailsScreen"
|
||||
import createFromScratchScreen from "./createFromScratchScreen"
|
||||
import formScreen from "./formScreen"
|
||||
|
||||
const allTemplates = datasources => [
|
||||
...rowListScreen(datasources),
|
||||
...gridListScreen(datasources),
|
||||
...gridDetailsScreen(datasources),
|
||||
...formScreen(datasources),
|
||||
]
|
||||
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
import sanitizeUrl from "helpers/sanitizeUrl"
|
||||
import { Screen } from "./Screen"
|
||||
import { Component } from "./Component"
|
||||
|
||||
export default function (datasources, mode = "table") {
|
||||
if (!Array.isArray(datasources)) {
|
||||
return []
|
||||
}
|
||||
return datasources.map(datasource => {
|
||||
return {
|
||||
name: `${datasource.label} - List`,
|
||||
create: () => createScreen(datasource, mode),
|
||||
id: ROW_LIST_TEMPLATE,
|
||||
resourceId: datasource.resourceId,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const ROW_LIST_TEMPLATE = "ROW_LIST_TEMPLATE"
|
||||
export const rowListUrl = datasource => sanitizeUrl(`/${datasource.label}`)
|
||||
|
||||
const generateTableBlock = datasource => {
|
||||
const tableBlock = new Component("@budibase/standard-components/tableblock")
|
||||
tableBlock
|
||||
.customProps({
|
||||
title: datasource.label,
|
||||
dataSource: datasource,
|
||||
sortOrder: "Ascending",
|
||||
size: "spectrum--medium",
|
||||
paginate: true,
|
||||
rowCount: 8,
|
||||
clickBehaviour: "details",
|
||||
showTitleButton: true,
|
||||
titleButtonText: "Create row",
|
||||
titleButtonClickBehaviour: "new",
|
||||
sidePanelSaveLabel: "Save",
|
||||
sidePanelDeleteLabel: "Delete",
|
||||
})
|
||||
.instanceName(`${datasource.label} - Table block`)
|
||||
return tableBlock
|
||||
}
|
||||
|
||||
const generateGridBlock = datasource => {
|
||||
const gridBlock = new Component("@budibase/standard-components/gridblock")
|
||||
gridBlock
|
||||
.customProps({
|
||||
table: datasource,
|
||||
})
|
||||
.instanceName(`${datasource.label} - Grid block`)
|
||||
return gridBlock
|
||||
}
|
||||
|
||||
const createScreen = (datasource, mode) => {
|
||||
return new Screen()
|
||||
.route(rowListUrl(datasource))
|
||||
.instanceName(`${datasource.label} - List`)
|
||||
.addChild(
|
||||
mode === "table"
|
||||
? generateTableBlock(datasource)
|
||||
: generateGridBlock(datasource)
|
||||
)
|
||||
.json()
|
||||
}
|
|
@ -4673,6 +4673,7 @@
|
|||
}
|
||||
},
|
||||
"table": {
|
||||
"deprecated": true,
|
||||
"name": "Table",
|
||||
"icon": "Table",
|
||||
"illegalChildren": ["section"],
|
||||
|
@ -5418,6 +5419,7 @@
|
|||
]
|
||||
},
|
||||
"tableblock": {
|
||||
"deprecated": true,
|
||||
"block": true,
|
||||
"name": "Table Block",
|
||||
"icon": "Table",
|
||||
|
@ -6595,7 +6597,7 @@
|
|||
]
|
||||
},
|
||||
"gridblock": {
|
||||
"name": "Grid Block",
|
||||
"name": "Table",
|
||||
"icon": "Table",
|
||||
"styles": ["size"],
|
||||
"size": {
|
||||
|
|
|
@ -246,15 +246,18 @@
|
|||
return
|
||||
}
|
||||
|
||||
const cacheId = `${definition.name}${
|
||||
definition?.deprecated === true ? "_deprecated" : ""
|
||||
}`
|
||||
// Get the settings definition for this component, and cache it
|
||||
if (SettingsDefinitionCache[definition.name]) {
|
||||
settingsDefinition = SettingsDefinitionCache[definition.name]
|
||||
settingsDefinitionMap = SettingsDefinitionMapCache[definition.name]
|
||||
if (SettingsDefinitionCache[cacheId]) {
|
||||
settingsDefinition = SettingsDefinitionCache[cacheId]
|
||||
settingsDefinitionMap = SettingsDefinitionMapCache[cacheId]
|
||||
} else {
|
||||
settingsDefinition = getSettingsDefinition(definition)
|
||||
settingsDefinitionMap = getSettingsDefinitionMap(settingsDefinition)
|
||||
SettingsDefinitionCache[definition.name] = settingsDefinition
|
||||
SettingsDefinitionMapCache[definition.name] = settingsDefinitionMap
|
||||
SettingsDefinitionCache[cacheId] = settingsDefinition
|
||||
SettingsDefinitionMapCache[cacheId] = settingsDefinitionMap
|
||||
}
|
||||
|
||||
// Parse the instance settings, and cache them
|
||||
|
|
|
@ -26,9 +26,12 @@
|
|||
|
||||
let schema
|
||||
|
||||
$: id = $component.id
|
||||
$: selected = $component.selected
|
||||
$: builderStep = $builderStore.metadata?.step
|
||||
$: fetchSchema(dataSource)
|
||||
$: enrichedSteps = enrichSteps(steps, schema, $component.id, $currentStep)
|
||||
$: updateCurrentStep(enrichedSteps, $builderStore, $component)
|
||||
$: enrichedSteps = enrichSteps(steps, schema, id)
|
||||
$: updateCurrentStep(enrichedSteps, selected, builderStep)
|
||||
|
||||
// Provide additional data context for live binding eval
|
||||
export const getAdditionalDataContext = () => {
|
||||
|
@ -40,30 +43,22 @@
|
|||
}
|
||||
}
|
||||
|
||||
const updateCurrentStep = (steps, builderStore, component) => {
|
||||
const { componentId, step } = builderStore.metadata || {}
|
||||
|
||||
// If we aren't in the builder or aren't selected then don't update the step
|
||||
// context at all, allowing the normal form to take control.
|
||||
if (
|
||||
!component.selected ||
|
||||
!builderStore.inBuilder ||
|
||||
componentId !== component.id
|
||||
) {
|
||||
const updateCurrentStep = (steps, selected, builderStep) => {
|
||||
// If we aren't selected in the builder then just allowing the normal form
|
||||
// to take control.
|
||||
if (!selected) {
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure we have a valid step selected
|
||||
let newStep = Math.min(step || 0, steps.length - 1)
|
||||
|
||||
// Sanity check
|
||||
let newStep = Math.min(builderStep || 0, steps.length - 1)
|
||||
newStep = Math.max(newStep, 0)
|
||||
|
||||
// Add 1 because the form component expects 1 indexed rather than 0 indexed
|
||||
currentStep.set(newStep + 1)
|
||||
}
|
||||
|
||||
const fetchSchema = async () => {
|
||||
const fetchSchema = async dataSource => {
|
||||
schema = (await fetchDatasourceSchema(dataSource)) || {}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
$: formattedFields = convertOldFieldFormat(fields)
|
||||
$: fieldsOrDefault = getDefaultFields(formattedFields, schema)
|
||||
$: fetchSchema(dataSource)
|
||||
$: id = $component.id
|
||||
// We could simply spread $$props into the inner form and append our
|
||||
// additions, but that would create svelte warnings about unused props and
|
||||
// make maintenance in future more confusing as we typically always have a
|
||||
|
@ -53,7 +54,7 @@
|
|||
buttons:
|
||||
buttons ||
|
||||
Utils.buildFormBlockButtonConfig({
|
||||
_id: $component.id,
|
||||
_id: id,
|
||||
showDeleteButton,
|
||||
showSaveButton,
|
||||
saveButtonLabel,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
export { default as tableblock } from "./TableBlock.svelte"
|
||||
export { default as cardsblock } from "./CardsBlock.svelte"
|
||||
export { default as repeaterblock } from "./RepeaterBlock.svelte"
|
||||
export { default as formblock } from "./form/FormBlock.svelte"
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
let schemaLoaded = false
|
||||
|
||||
$: deleteLabel = setDeleteLabel(sidePanelDeleteLabel, sidePanelShowDelete)
|
||||
$: id = $component.id
|
||||
$: isDSPlus = dataSource?.type === "table" || dataSource?.type === "viewV2"
|
||||
$: fetchSchema(dataSource)
|
||||
$: enrichSearchColumns(searchColumns, schema).then(
|
||||
|
@ -279,7 +280,7 @@
|
|||
dataSource,
|
||||
buttonPosition: "top",
|
||||
buttons: Utils.buildFormBlockButtonConfig({
|
||||
_id: $component.id + "-form-edit",
|
||||
_id: id + "-form-edit",
|
||||
showDeleteButton: deleteLabel !== "",
|
||||
showSaveButton: true,
|
||||
saveButtonLabel: sidePanelSaveLabel || "Save",
|
||||
|
@ -313,7 +314,7 @@
|
|||
dataSource,
|
||||
buttonPosition: "top",
|
||||
buttons: Utils.buildFormBlockButtonConfig({
|
||||
_id: $component.id + "-form-new",
|
||||
_id: id + "-form-new",
|
||||
showDeleteButton: false,
|
||||
showSaveButton: true,
|
||||
saveButtonLabel: "Save",
|
|
@ -3,7 +3,7 @@
|
|||
import { Table } from "@budibase/bbui"
|
||||
import SlotRenderer from "./SlotRenderer.svelte"
|
||||
import { canBeSortColumn } from "@budibase/shared-core"
|
||||
import Provider from "../../context/Provider.svelte"
|
||||
import Provider from "components/context/Provider.svelte"
|
||||
|
||||
export let dataProvider
|
||||
export let columns
|
||||
|
@ -16,8 +16,15 @@
|
|||
export let noRowsMessage
|
||||
|
||||
const component = getContext("component")
|
||||
const { styleable, getAction, ActionTypes, rowSelectionStore } =
|
||||
getContext("sdk")
|
||||
const context = getContext("context")
|
||||
const {
|
||||
styleable,
|
||||
getAction,
|
||||
ActionTypes,
|
||||
rowSelectionStore,
|
||||
generateGoldenSample,
|
||||
} = getContext("sdk")
|
||||
|
||||
const customColumnKey = `custom-${Math.random()}`
|
||||
const customRenderers = [
|
||||
{
|
||||
|
@ -28,6 +35,7 @@
|
|||
|
||||
let selectedRows = []
|
||||
|
||||
$: snippets = $context.snippets
|
||||
$: hasChildren = $component.children
|
||||
$: loading = dataProvider?.loading ?? false
|
||||
$: data = dataProvider?.rows || []
|
||||
|
@ -61,6 +69,16 @@
|
|||
selectedRows,
|
||||
}
|
||||
|
||||
// Provide additional data context for live binding eval
|
||||
export const getAdditionalDataContext = () => {
|
||||
const goldenRow = generateGoldenSample(data)
|
||||
return {
|
||||
eventContext: {
|
||||
row: goldenRow,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const getFields = (
|
||||
schema,
|
||||
customColumns,
|
||||
|
@ -178,6 +196,7 @@
|
|||
{quiet}
|
||||
{compact}
|
||||
{customRenderers}
|
||||
{snippets}
|
||||
allowSelectRows={allowSelectRows && table}
|
||||
bind:selectedRows
|
||||
allowEditRows={false}
|
|
@ -6,36 +6,24 @@ export const getOptions = (
|
|||
valueColumn,
|
||||
customOptions
|
||||
) => {
|
||||
const isArray = fieldSchema?.type === "array"
|
||||
// Take options from schema
|
||||
if (optionsSource == null || optionsSource === "schema") {
|
||||
return fieldSchema?.constraints?.inclusion ?? []
|
||||
}
|
||||
|
||||
if (optionsSource === "provider" && isArray) {
|
||||
let optionsSet = {}
|
||||
|
||||
dataProvider?.rows?.forEach(row => {
|
||||
const value = row?.[valueColumn]
|
||||
if (value != null) {
|
||||
const label = row[labelColumn] || value
|
||||
optionsSet[value] = { value, label }
|
||||
}
|
||||
})
|
||||
return Object.values(optionsSet)
|
||||
}
|
||||
|
||||
// Extract options from data provider
|
||||
if (optionsSource === "provider" && valueColumn) {
|
||||
let optionsSet = {}
|
||||
let valueCache = {}
|
||||
let options = []
|
||||
dataProvider?.rows?.forEach(row => {
|
||||
const value = row?.[valueColumn]
|
||||
if (value != null) {
|
||||
if (value != null && !valueCache[value]) {
|
||||
valueCache[value] = true
|
||||
const label = row[labelColumn] || value
|
||||
optionsSet[value] = { value, label }
|
||||
options.push({ value, label })
|
||||
}
|
||||
})
|
||||
return Object.values(optionsSet)
|
||||
return options
|
||||
}
|
||||
|
||||
// Extract custom options
|
||||
|
|
|
@ -40,11 +40,12 @@ export { default as sidepanel } from "./SidePanel.svelte"
|
|||
export { default as gridblock } from "./GridBlock.svelte"
|
||||
export * from "./charts"
|
||||
export * from "./forms"
|
||||
export * from "./table"
|
||||
export * from "./blocks"
|
||||
export * from "./dynamic-filter"
|
||||
|
||||
// Deprecated component left for compatibility in old apps
|
||||
export * from "./deprecated/table"
|
||||
export { default as tableblock } from "./deprecated/TableBlock.svelte"
|
||||
export { default as navigation } from "./deprecated/Navigation.svelte"
|
||||
export { default as cardhorizontal } from "./deprecated/CardHorizontal.svelte"
|
||||
export { default as stackedlist } from "./deprecated/StackedList.svelte"
|
||||
|
|
|
@ -345,8 +345,7 @@
|
|||
<IndicatorSet
|
||||
componentId={$dndParent}
|
||||
color="var(--spectrum-global-color-static-green-500)"
|
||||
zIndex="930"
|
||||
transition
|
||||
zIndex={920}
|
||||
prefix="Inside"
|
||||
/>
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<script>
|
||||
import { onMount, onDestroy } from "svelte"
|
||||
import IndicatorSet from "./IndicatorSet.svelte"
|
||||
import { builderStore, dndIsDragging, hoverStore } from "stores"
|
||||
import { dndIsDragging, hoverStore, builderStore } from "stores"
|
||||
|
||||
$: componentId = $hoverStore.hoveredComponentId
|
||||
$: zIndex = componentId === $builderStore.selectedComponentId ? 900 : 920
|
||||
$: selectedComponentId = $builderStore.selectedComponentId
|
||||
$: selected = componentId === selectedComponentId
|
||||
|
||||
const onMouseOver = e => {
|
||||
// Ignore if dragging
|
||||
|
@ -45,7 +46,6 @@
|
|||
<IndicatorSet
|
||||
componentId={$dndIsDragging ? null : componentId}
|
||||
color="var(--spectrum-global-color-static-blue-200)"
|
||||
transition
|
||||
{zIndex}
|
||||
zIndex={selected ? 890 : 910}
|
||||
allowResizeAnchors
|
||||
/>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<script>
|
||||
import { fade } from "svelte/transition"
|
||||
import { Icon } from "@budibase/bbui"
|
||||
|
||||
export let top
|
||||
|
@ -11,7 +10,6 @@
|
|||
export let color
|
||||
export let zIndex
|
||||
export let componentId
|
||||
export let transition = false
|
||||
export let line = false
|
||||
export let alignRight = false
|
||||
export let showResizeAnchors = false
|
||||
|
@ -31,10 +29,6 @@
|
|||
</script>
|
||||
|
||||
<div
|
||||
in:fade={{
|
||||
delay: transition ? 100 : 0,
|
||||
duration: transition ? 100 : 0,
|
||||
}}
|
||||
class="indicator"
|
||||
class:flipped
|
||||
class:line
|
||||
|
@ -127,10 +121,6 @@
|
|||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Icon styles */
|
||||
.label :global(.spectrum-Icon + .text) {
|
||||
}
|
||||
|
||||
/* Anchor */
|
||||
.anchor {
|
||||
--size: 24px;
|
||||
|
|
|
@ -4,27 +4,39 @@
|
|||
import { domDebounce } from "utils/domDebounce"
|
||||
import { builderStore } from "stores"
|
||||
|
||||
export let componentId
|
||||
export let color
|
||||
export let transition
|
||||
export let zIndex
|
||||
export let componentId = null
|
||||
export let color = null
|
||||
export let zIndex = 900
|
||||
export let prefix = null
|
||||
export let allowResizeAnchors = false
|
||||
|
||||
let indicators = []
|
||||
const errorColor = "var(--spectrum-global-color-static-red-600)"
|
||||
const defaultState = () => ({
|
||||
// Cached props
|
||||
componentId,
|
||||
color,
|
||||
zIndex,
|
||||
prefix,
|
||||
allowResizeAnchors,
|
||||
|
||||
// Computed state
|
||||
indicators: [],
|
||||
text: null,
|
||||
icon: null,
|
||||
insideGrid: false,
|
||||
error: false,
|
||||
})
|
||||
|
||||
let interval
|
||||
let text
|
||||
let icon
|
||||
let insideGrid = false
|
||||
let errorState = false
|
||||
|
||||
$: visibleIndicators = indicators.filter(x => x.visible)
|
||||
$: offset = $builderStore.inBuilder ? 0 : 2
|
||||
|
||||
let state = defaultState()
|
||||
let nextState = null
|
||||
let updating = false
|
||||
let observers = []
|
||||
let callbackCount = 0
|
||||
let nextIndicators = []
|
||||
|
||||
$: visibleIndicators = state.indicators.filter(x => x.visible)
|
||||
$: offset = $builderStore.inBuilder ? 0 : 2
|
||||
$: $$props, debouncedUpdate()
|
||||
|
||||
const checkInsideGrid = id => {
|
||||
const component = document.getElementsByClassName(id)[0]
|
||||
|
@ -44,10 +56,10 @@
|
|||
if (callbackCount >= observers.length) {
|
||||
return
|
||||
}
|
||||
nextIndicators[idx].visible =
|
||||
nextIndicators[idx].insideSidePanel || entries[0].isIntersecting
|
||||
nextState.indicators[idx].visible =
|
||||
nextState.indicators[idx].insideSidePanel || entries[0].isIntersecting
|
||||
if (++callbackCount === observers.length) {
|
||||
indicators = nextIndicators
|
||||
state = nextState
|
||||
updating = false
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +71,7 @@
|
|||
|
||||
// Sanity check
|
||||
if (!componentId) {
|
||||
indicators = []
|
||||
state = defaultState()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -68,25 +80,25 @@
|
|||
callbackCount = 0
|
||||
observers.forEach(o => o.disconnect())
|
||||
observers = []
|
||||
nextIndicators = []
|
||||
nextState = defaultState()
|
||||
|
||||
// Check if we're inside a grid
|
||||
if (allowResizeAnchors) {
|
||||
insideGrid = checkInsideGrid(componentId)
|
||||
nextState.insideGrid = checkInsideGrid(componentId)
|
||||
}
|
||||
|
||||
// Determine next set of indicators
|
||||
const parents = document.getElementsByClassName(componentId)
|
||||
if (parents.length) {
|
||||
text = parents[0].dataset.name
|
||||
if (prefix) {
|
||||
text = `${prefix} ${text}`
|
||||
nextState.text = parents[0].dataset.name
|
||||
if (nextState.prefix) {
|
||||
nextState.text = `${nextState.prefix} ${nextState.text}`
|
||||
}
|
||||
if (parents[0].dataset.icon) {
|
||||
icon = parents[0].dataset.icon
|
||||
nextState.icon = parents[0].dataset.icon
|
||||
}
|
||||
}
|
||||
errorState = parents?.[0]?.classList.contains("error")
|
||||
nextState.error = parents?.[0]?.classList.contains("error")
|
||||
|
||||
// Batch reads to minimize reflow
|
||||
const scrollX = window.scrollX
|
||||
|
@ -102,8 +114,9 @@
|
|||
|
||||
// If there aren't any nodes then reset
|
||||
if (!children.length) {
|
||||
indicators = []
|
||||
state = defaultState()
|
||||
updating = false
|
||||
return
|
||||
}
|
||||
|
||||
const device = document.getElementById("app-root")
|
||||
|
@ -119,7 +132,7 @@
|
|||
observers.push(observer)
|
||||
|
||||
const elBounds = child.getBoundingClientRect()
|
||||
nextIndicators.push({
|
||||
nextState.indicators.push({
|
||||
top: elBounds.top + scrollY - deviceBounds.top - offset,
|
||||
left: elBounds.left + scrollX - deviceBounds.left - offset,
|
||||
width: elBounds.width + 4,
|
||||
|
@ -144,20 +157,17 @@
|
|||
})
|
||||
</script>
|
||||
|
||||
{#key componentId}
|
||||
{#each visibleIndicators as indicator, idx}
|
||||
<Indicator
|
||||
top={indicator.top}
|
||||
left={indicator.left}
|
||||
width={indicator.width}
|
||||
height={indicator.height}
|
||||
text={idx === 0 ? text : null}
|
||||
icon={idx === 0 ? icon : null}
|
||||
showResizeAnchors={allowResizeAnchors && insideGrid}
|
||||
color={errorState ? "var(--spectrum-global-color-static-red-600)" : color}
|
||||
{componentId}
|
||||
{transition}
|
||||
{zIndex}
|
||||
/>
|
||||
{/each}
|
||||
{/key}
|
||||
{#each visibleIndicators as indicator, idx}
|
||||
<Indicator
|
||||
top={indicator.top}
|
||||
left={indicator.left}
|
||||
width={indicator.width}
|
||||
height={indicator.height}
|
||||
text={idx === 0 ? state.text : null}
|
||||
icon={idx === 0 ? state.icon : null}
|
||||
showResizeAnchors={state.allowResizeAnchors && state.insideGrid}
|
||||
color={state.error ? errorColor : state.color}
|
||||
componentId={state.componentId}
|
||||
zIndex={state.zIndex}
|
||||
/>
|
||||
{/each}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
<IndicatorSet
|
||||
componentId={$builderStore.selectedComponentId}
|
||||
{color}
|
||||
zIndex="910"
|
||||
transition
|
||||
zIndex={900}
|
||||
allowResizeAnchors
|
||||
/>
|
||||
|
|
|
@ -98,7 +98,7 @@ const loadBudibase = async () => {
|
|||
context: stringifiedContext,
|
||||
})
|
||||
} else if (type === "hover-component") {
|
||||
hoverStore.actions.hoverComponent(data)
|
||||
hoverStore.actions.hoverComponent(data, false)
|
||||
} else if (type === "builder-meta") {
|
||||
builderStore.actions.setMetadata(data)
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ import {
|
|||
LuceneUtils,
|
||||
Constants,
|
||||
RowUtils,
|
||||
memo,
|
||||
derivedMemo,
|
||||
} from "@budibase/frontend-core"
|
||||
|
||||
export default {
|
||||
|
@ -71,6 +73,8 @@ export default {
|
|||
makePropSafe,
|
||||
createContextStore,
|
||||
generateGoldenSample: RowUtils.generateGoldenSample,
|
||||
memo,
|
||||
derivedMemo,
|
||||
|
||||
// Components
|
||||
Provider,
|
||||
|
|
|
@ -5,13 +5,27 @@ const createHoverStore = () => {
|
|||
const store = writable({
|
||||
hoveredComponentId: null,
|
||||
})
|
||||
let hoverTimeout
|
||||
|
||||
const hoverComponent = id => {
|
||||
const hoverComponent = (id, notifyBuilder = true) => {
|
||||
clearTimeout(hoverTimeout)
|
||||
if (id) {
|
||||
processHover(id, notifyBuilder)
|
||||
} else {
|
||||
hoverTimeout = setTimeout(() => {
|
||||
processHover(id, notifyBuilder)
|
||||
}, 10)
|
||||
}
|
||||
}
|
||||
|
||||
const processHover = (id, notifyBuilder = true) => {
|
||||
if (id === get(store).hoveredComponentId) {
|
||||
return
|
||||
}
|
||||
store.set({ hoveredComponentId: id })
|
||||
eventStore.actions.dispatchEvent("hover-component", { id })
|
||||
if (notifyBuilder) {
|
||||
eventStore.actions.dispatchEvent("hover-component", { id })
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
module MongoMock {
|
||||
const mongodb: any = {}
|
||||
|
||||
mongodb.MongoClient = function () {
|
||||
this.connect = jest.fn()
|
||||
this.close = jest.fn()
|
||||
this.insertOne = jest.fn()
|
||||
this.insertMany = jest.fn(() => ({ toArray: () => [] }))
|
||||
this.find = jest.fn(() => ({ toArray: () => [] }))
|
||||
this.findOne = jest.fn()
|
||||
this.findOneAndUpdate = jest.fn()
|
||||
this.count = jest.fn()
|
||||
this.deleteOne = jest.fn()
|
||||
this.deleteMany = jest.fn(() => ({ toArray: () => [] }))
|
||||
this.updateOne = jest.fn()
|
||||
this.updateMany = jest.fn(() => ({ toArray: () => [] }))
|
||||
|
||||
this.collection = jest.fn(() => ({
|
||||
insertOne: this.insertOne,
|
||||
find: this.find,
|
||||
insertMany: this.insertMany,
|
||||
findOne: this.findOne,
|
||||
findOneAndUpdate: this.findOneAndUpdate,
|
||||
count: this.count,
|
||||
deleteOne: this.deleteOne,
|
||||
deleteMany: this.deleteMany,
|
||||
updateOne: this.updateOne,
|
||||
updateMany: this.updateMany,
|
||||
}))
|
||||
|
||||
this.db = () => ({
|
||||
collection: this.collection,
|
||||
})
|
||||
}
|
||||
|
||||
mongodb.ObjectId = jest.requireActual("mongodb").ObjectId
|
||||
|
||||
module.exports = mongodb
|
||||
}
|
|
@ -6,7 +6,7 @@ import { invalidateDynamicVariables } from "../../../threads/utils"
|
|||
import env from "../../../environment"
|
||||
import { events, context, utils, constants } from "@budibase/backend-core"
|
||||
import sdk from "../../../sdk"
|
||||
import { QueryEvent } from "../../../threads/definitions"
|
||||
import { QueryEvent, QueryEventParameters } from "../../../threads/definitions"
|
||||
import {
|
||||
ConfigType,
|
||||
Query,
|
||||
|
@ -18,7 +18,6 @@ import {
|
|||
FieldType,
|
||||
ExecuteQueryRequest,
|
||||
ExecuteQueryResponse,
|
||||
QueryParameter,
|
||||
PreviewQueryRequest,
|
||||
PreviewQueryResponse,
|
||||
} from "@budibase/types"
|
||||
|
@ -29,7 +28,7 @@ const Runner = new Thread(ThreadType.QUERY, {
|
|||
timeoutMs: env.QUERY_THREAD_TIMEOUT,
|
||||
})
|
||||
|
||||
function validateQueryInputs(parameters: Record<string, string>) {
|
||||
function validateQueryInputs(parameters: QueryEventParameters) {
|
||||
for (let entry of Object.entries(parameters)) {
|
||||
const [key, value] = entry
|
||||
if (typeof value !== "string") {
|
||||
|
@ -100,10 +99,18 @@ export async function save(ctx: UserCtx<Query, Query>) {
|
|||
const datasource = await sdk.datasources.get(query.datasourceId)
|
||||
|
||||
let eventFn
|
||||
if (!query._id) {
|
||||
if (!query._id && !query._rev) {
|
||||
query._id = generateQueryID(query.datasourceId)
|
||||
// flag to state whether the default bindings are empty strings (old behaviour) or null
|
||||
query.nullDefaultSupport = true
|
||||
eventFn = () => events.query.created(datasource, query)
|
||||
} else {
|
||||
// check if flag has previously been set, don't let it change
|
||||
// allow it to be explicitly set to false via API incase this is ever needed
|
||||
const existingQuery = await db.get<Query>(query._id)
|
||||
if (existingQuery.nullDefaultSupport && query.nullDefaultSupport == null) {
|
||||
query.nullDefaultSupport = true
|
||||
}
|
||||
eventFn = () => events.query.updated(datasource, query)
|
||||
}
|
||||
const response = await db.put(query)
|
||||
|
@ -135,16 +142,20 @@ function getAuthConfig(ctx: UserCtx) {
|
|||
}
|
||||
|
||||
function enrichParameters(
|
||||
queryParameters: QueryParameter[],
|
||||
requestParameters: Record<string, string> = {}
|
||||
): Record<string, string> {
|
||||
query: Query,
|
||||
requestParameters: QueryEventParameters = {}
|
||||
): QueryEventParameters {
|
||||
const paramNotSet = (val: unknown) => val === "" || val == undefined
|
||||
// first check parameters are all valid
|
||||
validateQueryInputs(requestParameters)
|
||||
// make sure parameters are fully enriched with defaults
|
||||
for (let parameter of queryParameters) {
|
||||
if (!requestParameters[parameter.name]) {
|
||||
requestParameters[parameter.name] = parameter.default
|
||||
for (const parameter of query.parameters) {
|
||||
let value: string | null =
|
||||
requestParameters[parameter.name] || parameter.default
|
||||
if (query.nullDefaultSupport && paramNotSet(value)) {
|
||||
value = null
|
||||
}
|
||||
requestParameters[parameter.name] = value
|
||||
}
|
||||
return requestParameters
|
||||
}
|
||||
|
@ -157,10 +168,15 @@ export async function preview(
|
|||
)
|
||||
// preview may not have a queryId as it hasn't been saved, but if it does
|
||||
// this stops dynamic variables from calling the same query
|
||||
const { fields, parameters, queryVerb, transformer, queryId, schema } =
|
||||
ctx.request.body
|
||||
const queryId = ctx.request.body.queryId
|
||||
// the body contains the makings of a query, which has not been saved yet
|
||||
const query: Query = ctx.request.body
|
||||
// hasn't been saved, new query
|
||||
if (!queryId && !query._id) {
|
||||
query.nullDefaultSupport = true
|
||||
}
|
||||
|
||||
let existingSchema = schema
|
||||
let existingSchema = query.schema
|
||||
if (queryId && !existingSchema) {
|
||||
try {
|
||||
const db = context.getAppDB()
|
||||
|
@ -268,13 +284,14 @@ export async function preview(
|
|||
try {
|
||||
const inputs: QueryEvent = {
|
||||
appId: ctx.appId,
|
||||
datasource,
|
||||
queryVerb,
|
||||
fields,
|
||||
parameters: enrichParameters(parameters),
|
||||
transformer,
|
||||
queryVerb: query.queryVerb,
|
||||
fields: query.fields,
|
||||
parameters: enrichParameters(query),
|
||||
transformer: query.transformer,
|
||||
schema: query.schema,
|
||||
nullDefaultSupport: query.nullDefaultSupport,
|
||||
queryId,
|
||||
schema,
|
||||
datasource,
|
||||
// have to pass down to the thread runner - can't put into context now
|
||||
environmentVariables: envVars,
|
||||
ctx: {
|
||||
|
@ -336,14 +353,12 @@ async function execute(
|
|||
queryVerb: query.queryVerb,
|
||||
fields: query.fields,
|
||||
pagination: ctx.request.body.pagination,
|
||||
parameters: enrichParameters(
|
||||
query.parameters,
|
||||
ctx.request.body.parameters
|
||||
),
|
||||
parameters: enrichParameters(query, ctx.request.body.parameters),
|
||||
transformer: query.transformer,
|
||||
queryId: ctx.params.queryId,
|
||||
// have to pass down to the thread runner - can't put into context now
|
||||
environmentVariables: envVars,
|
||||
nullDefaultSupport: query.nullDefaultSupport,
|
||||
ctx: {
|
||||
user: ctx.user,
|
||||
auth: { ...authConfigCtx },
|
||||
|
|
|
@ -143,7 +143,10 @@ describe("/api/env/variables", () => {
|
|||
delete response.body.datasource.config
|
||||
expect(events.query.previewed).toHaveBeenCalledWith(
|
||||
response.body.datasource,
|
||||
queryPreview
|
||||
{
|
||||
...queryPreview,
|
||||
nullDefaultSupport: true,
|
||||
}
|
||||
)
|
||||
expect(pg.Client).toHaveBeenCalledWith({ password: "test", ssl: undefined })
|
||||
})
|
||||
|
|
|
@ -12,19 +12,22 @@ const createTableSQL: Record<string, string> = {
|
|||
CREATE TABLE test_table (
|
||||
id serial PRIMARY KEY,
|
||||
name VARCHAR ( 50 ) NOT NULL,
|
||||
birthday TIMESTAMP
|
||||
birthday TIMESTAMP,
|
||||
number INT
|
||||
);`,
|
||||
[SourceName.MYSQL]: `
|
||||
CREATE TABLE test_table (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
birthday TIMESTAMP
|
||||
birthday TIMESTAMP,
|
||||
number INT
|
||||
);`,
|
||||
[SourceName.SQL_SERVER]: `
|
||||
CREATE TABLE test_table (
|
||||
id INT IDENTITY(1,1) PRIMARY KEY,
|
||||
name NVARCHAR(50) NOT NULL,
|
||||
birthday DATETIME
|
||||
birthday DATETIME,
|
||||
number INT
|
||||
);`,
|
||||
}
|
||||
|
||||
|
@ -36,7 +39,7 @@ describe.each([
|
|||
["mysql", databaseTestProviders.mysql],
|
||||
["mssql", databaseTestProviders.mssql],
|
||||
["mariadb", databaseTestProviders.mariadb],
|
||||
])("queries (%s)", (__, dsProvider) => {
|
||||
])("queries (%s)", (dbName, dsProvider) => {
|
||||
const config = setup.getConfig()
|
||||
let datasource: Datasource
|
||||
|
||||
|
@ -51,7 +54,7 @@ describe.each([
|
|||
transformer: "return data",
|
||||
readable: true,
|
||||
}
|
||||
return await config.api.query.create({ ...defaultQuery, ...query })
|
||||
return await config.api.query.save({ ...defaultQuery, ...query })
|
||||
}
|
||||
|
||||
async function rawQuery(sql: string): Promise<any> {
|
||||
|
@ -221,26 +224,31 @@ describe.each([
|
|||
id: 1,
|
||||
name: "one",
|
||||
birthday: null,
|
||||
number: null,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "two",
|
||||
birthday: null,
|
||||
number: null,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "three",
|
||||
birthday: null,
|
||||
number: null,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "four",
|
||||
birthday: null,
|
||||
number: null,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "five",
|
||||
birthday: null,
|
||||
number: null,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
@ -263,6 +271,7 @@ describe.each([
|
|||
id: 2,
|
||||
name: "one",
|
||||
birthday: null,
|
||||
number: null,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
@ -291,6 +300,7 @@ describe.each([
|
|||
id: 1,
|
||||
name: "one",
|
||||
birthday: null,
|
||||
number: null,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
@ -329,7 +339,9 @@ describe.each([
|
|||
])
|
||||
|
||||
const rows = await rawQuery("SELECT * FROM test_table WHERE id = 1")
|
||||
expect(rows).toEqual([{ id: 1, name: "foo", birthday: null }])
|
||||
expect(rows).toEqual([
|
||||
{ id: 1, name: "foo", birthday: null, number: null },
|
||||
])
|
||||
})
|
||||
|
||||
it("should be able to execute an update that updates no rows", async () => {
|
||||
|
@ -398,4 +410,55 @@ describe.each([
|
|||
expect(rows).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
// this parameter really only impacts SQL queries
|
||||
describe("confirm nullDefaultSupport", () => {
|
||||
const queryParams = {
|
||||
fields: {
|
||||
sql: "INSERT INTO test_table (name, number) VALUES ({{ bindingName }}, {{ bindingNumber }})",
|
||||
},
|
||||
parameters: [
|
||||
{
|
||||
name: "bindingName",
|
||||
default: "",
|
||||
},
|
||||
{
|
||||
name: "bindingNumber",
|
||||
default: "",
|
||||
},
|
||||
],
|
||||
queryVerb: "create",
|
||||
}
|
||||
|
||||
it("should error for old queries", async () => {
|
||||
const query = await createQuery(queryParams)
|
||||
await config.api.query.save({ ...query, nullDefaultSupport: false })
|
||||
let error: string | undefined
|
||||
try {
|
||||
await config.api.query.execute(query._id!, {
|
||||
parameters: {
|
||||
bindingName: "testing",
|
||||
},
|
||||
})
|
||||
} catch (err: any) {
|
||||
error = err.message
|
||||
}
|
||||
if (dbName === "mssql") {
|
||||
expect(error).toBeUndefined()
|
||||
} else {
|
||||
expect(error).toBeDefined()
|
||||
expect(error).toContain("integer")
|
||||
}
|
||||
})
|
||||
|
||||
it("should not error for new queries", async () => {
|
||||
const query = await createQuery(queryParams)
|
||||
const results = await config.api.query.execute(query._id!, {
|
||||
parameters: {
|
||||
bindingName: "testing",
|
||||
},
|
||||
})
|
||||
expect(results).toEqual({ data: [{ created: true }] })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -3,8 +3,6 @@ import * as setup from "../utilities"
|
|||
import { databaseTestProviders } from "../../../../integrations/tests/utils"
|
||||
import { MongoClient, type Collection, BSON } from "mongodb"
|
||||
|
||||
jest.unmock("mongodb")
|
||||
|
||||
const collection = "test_collection"
|
||||
|
||||
const expectValidId = expect.stringMatching(/^\w{24}$/)
|
||||
|
@ -33,30 +31,30 @@ describe("/queries", () => {
|
|||
) {
|
||||
combinedQuery.fields.extra.collection = collection
|
||||
}
|
||||
return await config.api.query.create(combinedQuery)
|
||||
return await config.api.query.save(combinedQuery)
|
||||
}
|
||||
|
||||
async function withClient(
|
||||
callback: (client: MongoClient) => Promise<void>
|
||||
): Promise<void> {
|
||||
async function withClient<T>(
|
||||
callback: (client: MongoClient) => Promise<T>
|
||||
): Promise<T> {
|
||||
const ds = await databaseTestProviders.mongodb.datasource()
|
||||
const client = new MongoClient(ds.config!.connectionString)
|
||||
await client.connect()
|
||||
try {
|
||||
await callback(client)
|
||||
return await callback(client)
|
||||
} finally {
|
||||
await client.close()
|
||||
}
|
||||
}
|
||||
|
||||
async function withCollection(
|
||||
callback: (collection: Collection) => Promise<void>
|
||||
): Promise<void> {
|
||||
await withClient(async client => {
|
||||
async function withCollection<T>(
|
||||
callback: (collection: Collection) => Promise<T>
|
||||
): Promise<T> {
|
||||
return await withClient(async client => {
|
||||
const db = client.db(
|
||||
(await databaseTestProviders.mongodb.datasource()).config!.db
|
||||
)
|
||||
await callback(db.collection(collection))
|
||||
return await callback(db.collection(collection))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -327,6 +325,42 @@ describe("/queries", () => {
|
|||
})
|
||||
})
|
||||
|
||||
it("should be able to updateOne by ObjectId", async () => {
|
||||
const insertResult = await withCollection(c => c.insertOne({ name: "one" }))
|
||||
const query = await createQuery({
|
||||
fields: {
|
||||
json: {
|
||||
filter: { _id: { $eq: `ObjectId("${insertResult.insertedId}")` } },
|
||||
update: { $set: { name: "newName" } },
|
||||
},
|
||||
extra: {
|
||||
actionType: "updateOne",
|
||||
},
|
||||
},
|
||||
queryVerb: "update",
|
||||
})
|
||||
|
||||
const result = await config.api.query.execute(query._id!)
|
||||
|
||||
expect(result.data).toEqual([
|
||||
{
|
||||
acknowledged: true,
|
||||
matchedCount: 1,
|
||||
modifiedCount: 1,
|
||||
upsertedCount: 0,
|
||||
upsertedId: null,
|
||||
},
|
||||
])
|
||||
|
||||
await withCollection(async collection => {
|
||||
const doc = await collection.findOne({ name: { $eq: "newName" } })
|
||||
expect(doc).toEqual({
|
||||
_id: insertResult.insertedId,
|
||||
name: "newName",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it("should be able to delete all records", async () => {
|
||||
const query = await createQuery({
|
||||
fields: {
|
||||
|
@ -390,4 +424,85 @@ describe("/queries", () => {
|
|||
}
|
||||
})
|
||||
})
|
||||
|
||||
it("should throw an error if the incorrect actionType is specified", async () => {
|
||||
const verbs = ["read", "create", "update", "delete"]
|
||||
for (const verb of verbs) {
|
||||
const query = await createQuery({
|
||||
fields: { json: {}, extra: { actionType: "invalid" } },
|
||||
queryVerb: verb,
|
||||
})
|
||||
await config.api.query.execute(query._id!, undefined, { status: 400 })
|
||||
}
|
||||
})
|
||||
|
||||
it("should ignore extra brackets in query", async () => {
|
||||
const query = await createQuery({
|
||||
fields: {
|
||||
json: { foo: "te}st" },
|
||||
extra: {
|
||||
actionType: "insertOne",
|
||||
},
|
||||
},
|
||||
queryVerb: "create",
|
||||
})
|
||||
|
||||
const result = await config.api.query.execute(query._id!)
|
||||
expect(result.data).toEqual([
|
||||
{
|
||||
acknowledged: true,
|
||||
insertedId: expectValidId,
|
||||
},
|
||||
])
|
||||
|
||||
await withCollection(async collection => {
|
||||
const doc = await collection.findOne({ foo: { $eq: "te}st" } })
|
||||
expect(doc).toEqual({
|
||||
_id: expectValidBsonObjectId,
|
||||
foo: "te}st",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it("should be able to save deeply nested data", async () => {
|
||||
const data = {
|
||||
foo: "bar",
|
||||
data: [
|
||||
{ cid: 1 },
|
||||
{ cid: 2 },
|
||||
{
|
||||
nested: {
|
||||
name: "test",
|
||||
ary: [1, 2, 3],
|
||||
aryOfObjects: [{ a: 1 }, { b: 2 }],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
const query = await createQuery({
|
||||
fields: {
|
||||
json: data,
|
||||
extra: {
|
||||
actionType: "insertOne",
|
||||
},
|
||||
},
|
||||
queryVerb: "create",
|
||||
})
|
||||
|
||||
const result = await config.api.query.execute(query._id!)
|
||||
expect(result.data).toEqual([
|
||||
{
|
||||
acknowledged: true,
|
||||
insertedId: expectValidId,
|
||||
},
|
||||
])
|
||||
|
||||
await withCollection(async collection => {
|
||||
const doc = await collection.findOne({ foo: { $eq: "bar" } })
|
||||
expect(doc).toEqual({
|
||||
_id: expectValidBsonObjectId,
|
||||
...data,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -78,6 +78,7 @@ describe("/queries", () => {
|
|||
_rev: res.body._rev,
|
||||
_id: res.body._id,
|
||||
...query,
|
||||
nullDefaultSupport: true,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
|
@ -103,6 +104,7 @@ describe("/queries", () => {
|
|||
_rev: res.body._rev,
|
||||
_id: res.body._id,
|
||||
...query,
|
||||
nullDefaultSupport: true,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
|
@ -130,6 +132,7 @@ describe("/queries", () => {
|
|||
_id: query._id,
|
||||
createdAt: new Date().toISOString(),
|
||||
...basicQuery(datasource._id),
|
||||
nullDefaultSupport: true,
|
||||
updatedAt: new Date().toISOString(),
|
||||
readable: true,
|
||||
},
|
||||
|
@ -245,10 +248,10 @@ describe("/queries", () => {
|
|||
expect(responseBody.rows.length).toEqual(1)
|
||||
expect(events.query.previewed).toHaveBeenCalledTimes(1)
|
||||
delete datasource.config
|
||||
expect(events.query.previewed).toHaveBeenCalledWith(
|
||||
datasource,
|
||||
queryPreview
|
||||
)
|
||||
expect(events.query.previewed).toHaveBeenCalledWith(datasource, {
|
||||
...queryPreview,
|
||||
nullDefaultSupport: true,
|
||||
})
|
||||
})
|
||||
|
||||
it("should apply authorization to endpoint", async () => {
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
} from "mongodb"
|
||||
import environment from "../environment"
|
||||
|
||||
interface MongoDBConfig {
|
||||
export interface MongoDBConfig {
|
||||
connectionString: string
|
||||
db: string
|
||||
tlsCertificateKeyFile: string
|
||||
|
@ -348,7 +348,7 @@ const getSchema = () => {
|
|||
|
||||
const SCHEMA: Integration = getSchema()
|
||||
|
||||
class MongoIntegration implements IntegrationBase {
|
||||
export class MongoIntegration implements IntegrationBase {
|
||||
private config: MongoDBConfig
|
||||
private client: MongoClient
|
||||
|
||||
|
|
|
@ -5,9 +5,10 @@ import sdk from "../../sdk"
|
|||
const CONST_CHAR_REGEX = new RegExp("'[^']*'", "g")
|
||||
|
||||
export async function interpolateSQL(
|
||||
fields: { [key: string]: any },
|
||||
fields: { sql: string; bindings: any[] },
|
||||
parameters: { [key: string]: any },
|
||||
integration: DatasourcePlus
|
||||
integration: DatasourcePlus,
|
||||
opts: { nullDefaultSupport: boolean }
|
||||
) {
|
||||
let sql = fields.sql
|
||||
if (!sql || typeof sql !== "string") {
|
||||
|
@ -64,7 +65,14 @@ export async function interpolateSQL(
|
|||
}
|
||||
// replicate the knex structure
|
||||
fields.sql = sql
|
||||
fields.bindings = await sdk.queries.enrichContext(variables, parameters)
|
||||
fields.bindings = await sdk.queries.enrichArrayContext(variables, parameters)
|
||||
if (opts.nullDefaultSupport) {
|
||||
for (let index in fields.bindings) {
|
||||
if (fields.bindings[index] === "") {
|
||||
fields.bindings[index] = null
|
||||
}
|
||||
}
|
||||
}
|
||||
// check for arrays in the data
|
||||
let updated: string[] = []
|
||||
for (let i = 0; i < variables.length; i++) {
|
||||
|
|
|
@ -1,325 +0,0 @@
|
|||
const mongo = require("mongodb")
|
||||
|
||||
import { default as MongoDBIntegration } from "../mongodb"
|
||||
|
||||
jest.mock("mongodb")
|
||||
|
||||
class TestConfiguration {
|
||||
integration: any
|
||||
|
||||
constructor(config: any = {}) {
|
||||
this.integration = new MongoDBIntegration.integration(config)
|
||||
}
|
||||
}
|
||||
|
||||
describe("MongoDB Integration", () => {
|
||||
let config: any
|
||||
let indexName = "Users"
|
||||
|
||||
beforeEach(() => {
|
||||
config = new TestConfiguration()
|
||||
})
|
||||
|
||||
it("calls the create method with the correct params", async () => {
|
||||
const body = {
|
||||
name: "Hello",
|
||||
}
|
||||
await config.integration.create({
|
||||
index: indexName,
|
||||
json: body,
|
||||
extra: { collection: "testCollection", actionType: "insertOne" },
|
||||
})
|
||||
expect(config.integration.client.insertOne).toHaveBeenCalledWith(body)
|
||||
})
|
||||
|
||||
it("calls the read method with the correct params", async () => {
|
||||
const query = {
|
||||
json: {
|
||||
address: "test",
|
||||
},
|
||||
extra: { collection: "testCollection", actionType: "find" },
|
||||
}
|
||||
const response = await config.integration.read(query)
|
||||
expect(config.integration.client.find).toHaveBeenCalledWith(query.json)
|
||||
expect(response).toEqual(expect.any(Array))
|
||||
})
|
||||
|
||||
it("calls the delete method with the correct params", async () => {
|
||||
const query = {
|
||||
json: {
|
||||
filter: {
|
||||
id: "test",
|
||||
},
|
||||
options: {
|
||||
opt: "option",
|
||||
},
|
||||
},
|
||||
extra: { collection: "testCollection", actionType: "deleteOne" },
|
||||
}
|
||||
await config.integration.delete(query)
|
||||
expect(config.integration.client.deleteOne).toHaveBeenCalledWith(
|
||||
query.json.filter,
|
||||
query.json.options
|
||||
)
|
||||
})
|
||||
|
||||
it("calls the update method with the correct params", async () => {
|
||||
const query = {
|
||||
json: {
|
||||
filter: {
|
||||
id: "test",
|
||||
},
|
||||
update: {
|
||||
name: "TestName",
|
||||
},
|
||||
options: {
|
||||
upsert: false,
|
||||
},
|
||||
},
|
||||
extra: { collection: "testCollection", actionType: "updateOne" },
|
||||
}
|
||||
await config.integration.update(query)
|
||||
expect(config.integration.client.updateOne).toHaveBeenCalledWith(
|
||||
query.json.filter,
|
||||
query.json.update,
|
||||
query.json.options
|
||||
)
|
||||
})
|
||||
|
||||
it("throws an error when an invalid query.extra.actionType is passed for each method", async () => {
|
||||
const query = {
|
||||
extra: { collection: "testCollection", actionType: "deleteOne" },
|
||||
}
|
||||
|
||||
let error = null
|
||||
try {
|
||||
await config.integration.read(query)
|
||||
} catch (err) {
|
||||
error = err
|
||||
}
|
||||
expect(error).toBeDefined()
|
||||
})
|
||||
|
||||
it("creates ObjectIds if the field contains a match on ObjectId", async () => {
|
||||
const query = {
|
||||
json: {
|
||||
filter: {
|
||||
_id: "ObjectId('ACBD12345678ABCD12345678')",
|
||||
name: "ObjectId('BBBB12345678ABCD12345678')",
|
||||
},
|
||||
update: {
|
||||
_id: "ObjectId('FFFF12345678ABCD12345678')",
|
||||
name: "ObjectId('CCCC12345678ABCD12345678')",
|
||||
},
|
||||
options: {
|
||||
upsert: false,
|
||||
},
|
||||
},
|
||||
extra: { collection: "testCollection", actionType: "updateOne" },
|
||||
}
|
||||
await config.integration.update(query)
|
||||
expect(config.integration.client.updateOne).toHaveBeenCalled()
|
||||
|
||||
const args = config.integration.client.updateOne.mock.calls[0]
|
||||
expect(args[0]).toEqual({
|
||||
_id: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
|
||||
name: mongo.ObjectId.createFromHexString("BBBB12345678ABCD12345678"),
|
||||
})
|
||||
expect(args[1]).toEqual({
|
||||
_id: mongo.ObjectId.createFromHexString("FFFF12345678ABCD12345678"),
|
||||
name: mongo.ObjectId.createFromHexString("CCCC12345678ABCD12345678"),
|
||||
})
|
||||
expect(args[2]).toEqual({
|
||||
upsert: false,
|
||||
})
|
||||
})
|
||||
|
||||
it("creates ObjectIds if the $ operator fields contains a match on ObjectId", async () => {
|
||||
const query = {
|
||||
json: {
|
||||
filter: {
|
||||
_id: {
|
||||
$eq: "ObjectId('ACBD12345678ABCD12345678')",
|
||||
},
|
||||
},
|
||||
update: {
|
||||
$set: {
|
||||
_id: "ObjectId('FFFF12345678ABCD12345678')",
|
||||
},
|
||||
},
|
||||
options: {
|
||||
upsert: true,
|
||||
},
|
||||
},
|
||||
extra: { collection: "testCollection", actionType: "updateOne" },
|
||||
}
|
||||
await config.integration.update(query)
|
||||
expect(config.integration.client.updateOne).toHaveBeenCalled()
|
||||
|
||||
const args = config.integration.client.updateOne.mock.calls[0]
|
||||
expect(args[0]).toEqual({
|
||||
_id: {
|
||||
$eq: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
|
||||
},
|
||||
})
|
||||
expect(args[1]).toEqual({
|
||||
$set: {
|
||||
_id: mongo.ObjectId.createFromHexString("FFFF12345678ABCD12345678"),
|
||||
},
|
||||
})
|
||||
expect(args[2]).toEqual({
|
||||
upsert: true,
|
||||
})
|
||||
})
|
||||
|
||||
it("supports findOneAndUpdate", async () => {
|
||||
const query = {
|
||||
json: {
|
||||
filter: {
|
||||
_id: {
|
||||
$eq: "ObjectId('ACBD12345678ABCD12345678')",
|
||||
},
|
||||
},
|
||||
update: {
|
||||
$set: {
|
||||
name: "UPDATED",
|
||||
age: 99,
|
||||
},
|
||||
},
|
||||
options: {
|
||||
upsert: false,
|
||||
},
|
||||
},
|
||||
extra: { collection: "testCollection", actionType: "findOneAndUpdate" },
|
||||
}
|
||||
await config.integration.read(query)
|
||||
expect(config.integration.client.findOneAndUpdate).toHaveBeenCalled()
|
||||
|
||||
const args = config.integration.client.findOneAndUpdate.mock.calls[0]
|
||||
expect(args[0]).toEqual({
|
||||
_id: {
|
||||
$eq: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
|
||||
},
|
||||
})
|
||||
expect(args[1]).toEqual({
|
||||
$set: {
|
||||
name: "UPDATED",
|
||||
age: 99,
|
||||
},
|
||||
})
|
||||
expect(args[2]).toEqual({
|
||||
upsert: false,
|
||||
includeResultMetadata: true,
|
||||
})
|
||||
})
|
||||
|
||||
it("can parse nested objects with arrays", async () => {
|
||||
const query = {
|
||||
json: `{
|
||||
"_id": {
|
||||
"$eq": "ObjectId('ACBD12345678ABCD12345678')"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$set": {
|
||||
"value": {
|
||||
"data": [
|
||||
{ "cid": 1 },
|
||||
{ "cid": 2 },
|
||||
{ "nested": {
|
||||
"name": "test"
|
||||
}}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"upsert": true
|
||||
}`,
|
||||
extra: { collection: "testCollection", actionType: "updateOne" },
|
||||
}
|
||||
await config.integration.update(query)
|
||||
expect(config.integration.client.updateOne).toHaveBeenCalled()
|
||||
|
||||
const args = config.integration.client.updateOne.mock.calls[0]
|
||||
expect(args[0]).toEqual({
|
||||
_id: {
|
||||
$eq: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
|
||||
},
|
||||
})
|
||||
expect(args[1]).toEqual({
|
||||
$set: {
|
||||
value: {
|
||||
data: [
|
||||
{ cid: 1 },
|
||||
{ cid: 2 },
|
||||
{
|
||||
nested: {
|
||||
name: "test",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(args[2]).toEqual({
|
||||
upsert: true,
|
||||
})
|
||||
})
|
||||
|
||||
it("ignores braces within strings when parsing nested objects", async () => {
|
||||
const query = {
|
||||
json: `{
|
||||
"_id": {
|
||||
"$eq": "ObjectId('ACBD12345678ABCD12345678')"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$set": {
|
||||
"value": {
|
||||
"data": [
|
||||
{ "cid": 1 },
|
||||
{ "cid": 2 },
|
||||
{ "nested": {
|
||||
"name": "te}st"
|
||||
}}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"upsert": true,
|
||||
"extra": "ad\\"{\\"d"
|
||||
}`,
|
||||
extra: { collection: "testCollection", actionType: "updateOne" },
|
||||
}
|
||||
await config.integration.update(query)
|
||||
expect(config.integration.client.updateOne).toHaveBeenCalled()
|
||||
|
||||
const args = config.integration.client.updateOne.mock.calls[0]
|
||||
expect(args[0]).toEqual({
|
||||
_id: {
|
||||
$eq: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
|
||||
},
|
||||
})
|
||||
expect(args[1]).toEqual({
|
||||
$set: {
|
||||
value: {
|
||||
data: [
|
||||
{ cid: 1 },
|
||||
{ cid: 2 },
|
||||
{
|
||||
nested: {
|
||||
name: "te}st",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(args[2]).toEqual({
|
||||
upsert: true,
|
||||
extra: 'ad"{"d',
|
||||
})
|
||||
})
|
||||
})
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,5 @@
|
|||
const {
|
||||
getJsHelperList,
|
||||
} = require("../../../../string-templates/src/helpers/list.js")
|
||||
// eslint-disable-next-line local-rules/no-budibase-imports
|
||||
import { getJsHelperList } from "@budibase/string-templates/src/helpers/list"
|
||||
|
||||
export default {
|
||||
...getJsHelperList(),
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
"use strict";var snippets=(()=>{var u=Object.create;var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var l=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),W=(i,e)=>{for(var p in e)n(i,p,{get:e[p],enumerable:!0})},f=(i,e,p,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of h(e))!C.call(i,t)&&t!==p&&n(i,t,{get:()=>e[t],enumerable:!(r=a(e,t))||r.enumerable});return i};var d=(i,e,p)=>(p=i!=null?u(x(i)):{},f(e||!i||!i.__esModule?n(p,"default",{value:i,enumerable:!0}):p,i)),g=i=>f(n({},"__esModule",{value:!0}),i);var s=l((D,o)=>{o.exports.iifeWrapper=i=>`(function(){
|
||||
"use strict";var snippets=(()=>{var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(i,e)=>{for(var n in e)p(i,n,{get:e[n],enumerable:!0})},a=(i,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of s(e))!c.call(i,t)&&t!==n&&p(i,t,{get:()=>e[t],enumerable:!(r=f(e,t))||r.enumerable});return i};var h=i=>a(p({},"__esModule",{value:!0}),i);var C={};u(C,{default:()=>x});var o=i=>`(function(){
|
||||
${i}
|
||||
})();`});var w={};W(w,{default:()=>v});var c=d(s()),v=new Proxy({},{get:function(i,e){return e in snippetCache||(snippetCache[e]=[eval][0]((0,c.iifeWrapper)(snippetDefinitions[e]))),snippetCache[e]}});return g(w);})();
|
||||
})();`;var x=new Proxy({},{get:function(i,e){return e in snippetCache||(snippetCache[e]=[eval][0](o(snippetDefinitions[e]))),snippetCache[e]}});return h(C);})();
|
||||
|
|
|
@ -65,14 +65,33 @@ export async function fetch(opts: { enrich: boolean } = { enrich: true }) {
|
|||
return updateSchemas(queries)
|
||||
}
|
||||
|
||||
export async function enrichArrayContext(
|
||||
fields: any[],
|
||||
inputs = {}
|
||||
): Promise<any[]> {
|
||||
const map: Record<string, any> = {}
|
||||
for (let index in fields) {
|
||||
map[index] = fields[index]
|
||||
}
|
||||
const output = await enrichContext(map, inputs)
|
||||
const outputArray: any[] = []
|
||||
for (let [key, value] of Object.entries(output)) {
|
||||
outputArray[parseInt(key)] = value
|
||||
}
|
||||
return outputArray
|
||||
}
|
||||
|
||||
export async function enrichContext(
|
||||
fields: Record<string, any>,
|
||||
inputs = {}
|
||||
): Promise<Record<string, any>> {
|
||||
const enrichedQuery: Record<string, any> = Array.isArray(fields) ? [] : {}
|
||||
const enrichedQuery: Record<string, any> = {}
|
||||
if (!fields || !inputs) {
|
||||
return enrichedQuery
|
||||
}
|
||||
if (Array.isArray(fields)) {
|
||||
return enrichArrayContext(fields, inputs)
|
||||
}
|
||||
const env = await getEnvironmentVariables()
|
||||
const parameters = { ...inputs, env }
|
||||
// enrich the fields with dynamic parameters
|
||||
|
|
|
@ -5,21 +5,23 @@ import {
|
|||
PreviewQueryRequest,
|
||||
PreviewQueryResponse,
|
||||
} from "@budibase/types"
|
||||
import { TestAPI } from "./base"
|
||||
import { Expectations, TestAPI } from "./base"
|
||||
|
||||
export class QueryAPI extends TestAPI {
|
||||
create = async (body: Query): Promise<Query> => {
|
||||
save = async (body: Query): Promise<Query> => {
|
||||
return await this._post<Query>(`/api/queries`, { body })
|
||||
}
|
||||
|
||||
execute = async (
|
||||
queryId: string,
|
||||
body?: ExecuteQueryRequest
|
||||
body?: ExecuteQueryRequest,
|
||||
expectations?: Expectations
|
||||
): Promise<ExecuteQueryResponse> => {
|
||||
return await this._post<ExecuteQueryResponse>(
|
||||
`/api/v2/queries/${queryId}`,
|
||||
{
|
||||
body,
|
||||
expectations,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
import { Datasource, QuerySchema, Row } from "@budibase/types"
|
||||
import { Datasource, Row, Query } from "@budibase/types"
|
||||
|
||||
export type WorkerCallback = (error: any, response?: any) => void
|
||||
|
||||
export interface QueryEvent {
|
||||
export interface QueryEvent
|
||||
extends Omit<Query, "datasourceId" | "name" | "parameters" | "readable"> {
|
||||
appId?: string
|
||||
datasource: Datasource
|
||||
queryVerb: string
|
||||
fields: { [key: string]: any }
|
||||
parameters: { [key: string]: unknown }
|
||||
pagination?: any
|
||||
transformer: any
|
||||
queryId?: string
|
||||
environmentVariables?: Record<string, string>
|
||||
parameters: QueryEventParameters
|
||||
ctx?: any
|
||||
schema?: Record<string, QuerySchema | string>
|
||||
}
|
||||
|
||||
export type QueryEventParameters = Record<string, string | null>
|
||||
|
||||
export interface QueryResponse {
|
||||
rows: Row[]
|
||||
keys: string[]
|
||||
|
|
|
@ -26,10 +26,11 @@ class QueryRunner {
|
|||
fields: any
|
||||
parameters: any
|
||||
pagination: any
|
||||
transformer: string
|
||||
transformer: string | null
|
||||
cachedVariables: any[]
|
||||
ctx: any
|
||||
queryResponse: any
|
||||
nullDefaultSupport: boolean
|
||||
noRecursiveQuery: boolean
|
||||
hasRerun: boolean
|
||||
hasRefreshedOAuth: boolean
|
||||
|
@ -45,6 +46,7 @@ class QueryRunner {
|
|||
this.transformer = input.transformer
|
||||
this.queryId = input.queryId!
|
||||
this.schema = input.schema
|
||||
this.nullDefaultSupport = !!input.nullDefaultSupport
|
||||
this.noRecursiveQuery = flags.noRecursiveQuery
|
||||
this.cachedVariables = []
|
||||
// Additional context items for enrichment
|
||||
|
@ -59,7 +61,14 @@ class QueryRunner {
|
|||
}
|
||||
|
||||
async execute(): Promise<QueryResponse> {
|
||||
let { datasource, fields, queryVerb, transformer, schema } = this
|
||||
let {
|
||||
datasource,
|
||||
fields,
|
||||
queryVerb,
|
||||
transformer,
|
||||
schema,
|
||||
nullDefaultSupport,
|
||||
} = this
|
||||
let datasourceClone = cloneDeep(datasource)
|
||||
let fieldsClone = cloneDeep(fields)
|
||||
|
||||
|
@ -100,10 +109,12 @@ class QueryRunner {
|
|||
)
|
||||
}
|
||||
|
||||
let query
|
||||
let query: Record<string, any>
|
||||
// handle SQL injections by interpolating the variables
|
||||
if (isSQL(datasourceClone)) {
|
||||
query = await interpolateSQL(fieldsClone, enrichedContext, integration)
|
||||
query = await interpolateSQL(fieldsClone, enrichedContext, integration, {
|
||||
nullDefaultSupport,
|
||||
})
|
||||
} else {
|
||||
query = await sdk.queries.enrichContext(fieldsClone, enrichedContext)
|
||||
}
|
||||
|
@ -137,7 +148,9 @@ class QueryRunner {
|
|||
data: rows,
|
||||
params: enrichedParameters,
|
||||
}
|
||||
rows = vm.withContext(ctx, () => vm.execute(transformer))
|
||||
if (transformer != null) {
|
||||
rows = vm.withContext(ctx, () => vm.execute(transformer!))
|
||||
}
|
||||
}
|
||||
|
||||
// if the request fails we retry once, invalidating the cached value
|
||||
|
@ -191,13 +204,15 @@ class QueryRunner {
|
|||
})
|
||||
return new QueryRunner(
|
||||
{
|
||||
datasource,
|
||||
schema: query.schema,
|
||||
queryVerb: query.queryVerb,
|
||||
fields: query.fields,
|
||||
parameters,
|
||||
transformer: query.transformer,
|
||||
queryId,
|
||||
nullDefaultSupport: query.nullDefaultSupport,
|
||||
ctx: this.ctx,
|
||||
parameters,
|
||||
datasource,
|
||||
queryId,
|
||||
},
|
||||
{ noRecursiveQuery: true }
|
||||
).execute()
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
"@budibase/backend-core/*": ["../backend-core/*"],
|
||||
"@budibase/shared-core": ["../shared-core/src"],
|
||||
"@budibase/pro": ["../pro/src"],
|
||||
"@budibase/string-templates": ["../string-templates/src"]
|
||||
"@budibase/string-templates": ["../string-templates/src"],
|
||||
"@budibase/string-templates/*": ["../string-templates/*"]
|
||||
},
|
||||
"allowArbitraryExtensions": true
|
||||
},
|
||||
|
|
|
@ -1,17 +1,29 @@
|
|||
import { date, duration } from "./date"
|
||||
|
||||
import {
|
||||
math,
|
||||
array,
|
||||
number,
|
||||
url,
|
||||
string,
|
||||
comparison,
|
||||
object,
|
||||
regex,
|
||||
uuid,
|
||||
// @ts-expect-error
|
||||
} from "@budibase/handlebars-helpers"
|
||||
/*
|
||||
@budibase/handlebars-helpers is not treeshakeable, so we can't use the barrel files.
|
||||
Otherwise, we have issues when generating the isolated-vm bundle because of the treeshaking
|
||||
*/
|
||||
/* eslint-disable local-rules/no-budibase-imports */
|
||||
// @ts-expect-error
|
||||
import math from "@budibase/handlebars-helpers/lib/math"
|
||||
// @ts-expect-error
|
||||
import array from "@budibase/handlebars-helpers/lib/array"
|
||||
// @ts-expect-error
|
||||
import number from "@budibase/handlebars-helpers/lib/number"
|
||||
// @ts-expect-error
|
||||
import url from "@budibase/handlebars-helpers/lib/url"
|
||||
// @ts-expect-error
|
||||
import string from "@budibase/handlebars-helpers/lib/string"
|
||||
// @ts-expect-error
|
||||
import comparison from "@budibase/handlebars-helpers/lib/comparison"
|
||||
// @ts-expect-error
|
||||
import object from "@budibase/handlebars-helpers/lib/object"
|
||||
// @ts-expect-error
|
||||
import regex from "@budibase/handlebars-helpers/lib/regex"
|
||||
// @ts-expect-error
|
||||
import uuid from "@budibase/handlebars-helpers/lib/uuid"
|
||||
/* eslint-enable local-rules/no-budibase-imports */
|
||||
|
||||
// https://github.com/evanw/esbuild/issues/56
|
||||
const externalCollections = {
|
||||
|
@ -42,14 +54,14 @@ export function getJsHelperList() {
|
|||
|
||||
helpers = {}
|
||||
for (let collection of Object.values(externalCollections)) {
|
||||
for (let [key, func] of Object.entries<any>(collection())) {
|
||||
for (let [key, func] of Object.entries<any>(collection)) {
|
||||
// Handlebars injects the hbs options to the helpers by default. We are adding an empty {} as a last parameter to simulate it
|
||||
helpers[key] = (...props: any) => func(...props, {})
|
||||
}
|
||||
}
|
||||
helpers = {
|
||||
...helpers,
|
||||
addedHelpers,
|
||||
...addedHelpers,
|
||||
}
|
||||
|
||||
for (const toRemove of helpersToRemoveForJs) {
|
||||
|
|
|
@ -94,7 +94,7 @@ export async function processObject<T extends Record<string, any>>(
|
|||
for (const key of Object.keys(object || {})) {
|
||||
if (object[key] != null) {
|
||||
const val = object[key]
|
||||
let parsedValue
|
||||
let parsedValue = val
|
||||
if (typeof val === "string") {
|
||||
parsedValue = await processString(object[key], context, opts)
|
||||
} else if (typeof val === "object") {
|
||||
|
|
|
@ -104,6 +104,26 @@ describe("Test that the object processing works correctly", () => {
|
|||
}
|
||||
expect(error).toBeNull()
|
||||
})
|
||||
|
||||
it("should be able to handle booleans", async () => {
|
||||
const output = await processObject(
|
||||
{
|
||||
first: true,
|
||||
second: "true",
|
||||
third: "another string",
|
||||
forth: "with {{ template }}",
|
||||
},
|
||||
{
|
||||
template: "value",
|
||||
}
|
||||
)
|
||||
expect(output).toEqual({
|
||||
first: true,
|
||||
second: "true",
|
||||
third: "another string",
|
||||
forth: "with value",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("check returning objects", () => {
|
||||
|
|
|
@ -15,6 +15,8 @@ export interface Query extends Document {
|
|||
schema: Record<string, QuerySchema | string>
|
||||
readable: boolean
|
||||
queryVerb: string
|
||||
// flag to state whether the default bindings are empty strings (old behaviour) or null
|
||||
nullDefaultSupport?: boolean
|
||||
}
|
||||
|
||||
export interface QueryPreview extends Omit<Query, "_id"> {
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
const mockS3 = {
|
||||
headBucket: jest.fn().mockReturnThis(),
|
||||
deleteObject: jest.fn().mockReturnThis(),
|
||||
deleteObjects: jest.fn().mockReturnThis(),
|
||||
createBucket: jest.fn().mockReturnThis(),
|
||||
listObjects: jest.fn().mockReturnThis(),
|
||||
promise: jest.fn().mockReturnThis(),
|
||||
catch: jest.fn(),
|
||||
}
|
||||
|
||||
const AWS = {
|
||||
S3: jest.fn(() => mockS3),
|
||||
}
|
||||
|
||||
export default AWS
|
|
@ -1,23 +0,0 @@
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
module FetchMock {
|
||||
const fetch = jest.requireActual("node-fetch")
|
||||
|
||||
const func = async (url: any, opts: any) => {
|
||||
if (url.includes("http://someconfigurl")) {
|
||||
return {
|
||||
ok: true,
|
||||
json: () => ({
|
||||
issuer: "test",
|
||||
authorization_endpoint: "http://localhost/auth",
|
||||
token_endpoint: "http://localhost/token",
|
||||
userinfo_endpoint: "http://localhost/userinfo",
|
||||
}),
|
||||
}
|
||||
}
|
||||
return fetch(url, opts)
|
||||
}
|
||||
|
||||
func.Headers = fetch.Headers
|
||||
|
||||
module.exports = func
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
import * as jwt from "jsonwebtoken"
|
||||
|
||||
const mockOAuth2 = {
|
||||
getOAuthAccessToken: (code: string, p: any, cb: any) => {
|
||||
const err = null
|
||||
const accessToken = "access_token"
|
||||
const refreshToken = "refresh_token"
|
||||
|
||||
const exp = new Date()
|
||||
exp.setDate(exp.getDate() + 1)
|
||||
|
||||
const iat = new Date()
|
||||
iat.setDate(iat.getDate() - 1)
|
||||
|
||||
const claims = {
|
||||
iss: "test",
|
||||
sub: "sub",
|
||||
aud: "clientId",
|
||||
exp: exp.getTime() / 1000,
|
||||
iat: iat.getTime() / 1000,
|
||||
email: "oauth@example.com",
|
||||
}
|
||||
|
||||
const idToken = jwt.sign(claims, "secret")
|
||||
|
||||
const params = {
|
||||
id_token: idToken,
|
||||
}
|
||||
return cb(err, accessToken, refreshToken, params)
|
||||
},
|
||||
_request: (
|
||||
method: string,
|
||||
url: string,
|
||||
headers: any,
|
||||
postBody: any,
|
||||
accessToken: string,
|
||||
cb: any
|
||||
) => {
|
||||
const err = null
|
||||
const body = {
|
||||
sub: "sub",
|
||||
user_id: "userId",
|
||||
name: "OAuth",
|
||||
family_name: "2",
|
||||
given_name: "OAuth",
|
||||
middle_name: "",
|
||||
}
|
||||
const res = {}
|
||||
return cb(err, JSON.stringify(body), res)
|
||||
},
|
||||
}
|
||||
|
||||
const oauth = {
|
||||
OAuth2: jest.fn(() => mockOAuth2),
|
||||
}
|
||||
|
||||
export = oauth
|
|
@ -86,6 +86,7 @@
|
|||
"@types/supertest": "2.0.14",
|
||||
"@types/uuid": "8.3.4",
|
||||
"jest": "29.7.0",
|
||||
"nock": "^13.5.4",
|
||||
"nodemon": "2.0.15",
|
||||
"rimraf": "3.0.2",
|
||||
"supertest": "6.3.3",
|
||||
|
|
|
@ -13,6 +13,8 @@ import { events, constants } from "@budibase/backend-core"
|
|||
import { Response } from "superagent"
|
||||
|
||||
import * as userSdk from "../../../../sdk/users"
|
||||
import nock from "nock"
|
||||
import * as jwt from "jsonwebtoken"
|
||||
|
||||
function getAuthCookie(response: Response) {
|
||||
return response.headers["set-cookie"]
|
||||
|
@ -274,45 +276,9 @@ describe("/api/global/auth", () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe("init", () => {
|
||||
describe("POST /api/global/auth/init", () => {})
|
||||
|
||||
describe("GET /api/global/auth/init", () => {})
|
||||
})
|
||||
|
||||
describe("datasource", () => {
|
||||
// MULTI TENANT
|
||||
|
||||
describe("GET /api/global/auth/:tenantId/datasource/:provider", () => {})
|
||||
|
||||
describe("GET /api/global/auth/:tenantId/datasource/:provider/callback", () => {})
|
||||
|
||||
// SINGLE TENANT
|
||||
|
||||
describe("GET /api/global/auth/datasource/:provider/callback", () => {})
|
||||
})
|
||||
|
||||
describe("google", () => {
|
||||
// MULTI TENANT
|
||||
|
||||
describe("GET /api/global/auth/:tenantId/google", () => {})
|
||||
|
||||
describe("GET /api/global/auth/:tenantId/google/callback", () => {})
|
||||
|
||||
// SINGLE TENANT
|
||||
|
||||
describe("GET /api/global/auth/google/callback", () => {})
|
||||
|
||||
describe("GET /api/admin/auth/google/callback", () => {})
|
||||
})
|
||||
|
||||
describe("oidc", () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
mockGetWellKnownConfig()
|
||||
|
||||
// see: __mocks__/oauth
|
||||
// for associated mocking inside passport
|
||||
afterEach(() => {
|
||||
nock.cleanAll()
|
||||
})
|
||||
|
||||
const generateOidcConfig = async () => {
|
||||
|
@ -321,21 +287,16 @@ describe("/api/global/auth", () => {
|
|||
return chosenConfig.uuid
|
||||
}
|
||||
|
||||
const mockGetWellKnownConfig = () => {
|
||||
mocks.fetch.mockReturnValue({
|
||||
ok: true,
|
||||
json: () => ({
|
||||
// MULTI TENANT
|
||||
describe("GET /api/global/auth/:tenantId/oidc/configs/:configId", () => {
|
||||
it("redirects to auth provider", async () => {
|
||||
nock("http://someconfigurl").get("/").times(1).reply(200, {
|
||||
issuer: "test",
|
||||
authorization_endpoint: "http://localhost/auth",
|
||||
token_endpoint: "http://localhost/token",
|
||||
userinfo_endpoint: "http://localhost/userinfo",
|
||||
}),
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// MULTI TENANT
|
||||
describe("GET /api/global/auth/:tenantId/oidc/configs/:configId", () => {
|
||||
it("redirects to auth provider", async () => {
|
||||
const configId = await generateOidcConfig()
|
||||
|
||||
const res = await config.api.configs.getOIDCConfig(configId)
|
||||
|
@ -352,10 +313,43 @@ describe("/api/global/auth", () => {
|
|||
|
||||
describe("GET /api/global/auth/:tenantId/oidc/callback", () => {
|
||||
it("logs in", async () => {
|
||||
nock("http://someconfigurl").get("/").times(2).reply(200, {
|
||||
issuer: "test",
|
||||
authorization_endpoint: "http://localhost/auth",
|
||||
token_endpoint: "http://localhost/token",
|
||||
userinfo_endpoint: "http://localhost/userinfo",
|
||||
})
|
||||
|
||||
const token = jwt.sign(
|
||||
{
|
||||
iss: "test",
|
||||
sub: "sub",
|
||||
aud: "clientId",
|
||||
exp: Math.floor(Date.now() / 1000) + 60 * 60,
|
||||
email: "oauth@example.com",
|
||||
},
|
||||
"secret"
|
||||
)
|
||||
|
||||
nock("http://localhost").post("/token").reply(200, {
|
||||
access_token: "access",
|
||||
refresh_token: "refresh",
|
||||
id_token: token,
|
||||
})
|
||||
|
||||
nock("http://localhost").get("/userinfo?schema=openid").reply(200, {
|
||||
sub: "sub",
|
||||
email: "oauth@example.com",
|
||||
})
|
||||
|
||||
const configId = await generateOidcConfig()
|
||||
const preAuthRes = await config.api.configs.getOIDCConfig(configId)
|
||||
|
||||
const res = await config.api.configs.OIDCCallback(configId, preAuthRes)
|
||||
if (res.status > 399) {
|
||||
throw new Error(
|
||||
`OIDC callback failed with status ${res.status}: ${res.text}`
|
||||
)
|
||||
}
|
||||
|
||||
expect(events.auth.login).toHaveBeenCalledWith(
|
||||
"oidc",
|
||||
|
|
179
yarn.lock
179
yarn.lock
|
@ -7303,7 +7303,37 @@ axios-retry@^3.1.9:
|
|||
"@babel/runtime" "^7.15.4"
|
||||
is-retry-allowed "^2.2.0"
|
||||
|
||||
axios@0.24.0, axios@1.1.3, axios@1.6.3, axios@^0.21.1, axios@^0.21.4, axios@^0.26.0, axios@^1.0.0, axios@^1.1.3, axios@^1.5.0:
|
||||
axios@0.24.0:
|
||||
version "0.24.0"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.24.0.tgz#804e6fa1e4b9c5288501dd9dff56a7a0940d20d6"
|
||||
integrity sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.4"
|
||||
|
||||
axios@1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-1.1.3.tgz#8274250dada2edf53814ed7db644b9c2866c1e35"
|
||||
integrity sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA==
|
||||
dependencies:
|
||||
follow-redirects "^1.15.0"
|
||||
form-data "^4.0.0"
|
||||
proxy-from-env "^1.1.0"
|
||||
|
||||
axios@^0.21.1, axios@^0.21.4:
|
||||
version "0.21.4"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
|
||||
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.0"
|
||||
|
||||
axios@^0.26.0:
|
||||
version "0.26.1"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9"
|
||||
integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.8"
|
||||
|
||||
axios@^1.0.0, axios@^1.1.3, axios@^1.5.0:
|
||||
version "1.6.3"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.3.tgz#7f50f23b3aa246eff43c54834272346c396613f4"
|
||||
integrity sha512-fWyNdeawGam70jXSVlKl+SUNVcL6j6W79CuSIPfi6HnDUmSCH6gyUys/HrqHeA/wU0Az41rRgean494d0Jb+ww==
|
||||
|
@ -11317,6 +11347,11 @@ fn.name@1.x.x:
|
|||
resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc"
|
||||
integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==
|
||||
|
||||
follow-redirects@^1.14.0, follow-redirects@^1.14.4, follow-redirects@^1.14.8:
|
||||
version "1.15.6"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b"
|
||||
integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==
|
||||
|
||||
follow-redirects@^1.15.0:
|
||||
version "1.15.2"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
|
||||
|
@ -12458,7 +12493,12 @@ http-assert@^1.3.0:
|
|||
deep-equal "~1.0.1"
|
||||
http-errors "~1.8.0"
|
||||
|
||||
http-cache-semantics@3.8.1, http-cache-semantics@4.1.1, http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1:
|
||||
http-cache-semantics@3.8.1:
|
||||
version "3.8.1"
|
||||
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2"
|
||||
integrity sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w==
|
||||
|
||||
http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a"
|
||||
integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==
|
||||
|
@ -13408,11 +13448,6 @@ isobject@^3.0.1:
|
|||
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
|
||||
integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==
|
||||
|
||||
isobject@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0"
|
||||
integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA==
|
||||
|
||||
isolated-vm@^4.7.2:
|
||||
version "4.7.2"
|
||||
resolved "https://registry.yarnpkg.com/isolated-vm/-/isolated-vm-4.7.2.tgz#5670d5cce1d92004f9b825bec5b0b11fc7501b65"
|
||||
|
@ -16040,7 +16075,7 @@ msgpackr-extract@^3.0.2:
|
|||
"@msgpackr-extract/msgpackr-extract-linux-x64" "3.0.2"
|
||||
"@msgpackr-extract/msgpackr-extract-win32-x64" "3.0.2"
|
||||
|
||||
msgpackr@1.10.1, msgpackr@^1.5.2:
|
||||
msgpackr@^1.5.2:
|
||||
version "1.10.1"
|
||||
resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.10.1.tgz#51953bb4ce4f3494f0c4af3f484f01cfbb306555"
|
||||
integrity sha512-r5VRLv9qouXuLiIBrLpl2d5ZvPt8svdQTl5/vMvE4nzDMyEX4sgW5yWhuBBj5UmgwOTWj8CIdSXn5sAfsHAWIQ==
|
||||
|
@ -16208,6 +16243,15 @@ nice-try@^1.0.4:
|
|||
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
|
||||
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
|
||||
|
||||
nock@^13.5.4:
|
||||
version "13.5.4"
|
||||
resolved "https://registry.yarnpkg.com/nock/-/nock-13.5.4.tgz#8918f0addc70a63736170fef7106a9721e0dc479"
|
||||
integrity sha512-yAyTfdeNJGGBFxWdzSKCBYxs5FxLbCg5X5Q4ets974hcQzG1+qCxvIyOo4j2Ry6MUlhWVMX4OoYDefAIIwupjw==
|
||||
dependencies:
|
||||
debug "^4.1.0"
|
||||
json-stringify-safe "^5.0.1"
|
||||
propagate "^2.0.0"
|
||||
|
||||
node-abi@^3.3.0:
|
||||
version "3.54.0"
|
||||
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.54.0.tgz#f6386f7548817acac6434c6cba02999c9aebcc69"
|
||||
|
@ -16245,13 +16289,25 @@ node-duration@^1.0.4:
|
|||
resolved "https://registry.yarnpkg.com/node-duration/-/node-duration-1.0.4.tgz#3e94ecc0e473691c89c4560074503362071cecac"
|
||||
integrity sha512-eUXYNSY7DL53vqfTosggWkvyIW3bhAcqBDIlolgNYlZhianXTrCL50rlUJWD1eRqkIxMppXTfiFbp+9SjpPrgA==
|
||||
|
||||
node-fetch@2.6.0, node-fetch@2.6.7, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7, node-fetch@^2.6.9, node-fetch@^2.7.0:
|
||||
node-fetch@2.6.0:
|
||||
version "2.6.0"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
|
||||
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
|
||||
|
||||
node-fetch@2.6.7, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7:
|
||||
version "2.6.7"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
|
||||
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
|
||||
dependencies:
|
||||
whatwg-url "^5.0.0"
|
||||
|
||||
node-fetch@^2.6.9, node-fetch@^2.7.0:
|
||||
version "2.7.0"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
|
||||
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
|
||||
dependencies:
|
||||
whatwg-url "^5.0.0"
|
||||
|
||||
node-forge@^1.3.1:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3"
|
||||
|
@ -17417,7 +17473,15 @@ passport-strategy@1.x.x, passport-strategy@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/passport-strategy/-/passport-strategy-1.0.0.tgz#b5539aa8fc225a3d1ad179476ddf236b440f52e4"
|
||||
integrity sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA==
|
||||
|
||||
passport@0.6.0, passport@^0.4.0, passport@^0.6.0:
|
||||
passport@^0.4.0:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/passport/-/passport-0.4.1.tgz#941446a21cb92fc688d97a0861c38ce9f738f270"
|
||||
integrity sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg==
|
||||
dependencies:
|
||||
passport-strategy "1.x.x"
|
||||
pause "0.0.1"
|
||||
|
||||
passport@^0.6.0:
|
||||
version "0.6.0"
|
||||
resolved "https://registry.yarnpkg.com/passport/-/passport-0.6.0.tgz#e869579fab465b5c0b291e841e6cc95c005fac9d"
|
||||
integrity sha512-0fe+p3ZnrWRW74fe8+SvCyf4a3Pb2/h7gFkQ8yTJpAO50gDzlfjZUZTO1k5Eg9kUct22OxHLqDZoKUWRHOh9ug==
|
||||
|
@ -18602,6 +18666,11 @@ promzard@^1.0.0:
|
|||
dependencies:
|
||||
read "^2.0.0"
|
||||
|
||||
propagate@^2.0.0:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/propagate/-/propagate-2.0.1.tgz#40cdedab18085c792334e64f0ac17256d38f9a45"
|
||||
integrity sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==
|
||||
|
||||
proper-lockfile@^4.1.2:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-4.1.2.tgz#c8b9de2af6b2f1601067f98e01ac66baa223141f"
|
||||
|
@ -18712,7 +18781,7 @@ pseudomap@^1.0.2:
|
|||
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
|
||||
integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==
|
||||
|
||||
psl@^1.1.33:
|
||||
psl@^1.1.28, psl@^1.1.33:
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"
|
||||
integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==
|
||||
|
@ -19737,6 +19806,11 @@ sax@1.2.1:
|
|||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a"
|
||||
integrity sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA==
|
||||
|
||||
sax@>=0.1.1:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.3.0.tgz#a5dbe77db3be05c9d1ee7785dbd3ea9de51593d0"
|
||||
integrity sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==
|
||||
|
||||
sax@>=0.6.0:
|
||||
version "1.2.4"
|
||||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
|
||||
|
@ -19818,13 +19892,40 @@ semver-diff@^3.1.1:
|
|||
dependencies:
|
||||
semver "^6.3.0"
|
||||
|
||||
"semver@2 || 3 || 4 || 5", semver@7.5.3, semver@^5.5.0, semver@^5.6.0, semver@^5.7.1, semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1, semver@^7.0.0, semver@^7.1.1, semver@^7.1.2, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4, semver@~2.3.1, semver@~7.0.0:
|
||||
"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0, semver@^5.7.1:
|
||||
version "5.7.2"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
|
||||
integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==
|
||||
|
||||
semver@7.5.3, semver@^7.0.0, semver@^7.1.1, semver@^7.1.2, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3:
|
||||
version "7.5.3"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e"
|
||||
integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1:
|
||||
version "6.3.1"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
|
||||
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
|
||||
|
||||
semver@^7.5.4:
|
||||
version "7.6.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d"
|
||||
integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
semver@~2.3.1:
|
||||
version "2.3.2"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-2.3.2.tgz#b9848f25d6cf36333073ec9ef8856d42f1233e52"
|
||||
integrity sha512-abLdIKCosKfpnmhS52NCTjO4RiLspDfsn37prjzGrp9im5DPJOgh82Os92vtwGh6XdQryKI/7SREZnV+aqiXrA==
|
||||
|
||||
semver@~7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
|
||||
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==
|
||||
|
||||
seq-queue@^0.0.5:
|
||||
version "0.0.5"
|
||||
resolved "https://registry.yarnpkg.com/seq-queue/-/seq-queue-0.0.5.tgz#d56812e1c017a6e4e7c3e3a37a1da6d78dd3c93e"
|
||||
|
@ -21478,7 +21579,7 @@ touch@^3.1.0:
|
|||
dependencies:
|
||||
nopt "~1.0.10"
|
||||
|
||||
tough-cookie@4.1.3, "tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0.0, tough-cookie@^4.1.2, tough-cookie@~2.5.0:
|
||||
"tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0.0, tough-cookie@^4.1.2:
|
||||
version "4.1.3"
|
||||
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf"
|
||||
integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==
|
||||
|
@ -21488,6 +21589,14 @@ tough-cookie@4.1.3, "tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0
|
|||
universalify "^0.2.0"
|
||||
url-parse "^1.5.3"
|
||||
|
||||
tough-cookie@~2.5.0:
|
||||
version "2.5.0"
|
||||
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2"
|
||||
integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==
|
||||
dependencies:
|
||||
psl "^1.1.28"
|
||||
punycode "^2.1.1"
|
||||
|
||||
tr46@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.1.0.tgz#fa87aa81ca5d5941da8cbf1f9b749dc969a4e240"
|
||||
|
@ -21978,14 +22087,6 @@ unpipe@1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
|
||||
integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==
|
||||
|
||||
unset-value@2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-2.0.1.tgz#57bed0c22d26f28d69acde5df9a11b77c74d2df3"
|
||||
integrity sha512-2hvrBfjUE00PkqN+q0XP6yRAOGrR06uSiUoIQGZkc7GxvQ9H7v8quUPNtZjMg4uux69i8HWpIjLPUKwCuRGyNg==
|
||||
dependencies:
|
||||
has-value "^2.0.2"
|
||||
isobject "^4.0.0"
|
||||
|
||||
untildify@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b"
|
||||
|
@ -22756,10 +22857,33 @@ xml-parse-from-string@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/xml-parse-from-string/-/xml-parse-from-string-1.0.1.tgz#a9029e929d3dbcded169f3c6e28238d95a5d5a28"
|
||||
integrity sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g==
|
||||
|
||||
xml2js@0.1.x, xml2js@0.4.19, xml2js@0.5.0, xml2js@0.6.2, xml2js@^0.4.19, xml2js@^0.4.5:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.6.2.tgz#dd0b630083aa09c161e25a4d0901e2b2a929b499"
|
||||
integrity sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==
|
||||
xml2js@0.1.x:
|
||||
version "0.1.14"
|
||||
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.1.14.tgz#5274e67f5a64c5f92974cd85139e0332adc6b90c"
|
||||
integrity sha512-pbdws4PPPNc1HPluSUKamY4GWMk592K7qwcj6BExbVOhhubub8+pMda/ql68b6L3luZs/OGjGSB5goV7SnmgnA==
|
||||
dependencies:
|
||||
sax ">=0.1.1"
|
||||
|
||||
xml2js@0.4.19:
|
||||
version "0.4.19"
|
||||
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.19.tgz#686c20f213209e94abf0d1bcf1efaa291c7827a7"
|
||||
integrity sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==
|
||||
dependencies:
|
||||
sax ">=0.6.0"
|
||||
xmlbuilder "~9.0.1"
|
||||
|
||||
xml2js@0.5.0:
|
||||
version "0.5.0"
|
||||
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.5.0.tgz#d9440631fbb2ed800203fad106f2724f62c493b7"
|
||||
integrity sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==
|
||||
dependencies:
|
||||
sax ">=0.6.0"
|
||||
xmlbuilder "~11.0.0"
|
||||
|
||||
xml2js@^0.4.19, xml2js@^0.4.5:
|
||||
version "0.4.23"
|
||||
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.23.tgz#a0c69516752421eb2ac758ee4d4ccf58843eac66"
|
||||
integrity sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==
|
||||
dependencies:
|
||||
sax ">=0.6.0"
|
||||
xmlbuilder "~11.0.0"
|
||||
|
@ -22769,6 +22893,11 @@ xmlbuilder@~11.0.0:
|
|||
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3"
|
||||
integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==
|
||||
|
||||
xmlbuilder@~9.0.1:
|
||||
version "9.0.7"
|
||||
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"
|
||||
integrity sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==
|
||||
|
||||
xmlchars@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
|
||||
|
|
Loading…
Reference in New Issue