Merge branch 'master' into feat/budi-8123-single-user
This commit is contained in:
commit
4bec2a3a48
4 changed files with 55 additions and 13 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}
|
||||
/>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 479879246aac5dd3073cc695945c62c41fae5b0e
|
||||
Subproject commit ff397e5454ad3361b25efdf14746c36dcbd3f409
|
Loading…
Reference in a new issue