Merge branch 'master' into fix/copy-id-rev
This commit is contained in:
commit
41e1e656ad
9 changed files with 91 additions and 33 deletions
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "2.24.2",
|
||||
"version": "2.25.0",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*",
|
||||
|
|
|
@ -3,11 +3,11 @@ import {
|
|||
AllDocsResponse,
|
||||
AnyDocument,
|
||||
Database,
|
||||
DatabaseOpts,
|
||||
DatabaseQueryOpts,
|
||||
DatabasePutOpts,
|
||||
DatabaseCreateIndexOpts,
|
||||
DatabaseDeleteIndexOpts,
|
||||
DatabaseOpts,
|
||||
DatabasePutOpts,
|
||||
DatabaseQueryOpts,
|
||||
Document,
|
||||
isDocument,
|
||||
RowResponse,
|
||||
|
@ -17,7 +17,7 @@ import {
|
|||
import { getCouchInfo } from "./connections"
|
||||
import { directCouchUrlCall } from "./utils"
|
||||
import { getPouchDB } from "./pouchDB"
|
||||
import { WriteStream, ReadStream } from "fs"
|
||||
import { ReadStream, WriteStream } from "fs"
|
||||
import { newid } from "../../docIds/newid"
|
||||
import { SQLITE_DESIGN_DOC_ID } from "../../constants"
|
||||
import { DDInstrumentedDatabase } from "../instrumentation"
|
||||
|
@ -38,6 +38,39 @@ function buildNano(couchInfo: { url: string; cookie: string }) {
|
|||
|
||||
type DBCall<T> = () => Promise<T>
|
||||
|
||||
class CouchDBError extends Error {
|
||||
status: number
|
||||
statusCode: number
|
||||
reason: string
|
||||
name: string
|
||||
errid: string
|
||||
error: string
|
||||
description: string
|
||||
|
||||
constructor(
|
||||
message: string,
|
||||
info: {
|
||||
status: number | undefined
|
||||
statusCode: number | undefined
|
||||
name: string
|
||||
errid: string
|
||||
description: string
|
||||
reason: string
|
||||
error: string
|
||||
}
|
||||
) {
|
||||
super(message)
|
||||
const statusCode = info.status || info.statusCode || 500
|
||||
this.status = statusCode
|
||||
this.statusCode = statusCode
|
||||
this.reason = info.reason
|
||||
this.name = info.name
|
||||
this.errid = info.errid
|
||||
this.description = info.description
|
||||
this.error = info.error
|
||||
}
|
||||
}
|
||||
|
||||
export function DatabaseWithConnection(
|
||||
dbName: string,
|
||||
connection: string,
|
||||
|
@ -119,7 +152,7 @@ export class DatabaseImpl implements Database {
|
|||
} catch (err: any) {
|
||||
// Handling race conditions
|
||||
if (err.statusCode !== 412) {
|
||||
throw err
|
||||
throw new CouchDBError(err.message, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,10 +171,9 @@ export class DatabaseImpl implements Database {
|
|||
if (err.statusCode === 404 && err.reason === DATABASE_NOT_FOUND) {
|
||||
await this.checkAndCreateDb()
|
||||
return await this.performCall(call)
|
||||
} else if (err.statusCode) {
|
||||
err.status = err.statusCode
|
||||
}
|
||||
throw err
|
||||
// stripping the error down the props which are safe/useful, drop everything else
|
||||
throw new CouchDBError(`CouchDB error: ${err.message}`, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,7 +320,7 @@ export class DatabaseImpl implements Database {
|
|||
if (err.statusCode === 404) {
|
||||
return
|
||||
} else {
|
||||
throw { ...err, status: err.statusCode }
|
||||
throw new CouchDBError(err.message, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
export let error = null
|
||||
export let validate = null
|
||||
export let suffix = null
|
||||
export let validateOn = "change"
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
|
@ -24,7 +25,16 @@
|
|||
const newValue = e.target.value
|
||||
dispatch("change", newValue)
|
||||
value = newValue
|
||||
if (validate) {
|
||||
if (validate && (error || validateOn === "change")) {
|
||||
error = validate(newValue)
|
||||
}
|
||||
}
|
||||
|
||||
const onBlur = e => {
|
||||
focused = false
|
||||
const newValue = e.target.value
|
||||
dispatch("blur", newValue)
|
||||
if (validate && validateOn === "blur") {
|
||||
error = validate(newValue)
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +71,7 @@
|
|||
type={type || "text"}
|
||||
on:input={onChange}
|
||||
on:focus={() => (focused = true)}
|
||||
on:blur={() => (focused = false)}
|
||||
on:blur={onBlur}
|
||||
class:placeholder
|
||||
bind:this={ref}
|
||||
/>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
OptionSelectDnD,
|
||||
Layout,
|
||||
AbsTooltip,
|
||||
ProgressCircle,
|
||||
} from "@budibase/bbui"
|
||||
import { SWITCHABLE_TYPES, ValidColumnNameRegex } from "@budibase/shared-core"
|
||||
import { createEventDispatcher, getContext, onMount } from "svelte"
|
||||
|
@ -245,11 +246,11 @@
|
|||
}
|
||||
|
||||
async function saveColumn() {
|
||||
savingColumn = true
|
||||
if (errors?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
savingColumn = true
|
||||
let saveColumn = cloneDeep(editableColumn)
|
||||
|
||||
delete saveColumn.fieldId
|
||||
|
@ -289,6 +290,8 @@
|
|||
}
|
||||
} catch (err) {
|
||||
notifications.error(`Error saving column: ${err.message}`)
|
||||
} finally {
|
||||
savingColumn = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -739,7 +742,20 @@
|
|||
<Button quiet warning text on:click={confirmDelete}>Delete</Button>
|
||||
{/if}
|
||||
<Button secondary newStyles on:click={cancelEdit}>Cancel</Button>
|
||||
<Button disabled={invalid} newStyles cta on:click={saveColumn}>Save</Button>
|
||||
<Button
|
||||
disabled={invalid || savingColumn}
|
||||
newStyles
|
||||
cta
|
||||
on:click={saveColumn}
|
||||
>
|
||||
{#if savingColumn}
|
||||
<div class="save-loading">
|
||||
<ProgressCircle overBackground={true} size="S" />
|
||||
</div>
|
||||
{:else}
|
||||
Save
|
||||
{/if}
|
||||
</Button>
|
||||
</div>
|
||||
<Modal bind:this={jsonSchemaModal}>
|
||||
<JSONSchemaModal
|
||||
|
@ -804,4 +820,9 @@
|
|||
cursor: pointer;
|
||||
color: var(--spectrum-global-color-gray-900);
|
||||
}
|
||||
|
||||
.save-loading {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 479879246aac5dd3073cc695945c62c41fae5b0e
|
||||
Subproject commit ff397e5454ad3361b25efdf14746c36dcbd3f409
|
|
@ -44,7 +44,7 @@ describe.each([
|
|||
const snippets = [
|
||||
{
|
||||
name: "WeeksAgo",
|
||||
code: "return function (weeks) {\n const currentTime = new Date();\n currentTime.setDate(currentTime.getDate()-(7 * (weeks || 1)));\n return currentTime.toISOString();\n}",
|
||||
code: `return function (weeks) {\n const currentTime = new Date(${Date.now()});\n currentTime.setDate(currentTime.getDate()-(7 * (weeks || 1)));\n return currentTime.toISOString();\n}`,
|
||||
},
|
||||
]
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ describe.each(
|
|||
let res = await setup.runStep(setup.actions.EXECUTE_QUERY.stepId, {
|
||||
query: { queryId: "wrong_id" },
|
||||
})
|
||||
expect(res.response).toEqual("Error: missing")
|
||||
expect(res.response).toEqual("Error: CouchDB error: missing")
|
||||
expect(res.success).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -371,9 +371,11 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
}
|
||||
|
||||
buildRowObject(headers: string[], values: string[], rowNumber: number) {
|
||||
const rowObject: { rowNumber: number; [key: string]: any } = { rowNumber }
|
||||
const rowObject: { rowNumber: number } & Row = {
|
||||
rowNumber,
|
||||
_id: rowNumber.toString(),
|
||||
}
|
||||
for (let i = 0; i < headers.length; i++) {
|
||||
rowObject._id = rowNumber
|
||||
rowObject[headers[i]] = values[i]
|
||||
}
|
||||
return rowObject
|
||||
|
@ -430,14 +432,6 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
}
|
||||
}
|
||||
|
||||
// clear out deleted columns
|
||||
for (let key of sheet.headerValues) {
|
||||
if (!Object.keys(table.schema).includes(key)) {
|
||||
const idx = updatedHeaderValues.indexOf(key)
|
||||
updatedHeaderValues.splice(idx, 1)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await sheet.setHeaderRow(updatedHeaderValues)
|
||||
} catch (err) {
|
||||
|
@ -458,7 +452,7 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
}
|
||||
}
|
||||
|
||||
async create(query: { sheet: string; row: any }) {
|
||||
async create(query: { sheet: string; row: Row }) {
|
||||
try {
|
||||
await this.connect()
|
||||
const sheet = this.client.sheetsByTitle[query.sheet]
|
||||
|
@ -474,7 +468,7 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
}
|
||||
}
|
||||
|
||||
async createBulk(query: { sheet: string; rows: any[] }) {
|
||||
async createBulk(query: { sheet: string; rows: Row[] }) {
|
||||
try {
|
||||
await this.connect()
|
||||
const sheet = this.client.sheetsByTitle[query.sheet]
|
||||
|
|
|
@ -129,10 +129,11 @@ describe("Google Sheets Integration", () => {
|
|||
})
|
||||
expect(sheet.loadHeaderRow).toHaveBeenCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toHaveBeenCalledTimes(1)
|
||||
expect(sheet.setHeaderRow).toHaveBeenCalledWith(["name"])
|
||||
|
||||
// No undefined are sent
|
||||
expect((sheet.setHeaderRow as any).mock.calls[0][0]).toHaveLength(1)
|
||||
expect(sheet.setHeaderRow).toHaveBeenCalledWith([
|
||||
"name",
|
||||
"description",
|
||||
"location",
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue