From a4c8fcb2aceb819e3e4621f521ce9bb7cce6063a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 3 Apr 2024 16:43:12 +0200 Subject: [PATCH 01/32] Clean and populate url --- .../server/src/utilities/rowProcessor/index.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts index c421929888..e69cfa471a 100644 --- a/packages/server/src/utilities/rowProcessor/index.ts +++ b/packages/server/src/utilities/rowProcessor/index.ts @@ -155,6 +155,11 @@ export async function inputProcessing( delete attachment.url }) } + } else if (field.type === FieldType.ATTACHMENT_SINGLE) { + const attachment = clonedRow[key] + if (attachment?.url) { + delete clonedRow[key].url + } } if (field.type === FieldType.BB_REFERENCE && value) { @@ -227,6 +232,16 @@ export async function outputProcessing( } }) } + } else if (column.type === FieldType.ATTACHMENT_SINGLE) { + for (let row of enriched) { + if (!row[property]) { + continue + } + + if (!row[property].url) { + row[property].url = objectStore.getAppFileUrl(row[property].key) + } + } } else if ( !opts.skipBBReferences && column.type == FieldType.BB_REFERENCE From 7d0090a8e24fc8e653410287554ea849fe85cad8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 3 Apr 2024 17:01:36 +0200 Subject: [PATCH 02/32] Fix import/export --- packages/server/src/utilities/schema.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utilities/schema.ts b/packages/server/src/utilities/schema.ts index 85dfdd3506..4c7f0b7423 100644 --- a/packages/server/src/utilities/schema.ts +++ b/packages/server/src/utilities/schema.ts @@ -54,7 +54,7 @@ export function validate(rows: Rows, schema: TableSchema): ValidationResults { type: columnType, subtype: columnSubtype, autocolumn: isAutoColumn, - } = schema[columnName] + } = schema[columnName] || {} // If the column had an invalid value we don't want to override it if (results.schemaValidation[columnName] === false) { @@ -147,6 +147,12 @@ export function parse(rows: Rows, schema: TableSchema): Rows { utils.unreachable(columnSubtype) } } + } else if ( + (columnType === FieldType.ATTACHMENTS || + columnType === FieldType.ATTACHMENT_SINGLE) && + typeof columnData === "string" + ) { + parsedRow[columnName] = parseCsvExport(columnData) } else { parsedRow[columnName] = columnData } From 543718838597a8c2779c34a7394705f9455893fc Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Wed, 3 Apr 2024 16:05:18 +0100 Subject: [PATCH 03/32] Revert "Revert "Single attachment column type"" --- packages/bbui/src/Form/Core/Dropzone.svelte | 2 +- .../components/backend/DataTable/formula.js | 2 +- .../DataTable/modals/CreateEditColumn.svelte | 3 +- .../controls/FieldConfiguration/utils.js | 3 +- .../builder/src/constants/backend/index.js | 16 ++- packages/builder/tsconfig.json | 3 - packages/client/manifest.json | 99 ++++++++++++++++++- .../app/blocks/FormBlockComponent.svelte | 5 +- .../app/forms/AttachmentField.svelte | 15 ++- .../app/forms/AttachmentSingleField.svelte | 16 +++ .../client/src/components/app/forms/index.js | 1 + .../src/components/app/forms/validation.js | 2 +- .../grid/cells/AttachmentCell.svelte | 3 +- .../grid/cells/AttachmentSingleCell.svelte | 20 ++++ .../src/components/grid/lib/renderers.js | 4 +- .../src/components/grid/lib/utils.js | 3 +- .../server/src/api/controllers/table/utils.ts | 22 ----- .../server/src/api/routes/tests/row.spec.ts | 4 +- .../db/defaultData/datasource_bb_default.ts | 4 +- .../server/src/sdk/app/rows/attachments.ts | 2 +- packages/server/src/sdk/app/rows/utils.ts | 4 +- .../src/utilities/rowProcessor/attachments.ts | 6 +- .../src/utilities/rowProcessor/index.ts | 4 +- .../server/src/utilities/rowProcessor/map.ts | 2 +- .../rowProcessor/tests/attachments.spec.ts | 2 +- .../tests/outputProcessing.spec.ts | 2 +- packages/shared-core/src/table.ts | 7 +- packages/types/src/documents/app/row.ts | 7 +- .../types/src/documents/app/table/schema.ts | 10 +- 29 files changed, 200 insertions(+), 73 deletions(-) create mode 100644 packages/client/src/components/app/forms/AttachmentSingleField.svelte create mode 100644 packages/frontend-core/src/components/grid/cells/AttachmentSingleCell.svelte diff --git a/packages/bbui/src/Form/Core/Dropzone.svelte b/packages/bbui/src/Form/Core/Dropzone.svelte index 3d803c0961..dd72167791 100644 --- a/packages/bbui/src/Form/Core/Dropzone.svelte +++ b/packages/bbui/src/Form/Core/Dropzone.svelte @@ -67,7 +67,7 @@ } $: showDropzone = - (!maximum || (maximum && value?.length < maximum)) && !disabled + (!maximum || (maximum && (value?.length || 0) < maximum)) && !disabled async function processFileList(fileList) { if ( diff --git a/packages/builder/src/components/backend/DataTable/formula.js b/packages/builder/src/components/backend/DataTable/formula.js index e3da4249bc..b339729391 100644 --- a/packages/builder/src/components/backend/DataTable/formula.js +++ b/packages/builder/src/components/backend/DataTable/formula.js @@ -9,7 +9,7 @@ const MAX_DEPTH = 1 const TYPES_TO_SKIP = [ FieldType.FORMULA, FieldType.LONGFORM, - FieldType.ATTACHMENT, + FieldType.ATTACHMENTS, //https://github.com/Budibase/budibase/issues/3030 FieldType.INTERNAL, ] diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index cfc6e9a7be..92501bec3b 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -394,7 +394,8 @@ FIELDS.BIGINT, FIELDS.BOOLEAN, FIELDS.DATETIME, - FIELDS.ATTACHMENT, + FIELDS.ATTACHMENT_SINGLE, + FIELDS.ATTACHMENTS, FIELDS.LINK, FIELDS.FORMULA, FIELDS.JSON, diff --git a/packages/builder/src/components/design/settings/controls/FieldConfiguration/utils.js b/packages/builder/src/components/design/settings/controls/FieldConfiguration/utils.js index 18ebf57d98..d0f9afda40 100644 --- a/packages/builder/src/components/design/settings/controls/FieldConfiguration/utils.js +++ b/packages/builder/src/components/design/settings/controls/FieldConfiguration/utils.js @@ -41,7 +41,8 @@ export const FieldTypeToComponentMap = { [FieldType.BOOLEAN]: "booleanfield", [FieldType.LONGFORM]: "longformfield", [FieldType.DATETIME]: "datetimefield", - [FieldType.ATTACHMENT]: "attachmentfield", + [FieldType.ATTACHMENTS]: "attachmentfield", + [FieldType.ATTACHMENT_SINGLE]: "attachmentsinglefield", [FieldType.LINK]: "relationshipfield", [FieldType.JSON]: "jsonfield", [FieldType.BARCODEQR]: "codescanner", diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index dd751d4e13..e3888a52e0 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -107,10 +107,18 @@ export const FIELDS = { }, }, }, - ATTACHMENT: { + ATTACHMENT_SINGLE: { name: "Attachment", - type: FieldType.ATTACHMENT, - icon: "Folder", + type: FieldType.ATTACHMENT_SINGLE, + icon: "Document", + constraints: { + presence: false, + }, + }, + ATTACHMENTS: { + name: "Attachment List", + type: FieldType.ATTACHMENTS, + icon: "AppleFiles", constraints: { type: "array", presence: false, @@ -299,7 +307,7 @@ export const PaginationLocations = [ export const BannedSearchTypes = [ FieldType.LINK, - FieldType.ATTACHMENT, + FieldType.ATTACHMENTS, FieldType.FORMULA, FieldType.JSON, "jsonarray", diff --git a/packages/builder/tsconfig.json b/packages/builder/tsconfig.json index be79dfd85c..a7a4c3d800 100644 --- a/packages/builder/tsconfig.json +++ b/packages/builder/tsconfig.json @@ -1,9 +1,6 @@ { "extends": "./tsconfig.build.json", "compilerOptions": { - "composite": true, - "declaration": true, - "sourceMap": true, "baseUrl": ".", "paths": { "assets/*": ["./assets/*"], diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 08d614391b..cc5c68ea83 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -4226,7 +4226,7 @@ ] }, "attachmentfield": { - "name": "Attachment", + "name": "Attachment list", "icon": "Attach", "styles": ["size"], "requiredAncestors": ["form"], @@ -4322,6 +4322,103 @@ } ] }, + "attachmentsinglefield": { + "name": "Single Attachment", + "icon": "Attach", + "styles": ["size"], + "requiredAncestors": ["form"], + "editable": true, + "size": { + "width": 400, + "height": 200 + }, + "settings": [ + { + "type": "field/attachment_single", + "label": "Field", + "key": "field", + "required": true + }, + { + "type": "text", + "label": "Label", + "key": "label" + }, + { + "type": "text", + "label": "Help text", + "key": "helpText" + }, + { + "type": "text", + "label": "Extensions", + "key": "extensions" + }, + { + "type": "number", + "label": "Max attachments", + "key": "maximum", + "min": 1 + }, + { + "type": "event", + "label": "On change", + "key": "onChange", + "context": [ + { + "label": "Field Value", + "key": "value" + } + ] + }, + { + "type": "boolean", + "label": "Compact", + "key": "compact", + "defaultValue": false + }, + { + "type": "boolean", + "label": "Read only", + "key": "disabled", + "defaultValue": false + }, + { + "type": "validation/attachment", + "label": "Validation", + "key": "validation" + }, + { + "type": "select", + "label": "Layout", + "key": "span", + "defaultValue": 6, + "hidden": true, + "showInBar": true, + "barStyle": "buttons", + "options": [ + { + "label": "1 column", + "value": 6, + "barIcon": "Stop", + "barTitle": "1 column" + }, + { + "label": "2 columns", + "value": 3, + "barIcon": "ColumnTwoA", + "barTitle": "2 columns" + }, + { + "label": "3 columns", + "value": 2, + "barIcon": "ViewColumn", + "barTitle": "3 columns" + } + ] + } + ] + }, "relationshipfield": { "name": "Relationship Picker", "icon": "TaskList", diff --git a/packages/client/src/components/app/blocks/FormBlockComponent.svelte b/packages/client/src/components/app/blocks/FormBlockComponent.svelte index 34168355c4..968ed36b8b 100644 --- a/packages/client/src/components/app/blocks/FormBlockComponent.svelte +++ b/packages/client/src/components/app/blocks/FormBlockComponent.svelte @@ -15,7 +15,8 @@ [FieldType.BOOLEAN]: "booleanfield", [FieldType.LONGFORM]: "longformfield", [FieldType.DATETIME]: "datetimefield", - [FieldType.ATTACHMENT]: "attachmentfield", + [FieldType.ATTACHMENTS]: "attachmentfield", + [FieldType.ATTACHMENT_SINGLE]: "attachmentsinglefield", [FieldType.LINK]: "relationshipfield", [FieldType.JSON]: "jsonfield", [FieldType.BARCODEQR]: "codescanner", @@ -60,7 +61,7 @@ function getPropsByType(field) { const propsMapByType = { - [FieldType.ATTACHMENT]: (_field, schema) => { + [FieldType.ATTACHMENTS]: (_field, schema) => { return { maximum: schema?.constraints?.length?.maximum, } diff --git a/packages/client/src/components/app/forms/AttachmentField.svelte b/packages/client/src/components/app/forms/AttachmentField.svelte index b61f88daeb..8be70bc011 100644 --- a/packages/client/src/components/app/forms/AttachmentField.svelte +++ b/packages/client/src/components/app/forms/AttachmentField.svelte @@ -1,6 +1,7 @@ @@ -78,14 +85,14 @@ {validation} {span} {helpText} - type="attachment" + {type} bind:fieldState bind:fieldApi defaultValue={[]} > {#if fieldState} + import { FieldType } from "@budibase/types" + import AttachmentField from "./AttachmentField.svelte" + + const fieldApiMapper = { + get: value => (!Array.isArray(value) && value ? [value] : value) || [], + set: value => value[0] || null, + } + + + diff --git a/packages/client/src/components/app/forms/index.js b/packages/client/src/components/app/forms/index.js index 5804d3a79d..aa54204454 100644 --- a/packages/client/src/components/app/forms/index.js +++ b/packages/client/src/components/app/forms/index.js @@ -9,6 +9,7 @@ export { default as booleanfield } from "./BooleanField.svelte" export { default as longformfield } from "./LongFormField.svelte" export { default as datetimefield } from "./DateTimeField.svelte" export { default as attachmentfield } from "./AttachmentField.svelte" +export { default as attachmentsinglefield } from "./AttachmentSingleField.svelte" export { default as relationshipfield } from "./RelationshipField.svelte" export { default as passwordfield } from "./PasswordField.svelte" export { default as formstep } from "./FormStep.svelte" diff --git a/packages/client/src/components/app/forms/validation.js b/packages/client/src/components/app/forms/validation.js index 3b3a5d6e1d..cdedd85cf2 100644 --- a/packages/client/src/components/app/forms/validation.js +++ b/packages/client/src/components/app/forms/validation.js @@ -192,7 +192,7 @@ const parseType = (value, type) => { } // Parse attachments, treating no elements as null - if (type === FieldTypes.ATTACHMENT) { + if (type === FieldTypes.ATTACHMENTS) { if (!Array.isArray(value) || !value.length) { return null } diff --git a/packages/frontend-core/src/components/grid/cells/AttachmentCell.svelte b/packages/frontend-core/src/components/grid/cells/AttachmentCell.svelte index a1f5c4f2aa..3a1f165b6e 100644 --- a/packages/frontend-core/src/components/grid/cells/AttachmentCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/AttachmentCell.svelte @@ -10,6 +10,7 @@ export let invertX = false export let invertY = false export let schema + export let maximum const { API, notifications } = getContext("grid") const imageExtensions = ["png", "tiff", "gif", "raw", "jpg", "jpeg"] @@ -98,7 +99,7 @@ {value} compact on:change={e => onChange(e.detail)} - maximum={schema.constraints?.length?.maximum} + maximum={maximum || schema.constraints?.length?.maximum} {processFiles} {deleteAttachments} {handleFileTooLarge} diff --git a/packages/frontend-core/src/components/grid/cells/AttachmentSingleCell.svelte b/packages/frontend-core/src/components/grid/cells/AttachmentSingleCell.svelte new file mode 100644 index 0000000000..c2e29b6ede --- /dev/null +++ b/packages/frontend-core/src/components/grid/cells/AttachmentSingleCell.svelte @@ -0,0 +1,20 @@ + + + diff --git a/packages/frontend-core/src/components/grid/lib/renderers.js b/packages/frontend-core/src/components/grid/lib/renderers.js index 19bf63312d..c3ee276ff9 100644 --- a/packages/frontend-core/src/components/grid/lib/renderers.js +++ b/packages/frontend-core/src/components/grid/lib/renderers.js @@ -11,6 +11,7 @@ import BooleanCell from "../cells/BooleanCell.svelte" import FormulaCell from "../cells/FormulaCell.svelte" import JSONCell from "../cells/JSONCell.svelte" import AttachmentCell from "../cells/AttachmentCell.svelte" +import AttachmentSingleCell from "../cells/AttachmentSingleCell.svelte" import BBReferenceCell from "../cells/BBReferenceCell.svelte" const TypeComponentMap = { @@ -22,7 +23,8 @@ const TypeComponentMap = { [FieldType.ARRAY]: MultiSelectCell, [FieldType.NUMBER]: NumberCell, [FieldType.BOOLEAN]: BooleanCell, - [FieldType.ATTACHMENT]: AttachmentCell, + [FieldType.ATTACHMENTS]: AttachmentCell, + [FieldType.ATTACHMENT_SINGLE]: AttachmentSingleCell, [FieldType.LINK]: RelationshipCell, [FieldType.FORMULA]: FormulaCell, [FieldType.JSON]: JSONCell, diff --git a/packages/frontend-core/src/components/grid/lib/utils.js b/packages/frontend-core/src/components/grid/lib/utils.js index 8382bfece8..49d6b0a439 100644 --- a/packages/frontend-core/src/components/grid/lib/utils.js +++ b/packages/frontend-core/src/components/grid/lib/utils.js @@ -16,7 +16,8 @@ const TypeIconMap = { [FieldType.ARRAY]: "Dropdown", [FieldType.NUMBER]: "123", [FieldType.BOOLEAN]: "Boolean", - [FieldType.ATTACHMENT]: "AppleFiles", + [FieldType.ATTACHMENTS]: "AppleFiles", + [FieldType.ATTACHMENT_SINGLE]: "Document", [FieldType.LINK]: "DataCorrelated", [FieldType.FORMULA]: "Calculator", [FieldType.JSON]: "Brackets", diff --git a/packages/server/src/api/controllers/table/utils.ts b/packages/server/src/api/controllers/table/utils.ts index 0c9933a4cf..5649a1d996 100644 --- a/packages/server/src/api/controllers/table/utils.ts +++ b/packages/server/src/api/controllers/table/utils.ts @@ -30,8 +30,6 @@ import { View, RelationshipFieldMetadata, FieldType, - FieldTypeSubtypes, - AttachmentFieldMetadata, } from "@budibase/types" export async function clearColumns(table: Table, columnNames: string[]) { @@ -91,26 +89,6 @@ export async function checkForColumnUpdates( await checkForViewUpdates(updatedTable, deletedColumns, columnRename) } - const changedAttachmentSubtypeColumns = Object.values( - updatedTable.schema - ).filter( - (column): column is AttachmentFieldMetadata => - column.type === FieldType.ATTACHMENT && - column.subtype !== oldTable?.schema[column.name]?.subtype - ) - for (const attachmentColumn of changedAttachmentSubtypeColumns) { - if (attachmentColumn.subtype === FieldTypeSubtypes.ATTACHMENT.SINGLE) { - attachmentColumn.constraints ??= { length: {} } - attachmentColumn.constraints.length ??= {} - attachmentColumn.constraints.length.maximum = 1 - attachmentColumn.constraints.length.message = - "cannot contain multiple files" - } else { - delete attachmentColumn.constraints?.length?.maximum - delete attachmentColumn.constraints?.length?.message - } - } - return { rows: updatedRows, table: updatedTable } } diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 8910522565..0fe8beb7ea 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -234,7 +234,7 @@ describe.each([ constraints: { type: "string", presence: false }, } const attachment: FieldSchema = { - type: FieldType.ATTACHMENT, + type: FieldType.ATTACHMENTS, name: "attachment", constraints: { type: "array", presence: false }, } @@ -790,7 +790,7 @@ describe.each([ defaultTable({ schema: { attachment: { - type: FieldType.ATTACHMENT, + type: FieldType.ATTACHMENTS, name: "attachment", constraints: { type: "array", presence: false }, }, diff --git a/packages/server/src/db/defaultData/datasource_bb_default.ts b/packages/server/src/db/defaultData/datasource_bb_default.ts index 03aed3c118..68d49b2d8b 100644 --- a/packages/server/src/db/defaultData/datasource_bb_default.ts +++ b/packages/server/src/db/defaultData/datasource_bb_default.ts @@ -299,7 +299,7 @@ export const DEFAULT_EMPLOYEE_TABLE_SCHEMA: Table = { sortable: false, }, "Badge Photo": { - type: FieldType.ATTACHMENT, + type: FieldType.ATTACHMENTS, constraints: { type: FieldType.ARRAY, presence: false, @@ -607,7 +607,7 @@ export const DEFAULT_EXPENSES_TABLE_SCHEMA: Table = { ignoreTimezones: true, }, Attachment: { - type: FieldType.ATTACHMENT, + type: FieldType.ATTACHMENTS, constraints: { type: FieldType.ARRAY, presence: false, diff --git a/packages/server/src/sdk/app/rows/attachments.ts b/packages/server/src/sdk/app/rows/attachments.ts index 2ab9e83c47..8fd2ccf795 100644 --- a/packages/server/src/sdk/app/rows/attachments.ts +++ b/packages/server/src/sdk/app/rows/attachments.ts @@ -30,7 +30,7 @@ export async function getRowsWithAttachments(appId: string, table: Table) { const db = dbCore.getDB(appId) const attachmentCols: string[] = [] for (let [key, column] of Object.entries(table.schema)) { - if (column.type === FieldType.ATTACHMENT) { + if (column.type === FieldType.ATTACHMENTS) { attachmentCols.push(key) } } diff --git a/packages/server/src/sdk/app/rows/utils.ts b/packages/server/src/sdk/app/rows/utils.ts index 8aa017d238..e1a0fbb5c4 100644 --- a/packages/server/src/sdk/app/rows/utils.ts +++ b/packages/server/src/sdk/app/rows/utils.ts @@ -175,13 +175,13 @@ export async function validate({ errors[fieldName] = [`${fieldName} is required`] } } else if ( - (type === FieldType.ATTACHMENT || type === FieldType.JSON) && + (type === FieldType.ATTACHMENTS || type === FieldType.JSON) && typeof row[fieldName] === "string" ) { // this should only happen if there is an error try { const json = JSON.parse(row[fieldName]) - if (type === FieldType.ATTACHMENT) { + if (type === FieldType.ATTACHMENTS) { if (Array.isArray(json)) { row[fieldName] = json } else { diff --git a/packages/server/src/utilities/rowProcessor/attachments.ts b/packages/server/src/utilities/rowProcessor/attachments.ts index e1c83352d4..652851a48b 100644 --- a/packages/server/src/utilities/rowProcessor/attachments.ts +++ b/packages/server/src/utilities/rowProcessor/attachments.ts @@ -34,7 +34,7 @@ export class AttachmentCleanup { let files: string[] = [] const tableSchema = opts.oldTable?.schema || table.schema for (let [key, schema] of Object.entries(tableSchema)) { - if (schema.type !== FieldType.ATTACHMENT) { + if (schema.type !== FieldType.ATTACHMENTS) { continue } const columnRemoved = opts.oldTable && !table.schema[key] @@ -68,7 +68,7 @@ export class AttachmentCleanup { return AttachmentCleanup.coreCleanup(() => { let files: string[] = [] for (let [key, schema] of Object.entries(table.schema)) { - if (schema.type !== FieldType.ATTACHMENT) { + if (schema.type !== FieldType.ATTACHMENTS) { continue } rows.forEach(row => { @@ -88,7 +88,7 @@ export class AttachmentCleanup { return AttachmentCleanup.coreCleanup(() => { let files: string[] = [] for (let [key, schema] of Object.entries(table.schema)) { - if (schema.type !== FieldType.ATTACHMENT) { + if (schema.type !== FieldType.ATTACHMENTS) { continue } const oldKeys = diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts index 0015680e77..c421929888 100644 --- a/packages/server/src/utilities/rowProcessor/index.ts +++ b/packages/server/src/utilities/rowProcessor/index.ts @@ -148,7 +148,7 @@ export async function inputProcessing( } // remove any attachment urls, they are generated on read - if (field.type === FieldType.ATTACHMENT) { + if (field.type === FieldType.ATTACHMENTS) { const attachments = clonedRow[key] if (attachments?.length) { attachments.forEach((attachment: RowAttachment) => { @@ -216,7 +216,7 @@ export async function outputProcessing( // process complex types: attachements, bb references... for (let [property, column] of Object.entries(table.schema)) { - if (column.type === FieldType.ATTACHMENT) { + if (column.type === FieldType.ATTACHMENTS) { for (let row of enriched) { if (row[property] == null || !Array.isArray(row[property])) { continue diff --git a/packages/server/src/utilities/rowProcessor/map.ts b/packages/server/src/utilities/rowProcessor/map.ts index 60fe5a001b..2e0ac9efe1 100644 --- a/packages/server/src/utilities/rowProcessor/map.ts +++ b/packages/server/src/utilities/rowProcessor/map.ts @@ -106,7 +106,7 @@ export const TYPE_TRANSFORM_MAP: any = { return date }, }, - [FieldType.ATTACHMENT]: { + [FieldType.ATTACHMENTS]: { //@ts-ignore [null]: [], //@ts-ignore diff --git a/packages/server/src/utilities/rowProcessor/tests/attachments.spec.ts b/packages/server/src/utilities/rowProcessor/tests/attachments.spec.ts index cefea7e504..1b36a4cb81 100644 --- a/packages/server/src/utilities/rowProcessor/tests/attachments.spec.ts +++ b/packages/server/src/utilities/rowProcessor/tests/attachments.spec.ts @@ -34,7 +34,7 @@ function table(): Table { schema: { attach: { name: "attach", - type: FieldType.ATTACHMENT, + type: FieldType.ATTACHMENTS, constraints: {}, }, }, diff --git a/packages/server/src/utilities/rowProcessor/tests/outputProcessing.spec.ts b/packages/server/src/utilities/rowProcessor/tests/outputProcessing.spec.ts index a17bd5f393..93404e0469 100644 --- a/packages/server/src/utilities/rowProcessor/tests/outputProcessing.spec.ts +++ b/packages/server/src/utilities/rowProcessor/tests/outputProcessing.spec.ts @@ -82,7 +82,7 @@ describe("rowProcessor - outputProcessing", () => { sourceType: TableSourceType.INTERNAL, schema: { attach: { - type: FieldType.ATTACHMENT, + type: FieldType.ATTACHMENTS, name: "attach", constraints: {}, }, diff --git a/packages/shared-core/src/table.ts b/packages/shared-core/src/table.ts index 5eab2fc340..26a7e77cd0 100644 --- a/packages/shared-core/src/table.ts +++ b/packages/shared-core/src/table.ts @@ -11,10 +11,10 @@ const allowDisplayColumnByType: Record = { [FieldType.INTERNAL]: true, [FieldType.BARCODEQR]: true, [FieldType.BIGINT]: true, - [FieldType.BOOLEAN]: false, [FieldType.ARRAY]: false, - [FieldType.ATTACHMENT]: false, + [FieldType.ATTACHMENTS]: false, + [FieldType.ATTACHMENT_SINGLE]: false, [FieldType.LINK]: false, [FieldType.JSON]: false, [FieldType.BB_REFERENCE]: false, @@ -34,7 +34,8 @@ const allowSortColumnByType: Record = { [FieldType.JSON]: true, [FieldType.FORMULA]: false, - [FieldType.ATTACHMENT]: false, + [FieldType.ATTACHMENTS]: false, + [FieldType.ATTACHMENT_SINGLE]: false, [FieldType.ARRAY]: false, [FieldType.LINK]: false, [FieldType.BB_REFERENCE]: false, diff --git a/packages/types/src/documents/app/row.ts b/packages/types/src/documents/app/row.ts index aa8f50d4a8..222c346591 100644 --- a/packages/types/src/documents/app/row.ts +++ b/packages/types/src/documents/app/row.ts @@ -8,7 +8,8 @@ export enum FieldType { BOOLEAN = "boolean", ARRAY = "array", DATETIME = "datetime", - ATTACHMENT = "attachment", + ATTACHMENTS = "attachment", + ATTACHMENT_SINGLE = "attachment_single", LINK = "link", FORMULA = "formula", AUTO = "auto", @@ -38,7 +39,6 @@ export interface Row extends Document { export enum FieldSubtype { USER = "user", USERS = "users", - SINGLE = "single", } // The 'as' are required for typescript not to type the outputs as generic FieldSubtype @@ -47,7 +47,4 @@ export const FieldTypeSubtypes = { USER: FieldSubtype.USER as FieldSubtype.USER, USERS: FieldSubtype.USERS as FieldSubtype.USERS, }, - ATTACHMENT: { - SINGLE: FieldSubtype.SINGLE as FieldSubtype.SINGLE, - }, } diff --git a/packages/types/src/documents/app/table/schema.ts b/packages/types/src/documents/app/table/schema.ts index 45e39268ac..86c34b6a5c 100644 --- a/packages/types/src/documents/app/table/schema.ts +++ b/packages/types/src/documents/app/table/schema.ts @@ -112,10 +112,8 @@ export interface BBReferenceFieldMetadata relationshipType?: RelationshipType } -export interface AttachmentFieldMetadata - extends Omit { - type: FieldType.ATTACHMENT - subtype?: FieldSubtype.SINGLE +export interface AttachmentFieldMetadata extends BaseFieldSchema { + type: FieldType.ATTACHMENTS } export interface FieldConstraints { @@ -164,7 +162,7 @@ interface OtherFieldMetadata extends BaseFieldSchema { | FieldType.NUMBER | FieldType.LONGFORM | FieldType.BB_REFERENCE - | FieldType.ATTACHMENT + | FieldType.ATTACHMENTS > } @@ -217,5 +215,5 @@ export function isBBReferenceField( export function isAttachmentField( field: FieldSchema ): field is AttachmentFieldMetadata { - return field.type === FieldType.ATTACHMENT + return field.type === FieldType.ATTACHMENTS } From 6d9d1acfcd5360de0742baa84a743cb6d439e358 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 4 Apr 2024 10:01:05 +0200 Subject: [PATCH 04/32] Update yarn.lock --- yarn.lock | 165 +++++++++--------------------------------------------- 1 file changed, 25 insertions(+), 140 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4deda92484..545ee21c84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7261,37 +7261,7 @@ axios-retry@^3.1.9: "@babel/runtime" "^7.15.4" is-retry-allowed "^2.2.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: +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: version "1.6.3" resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.3.tgz#7f50f23b3aa246eff43c54834272346c396613f4" integrity sha512-fWyNdeawGam70jXSVlKl+SUNVcL6j6W79CuSIPfi6HnDUmSCH6gyUys/HrqHeA/wU0Az41rRgean494d0Jb+ww== @@ -11242,11 +11212,6 @@ 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" @@ -12365,12 +12330,7 @@ http-assert@^1.3.0: deep-equal "~1.0.1" http-errors "~1.8.0" -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: +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: 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== @@ -13315,6 +13275,11 @@ 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" @@ -15909,7 +15874,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.5.2: +msgpackr@1.10.1, msgpackr@^1.5.2: version "1.10.1" resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.10.1.tgz#51953bb4ce4f3494f0c4af3f484f01cfbb306555" integrity sha512-r5VRLv9qouXuLiIBrLpl2d5ZvPt8svdQTl5/vMvE4nzDMyEX4sgW5yWhuBBj5UmgwOTWj8CIdSXn5sAfsHAWIQ== @@ -16113,25 +16078,13 @@ node-addon-api@^6.1.0: resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-6.1.0.tgz#ac8470034e58e67d0c6f1204a18ae6995d9c0d76" integrity sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA== -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: +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: 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" @@ -17276,15 +17229,7 @@ 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.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: +passport@0.6.0, passport@^0.4.0, 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== @@ -18585,7 +18530,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.28, psl@^1.1.33: +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== @@ -19602,11 +19547,6 @@ 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" @@ -19688,40 +19628,13 @@ semver-diff@^3.1.1: dependencies: semver "^6.3.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: +"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: 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" @@ -21307,7 +21220,7 @@ touch@^3.1.0: dependencies: nopt "~1.0.10" -"tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0.0, tough-cookie@^4.1.2: +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: 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== @@ -21317,14 +21230,6 @@ touch@^3.1.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" @@ -21801,6 +21706,14 @@ 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" @@ -22571,33 +22484,10 @@ 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: - 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== +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== dependencies: sax ">=0.6.0" xmlbuilder "~11.0.0" @@ -22607,11 +22497,6 @@ 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" From 0cb956a7b5cd3c623bc74587162b7ce6ecc7644b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 4 Apr 2024 10:10:32 +0200 Subject: [PATCH 05/32] Update submodules --- packages/account-portal | 2 +- packages/pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/account-portal b/packages/account-portal index 011fa3c175..532c4db35c 160000 --- a/packages/account-portal +++ b/packages/account-portal @@ -1 +1 @@ -Subproject commit 011fa3c175ae0a1bbbb0f6e1341ba0154bca5c76 +Subproject commit 532c4db35cecd346b5c24f0b89ab7b397a122a36 diff --git a/packages/pro b/packages/pro index 6b62505be0..f8e8f87bd5 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 6b62505be0c0b50a57b4f4980d86541ebdc86428 +Subproject commit f8e8f87bd52081e1303a5ae92c432ea5b38f3bb4 From 28d10ec086d4ca59ab404d9c73fdddb87f7f24f6 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 4 Apr 2024 19:58:25 +0200 Subject: [PATCH 06/32] Fix --- .../ExistingTableDataImport.svelte | 27 +++++++++++-------- .../server/src/sdk/tests/attachments.spec.ts | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte b/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte index efbfd26565..6901503071 100644 --- a/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte +++ b/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte @@ -1,6 +1,7 @@ Date: Wed, 10 Apr 2024 10:10:15 +0200 Subject: [PATCH 19/32] Fix merge conflicts --- packages/server/src/sdk/app/tables/internal/sqs.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/server/src/sdk/app/tables/internal/sqs.ts b/packages/server/src/sdk/app/tables/internal/sqs.ts index da947c62c2..79d9be2348 100644 --- a/packages/server/src/sdk/app/tables/internal/sqs.ts +++ b/packages/server/src/sdk/app/tables/internal/sqs.ts @@ -27,7 +27,8 @@ const FieldTypeMap: Record = { [FieldType.JSON]: SQLiteType.BLOB, [FieldType.INTERNAL]: SQLiteType.BLOB, [FieldType.BARCODEQR]: SQLiteType.BLOB, - [FieldType.ATTACHMENT]: SQLiteType.BLOB, + [FieldType.ATTACHMENTS]: SQLiteType.BLOB, + [FieldType.ATTACHMENT_SINGLE]: SQLiteType.BLOB, [FieldType.ARRAY]: SQLiteType.BLOB, [FieldType.LINK]: SQLiteType.BLOB, [FieldType.BIGINT]: SQLiteType.REAL, From 06db50147ed580d0e8625aed9dc852f9d25a3499 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 10 Apr 2024 09:20:54 +0100 Subject: [PATCH 20/32] PR Feedback --- packages/client/src/components/app/GridBlock.svelte | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/client/src/components/app/GridBlock.svelte b/packages/client/src/components/app/GridBlock.svelte index f6ef55f802..8be3893da0 100644 --- a/packages/client/src/components/app/GridBlock.svelte +++ b/packages/client/src/components/app/GridBlock.svelte @@ -111,7 +111,6 @@
Date: Wed, 10 Apr 2024 09:28:36 +0100 Subject: [PATCH 21/32] Lint --- packages/client/src/components/app/GridBlock.svelte | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/client/src/components/app/GridBlock.svelte b/packages/client/src/components/app/GridBlock.svelte index 8be3893da0..0ee2cf1487 100644 --- a/packages/client/src/components/app/GridBlock.svelte +++ b/packages/client/src/components/app/GridBlock.svelte @@ -49,7 +49,6 @@ metadata: { dataSource: table }, }, ] - $: customHeight = $component?.styles?.normal?.height // Provide additional data context for live binding eval export const getAdditionalDataContext = () => { From 245fa93bd29ecfc7230226ce58672bac37f400a7 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Wed, 10 Apr 2024 09:30:01 +0100 Subject: [PATCH 22/32] Make test cases a little cleaner. --- .../src/api/routes/tests/search.spec.ts | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 24ba277bbf..2b08f9afc1 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -54,18 +54,20 @@ describe.each([ }) describe("strings", () => { + const rows = [{ name: "foo" }, { name: "bar" }] + interface StringSearchTest { query: SearchFilters - expected: number[] + expected: (typeof rows)[number][] } const stringSearchTests: StringSearchTest[] = [ - { query: {}, expected: [0, 1] }, - { query: { string: { name: "foo" } }, expected: [0] }, - { query: { fuzzy: { name: "oo" } }, expected: [0] }, - { query: { equal: { name: "foo" } }, expected: [0] }, - { query: { notEqual: { name: "foo" } }, expected: [1] }, - { query: { oneOf: { name: ["foo"] } }, expected: [0] }, + { query: {}, expected: rows }, + { query: { string: { name: "foo" } }, expected: [rows[0]] }, + { query: { fuzzy: { name: "oo" } }, expected: [rows[0]] }, + { query: { equal: { name: "foo" } }, expected: [rows[0]] }, + { query: { notEqual: { name: "foo" } }, expected: [rows[1]] }, + { query: { oneOf: { name: ["foo"] } }, expected: [rows[0]] }, // { query: { contains: { name: "f" } }, expected: [0] }, // { query: { notContains: { name: ["f"] } }, expected: [1] }, // { query: { containsAny: { name: ["f"] } }, expected: [0] }, @@ -74,18 +76,13 @@ describe.each([ it.each(stringSearchTests)( `should be able to run query: $query`, async ({ query, expected }) => { - const rows = await Promise.all([ - config.api.row.save(table._id!, { name: "foo" }), - config.api.row.save(table._id!, { name: "bar" }), - ]) - - const result = await config.api.row.search(table._id!, { + await Promise.all(rows.map(r => config.api.row.save(table._id!, r))) + const { rows: foundRows } = await config.api.row.search(table._id!, { tableId: table._id!, query, }) - - expect(result.rows.map(r => r._id)).toEqual( - expect.arrayContaining(expected.map(i => rows[i]._id)) + expect(foundRows).toEqual( + expect.arrayContaining(expected.map(r => expect.objectContaining(r))) ) } ) From e744e4ebb1cd5780b84dd71fe3704fd146965f7e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 11:52:19 +0200 Subject: [PATCH 23/32] Unify icons --- .../builder/src/constants/backend/index.js | 34 ++++++++++--------- .../src/components/grid/lib/utils.js | 22 +----------- packages/frontend-core/src/constants.js | 23 +++++++++++++ 3 files changed, 42 insertions(+), 37 deletions(-) diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index dd751d4e13..e4736892b9 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -5,6 +5,8 @@ import { AutoFieldSubType, Hosting, } from "@budibase/types" +import { Constants } from "@budibase/frontend-core" +const { TypeIconMap } = Constants export { RelationshipType } from "@budibase/types" @@ -22,7 +24,7 @@ export const FIELDS = { STRING: { name: "Text", type: FieldType.STRING, - icon: "Text", + icon: TypeIconMap[FieldType.STRING], constraints: { type: "string", length: {}, @@ -32,7 +34,7 @@ export const FIELDS = { BARCODEQR: { name: "Barcode/QR", type: FieldType.BARCODEQR, - icon: "Camera", + icon: TypeIconMap[FieldType.BARCODEQR], constraints: { type: "string", length: {}, @@ -42,7 +44,7 @@ export const FIELDS = { LONGFORM: { name: "Long Form Text", type: FieldType.LONGFORM, - icon: "TextAlignLeft", + icon: TypeIconMap[FieldType.LONGFORM], constraints: { type: "string", length: {}, @@ -52,7 +54,7 @@ export const FIELDS = { OPTIONS: { name: "Options", type: FieldType.OPTIONS, - icon: "Dropdown", + icon: TypeIconMap[FieldType.OPTIONS], constraints: { type: "string", presence: false, @@ -62,7 +64,7 @@ export const FIELDS = { ARRAY: { name: "Multi-select", type: FieldType.ARRAY, - icon: "Duplicate", + icon: TypeIconMap[FieldType.ARRAY], constraints: { type: "array", presence: false, @@ -72,7 +74,7 @@ export const FIELDS = { NUMBER: { name: "Number", type: FieldType.NUMBER, - icon: "123", + icon: TypeIconMap[FieldType.NUMBER], constraints: { type: "number", presence: false, @@ -82,12 +84,12 @@ export const FIELDS = { BIGINT: { name: "BigInt", type: FieldType.BIGINT, - icon: "TagBold", + icon: TypeIconMap[FieldType.BIGINT], }, BOOLEAN: { name: "Boolean", type: FieldType.BOOLEAN, - icon: "Boolean", + icon: TypeIconMap[FieldType.BOOLEAN], constraints: { type: "boolean", presence: false, @@ -96,7 +98,7 @@ export const FIELDS = { DATETIME: { name: "Date/Time", type: FieldType.DATETIME, - icon: "Calendar", + icon: TypeIconMap[FieldType.DATETIME], constraints: { type: "string", length: {}, @@ -110,7 +112,7 @@ export const FIELDS = { ATTACHMENT: { name: "Attachment", type: FieldType.ATTACHMENT, - icon: "Folder", + icon: TypeIconMap[FieldType.ATTACHMENT], constraints: { type: "array", presence: false, @@ -119,7 +121,7 @@ export const FIELDS = { LINK: { name: "Relationship", type: FieldType.LINK, - icon: "Link", + icon: TypeIconMap[FieldType.LINK], constraints: { type: "array", presence: false, @@ -128,19 +130,19 @@ export const FIELDS = { AUTO: { name: "Auto Column", type: FieldType.AUTO, - icon: "MagicWand", + icon: TypeIconMap[FieldType.AUTO], constraints: {}, }, FORMULA: { name: "Formula", type: FieldType.FORMULA, - icon: "Calculator", + icon: TypeIconMap[FieldType.FORMULA], constraints: {}, }, JSON: { name: "JSON", type: FieldType.JSON, - icon: "Brackets", + icon: TypeIconMap[FieldType.JSON], constraints: { type: "object", presence: false, @@ -150,13 +152,13 @@ export const FIELDS = { name: "User", type: FieldType.BB_REFERENCE, subtype: FieldSubtype.USER, - icon: "User", + icon: TypeIconMap[FieldType.USER], }, USERS: { name: "Users", type: FieldType.BB_REFERENCE, subtype: FieldSubtype.USERS, - icon: "User", + icon: TypeIconMap[FieldType.USERS], constraints: { type: "array", }, diff --git a/packages/frontend-core/src/components/grid/lib/utils.js b/packages/frontend-core/src/components/grid/lib/utils.js index 8382bfece8..c7c618e6f8 100644 --- a/packages/frontend-core/src/components/grid/lib/utils.js +++ b/packages/frontend-core/src/components/grid/lib/utils.js @@ -1,4 +1,4 @@ -import { FieldType, FieldTypeSubtypes } from "@budibase/types" +import { TypeIconMap } from "../../../constants" export const getColor = (idx, opacity = 0.3) => { if (idx == null || idx === -1) { @@ -7,26 +7,6 @@ export const getColor = (idx, opacity = 0.3) => { return `hsla(${((idx + 1) * 222) % 360}, 90%, 75%, ${opacity})` } -const TypeIconMap = { - [FieldType.STRING]: "Text", - [FieldType.OPTIONS]: "Dropdown", - [FieldType.DATETIME]: "Date", - [FieldType.BARCODEQR]: "Camera", - [FieldType.LONGFORM]: "TextAlignLeft", - [FieldType.ARRAY]: "Dropdown", - [FieldType.NUMBER]: "123", - [FieldType.BOOLEAN]: "Boolean", - [FieldType.ATTACHMENT]: "AppleFiles", - [FieldType.LINK]: "DataCorrelated", - [FieldType.FORMULA]: "Calculator", - [FieldType.JSON]: "Brackets", - [FieldType.BIGINT]: "TagBold", - [FieldType.BB_REFERENCE]: { - [FieldTypeSubtypes.BB_REFERENCE.USER]: "User", - [FieldTypeSubtypes.BB_REFERENCE.USERS]: "UserGroup", - }, -} - export const getColumnIcon = column => { if (column.schema.autocolumn) { return "MagicWand" diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index 68da439195..a05a0eeb7f 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -4,6 +4,7 @@ export { OperatorOptions, SqlNumberTypeRangeMap } from "@budibase/shared-core" export { Feature as Features } from "@budibase/types" import { BpmCorrelationKey } from "@budibase/shared-core" +import { FieldType, FieldTypeSubtypes } from "@budibase/types" // Cookie names export const Cookies = { @@ -113,3 +114,25 @@ export const ContextScopes = { Local: "local", Global: "global", } + +export const TypeIconMap = { + [FieldType.STRING]: "Text", + [FieldType.OPTIONS]: "Dropdown", + [FieldType.DATETIME]: "Date", + [FieldType.BARCODEQR]: "Camera", + [FieldType.LONGFORM]: "TextAlignLeft", + [FieldType.ARRAY]: "Dropdown", + [FieldType.NUMBER]: "123", + [FieldType.BOOLEAN]: "Boolean", + [FieldType.ATTACHMENT]: "AppleFiles", + [FieldType.LINK]: "DataCorrelated", + [FieldType.FORMULA]: "Calculator", + [FieldType.JSON]: "Brackets", + [FieldType.BIGINT]: "TagBold", + [FieldType.USER]: "User", + [FieldType.USERS]: "UserGroup", + [FieldType.BB_REFERENCE]: { + [FieldTypeSubtypes.BB_REFERENCE.USER]: "User", + [FieldTypeSubtypes.BB_REFERENCE.USERS]: "UserGroup", + }, +} From d821d04d5ba54c8311cd8bfad296e737840bd089 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:01:41 +0200 Subject: [PATCH 24/32] Change icon --- packages/frontend-core/src/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index a05a0eeb7f..de1f906ba9 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -121,7 +121,7 @@ export const TypeIconMap = { [FieldType.DATETIME]: "Date", [FieldType.BARCODEQR]: "Camera", [FieldType.LONGFORM]: "TextAlignLeft", - [FieldType.ARRAY]: "Dropdown", + [FieldType.ARRAY]: "Duplicate", [FieldType.NUMBER]: "123", [FieldType.BOOLEAN]: "Boolean", [FieldType.ATTACHMENT]: "AppleFiles", From 5cdbc75fef1dce318f6f15a88dd5ab13ad2de8b6 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:03:46 +0200 Subject: [PATCH 25/32] Change icon --- packages/frontend-core/src/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index de1f906ba9..94e1dce237 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -118,7 +118,7 @@ export const ContextScopes = { export const TypeIconMap = { [FieldType.STRING]: "Text", [FieldType.OPTIONS]: "Dropdown", - [FieldType.DATETIME]: "Date", + [FieldType.DATETIME]: "Calendar", [FieldType.BARCODEQR]: "Camera", [FieldType.LONGFORM]: "TextAlignLeft", [FieldType.ARRAY]: "Duplicate", From 61e235767dc2af88f6fdcb99a33a595f2c3c95c8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:06:53 +0200 Subject: [PATCH 26/32] Add auto icon --- packages/frontend-core/src/constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index 94e1dce237..79b35bfb8e 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -129,6 +129,7 @@ export const TypeIconMap = { [FieldType.FORMULA]: "Calculator", [FieldType.JSON]: "Brackets", [FieldType.BIGINT]: "TagBold", + [FieldType.AUTO]: "MagicWand", [FieldType.USER]: "User", [FieldType.USERS]: "UserGroup", [FieldType.BB_REFERENCE]: { From 2322e430c47c484ec3abf7be04a846a6e6c5cf8f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:26:22 +0200 Subject: [PATCH 27/32] Lint --- packages/builder/src/constants/backend/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index e4736892b9..773e095f88 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -6,6 +6,7 @@ import { Hosting, } from "@budibase/types" import { Constants } from "@budibase/frontend-core" + const { TypeIconMap } = Constants export { RelationshipType } from "@budibase/types" From bc0b42bda6308d271cf426da057452e7da0b405a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:35:31 +0200 Subject: [PATCH 28/32] Fix test --- .../src/stores/builder/tests/sortedIntegrations.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/stores/builder/tests/sortedIntegrations.test.js b/packages/builder/src/stores/builder/tests/sortedIntegrations.test.js index 9b430b1621..d57aa19148 100644 --- a/packages/builder/src/stores/builder/tests/sortedIntegrations.test.js +++ b/packages/builder/src/stores/builder/tests/sortedIntegrations.test.js @@ -6,7 +6,10 @@ import { derived } from "svelte/store" import { integrations } from "stores/builder/integrations" vi.mock("svelte/store", () => ({ - derived: vi.fn(() => {}), + derived: vi.fn(), + writable: vi.fn(() => ({ + subscribe: vi.fn(), + })), })) vi.mock("stores/builder/integrations", () => ({ integrations: vi.fn() })) From 8483bdf0f78fbcb3de9404b642314b495c8f519c Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Wed, 10 Apr 2024 11:50:27 +0100 Subject: [PATCH 29/32] Add number and date tests. --- .../src/api/routes/tests/search.spec.ts | 224 ++++++++++++++++-- 1 file changed, 208 insertions(+), 16 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 2b08f9afc1..f5d107d0de 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -2,7 +2,13 @@ import { tableForDatasource } from "../../../tests/utilities/structures" import { DatabaseName, getDatasource } from "../../../integrations/tests/utils" import * as setup from "./utilities" -import { Datasource, FieldType, SearchFilters, Table } from "@budibase/types" +import { + Datasource, + EmptyFilterOption, + FieldType, + SearchFilters, + Table, +} from "@budibase/types" jest.unmock("mssql") @@ -40,20 +46,20 @@ describe.each([ } }) - beforeEach(async () => { - table = await config.api.table.save( - tableForDatasource(datasource, { - schema: { - name: { - name: "name", - type: FieldType.STRING, - }, - }, - }) - ) - }) - describe("strings", () => { + beforeEach(async () => { + table = await config.api.table.save( + tableForDatasource(datasource, { + schema: { + name: { + name: "name", + type: FieldType.STRING, + }, + }, + }) + ) + }) + const rows = [{ name: "foo" }, { name: "bar" }] interface StringSearchTest { @@ -63,7 +69,16 @@ describe.each([ const stringSearchTests: StringSearchTest[] = [ { query: {}, expected: rows }, + { + query: { onEmptyFilter: EmptyFilterOption.RETURN_ALL }, + expected: rows, + }, + { + query: { onEmptyFilter: EmptyFilterOption.RETURN_NONE }, + expected: [], + }, { query: { string: { name: "foo" } }, expected: [rows[0]] }, + { query: { string: { name: "none" } }, expected: [] }, { query: { fuzzy: { name: "oo" } }, expected: [rows[0]] }, { query: { equal: { name: "foo" } }, expected: [rows[0]] }, { query: { notEqual: { name: "foo" } }, expected: [rows[1]] }, @@ -76,13 +91,190 @@ describe.each([ it.each(stringSearchTests)( `should be able to run query: $query`, async ({ query, expected }) => { - await Promise.all(rows.map(r => config.api.row.save(table._id!, r))) + const savedRows = await Promise.all( + rows.map(r => config.api.row.save(table._id!, r)) + ) const { rows: foundRows } = await config.api.row.search(table._id!, { tableId: table._id!, query, }) expect(foundRows).toEqual( - expect.arrayContaining(expected.map(r => expect.objectContaining(r))) + expect.arrayContaining( + expected.map(r => + expect.objectContaining(savedRows.find(sr => sr.name === r.name)!) + ) + ) + ) + } + ) + }) + + describe("number", () => { + beforeEach(async () => { + table = await config.api.table.save( + tableForDatasource(datasource, { + schema: { + age: { + name: "age", + type: FieldType.NUMBER, + }, + }, + }) + ) + }) + + const rows = [{ age: 1 }, { age: 10 }] + + interface NumberSearchTest { + query: SearchFilters + expected: (typeof rows)[number][] + } + + const numberSearchTests: NumberSearchTest[] = [ + { query: {}, expected: rows }, + { + query: { onEmptyFilter: EmptyFilterOption.RETURN_ALL }, + expected: rows, + }, + { + query: { onEmptyFilter: EmptyFilterOption.RETURN_NONE }, + expected: [], + }, + { query: { equal: { age: 1 } }, expected: [rows[0]] }, + { query: { equal: { age: 2 } }, expected: [] }, + { query: { notEqual: { age: 1 } }, expected: [rows[1]] }, + { query: { oneOf: { age: [1] } }, expected: [rows[0]] }, + { query: { range: { age: { low: 1, high: 5 } } }, expected: [rows[0]] }, + { query: { range: { age: { low: 0, high: 1 } } }, expected: [rows[0]] }, + { query: { range: { age: { low: 3, high: 4 } } }, expected: [] }, + { query: { range: { age: { low: 0, high: 11 } } }, expected: rows }, + ] + + it.each(numberSearchTests)( + `should be able to run query: $query`, + async ({ query, expected }) => { + const savedRows = await Promise.all( + rows.map(r => config.api.row.save(table._id!, r)) + ) + const { rows: foundRows } = await config.api.row.search(table._id!, { + tableId: table._id!, + query, + }) + expect(foundRows).toEqual( + expect.arrayContaining( + expected.map(r => + expect.objectContaining(savedRows.find(sr => sr.age === r.age)!) + ) + ) + ) + } + ) + }) + + describe("dates", () => { + beforeEach(async () => { + table = await config.api.table.save( + tableForDatasource(datasource, { + schema: { + dob: { + name: "dob", + type: FieldType.DATETIME, + }, + }, + }) + ) + }) + + const rows = [ + { dob: new Date("2020-01-01") }, + { dob: new Date("2020-01-10") }, + ] + + interface DateSearchTest { + query: SearchFilters + expected: (typeof rows)[number][] + } + + const dateSearchTests: DateSearchTest[] = [ + { query: {}, expected: rows }, + { + query: { onEmptyFilter: EmptyFilterOption.RETURN_ALL }, + expected: rows, + }, + { + query: { onEmptyFilter: EmptyFilterOption.RETURN_NONE }, + expected: [], + }, + { + query: { equal: { dob: new Date("2020-01-01") } }, + expected: [rows[0]], + }, + { query: { equal: { dob: new Date("2020-01-02") } }, expected: [] }, + { + query: { notEqual: { dob: new Date("2020-01-01") } }, + expected: [rows[1]], + }, + { + query: { oneOf: { dob: [new Date("2020-01-01")] } }, + expected: [rows[0]], + }, + { + query: { + range: { + dob: { + low: new Date("2020-01-01").toISOString(), + high: new Date("2020-01-05").toISOString(), + }, + }, + }, + expected: [rows[0]], + }, + { + query: { + range: { + dob: { + low: new Date("2020-01-01").toISOString(), + high: new Date("2020-01-10").toISOString(), + }, + }, + }, + expected: rows, + }, + { + query: { + range: { + dob: { + low: new Date("2020-01-05").toISOString(), + high: new Date("2020-01-10").toISOString(), + }, + }, + }, + expected: [rows[1]], + }, + ] + + it.each(dateSearchTests)( + `should be able to run query: $query`, + async ({ query, expected }) => { + // TODO(samwho): most of these work for SQS, but not all. Fix 'em. + if (isSqs) { + return + } + const savedRows = await Promise.all( + rows.map(r => config.api.row.save(table._id!, r)) + ) + const { rows: foundRows } = await config.api.row.search(table._id!, { + tableId: table._id!, + query, + }) + expect(foundRows).toEqual( + expect.arrayContaining( + expected.map(r => + expect.objectContaining( + savedRows.find(sr => sr.dob === r.dob.toISOString())! + ) + ) + ) ) } ) From 5a93f2b5421f9e0d558d110a78e59f9ef8a78b18 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 12:53:42 +0200 Subject: [PATCH 30/32] Change icons to attach --- packages/client/manifest.json | 2 +- packages/frontend-core/src/constants.js | 4 ++-- packages/frontend-core/src/utils/rows.js | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 7689907e3c..40abc7a9a0 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -4324,7 +4324,7 @@ }, "attachmentsinglefield": { "name": "Single Attachment", - "icon": "Document", + "icon": "Attach", "styles": ["size"], "requiredAncestors": ["form"], "editable": true, diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index e6860da52d..95228c3bdc 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -124,8 +124,8 @@ export const TypeIconMap = { [FieldType.ARRAY]: "Duplicate", [FieldType.NUMBER]: "123", [FieldType.BOOLEAN]: "Boolean", - [FieldType.ATTACHMENTS]: "AppleFiles", - [FieldType.ATTACHMENT_SINGLE]: "Document", + [FieldType.ATTACHMENTS]: "Attach", + [FieldType.ATTACHMENT_SINGLE]: "Attach", [FieldType.LINK]: "DataCorrelated", [FieldType.FORMULA]: "Calculator", [FieldType.JSON]: "Brackets", diff --git a/packages/frontend-core/src/utils/rows.js b/packages/frontend-core/src/utils/rows.js index ea43d63734..1fb26eabd5 100644 --- a/packages/frontend-core/src/utils/rows.js +++ b/packages/frontend-core/src/utils/rows.js @@ -21,6 +21,8 @@ const isBetterSample = (newValue, oldValue) => { } if ( newType === "object" && + Array.isArray(newValue) && + Array.isArray(oldValue) && Object.keys(newValue).length > Object.keys(oldValue).length ) { return true From 38f53020eb03a0c2107f067de3bd4c0dfa4c2b44 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 13:19:22 +0200 Subject: [PATCH 31/32] Revert check --- packages/frontend-core/src/utils/rows.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/frontend-core/src/utils/rows.js b/packages/frontend-core/src/utils/rows.js index 1fb26eabd5..ea43d63734 100644 --- a/packages/frontend-core/src/utils/rows.js +++ b/packages/frontend-core/src/utils/rows.js @@ -21,8 +21,6 @@ const isBetterSample = (newValue, oldValue) => { } if ( newType === "object" && - Array.isArray(newValue) && - Array.isArray(oldValue) && Object.keys(newValue).length > Object.keys(oldValue).length ) { return true From b707514deb62c07008ad3b65d53f390587e46554 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 10 Apr 2024 13:40:38 +0200 Subject: [PATCH 32/32] Update pro ref to fix flakiness --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index f8e8f87bd5..ef186d0024 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit f8e8f87bd52081e1303a5ae92c432ea5b38f3bb4 +Subproject commit ef186d00241f96037f9fd34d7a3826041977ab3a