Merge remote-tracking branch 'origin/master' into fix/block-duplicate-autocolumn-types
This commit is contained in:
commit
dd914d0342
|
@ -78,7 +78,7 @@ mkdir -p ${DATA_DIR}/search
|
||||||
chown -R couchdb:couchdb ${DATA_DIR}/couch
|
chown -R couchdb:couchdb ${DATA_DIR}/couch
|
||||||
redis-server --requirepass $REDIS_PASSWORD > /dev/stdout 2>&1 &
|
redis-server --requirepass $REDIS_PASSWORD > /dev/stdout 2>&1 &
|
||||||
/opt/clouseau/bin/clouseau > /dev/stdout 2>&1 &
|
/opt/clouseau/bin/clouseau > /dev/stdout 2>&1 &
|
||||||
/minio/minio server ${DATA_DIR}/minio > /dev/stdout 2>&1 &
|
/minio/minio server --console-address ":9001" ${DATA_DIR}/minio > /dev/stdout 2>&1 &
|
||||||
/docker-entrypoint.sh /opt/couchdb/bin/couchdb &
|
/docker-entrypoint.sh /opt/couchdb/bin/couchdb &
|
||||||
/etc/init.d/nginx restart
|
/etc/init.d/nginx restart
|
||||||
if [[ ! -z "${CUSTOM_DOMAIN}" ]]; then
|
if [[ ! -z "${CUSTOM_DOMAIN}" ]]; then
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/backend-core",
|
"name": "@budibase/backend-core",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"description": "Budibase backend core libraries used in server and worker",
|
"description": "Budibase backend core libraries used in server and worker",
|
||||||
"main": "dist/src/index.js",
|
"main": "dist/src/index.js",
|
||||||
"types": "dist/src/index.d.ts",
|
"types": "dist/src/index.d.ts",
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/nano": "10.1.1",
|
"@budibase/nano": "10.1.1",
|
||||||
"@budibase/types": "^2.2.9",
|
"@budibase/types": "^2.2.12",
|
||||||
"@shopify/jest-koa-mocks": "5.0.1",
|
"@shopify/jest-koa-mocks": "5.0.1",
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
"aws-sdk": "2.1030.0",
|
"aws-sdk": "2.1030.0",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/bbui",
|
"name": "@budibase/bbui",
|
||||||
"description": "A UI solution used in the different Budibase projects.",
|
"description": "A UI solution used in the different Budibase projects.",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"svelte": "src/index.js",
|
"svelte": "src/index.js",
|
||||||
"module": "dist/bbui.es.js",
|
"module": "dist/bbui.es.js",
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adobe/spectrum-css-workflow-icons": "1.2.1",
|
"@adobe/spectrum-css-workflow-icons": "1.2.1",
|
||||||
"@budibase/string-templates": "^2.2.9",
|
"@budibase/string-templates": "^2.2.12",
|
||||||
"@spectrum-css/actionbutton": "1.0.1",
|
"@spectrum-css/actionbutton": "1.0.1",
|
||||||
"@spectrum-css/actiongroup": "1.0.1",
|
"@spectrum-css/actiongroup": "1.0.1",
|
||||||
"@spectrum-css/avatar": "3.0.2",
|
"@spectrum-css/avatar": "3.0.2",
|
||||||
|
|
|
@ -11,14 +11,31 @@
|
||||||
export let getOptionLabel = option => option
|
export let getOptionLabel = option => option
|
||||||
export let getOptionValue = option => option
|
export let getOptionValue = option => option
|
||||||
export let getOptionTitle = option => option
|
export let getOptionTitle = option => option
|
||||||
|
export let sort = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = e => dispatch("change", e.target.value)
|
const onChange = e => dispatch("change", e.target.value)
|
||||||
|
|
||||||
|
const getSortedOptions = (options, getLabel, sort) => {
|
||||||
|
if (!options?.length || !Array.isArray(options)) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
if (!sort) {
|
||||||
|
return options
|
||||||
|
}
|
||||||
|
return [...options].sort((a, b) => {
|
||||||
|
const labelA = getLabel(a)
|
||||||
|
const labelB = getLabel(b)
|
||||||
|
return labelA > labelB ? 1 : -1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$: parsedOptions = getSortedOptions(options, getOptionLabel, sort)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={`spectrum-FieldGroup spectrum-FieldGroup--${direction}`}>
|
<div class={`spectrum-FieldGroup spectrum-FieldGroup--${direction}`}>
|
||||||
{#if options && Array.isArray(options)}
|
{#if parsedOptions && Array.isArray(parsedOptions)}
|
||||||
{#each options as option}
|
{#each parsedOptions as option}
|
||||||
<div
|
<div
|
||||||
title={getOptionTitle(option)}
|
title={getOptionTitle(option)}
|
||||||
class="spectrum-Radio spectrum-FieldGroup-item spectrum-Radio--emphasized"
|
class="spectrum-Radio spectrum-FieldGroup-item spectrum-Radio--emphasized"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/builder",
|
"name": "@budibase/builder",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -71,10 +71,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "^2.2.9",
|
"@budibase/bbui": "^2.2.12",
|
||||||
"@budibase/client": "^2.2.9",
|
"@budibase/client": "^2.2.12",
|
||||||
"@budibase/frontend-core": "^2.2.9",
|
"@budibase/frontend-core": "^2.2.12",
|
||||||
"@budibase/string-templates": "^2.2.9",
|
"@budibase/string-templates": "^2.2.12",
|
||||||
"@sentry/browser": "5.19.1",
|
"@sentry/browser": "5.19.1",
|
||||||
"@spectrum-css/page": "^3.0.1",
|
"@spectrum-css/page": "^3.0.1",
|
||||||
"@spectrum-css/vars": "^3.0.1",
|
"@spectrum-css/vars": "^3.0.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/cli",
|
"name": "@budibase/cli",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -26,9 +26,9 @@
|
||||||
"outputPath": "build"
|
"outputPath": "build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/backend-core": "^2.2.9",
|
"@budibase/backend-core": "^2.2.12",
|
||||||
"@budibase/string-templates": "^2.2.9",
|
"@budibase/string-templates": "^2.2.12",
|
||||||
"@budibase/types": "^2.2.9",
|
"@budibase/types": "^2.2.12",
|
||||||
"axios": "0.21.2",
|
"axios": "0.21.2",
|
||||||
"chalk": "4.1.0",
|
"chalk": "4.1.0",
|
||||||
"cli-progress": "3.11.2",
|
"cli-progress": "3.11.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/client",
|
"name": "@budibase/client",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"module": "dist/budibase-client.js",
|
"module": "dist/budibase-client.js",
|
||||||
"main": "dist/budibase-client.js",
|
"main": "dist/budibase-client.js",
|
||||||
|
@ -19,9 +19,9 @@
|
||||||
"dev:builder": "rollup -cw"
|
"dev:builder": "rollup -cw"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "^2.2.9",
|
"@budibase/bbui": "^2.2.12",
|
||||||
"@budibase/frontend-core": "^2.2.9",
|
"@budibase/frontend-core": "^2.2.12",
|
||||||
"@budibase/string-templates": "^2.2.9",
|
"@budibase/string-templates": "^2.2.12",
|
||||||
"@spectrum-css/button": "^3.0.3",
|
"@spectrum-css/button": "^3.0.3",
|
||||||
"@spectrum-css/card": "^3.0.3",
|
"@spectrum-css/card": "^3.0.3",
|
||||||
"@spectrum-css/divider": "^1.0.3",
|
"@spectrum-css/divider": "^1.0.3",
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
getOptionLabel={flatOptions ? x => x : x => x.label}
|
getOptionLabel={flatOptions ? x => x : x => x.label}
|
||||||
getOptionTitle={flatOptions ? x => x : x => x.label}
|
getOptionTitle={flatOptions ? x => x : x => x.label}
|
||||||
getOptionValue={flatOptions ? x => x : x => x.value}
|
getOptionValue={flatOptions ? x => x : x => x.value}
|
||||||
|
{sort}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/frontend-core",
|
"name": "@budibase/frontend-core",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"description": "Budibase frontend core libraries used in builder and client",
|
"description": "Budibase frontend core libraries used in builder and client",
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"svelte": "src/index.js",
|
"svelte": "src/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "^2.2.9",
|
"@budibase/bbui": "^2.2.12",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"svelte": "^3.46.2"
|
"svelte": "^3.46.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/sdk",
|
"name": "@budibase/sdk",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"description": "Budibase Public API SDK",
|
"description": "Budibase Public API SDK",
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/server",
|
"name": "@budibase/server",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"description": "Budibase Web Server",
|
"description": "Budibase Web Server",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -43,11 +43,11 @@
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/swagger-parser": "10.0.3",
|
"@apidevtools/swagger-parser": "10.0.3",
|
||||||
"@budibase/backend-core": "^2.2.9",
|
"@budibase/backend-core": "^2.2.12",
|
||||||
"@budibase/client": "^2.2.9",
|
"@budibase/client": "^2.2.12",
|
||||||
"@budibase/pro": "2.2.9",
|
"@budibase/pro": "2.2.12",
|
||||||
"@budibase/string-templates": "^2.2.9",
|
"@budibase/string-templates": "^2.2.12",
|
||||||
"@budibase/types": "^2.2.9",
|
"@budibase/types": "^2.2.12",
|
||||||
"@bull-board/api": "3.7.0",
|
"@bull-board/api": "3.7.0",
|
||||||
"@bull-board/koa": "3.9.4",
|
"@bull-board/koa": "3.9.4",
|
||||||
"@elastic/elasticsearch": "7.10.0",
|
"@elastic/elasticsearch": "7.10.0",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const setup = require("./utilities")
|
const setup = require("./utilities")
|
||||||
const { events, constants, db } = require("@budibase/backend-core")
|
const { events, constants } = require("@budibase/backend-core")
|
||||||
|
|
||||||
describe("/static", () => {
|
describe("/static", () => {
|
||||||
let request = setup.getRequest()
|
let request = setup.getRequest()
|
||||||
|
|
|
@ -151,6 +151,9 @@ class MySQLIntegration extends Sql implements DatasourcePlus {
|
||||||
) {
|
) {
|
||||||
return field.string()
|
return field.string()
|
||||||
}
|
}
|
||||||
|
if (field.type === "BIT" && field.length === 1) {
|
||||||
|
return field.buffer()?.[0]
|
||||||
|
}
|
||||||
return next()
|
return next()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
import { db as dbCore, objectStore } from "@budibase/backend-core"
|
import { db as dbCore, objectStore } from "@budibase/backend-core"
|
||||||
import { Database } from "@budibase/types"
|
import { Database, Row } from "@budibase/types"
|
||||||
import { getAutomationParams, TABLE_ROW_PREFIX } from "../../../db/utils"
|
import { getAutomationParams, TABLE_ROW_PREFIX } from "../../../db/utils"
|
||||||
import { budibaseTempDir } from "../../../utilities/budibaseDir"
|
import { budibaseTempDir } from "../../../utilities/budibaseDir"
|
||||||
import { DB_EXPORT_FILE, GLOBAL_DB_EXPORT_FILE } from "./constants"
|
import { DB_EXPORT_FILE, GLOBAL_DB_EXPORT_FILE } from "./constants"
|
||||||
import { downloadTemplate } from "../../../utilities/fileSystem"
|
import { downloadTemplate } from "../../../utilities/fileSystem"
|
||||||
import { FieldTypes, ObjectStoreBuckets } from "../../../constants"
|
import { ObjectStoreBuckets } from "../../../constants"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import sdk from "../../"
|
import sdk from "../../"
|
||||||
import {
|
import {
|
||||||
Automation,
|
Automation,
|
||||||
AutomationTriggerStepId,
|
AutomationTriggerStepId,
|
||||||
CouchFindOptions,
|
|
||||||
RowAttachment,
|
RowAttachment,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
const uuid = require("uuid/v4")
|
const uuid = require("uuid/v4")
|
||||||
|
@ -25,58 +24,49 @@ type TemplateType = {
|
||||||
key?: string
|
key?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateAttachmentColumns(prodAppId: string, db: Database) {
|
function rewriteAttachmentUrl(appId: string, attachment: RowAttachment) {
|
||||||
|
// URL looks like: /prod-budi-app-assets/appId/attachments/file.csv
|
||||||
|
const urlParts = attachment.url.split("/")
|
||||||
|
// drop the first empty element
|
||||||
|
urlParts.shift()
|
||||||
|
// get the prefix
|
||||||
|
const prefix = urlParts.shift()
|
||||||
|
// remove the app ID
|
||||||
|
urlParts.shift()
|
||||||
|
// add new app ID
|
||||||
|
urlParts.unshift(appId)
|
||||||
|
const key = urlParts.join("/")
|
||||||
|
return {
|
||||||
|
...attachment,
|
||||||
|
key,
|
||||||
|
url: `/${prefix}/${key}`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateAttachmentColumns(prodAppId: string, db: Database) {
|
||||||
// iterate through attachment documents and update them
|
// iterate through attachment documents and update them
|
||||||
const tables = await sdk.tables.getAllInternalTables(db)
|
const tables = await sdk.tables.getAllInternalTables(db)
|
||||||
|
let updatedRows: Row[] = []
|
||||||
for (let table of tables) {
|
for (let table of tables) {
|
||||||
const attachmentCols: string[] = []
|
const { rows, columns } = await sdk.rows.getRowsWithAttachments(
|
||||||
for (let [key, column] of Object.entries(table.schema)) {
|
db.name,
|
||||||
if (column.type === FieldTypes.ATTACHMENT) {
|
table
|
||||||
attachmentCols.push(key)
|
)
|
||||||
}
|
updatedRows = updatedRows.concat(
|
||||||
}
|
rows.map(row => {
|
||||||
// no attachment columns, nothing to do
|
for (let column of columns) {
|
||||||
if (attachmentCols.length === 0) {
|
if (Array.isArray(row[column])) {
|
||||||
continue
|
row[column] = row[column].map((attachment: RowAttachment) =>
|
||||||
}
|
rewriteAttachmentUrl(prodAppId, attachment)
|
||||||
// use the CouchDB Mango query API to lookup rows that have attachments
|
)
|
||||||
const params: CouchFindOptions = {
|
|
||||||
selector: {
|
|
||||||
_id: {
|
|
||||||
$regex: `^${TABLE_ROW_PREFIX}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
attachmentCols.forEach(col => (params.selector[col] = { $exists: true }))
|
|
||||||
const { rows } = await dbCore.directCouchFind(db.name, params)
|
|
||||||
for (let row of rows) {
|
|
||||||
for (let column of attachmentCols) {
|
|
||||||
if (!Array.isArray(row[column])) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
row[column] = row[column].map((attachment: RowAttachment) => {
|
|
||||||
// URL looks like: /prod-budi-app-assets/appId/attachments/file.csv
|
|
||||||
const urlParts = attachment.url.split("/")
|
|
||||||
// drop the first empty element
|
|
||||||
urlParts.shift()
|
|
||||||
// get the prefix
|
|
||||||
const prefix = urlParts.shift()
|
|
||||||
// remove the app ID
|
|
||||||
urlParts.shift()
|
|
||||||
// add new app ID
|
|
||||||
urlParts.unshift(prodAppId)
|
|
||||||
const key = urlParts.join("/")
|
|
||||||
return {
|
|
||||||
...attachment,
|
|
||||||
key,
|
|
||||||
url: `/${prefix}/${key}`,
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
return row
|
||||||
}
|
})
|
||||||
// write back the updated attachments
|
)
|
||||||
await db.bulkDocs(rows)
|
|
||||||
}
|
}
|
||||||
|
// write back the updated attachments
|
||||||
|
await db.bulkDocs(updatedRows)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateAutomations(prodAppId: string, db: Database) {
|
async function updateAutomations(prodAppId: string, db: Database) {
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
import { CouchFindOptions, Table, Row } from "@budibase/types"
|
||||||
|
import { db as dbCore } from "@budibase/backend-core"
|
||||||
|
import { DocumentType, SEPARATOR } from "../../../db/utils"
|
||||||
|
import { FieldTypes } from "../../../constants"
|
||||||
|
|
||||||
|
// default limit - seems to work well for performance
|
||||||
|
export const FIND_LIMIT = 25
|
||||||
|
|
||||||
|
function generateAttachmentFindParams(
|
||||||
|
tableId: string,
|
||||||
|
attachmentCols: string[],
|
||||||
|
bookmark: null | string
|
||||||
|
) {
|
||||||
|
const params: CouchFindOptions = {
|
||||||
|
selector: {
|
||||||
|
_id: {
|
||||||
|
$regex: `^${DocumentType.ROW}${SEPARATOR}${tableId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
limit: FIND_LIMIT,
|
||||||
|
}
|
||||||
|
attachmentCols.forEach(col => (params.selector[col] = { $exists: true }))
|
||||||
|
if (bookmark) {
|
||||||
|
params.bookmark = bookmark
|
||||||
|
}
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getRowsWithAttachments(appId: string, table: Table) {
|
||||||
|
// iterate through attachment documents and update them
|
||||||
|
const db = dbCore.getDB(appId)
|
||||||
|
const attachmentCols: string[] = []
|
||||||
|
for (let [key, column] of Object.entries(table.schema)) {
|
||||||
|
if (column.type === FieldTypes.ATTACHMENT) {
|
||||||
|
attachmentCols.push(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// no attachment columns, nothing to do
|
||||||
|
if (attachmentCols.length === 0) {
|
||||||
|
return { rows: [], columns: [] }
|
||||||
|
}
|
||||||
|
let bookmark: null | string = null,
|
||||||
|
rowsLength = 0,
|
||||||
|
rowList: Row[] = []
|
||||||
|
do {
|
||||||
|
const params = generateAttachmentFindParams(
|
||||||
|
table._id!,
|
||||||
|
attachmentCols,
|
||||||
|
bookmark
|
||||||
|
)
|
||||||
|
// use the CouchDB Mango query API to lookup rows that have attachments
|
||||||
|
const resp = await dbCore.directCouchFind(db.name, params)
|
||||||
|
bookmark = resp.bookmark
|
||||||
|
rowsLength = resp.rows.length
|
||||||
|
const rows = resp.rows
|
||||||
|
rowList = rowList.concat(rows)
|
||||||
|
} while (rowsLength === FIND_LIMIT)
|
||||||
|
// write back the updated attachments
|
||||||
|
return { rows: rowList, columns: attachmentCols }
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
import * as attachments from "./attachments"
|
||||||
|
import * as rows from "./rows"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
...attachments,
|
||||||
|
...rows,
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { db as dbCore, context } from "@budibase/backend-core"
|
||||||
|
import { Database, Row } from "@budibase/types"
|
||||||
|
import { getRowParams } from "../../../db/utils"
|
||||||
|
|
||||||
|
export async function getAllInternalRows(appId?: string) {
|
||||||
|
let db: Database
|
||||||
|
if (appId) {
|
||||||
|
db = dbCore.getDB(appId)
|
||||||
|
} else {
|
||||||
|
db = context.getAppDB()
|
||||||
|
}
|
||||||
|
const response = await db.allDocs(
|
||||||
|
getRowParams(null, null, {
|
||||||
|
include_docs: true,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
return response.rows.map(row => row.doc) as Row[]
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ import { default as backups } from "./app/backups"
|
||||||
import { default as tables } from "./app/tables"
|
import { default as tables } from "./app/tables"
|
||||||
import { default as automations } from "./app/automations"
|
import { default as automations } from "./app/automations"
|
||||||
import { default as applications } from "./app/applications"
|
import { default as applications } from "./app/applications"
|
||||||
|
import { default as rows } from "./app/rows"
|
||||||
import { default as users } from "./users"
|
import { default as users } from "./users"
|
||||||
|
|
||||||
const sdk = {
|
const sdk = {
|
||||||
|
@ -9,6 +10,7 @@ const sdk = {
|
||||||
tables,
|
tables,
|
||||||
automations,
|
automations,
|
||||||
applications,
|
applications,
|
||||||
|
rows,
|
||||||
users,
|
users,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
import newid from "../../db/newid"
|
||||||
|
|
||||||
|
const attachment = {
|
||||||
|
size: 73479,
|
||||||
|
name: "2022-12-14 11_11_44-.png",
|
||||||
|
url: "/prod-budi-app-assets/app_bbb/attachments/a.png",
|
||||||
|
extension: "png",
|
||||||
|
key: "app_bbb/attachments/a.png",
|
||||||
|
}
|
||||||
|
|
||||||
|
const row = {
|
||||||
|
_id: "ro_ta_aaa",
|
||||||
|
photo: [attachment],
|
||||||
|
otherCol: "string",
|
||||||
|
}
|
||||||
|
|
||||||
|
const table = {
|
||||||
|
_id: "ta_aaa",
|
||||||
|
name: "photos",
|
||||||
|
schema: {
|
||||||
|
photo: {
|
||||||
|
type: "attachment",
|
||||||
|
name: "photo",
|
||||||
|
},
|
||||||
|
otherCol: {
|
||||||
|
type: "string",
|
||||||
|
name: "otherCol",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
jest.mock("@budibase/backend-core", () => {
|
||||||
|
const core = jest.requireActual("@budibase/backend-core")
|
||||||
|
return {
|
||||||
|
...core,
|
||||||
|
db: {
|
||||||
|
...core.db,
|
||||||
|
directCouchFind: jest.fn(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
import { db as dbCore } from "@budibase/backend-core"
|
||||||
|
import sdk from "../index"
|
||||||
|
|
||||||
|
describe("should be able to re-write attachment URLs", () => {
|
||||||
|
it("it should update URLs on a number of rows over the limit", async () => {
|
||||||
|
const db = dbCore.getDB("app_aaa")
|
||||||
|
await db.put(table)
|
||||||
|
const limit = 30
|
||||||
|
let rows = []
|
||||||
|
for (let i = 0; i < limit; i++) {
|
||||||
|
const rowToWrite = {
|
||||||
|
...row,
|
||||||
|
_id: `${row._id}_${newid()}`,
|
||||||
|
}
|
||||||
|
const { rev } = await db.put(rowToWrite)
|
||||||
|
rows.push({
|
||||||
|
...rowToWrite,
|
||||||
|
_rev: rev,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
dbCore.directCouchFind
|
||||||
|
// @ts-ignore
|
||||||
|
.mockReturnValueOnce({ rows: rows.slice(0, 25), bookmark: "aaa" })
|
||||||
|
.mockReturnValueOnce({ rows: rows.slice(25, limit), bookmark: "bbb" })
|
||||||
|
await sdk.backups.updateAttachmentColumns(db.name, db)
|
||||||
|
const finalRows = await sdk.rows.getAllInternalRows(db.name)
|
||||||
|
for (let rowToCheck of finalRows) {
|
||||||
|
expect(rowToCheck.otherCol).toBe(row.otherCol)
|
||||||
|
expect(rowToCheck.photo[0].url).not.toBe(row.photo[0].url)
|
||||||
|
expect(rowToCheck.photo[0].url).toBe(
|
||||||
|
`/prod-budi-app-assets/${db.name}/attachments/a.png`
|
||||||
|
)
|
||||||
|
expect(rowToCheck.photo[0].key).toBe(`${db.name}/attachments/a.png`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
|
@ -1273,13 +1273,13 @@
|
||||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||||
|
|
||||||
"@budibase/backend-core@2.2.9":
|
"@budibase/backend-core@2.2.12":
|
||||||
version "2.2.9"
|
version "2.2.12"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.9.tgz#0b7f7c2cef2c51e4304287b988e3af531d05b7b1"
|
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.12.tgz#d109a4196e2ca29319649b37b5ba9233e5f3b7ea"
|
||||||
integrity sha512-zZOdK67XBtybnWa5E5D5ioCpBhbTJelkWVNcH2E8vsKqLNu+6g0SZGKgUqKy8O7uiX6JZ/nLdNi80TiRKFpAxg==
|
integrity sha512-OgHZhHvpG02CRiJqQfAcXATkNgsi/mF6/cZ1gVCwRl7gccSCLIEUf17SkM1MRykdERU6R93Fkv0Z7LOrU6bn4A==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/nano" "10.1.1"
|
"@budibase/nano" "10.1.1"
|
||||||
"@budibase/types" "^2.2.9"
|
"@budibase/types" "^2.2.12"
|
||||||
"@shopify/jest-koa-mocks" "5.0.1"
|
"@shopify/jest-koa-mocks" "5.0.1"
|
||||||
"@techpass/passport-openidconnect" "0.3.2"
|
"@techpass/passport-openidconnect" "0.3.2"
|
||||||
aws-sdk "2.1030.0"
|
aws-sdk "2.1030.0"
|
||||||
|
@ -1372,13 +1372,13 @@
|
||||||
qs "^6.11.0"
|
qs "^6.11.0"
|
||||||
tough-cookie "^4.1.2"
|
tough-cookie "^4.1.2"
|
||||||
|
|
||||||
"@budibase/pro@2.2.9":
|
"@budibase/pro@2.2.12":
|
||||||
version "2.2.9"
|
version "2.2.12"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.9.tgz#46f563d5c6ca6ce6621ee79ef77830a81feb2421"
|
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.12.tgz#71d664718a8c0a11e1350ae2db91bc82b96850bc"
|
||||||
integrity sha512-QCl/kZ8hAd9+GumxLYL6LpDW0/QWm57fda7zKrONDETA9e9+bZwoK94vYYWr9xs3VFq3CwvomKSYre8HfNrFDg==
|
integrity sha512-weEUNepZSierkBi/EMhKiT52VAsdc2d7GxD1jvAU0NcLDm4C1lfVt8sBSZ7+RmQS4V9n5XMqgORcnV5HmLOUIg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/backend-core" "2.2.9"
|
"@budibase/backend-core" "2.2.12"
|
||||||
"@budibase/types" "2.2.9"
|
"@budibase/types" "2.2.12"
|
||||||
"@koa/router" "8.0.8"
|
"@koa/router" "8.0.8"
|
||||||
bull "4.10.1"
|
bull "4.10.1"
|
||||||
joi "17.6.0"
|
joi "17.6.0"
|
||||||
|
@ -1402,10 +1402,10 @@
|
||||||
svelte-apexcharts "^1.0.2"
|
svelte-apexcharts "^1.0.2"
|
||||||
svelte-flatpickr "^3.1.0"
|
svelte-flatpickr "^3.1.0"
|
||||||
|
|
||||||
"@budibase/types@2.2.9", "@budibase/types@^2.2.9":
|
"@budibase/types@2.2.12", "@budibase/types@^2.2.12":
|
||||||
version "2.2.9"
|
version "2.2.12"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.9.tgz#6fe26748b3506150657612eb4ef5e895e96b72cc"
|
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12.tgz#a7e8e99bfa3e30f3c416b79636a2e5f4297017d3"
|
||||||
integrity sha512-jVW2vgx6TrjJuY0XmhnhKLZyZnlQI9xGzzGXr4jORcrdP5VCEp3BBHDh/3hxrLhlmnJ6+9o0Ey0Ru2dy/j9YPA==
|
integrity sha512-2Tc74etbXi4bPAyGYdyLCbQzY0y3DhrEe6ZPSGLi2GzI2uePH7qlUKSaS8bz4cxbrXccZoq+DwzAbf9rL9pZww==
|
||||||
|
|
||||||
"@bull-board/api@3.7.0":
|
"@bull-board/api@3.7.0":
|
||||||
version "3.7.0"
|
version "3.7.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/string-templates",
|
"name": "@budibase/string-templates",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"description": "Handlebars wrapper for Budibase templating.",
|
"description": "Handlebars wrapper for Budibase templating.",
|
||||||
"main": "src/index.cjs",
|
"main": "src/index.cjs",
|
||||||
"module": "dist/bundle.mjs",
|
"module": "dist/bundle.mjs",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/types",
|
"name": "@budibase/types",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"description": "Budibase types",
|
"description": "Budibase types",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/worker",
|
"name": "@budibase/worker",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "2.2.9",
|
"version": "2.2.12",
|
||||||
"description": "Budibase background service",
|
"description": "Budibase background service",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -36,10 +36,10 @@
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/backend-core": "^2.2.9",
|
"@budibase/backend-core": "^2.2.12",
|
||||||
"@budibase/pro": "2.2.9",
|
"@budibase/pro": "2.2.12",
|
||||||
"@budibase/string-templates": "^2.2.9",
|
"@budibase/string-templates": "^2.2.12",
|
||||||
"@budibase/types": "^2.2.9",
|
"@budibase/types": "^2.2.12",
|
||||||
"@koa/router": "8.0.8",
|
"@koa/router": "8.0.8",
|
||||||
"@sentry/node": "6.17.7",
|
"@sentry/node": "6.17.7",
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
|
|
|
@ -470,13 +470,13 @@
|
||||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||||
|
|
||||||
"@budibase/backend-core@2.2.9":
|
"@budibase/backend-core@2.2.12":
|
||||||
version "2.2.9"
|
version "2.2.12"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.9.tgz#0b7f7c2cef2c51e4304287b988e3af531d05b7b1"
|
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.12.tgz#d109a4196e2ca29319649b37b5ba9233e5f3b7ea"
|
||||||
integrity sha512-zZOdK67XBtybnWa5E5D5ioCpBhbTJelkWVNcH2E8vsKqLNu+6g0SZGKgUqKy8O7uiX6JZ/nLdNi80TiRKFpAxg==
|
integrity sha512-OgHZhHvpG02CRiJqQfAcXATkNgsi/mF6/cZ1gVCwRl7gccSCLIEUf17SkM1MRykdERU6R93Fkv0Z7LOrU6bn4A==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/nano" "10.1.1"
|
"@budibase/nano" "10.1.1"
|
||||||
"@budibase/types" "^2.2.9"
|
"@budibase/types" "^2.2.12"
|
||||||
"@shopify/jest-koa-mocks" "5.0.1"
|
"@shopify/jest-koa-mocks" "5.0.1"
|
||||||
"@techpass/passport-openidconnect" "0.3.2"
|
"@techpass/passport-openidconnect" "0.3.2"
|
||||||
aws-sdk "2.1030.0"
|
aws-sdk "2.1030.0"
|
||||||
|
@ -519,22 +519,22 @@
|
||||||
qs "^6.11.0"
|
qs "^6.11.0"
|
||||||
tough-cookie "^4.1.2"
|
tough-cookie "^4.1.2"
|
||||||
|
|
||||||
"@budibase/pro@2.2.9":
|
"@budibase/pro@2.2.12":
|
||||||
version "2.2.9"
|
version "2.2.12"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.9.tgz#46f563d5c6ca6ce6621ee79ef77830a81feb2421"
|
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.12.tgz#71d664718a8c0a11e1350ae2db91bc82b96850bc"
|
||||||
integrity sha512-QCl/kZ8hAd9+GumxLYL6LpDW0/QWm57fda7zKrONDETA9e9+bZwoK94vYYWr9xs3VFq3CwvomKSYre8HfNrFDg==
|
integrity sha512-weEUNepZSierkBi/EMhKiT52VAsdc2d7GxD1jvAU0NcLDm4C1lfVt8sBSZ7+RmQS4V9n5XMqgORcnV5HmLOUIg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/backend-core" "2.2.9"
|
"@budibase/backend-core" "2.2.12"
|
||||||
"@budibase/types" "2.2.9"
|
"@budibase/types" "2.2.12"
|
||||||
"@koa/router" "8.0.8"
|
"@koa/router" "8.0.8"
|
||||||
bull "4.10.1"
|
bull "4.10.1"
|
||||||
joi "17.6.0"
|
joi "17.6.0"
|
||||||
node-fetch "^2.6.1"
|
node-fetch "^2.6.1"
|
||||||
|
|
||||||
"@budibase/types@2.2.9", "@budibase/types@^2.2.9":
|
"@budibase/types@2.2.12", "@budibase/types@^2.2.12":
|
||||||
version "2.2.9"
|
version "2.2.12"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.9.tgz#6fe26748b3506150657612eb4ef5e895e96b72cc"
|
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12.tgz#a7e8e99bfa3e30f3c416b79636a2e5f4297017d3"
|
||||||
integrity sha512-jVW2vgx6TrjJuY0XmhnhKLZyZnlQI9xGzzGXr4jORcrdP5VCEp3BBHDh/3hxrLhlmnJ6+9o0Ey0Ru2dy/j9YPA==
|
integrity sha512-2Tc74etbXi4bPAyGYdyLCbQzY0y3DhrEe6ZPSGLi2GzI2uePH7qlUKSaS8bz4cxbrXccZoq+DwzAbf9rL9pZww==
|
||||||
|
|
||||||
"@cspotcode/source-map-support@^0.8.0":
|
"@cspotcode/source-map-support@^0.8.0":
|
||||||
version "0.8.1"
|
version "0.8.1"
|
||||||
|
|
Loading…
Reference in New Issue