Merge branch 'master' into budi-7859-docker-compose-up-1-errors-decoding-error-decoding-command
This commit is contained in:
commit
f8965a437f
|
@ -252,4 +252,10 @@ spec:
|
||||||
{{ end }}
|
{{ end }}
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
serviceAccountName: ""
|
serviceAccountName: ""
|
||||||
|
{{ if .Values.services.apps.ndots }}
|
||||||
|
dnsConfig:
|
||||||
|
options:
|
||||||
|
- name: ndots
|
||||||
|
value: {{ .Values.services.apps.ndots | quote }}
|
||||||
|
{{ end }}
|
||||||
status: {}
|
status: {}
|
||||||
|
|
|
@ -227,6 +227,7 @@ spec:
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml . | nindent 10 }}
|
{{- toYaml . | nindent 10 }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ if .Values.services.automationWorkers.command }}
|
||||||
command:
|
command:
|
||||||
{{- toYaml .Values.services.automationWorkers.command | nindent 10 }}
|
{{- toYaml .Values.services.automationWorkers.command | nindent 10 }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -251,6 +252,11 @@ spec:
|
||||||
{{ end }}
|
{{ end }}
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
serviceAccountName: ""
|
serviceAccountName: ""
|
||||||
{{ if .Values.services.automationWorkers.command }}}
|
{{ if .Values.services.automationWorkers.ndots }}
|
||||||
|
dnsConfig:
|
||||||
|
options:
|
||||||
|
- name: ndots
|
||||||
|
value: {{ .Values.services.automationWorkers.ndots | quote }}
|
||||||
|
{{ end }}
|
||||||
status: {}
|
status: {}
|
||||||
{{- end }}
|
{{- end }}
|
|
@ -109,4 +109,10 @@ spec:
|
||||||
{{- toYaml .Values.services.proxy.args | nindent 8 }}
|
{{- toYaml .Values.services.proxy.args | nindent 8 }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
volumes:
|
volumes:
|
||||||
|
{{ if .Values.services.proxy.ndots }}
|
||||||
|
dnsConfig:
|
||||||
|
options:
|
||||||
|
- name: ndots
|
||||||
|
value: {{ .Values.services.proxy.ndots | quote }}
|
||||||
|
{{ end }}
|
||||||
status: {}
|
status: {}
|
||||||
|
|
|
@ -238,4 +238,10 @@ spec:
|
||||||
{{ end }}
|
{{ end }}
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
serviceAccountName: ""
|
serviceAccountName: ""
|
||||||
|
{{ if .Values.services.worker.ndots }}
|
||||||
|
dnsConfig:
|
||||||
|
options:
|
||||||
|
- name: ndots
|
||||||
|
value: {{ .Values.services.worker.ndots | quote }}
|
||||||
|
{{ end }}
|
||||||
status: {}
|
status: {}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "2.14.0",
|
"version": "2.14.2",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
|
@ -2,7 +2,6 @@ import Redlock from "redlock"
|
||||||
import { getLockClient } from "./init"
|
import { getLockClient } from "./init"
|
||||||
import { LockOptions, LockType } from "@budibase/types"
|
import { LockOptions, LockType } from "@budibase/types"
|
||||||
import * as context from "../context"
|
import * as context from "../context"
|
||||||
import { logWarn } from "../logging"
|
|
||||||
import { utils } from "@budibase/shared-core"
|
import { utils } from "@budibase/shared-core"
|
||||||
import { Duration } from "../utils"
|
import { Duration } from "../utils"
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ export class ExecutionTimeTracker {
|
||||||
return this.totalTimeMs
|
return this.totalTimeMs
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkLimit() {
|
checkLimit() {
|
||||||
if (this.totalTimeMs > this.limitMs) {
|
if (this.totalTimeMs > this.limitMs) {
|
||||||
throw new ExecutionTimeoutError(
|
throw new ExecutionTimeoutError(
|
||||||
`Execution time limit of ${this.limitMs}ms exceeded: ${this.totalTimeMs}ms`
|
`Execution time limit of ${this.limitMs}ms exceeded: ${this.totalTimeMs}ms`
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let placeholder = null
|
export let placeholder = null
|
||||||
export let autocompleteEnabled = true
|
export let autocompleteEnabled = true
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
// Export a function to expose caret position
|
// Export a function to expose caret position
|
||||||
export const getCaretPosition = () => {
|
export const getCaretPosition = () => {
|
||||||
|
@ -241,6 +242,12 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (autofocus && isEditorInitialised) {
|
||||||
|
editor.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$: editorHeight = typeof height === "number" ? `${height}px` : height
|
$: editorHeight = typeof height === "number" ? `${height}px` : height
|
||||||
|
|
||||||
// Init when all elements are ready
|
// Init when all elements are ready
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
export let valid
|
export let valid
|
||||||
export let allowJS = false
|
export let allowJS = false
|
||||||
export let allowHelpers = true
|
export let allowHelpers = true
|
||||||
|
export let autofocusEditor = false
|
||||||
|
|
||||||
const drawerActions = getContext("drawer-actions")
|
const drawerActions = getContext("drawer-actions")
|
||||||
const bindingDrawerActions = getContext("binding-drawer-actions")
|
const bindingDrawerActions = getContext("binding-drawer-actions")
|
||||||
|
@ -199,6 +200,7 @@
|
||||||
]}
|
]}
|
||||||
placeholder=""
|
placeholder=""
|
||||||
height="100%"
|
height="100%"
|
||||||
|
autofocus={autofocusEditor}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="binding-footer">
|
<div class="binding-footer">
|
||||||
|
@ -301,6 +303,7 @@
|
||||||
bind:getCaretPosition
|
bind:getCaretPosition
|
||||||
bind:insertAtPos
|
bind:insertAtPos
|
||||||
height="100%"
|
height="100%"
|
||||||
|
autofocus={autofocusEditor}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="binding-footer">
|
<div class="binding-footer">
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let allowJS = false
|
export let allowJS = false
|
||||||
export let allowHelpers = true
|
export let allowHelpers = true
|
||||||
|
export let autofocusEditor = false
|
||||||
|
|
||||||
$: enrichedBindings = enrichBindings(bindings)
|
$: enrichedBindings = enrichBindings(bindings)
|
||||||
|
|
||||||
|
@ -27,5 +28,6 @@
|
||||||
{value}
|
{value}
|
||||||
{allowJS}
|
{allowJS}
|
||||||
{allowHelpers}
|
{allowHelpers}
|
||||||
|
{autofocusEditor}
|
||||||
on:change
|
on:change
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -44,7 +44,11 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
const onChange = value => {
|
const onChange = value => {
|
||||||
if (type === "link" && value && hasValidLinks(value)) {
|
if (
|
||||||
|
(type === "link" || type === "bb_reference") &&
|
||||||
|
value &&
|
||||||
|
hasValidLinks(value)
|
||||||
|
) {
|
||||||
currentVal = value.split(",")
|
currentVal = value.split(",")
|
||||||
} else if (type === "array" && value && hasValidOptions(value)) {
|
} else if (type === "array" && value && hasValidOptions(value)) {
|
||||||
currentVal = value.split(",")
|
currentVal = value.split(",")
|
||||||
|
@ -95,6 +99,7 @@
|
||||||
date: isValidDate,
|
date: isValidDate,
|
||||||
datetime: isValidDate,
|
datetime: isValidDate,
|
||||||
link: hasValidLinks,
|
link: hasValidLinks,
|
||||||
|
bb_reference: hasValidLinks,
|
||||||
array: hasValidOptions,
|
array: hasValidOptions,
|
||||||
longform: value => !isJSBinding(value),
|
longform: value => !isJSBinding(value),
|
||||||
json: value => !isJSBinding(value),
|
json: value => !isJSBinding(value),
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="options-wrap">
|
<div class="options-wrap">
|
||||||
<div />
|
|
||||||
<div><ActionButton on:click={drawer.show}>Define Options</ActionButton></div>
|
<div><ActionButton on:click={drawer.show}>Define Options</ActionButton></div>
|
||||||
</div>
|
</div>
|
||||||
<Drawer bind:this={drawer} title="Options" on:drawerHide on:drawerShow>
|
<Drawer bind:this={drawer} title="Options" on:drawerHide on:drawerShow>
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
on:change={event => (tempValue = event.detail)}
|
on:change={event => (tempValue = event.detail)}
|
||||||
allowJS
|
allowJS
|
||||||
{bindings}
|
{bindings}
|
||||||
|
autofocusEditor={true}
|
||||||
/>
|
/>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
{/key}
|
{/key}
|
||||||
|
|
|
@ -3295,6 +3295,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "options",
|
"type": "options",
|
||||||
|
"label": "Custom options",
|
||||||
"key": "customOptions",
|
"key": "customOptions",
|
||||||
"dependsOn": {
|
"dependsOn": {
|
||||||
"setting": "optionsSource",
|
"setting": "optionsSource",
|
||||||
|
@ -3502,6 +3503,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "options",
|
"type": "options",
|
||||||
|
"label": "Custom options",
|
||||||
"key": "customOptions",
|
"key": "customOptions",
|
||||||
"dependsOn": {
|
"dependsOn": {
|
||||||
"setting": "optionsSource",
|
"setting": "optionsSource",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit dc2b1b22e7f9bac705746bf1fb72c817db043fa3
|
Subproject commit b1c10c2daf808d103724c324256cbff67f33fb46
|
|
@ -161,11 +161,8 @@ export async function preview(ctx: UserCtx) {
|
||||||
auth: { ...authConfigCtx },
|
auth: { ...authConfigCtx },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const runFn = () => Runner.run(inputs)
|
|
||||||
|
|
||||||
const { rows, keys, info, extra } = await quotas.addQuery<any>(runFn, {
|
const { rows, keys, info, extra } = (await Runner.run(inputs)) as any
|
||||||
datasourceId: datasource._id,
|
|
||||||
})
|
|
||||||
const schemaFields: any = {}
|
const schemaFields: any = {}
|
||||||
if (rows?.length > 0) {
|
if (rows?.length > 0) {
|
||||||
for (let key of [...new Set(keys)] as string[]) {
|
for (let key of [...new Set(keys)] as string[]) {
|
||||||
|
@ -259,14 +256,8 @@ async function execute(
|
||||||
},
|
},
|
||||||
schema: query.schema,
|
schema: query.schema,
|
||||||
}
|
}
|
||||||
const runFn = () => Runner.run(inputs)
|
|
||||||
|
|
||||||
const { rows, pagination, extra, info } = await quotas.addQuery<any>(
|
const { rows, pagination, extra, info } = (await Runner.run(inputs)) as any
|
||||||
runFn,
|
|
||||||
{
|
|
||||||
datasourceId: datasource._id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
// remove the raw from execution incase transformer being used to hide data
|
// remove the raw from execution incase transformer being used to hide data
|
||||||
if (extra?.raw) {
|
if (extra?.raw) {
|
||||||
delete extra.raw
|
delete extra.raw
|
||||||
|
|
|
@ -4,20 +4,20 @@ import * as external from "./external"
|
||||||
import { isExternalTableID } from "../../../integrations/utils"
|
import { isExternalTableID } from "../../../integrations/utils"
|
||||||
import {
|
import {
|
||||||
Ctx,
|
Ctx,
|
||||||
UserCtx,
|
|
||||||
DeleteRowRequest,
|
|
||||||
DeleteRow,
|
DeleteRow,
|
||||||
|
DeleteRowRequest,
|
||||||
DeleteRows,
|
DeleteRows,
|
||||||
Row,
|
|
||||||
PatchRowRequest,
|
|
||||||
PatchRowResponse,
|
|
||||||
SearchRowResponse,
|
|
||||||
SearchRowRequest,
|
|
||||||
SearchParams,
|
|
||||||
GetRowResponse,
|
|
||||||
ValidateResponse,
|
|
||||||
ExportRowsRequest,
|
ExportRowsRequest,
|
||||||
ExportRowsResponse,
|
ExportRowsResponse,
|
||||||
|
GetRowResponse,
|
||||||
|
PatchRowRequest,
|
||||||
|
PatchRowResponse,
|
||||||
|
Row,
|
||||||
|
SearchParams,
|
||||||
|
SearchRowRequest,
|
||||||
|
SearchRowResponse,
|
||||||
|
UserCtx,
|
||||||
|
ValidateResponse,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import * as utils from "./utils"
|
import * as utils from "./utils"
|
||||||
import { gridSocket } from "../../../websockets"
|
import { gridSocket } from "../../../websockets"
|
||||||
|
@ -25,8 +25,8 @@ import { addRev } from "../public/utils"
|
||||||
import { fixRow } from "../public/rows"
|
import { fixRow } from "../public/rows"
|
||||||
import sdk from "../../../sdk"
|
import sdk from "../../../sdk"
|
||||||
import * as exporters from "../view/exporters"
|
import * as exporters from "../view/exporters"
|
||||||
import { apiFileReturn } from "../../../utilities/fileSystem"
|
|
||||||
import { Format } from "../view/exporters"
|
import { Format } from "../view/exporters"
|
||||||
|
import { apiFileReturn } from "../../../utilities/fileSystem"
|
||||||
|
|
||||||
export * as views from "./views"
|
export * as views from "./views"
|
||||||
|
|
||||||
|
@ -49,12 +49,7 @@ export async function patch(
|
||||||
return save(ctx)
|
return save(ctx)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { row, table } = await quotas.addQuery(
|
const { row, table } = await pickApi(tableId).patch(ctx)
|
||||||
() => pickApi(tableId).patch(ctx),
|
|
||||||
{
|
|
||||||
datasourceId: tableId,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
if (!row) {
|
if (!row) {
|
||||||
ctx.throw(404, "Row not found")
|
ctx.throw(404, "Row not found")
|
||||||
}
|
}
|
||||||
|
@ -84,12 +79,7 @@ export const save = async (ctx: UserCtx<Row, Row>) => {
|
||||||
return patch(ctx as UserCtx<PatchRowRequest, PatchRowResponse>)
|
return patch(ctx as UserCtx<PatchRowRequest, PatchRowResponse>)
|
||||||
}
|
}
|
||||||
const { row, table, squashed } = await quotas.addRow(() =>
|
const { row, table, squashed } = await quotas.addRow(() =>
|
||||||
quotas.addQuery(
|
sdk.rows.save(tableId, ctx.request.body, ctx.user?._id)
|
||||||
() => sdk.rows.save(tableId, ctx.request.body, ctx.user?._id),
|
|
||||||
{
|
|
||||||
datasourceId: tableId,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:save`, appId, row, table)
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:save`, appId, row, table)
|
||||||
|
@ -105,31 +95,21 @@ export async function fetchView(ctx: any) {
|
||||||
|
|
||||||
const { calculation, group, field } = ctx.query
|
const { calculation, group, field } = ctx.query
|
||||||
|
|
||||||
ctx.body = await quotas.addQuery(
|
ctx.body = await sdk.rows.fetchView(tableId, viewName, {
|
||||||
() =>
|
|
||||||
sdk.rows.fetchView(tableId, viewName, {
|
|
||||||
calculation,
|
calculation,
|
||||||
group: calculation ? group : null,
|
group: calculation ? group : null,
|
||||||
field,
|
field,
|
||||||
}),
|
})
|
||||||
{
|
|
||||||
datasourceId: tableId,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetch(ctx: any) {
|
export async function fetch(ctx: any) {
|
||||||
const tableId = utils.getTableId(ctx)
|
const tableId = utils.getTableId(ctx)
|
||||||
ctx.body = await quotas.addQuery(() => sdk.rows.fetch(tableId), {
|
ctx.body = await sdk.rows.fetch(tableId)
|
||||||
datasourceId: tableId,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function find(ctx: UserCtx<void, GetRowResponse>) {
|
export async function find(ctx: UserCtx<void, GetRowResponse>) {
|
||||||
const tableId = utils.getTableId(ctx)
|
const tableId = utils.getTableId(ctx)
|
||||||
ctx.body = await quotas.addQuery(() => pickApi(tableId).find(ctx), {
|
ctx.body = await pickApi(tableId).find(ctx)
|
||||||
datasourceId: tableId,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDeleteRows(input: any): input is DeleteRows {
|
function isDeleteRows(input: any): input is DeleteRows {
|
||||||
|
@ -160,15 +140,9 @@ async function deleteRows(ctx: UserCtx<DeleteRowRequest>) {
|
||||||
|
|
||||||
let deleteRequest = ctx.request.body as DeleteRows
|
let deleteRequest = ctx.request.body as DeleteRows
|
||||||
|
|
||||||
const rowDeletes: Row[] = await processDeleteRowsRequest(ctx)
|
deleteRequest.rows = await processDeleteRowsRequest(ctx)
|
||||||
deleteRequest.rows = rowDeletes
|
|
||||||
|
|
||||||
const { rows } = await quotas.addQuery(
|
const { rows } = await pickApi(tableId).bulkDestroy(ctx)
|
||||||
() => pickApi(tableId).bulkDestroy(ctx),
|
|
||||||
{
|
|
||||||
datasourceId: tableId,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
await quotas.removeRows(rows.length)
|
await quotas.removeRows(rows.length)
|
||||||
|
|
||||||
for (let row of rows) {
|
for (let row of rows) {
|
||||||
|
@ -183,9 +157,7 @@ async function deleteRow(ctx: UserCtx<DeleteRowRequest>) {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const tableId = utils.getTableId(ctx)
|
const tableId = utils.getTableId(ctx)
|
||||||
|
|
||||||
const resp = await quotas.addQuery(() => pickApi(tableId).destroy(ctx), {
|
const resp = await pickApi(tableId).destroy(ctx)
|
||||||
datasourceId: tableId,
|
|
||||||
})
|
|
||||||
await quotas.removeRow()
|
await quotas.removeRow()
|
||||||
|
|
||||||
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, resp.row)
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, resp.row)
|
||||||
|
@ -223,9 +195,7 @@ export async function search(ctx: Ctx<SearchRowRequest, SearchRowResponse>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
ctx.body = await quotas.addQuery(() => sdk.rows.search(searchParams), {
|
ctx.body = await sdk.rows.search(searchParams)
|
||||||
datasourceId: tableId,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function validate(ctx: Ctx<Row, ValidateResponse>) {
|
export async function validate(ctx: Ctx<Row, ValidateResponse>) {
|
||||||
|
@ -243,12 +213,7 @@ export async function validate(ctx: Ctx<Row, ValidateResponse>) {
|
||||||
|
|
||||||
export async function fetchEnrichedRow(ctx: any) {
|
export async function fetchEnrichedRow(ctx: any) {
|
||||||
const tableId = utils.getTableId(ctx)
|
const tableId = utils.getTableId(ctx)
|
||||||
ctx.body = await quotas.addQuery(
|
ctx.body = await pickApi(tableId).fetchEnrichedRow(ctx)
|
||||||
() => pickApi(tableId).fetchEnrichedRow(ctx),
|
|
||||||
{
|
|
||||||
datasourceId: tableId,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const exportRows = async (
|
export const exportRows = async (
|
||||||
|
@ -268,8 +233,6 @@ export const exportRows = async (
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.body = await quotas.addQuery(
|
|
||||||
async () => {
|
|
||||||
const { fileName, content } = await sdk.rows.exportRows({
|
const { fileName, content } = await sdk.rows.exportRows({
|
||||||
tableId,
|
tableId,
|
||||||
format: format as Format,
|
format: format as Format,
|
||||||
|
@ -280,10 +243,5 @@ export const exportRows = async (
|
||||||
sortOrder,
|
sortOrder,
|
||||||
})
|
})
|
||||||
ctx.attachment(fileName)
|
ctx.attachment(fileName)
|
||||||
return apiFileReturn(content)
|
ctx.body = apiFileReturn(content)
|
||||||
},
|
|
||||||
{
|
|
||||||
datasourceId: tableId,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,10 +68,7 @@ export async function searchView(
|
||||||
paginate: body.paginate,
|
paginate: body.paginate,
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await quotas.addQuery(() => sdk.rows.search(searchOptions), {
|
const result = await sdk.rows.search(searchOptions)
|
||||||
datasourceId: view.tableId,
|
|
||||||
})
|
|
||||||
|
|
||||||
result.rows.forEach(r => (r._viewId = view.id))
|
result.rows.forEach(r => (r._viewId = view.id))
|
||||||
ctx.body = result
|
ctx.body = result
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,11 +132,6 @@ describe.each([
|
||||||
expect(usage).toBe(expected)
|
expect(usage).toBe(expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
const assertQueryUsage = async (expected: number) => {
|
|
||||||
const usage = await getQueryUsage()
|
|
||||||
expect(usage).toBe(expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultRowFields = isInternal
|
const defaultRowFields = isInternal
|
||||||
? {
|
? {
|
||||||
type: "row",
|
type: "row",
|
||||||
|
@ -181,7 +176,6 @@ describe.each([
|
||||||
expect(res.body.name).toEqual("Test Contact")
|
expect(res.body.name).toEqual("Test Contact")
|
||||||
expect(res.body._rev).toBeDefined()
|
expect(res.body._rev).toBeDefined()
|
||||||
await assertRowUsage(rowUsage + 1)
|
await assertRowUsage(rowUsage + 1)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Increment row autoId per create row request", async () => {
|
it("Increment row autoId per create row request", async () => {
|
||||||
|
@ -232,7 +226,6 @@ describe.each([
|
||||||
}
|
}
|
||||||
|
|
||||||
await assertRowUsage(rowUsage + ids.length)
|
await assertRowUsage(rowUsage + ids.length)
|
||||||
await assertQueryUsage(queryUsage + ids.length)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("updates a row successfully", async () => {
|
it("updates a row successfully", async () => {
|
||||||
|
@ -249,7 +242,6 @@ describe.each([
|
||||||
|
|
||||||
expect(res.name).toEqual("Updated Name")
|
expect(res.name).toEqual("Updated Name")
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should load a row", async () => {
|
it("should load a row", async () => {
|
||||||
|
@ -262,7 +254,6 @@ describe.each([
|
||||||
...existing,
|
...existing,
|
||||||
...defaultRowFields,
|
...defaultRowFields,
|
||||||
})
|
})
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should list all rows for given tableId", async () => {
|
it("should list all rows for given tableId", async () => {
|
||||||
|
@ -284,7 +275,6 @@ describe.each([
|
||||||
expect(res.length).toBe(2)
|
expect(res.length).toBe(2)
|
||||||
expect(res.find((r: Row) => r.name === newRow.name)).toBeDefined()
|
expect(res.find((r: Row) => r.name === newRow.name)).toBeDefined()
|
||||||
expect(res.find((r: Row) => r.name === firstRow.name)).toBeDefined()
|
expect(res.find((r: Row) => r.name === firstRow.name)).toBeDefined()
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("load should return 404 when row does not exist", async () => {
|
it("load should return 404 when row does not exist", async () => {
|
||||||
|
@ -294,7 +284,6 @@ describe.each([
|
||||||
await config.api.row.get(tableId, "1234567", {
|
await config.api.row.get(tableId, "1234567", {
|
||||||
expectStatus: 404,
|
expectStatus: 404,
|
||||||
})
|
})
|
||||||
await assertQueryUsage(queryUsage) // no change
|
|
||||||
})
|
})
|
||||||
|
|
||||||
isInternal &&
|
isInternal &&
|
||||||
|
@ -558,7 +547,6 @@ describe.each([
|
||||||
expect(savedRow.body.description).toEqual(existing.description)
|
expect(savedRow.body.description).toEqual(existing.description)
|
||||||
expect(savedRow.body.name).toEqual("Updated Name")
|
expect(savedRow.body.name).toEqual("Updated Name")
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage + 2) // account for the second load
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw an error when given improper types", async () => {
|
it("should throw an error when given improper types", async () => {
|
||||||
|
@ -578,7 +566,6 @@ describe.each([
|
||||||
)
|
)
|
||||||
|
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should not overwrite links if those links are not set", async () => {
|
it("should not overwrite links if those links are not set", async () => {
|
||||||
|
@ -668,7 +655,6 @@ describe.each([
|
||||||
const res = await config.api.row.delete(table._id!, [createdRow])
|
const res = await config.api.row.delete(table._id!, [createdRow])
|
||||||
expect(res.body[0]._id).toEqual(createdRow._id)
|
expect(res.body[0]._id).toEqual(createdRow._id)
|
||||||
await assertRowUsage(rowUsage - 1)
|
await assertRowUsage(rowUsage - 1)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -687,7 +673,6 @@ describe.each([
|
||||||
expect(res.valid).toBe(true)
|
expect(res.valid).toBe(true)
|
||||||
expect(Object.keys(res.errors)).toEqual([])
|
expect(Object.keys(res.errors)).toEqual([])
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should errors on invalid row", async () => {
|
it("should errors on invalid row", async () => {
|
||||||
|
@ -705,7 +690,6 @@ describe.each([
|
||||||
expect(Object.keys(res.errors)).toEqual([])
|
expect(Object.keys(res.errors)).toEqual([])
|
||||||
}
|
}
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -726,7 +710,6 @@ describe.each([
|
||||||
expect(res.body.length).toEqual(2)
|
expect(res.body.length).toEqual(2)
|
||||||
await loadRow(row1._id!, table._id!, 404)
|
await loadRow(row1._id!, table._id!, 404)
|
||||||
await assertRowUsage(rowUsage - 2)
|
await assertRowUsage(rowUsage - 2)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be able to delete a variety of row set types", async () => {
|
it("should be able to delete a variety of row set types", async () => {
|
||||||
|
@ -747,7 +730,6 @@ describe.each([
|
||||||
expect(res.body.length).toEqual(3)
|
expect(res.body.length).toEqual(3)
|
||||||
await loadRow(row1._id!, table._id!, 404)
|
await loadRow(row1._id!, table._id!, 404)
|
||||||
await assertRowUsage(rowUsage - 3)
|
await assertRowUsage(rowUsage - 3)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should accept a valid row object and delete the row", async () => {
|
it("should accept a valid row object and delete the row", async () => {
|
||||||
|
@ -760,7 +742,6 @@ describe.each([
|
||||||
expect(res.body.id).toEqual(row1._id)
|
expect(res.body.id).toEqual(row1._id)
|
||||||
await loadRow(row1._id!, table._id!, 404)
|
await loadRow(row1._id!, table._id!, 404)
|
||||||
await assertRowUsage(rowUsage - 1)
|
await assertRowUsage(rowUsage - 1)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Should ignore malformed/invalid delete requests", async () => {
|
it("Should ignore malformed/invalid delete requests", async () => {
|
||||||
|
@ -787,7 +768,6 @@ describe.each([
|
||||||
expect(res3.body.message).toEqual("Invalid delete rows request")
|
expect(res3.body.message).toEqual("Invalid delete rows request")
|
||||||
|
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -808,7 +788,6 @@ describe.each([
|
||||||
expect(res.body.length).toEqual(1)
|
expect(res.body.length).toEqual(1)
|
||||||
expect(res.body[0]._id).toEqual(row._id)
|
expect(res.body[0]._id).toEqual(row._id)
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw an error if view doesn't exist", async () => {
|
it("should throw an error if view doesn't exist", async () => {
|
||||||
|
@ -818,7 +797,6 @@ describe.each([
|
||||||
await config.api.legacyView.get("derp", { expectStatus: 404 })
|
await config.api.legacyView.get("derp", { expectStatus: 404 })
|
||||||
|
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be able to run on a view", async () => {
|
it("should be able to run on a view", async () => {
|
||||||
|
@ -837,7 +815,6 @@ describe.each([
|
||||||
expect(res.body[0]._id).toEqual(row._id)
|
expect(res.body[0]._id).toEqual(row._id)
|
||||||
|
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -910,7 +887,6 @@ describe.each([
|
||||||
expect(resEnriched.body.link[0].name).toBe("Test Contact")
|
expect(resEnriched.body.link[0].name).toBe("Test Contact")
|
||||||
expect(resEnriched.body.link[0].description).toBe("original description")
|
expect(resEnriched.body.link[0].description).toBe("original description")
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage + 2)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1129,7 +1105,6 @@ describe.each([
|
||||||
await config.api.row.delete(view.id, [createdRow])
|
await config.api.row.delete(view.id, [createdRow])
|
||||||
|
|
||||||
await assertRowUsage(rowUsage - 1)
|
await assertRowUsage(rowUsage - 1)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
|
|
||||||
await config.api.row.get(tableId, createdRow._id!, {
|
await config.api.row.get(tableId, createdRow._id!, {
|
||||||
expectStatus: 404,
|
expectStatus: 404,
|
||||||
|
@ -1157,7 +1132,6 @@ describe.each([
|
||||||
await config.api.row.delete(view.id, [rows[0], rows[2]])
|
await config.api.row.delete(view.id, [rows[0], rows[2]])
|
||||||
|
|
||||||
await assertRowUsage(rowUsage - 2)
|
await assertRowUsage(rowUsage - 2)
|
||||||
await assertQueryUsage(queryUsage + 1)
|
|
||||||
|
|
||||||
await config.api.row.get(tableId, rows[0]._id!, {
|
await config.api.row.get(tableId, rows[0]._id!, {
|
||||||
expectStatus: 404,
|
expectStatus: 404,
|
||||||
|
|
|
@ -305,8 +305,8 @@ export function shouldCopySpecialColumn(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for columns which need to be copied over into the new table definitions, like relationships
|
* Looks for columns which need to be copied over into the new table definitions, like relationships,
|
||||||
* and options types.
|
* options types and views.
|
||||||
* @param tableName The name of the table which is being checked.
|
* @param tableName The name of the table which is being checked.
|
||||||
* @param table The specific table which is being checked.
|
* @param table The specific table which is being checked.
|
||||||
* @param entities All the tables that existed before - the old table definitions.
|
* @param entities All the tables that existed before - the old table definitions.
|
||||||
|
@ -325,6 +325,9 @@ function copyExistingPropsOver(
|
||||||
if (entities[tableName]?.created) {
|
if (entities[tableName]?.created) {
|
||||||
table.created = entities[tableName]?.created
|
table.created = entities[tableName]?.created
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.views = entities[tableName].views
|
||||||
|
|
||||||
const existingTableSchema = entities[tableName].schema
|
const existingTableSchema = entities[tableName].schema
|
||||||
for (let key in existingTableSchema) {
|
for (let key in existingTableSchema) {
|
||||||
if (!existingTableSchema.hasOwnProperty(key)) {
|
if (!existingTableSchema.hasOwnProperty(key)) {
|
||||||
|
|
|
@ -18,13 +18,16 @@ export function init() {
|
||||||
bbCtx.jsExecutionTracker =
|
bbCtx.jsExecutionTracker =
|
||||||
timers.ExecutionTimeTracker.withLimit(perRequestLimit)
|
timers.ExecutionTimeTracker.withLimit(perRequestLimit)
|
||||||
}
|
}
|
||||||
track = bbCtx.jsExecutionTracker.track.bind(bbCtx.jsExecutionTracker)
|
|
||||||
span?.addTags({
|
span?.addTags({
|
||||||
js: {
|
js: {
|
||||||
limitMS: bbCtx.jsExecutionTracker.limitMs,
|
limitMS: bbCtx.jsExecutionTracker.limitMs,
|
||||||
elapsedMS: bbCtx.jsExecutionTracker.elapsedMS,
|
elapsedMS: bbCtx.jsExecutionTracker.elapsedMS,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
// We call checkLimit() here to prevent paying the cost of creating
|
||||||
|
// a new VM context below when we don't need to.
|
||||||
|
bbCtx.jsExecutionTracker.checkLimit()
|
||||||
|
track = bbCtx.jsExecutionTracker.track.bind(bbCtx.jsExecutionTracker)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"baseUrl": "."
|
"baseUrl": "."
|
||||||
},
|
},
|
||||||
|
"ts-node": {
|
||||||
|
"require": ["tsconfig-paths/register"]
|
||||||
|
},
|
||||||
"include": ["src/**/*", "__mocks__/**/*"],
|
"include": ["src/**/*", "__mocks__/**/*"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue