Merge pull request #14254 from Budibase/chore/renames
Renaming some js objects
This commit is contained in:
commit
3c7ec1a2a2
|
@ -1,6 +1,6 @@
|
||||||
import {
|
import {
|
||||||
CONSTANT_EXTERNAL_ROW_COLS,
|
PROTECTED_EXTERNAL_COLUMNS,
|
||||||
CONSTANT_INTERNAL_ROW_COLS,
|
PROTECTED_INTERNAL_COLUMNS,
|
||||||
} from "@budibase/shared-core"
|
} from "@budibase/shared-core"
|
||||||
|
|
||||||
export function expectFunctionWasCalledTimesWith(
|
export function expectFunctionWasCalledTimesWith(
|
||||||
|
@ -14,7 +14,7 @@ export function expectFunctionWasCalledTimesWith(
|
||||||
}
|
}
|
||||||
|
|
||||||
export const expectAnyInternalColsAttributes: {
|
export const expectAnyInternalColsAttributes: {
|
||||||
[K in (typeof CONSTANT_INTERNAL_ROW_COLS)[number]]: any
|
[K in (typeof PROTECTED_INTERNAL_COLUMNS)[number]]: any
|
||||||
} = {
|
} = {
|
||||||
tableId: expect.anything(),
|
tableId: expect.anything(),
|
||||||
type: expect.anything(),
|
type: expect.anything(),
|
||||||
|
@ -25,7 +25,7 @@ export const expectAnyInternalColsAttributes: {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const expectAnyExternalColsAttributes: {
|
export const expectAnyExternalColsAttributes: {
|
||||||
[K in (typeof CONSTANT_EXTERNAL_ROW_COLS)[number]]: any
|
[K in (typeof PROTECTED_EXTERNAL_COLUMNS)[number]]: any
|
||||||
} = {
|
} = {
|
||||||
tableId: expect.anything(),
|
tableId: expect.anything(),
|
||||||
_id: expect.anything(),
|
_id: expect.anything(),
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
SWITCHABLE_TYPES,
|
SWITCHABLE_TYPES,
|
||||||
ValidColumnNameRegex,
|
ValidColumnNameRegex,
|
||||||
helpers,
|
helpers,
|
||||||
CONSTANT_INTERNAL_ROW_COLS,
|
PROTECTED_INTERNAL_COLUMNS,
|
||||||
CONSTANT_EXTERNAL_ROW_COLS,
|
PROTECTED_EXTERNAL_COLUMNS,
|
||||||
} from "@budibase/shared-core"
|
} from "@budibase/shared-core"
|
||||||
import { createEventDispatcher, getContext, onMount } from "svelte"
|
import { createEventDispatcher, getContext, onMount } from "svelte"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
@ -489,8 +489,8 @@
|
||||||
}
|
}
|
||||||
const newError = {}
|
const newError = {}
|
||||||
const prohibited = externalTable
|
const prohibited = externalTable
|
||||||
? CONSTANT_EXTERNAL_ROW_COLS
|
? PROTECTED_EXTERNAL_COLUMNS
|
||||||
: CONSTANT_INTERNAL_ROW_COLS
|
: PROTECTED_INTERNAL_COLUMNS
|
||||||
if (!externalTable && fieldInfo.name?.startsWith("_")) {
|
if (!externalTable && fieldInfo.name?.startsWith("_")) {
|
||||||
newError.name = `Column name cannot start with an underscore.`
|
newError.name = `Column name cannot start with an underscore.`
|
||||||
} else if (fieldInfo.name && !fieldInfo.name.match(ValidColumnNameRegex)) {
|
} else if (fieldInfo.name && !fieldInfo.name.match(ValidColumnNameRegex)) {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
// need to handle table name + field or just field, depending on if relationships used
|
// need to handle table name + field or just field, depending on if relationships used
|
||||||
import { FieldType, Row, Table } from "@budibase/types"
|
import { FieldType, Row, Table } from "@budibase/types"
|
||||||
import { helpers } from "@budibase/shared-core"
|
import { helpers, PROTECTED_INTERNAL_COLUMNS } from "@budibase/shared-core"
|
||||||
import { generateRowIdField } from "../../../../integrations/utils"
|
import { generateRowIdField } from "../../../../integrations/utils"
|
||||||
import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils"
|
|
||||||
|
|
||||||
function extractFieldValue({
|
function extractFieldValue({
|
||||||
row,
|
row,
|
||||||
|
@ -94,7 +93,7 @@ export function basicProcessing({
|
||||||
thisRow._rev = "rev"
|
thisRow._rev = "rev"
|
||||||
} else {
|
} else {
|
||||||
const columns = Object.keys(table.schema)
|
const columns = Object.keys(table.schema)
|
||||||
for (let internalColumn of [...CONSTANT_INTERNAL_ROW_COLS, ...columns]) {
|
for (let internalColumn of [...PROTECTED_INTERNAL_COLUMNS, ...columns]) {
|
||||||
thisRow[internalColumn] = extractFieldValue({
|
thisRow[internalColumn] = extractFieldValue({
|
||||||
row,
|
row,
|
||||||
tableName: table._id!,
|
tableName: table._id!,
|
||||||
|
|
|
@ -57,14 +57,6 @@ export const getUserMetadataParams = dbCore.getUserMetadataParams
|
||||||
export const generateUserMetadataID = dbCore.generateUserMetadataID
|
export const generateUserMetadataID = dbCore.generateUserMetadataID
|
||||||
export const getGlobalIDFromUserMetadataID =
|
export const getGlobalIDFromUserMetadataID =
|
||||||
dbCore.getGlobalIDFromUserMetadataID
|
dbCore.getGlobalIDFromUserMetadataID
|
||||||
export const CONSTANT_INTERNAL_ROW_COLS = [
|
|
||||||
"_id",
|
|
||||||
"_rev",
|
|
||||||
"type",
|
|
||||||
"createdAt",
|
|
||||||
"updatedAt",
|
|
||||||
"tableId",
|
|
||||||
]
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets parameters for retrieving tables, this is a utility function for the getDocParams function.
|
* Gets parameters for retrieving tables, this is a utility function for the getDocParams function.
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {
|
||||||
breakExternalTableId,
|
breakExternalTableId,
|
||||||
breakRowIdField,
|
breakRowIdField,
|
||||||
} from "../../../../integrations/utils"
|
} from "../../../../integrations/utils"
|
||||||
import { utils, CONSTANT_EXTERNAL_ROW_COLS } from "@budibase/shared-core"
|
import { utils, PROTECTED_EXTERNAL_COLUMNS } from "@budibase/shared-core"
|
||||||
import { ExportRowsParams, ExportRowsResult } from "./types"
|
import { ExportRowsParams, ExportRowsResult } from "./types"
|
||||||
import { HTTPError } from "@budibase/backend-core"
|
import { HTTPError } from "@budibase/backend-core"
|
||||||
import pick from "lodash/pick"
|
import pick from "lodash/pick"
|
||||||
|
@ -99,7 +99,7 @@ export async function search(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.fields) {
|
if (options.fields) {
|
||||||
const fields = [...options.fields, ...CONSTANT_EXTERNAL_ROW_COLS]
|
const fields = [...options.fields, ...PROTECTED_EXTERNAL_COLUMNS]
|
||||||
rows = rows.map((r: any) => pick(r, fields))
|
rows = rows.map((r: any) => pick(r, fields))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { context, HTTPError } from "@budibase/backend-core"
|
import { context, HTTPError } from "@budibase/backend-core"
|
||||||
import { CONSTANT_INTERNAL_ROW_COLS } from "@budibase/shared-core"
|
import { PROTECTED_INTERNAL_COLUMNS } from "@budibase/shared-core"
|
||||||
import env from "../../../../environment"
|
import env from "../../../../environment"
|
||||||
import { fullSearch, paginatedSearch } from "./utils"
|
import { fullSearch, paginatedSearch } from "./utils"
|
||||||
import { getRowParams, InternalTables } from "../../../../db/utils"
|
import { getRowParams, InternalTables } from "../../../../db/utils"
|
||||||
|
@ -75,7 +75,7 @@ export async function search(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.fields) {
|
if (options.fields) {
|
||||||
const fields = [...options.fields, ...CONSTANT_INTERNAL_ROW_COLS]
|
const fields = [...options.fields, ...PROTECTED_INTERNAL_COLUMNS]
|
||||||
response.rows = response.rows.map((r: any) => pick(r, fields))
|
response.rows = response.rows.map((r: any) => pick(r, fields))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,7 @@ import {
|
||||||
SQLITE_DESIGN_DOC_ID,
|
SQLITE_DESIGN_DOC_ID,
|
||||||
SQS_DATASOURCE_INTERNAL,
|
SQS_DATASOURCE_INTERNAL,
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import {
|
import { generateJunctionTableID } from "../../../../db/utils"
|
||||||
CONSTANT_INTERNAL_ROW_COLS,
|
|
||||||
generateJunctionTableID,
|
|
||||||
} from "../../../../db/utils"
|
|
||||||
import AliasTables from "../sqlAlias"
|
import AliasTables from "../sqlAlias"
|
||||||
import { outputProcessing } from "../../../../utilities/rowProcessor"
|
import { outputProcessing } from "../../../../utilities/rowProcessor"
|
||||||
import pick from "lodash/pick"
|
import pick from "lodash/pick"
|
||||||
|
@ -44,7 +41,7 @@ import {
|
||||||
getRelationshipColumns,
|
getRelationshipColumns,
|
||||||
getTableIDList,
|
getTableIDList,
|
||||||
} from "./filters"
|
} from "./filters"
|
||||||
import { dataFilters } from "@budibase/shared-core"
|
import { dataFilters, PROTECTED_INTERNAL_COLUMNS } from "@budibase/shared-core"
|
||||||
|
|
||||||
const builder = new sql.Sql(SqlClient.SQL_LITE)
|
const builder = new sql.Sql(SqlClient.SQL_LITE)
|
||||||
const MISSING_COLUMN_REGEX = new RegExp(`no such column: .+`)
|
const MISSING_COLUMN_REGEX = new RegExp(`no such column: .+`)
|
||||||
|
@ -65,7 +62,7 @@ function buildInternalFieldList(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fieldList = fieldList.concat(
|
fieldList = fieldList.concat(
|
||||||
CONSTANT_INTERNAL_ROW_COLS.map(col => `${table._id}.${col}`)
|
PROTECTED_INTERNAL_COLUMNS.map(col => `${table._id}.${col}`)
|
||||||
)
|
)
|
||||||
for (let col of Object.values(table.schema)) {
|
for (let col of Object.values(table.schema)) {
|
||||||
const isRelationship = col.type === FieldType.LINK
|
const isRelationship = col.type === FieldType.LINK
|
||||||
|
@ -355,7 +352,7 @@ export async function search(
|
||||||
|
|
||||||
// check if we need to pick specific rows out
|
// check if we need to pick specific rows out
|
||||||
if (options.fields) {
|
if (options.fields) {
|
||||||
const fields = [...options.fields, ...CONSTANT_INTERNAL_ROW_COLS]
|
const fields = [...options.fields, ...PROTECTED_INTERNAL_COLUMNS]
|
||||||
finalRows = finalRows.map((r: any) => pick(r, fields))
|
finalRows = finalRows.map((r: any) => pick(r, fields))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,10 @@ import {
|
||||||
Table,
|
Table,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import tablesSdk from "../"
|
import tablesSdk from "../"
|
||||||
import {
|
import { generateJunctionTableID } from "../../../../db/utils"
|
||||||
CONSTANT_INTERNAL_ROW_COLS,
|
|
||||||
generateJunctionTableID,
|
|
||||||
} from "../../../../db/utils"
|
|
||||||
import { isEqual } from "lodash"
|
import { isEqual } from "lodash"
|
||||||
import { DEFAULT_TABLES } from "../../../../db/defaultData/datasource_bb_default"
|
import { DEFAULT_TABLES } from "../../../../db/defaultData/datasource_bb_default"
|
||||||
|
import { PROTECTED_INTERNAL_COLUMNS } from "@budibase/shared-core"
|
||||||
|
|
||||||
const FieldTypeMap: Record<FieldType, SQLiteType> = {
|
const FieldTypeMap: Record<FieldType, SQLiteType> = {
|
||||||
[FieldType.BOOLEAN]: SQLiteType.NUMERIC,
|
[FieldType.BOOLEAN]: SQLiteType.NUMERIC,
|
||||||
|
@ -122,7 +120,7 @@ function mapTable(table: Table): SQLiteTables {
|
||||||
}
|
}
|
||||||
// there are some extra columns to map - add these in
|
// there are some extra columns to map - add these in
|
||||||
const constantMap: Record<string, SQLiteType> = {}
|
const constantMap: Record<string, SQLiteType> = {}
|
||||||
CONSTANT_INTERNAL_ROW_COLS.forEach(col => {
|
PROTECTED_INTERNAL_COLUMNS.forEach(col => {
|
||||||
constantMap[col] = SQLiteType.TEXT
|
constantMap[col] = SQLiteType.TEXT
|
||||||
})
|
})
|
||||||
const thisTable: SQLiteTable = {
|
const thisTable: SQLiteTable = {
|
||||||
|
|
|
@ -10,8 +10,8 @@ import { HTTPError } from "@budibase/backend-core"
|
||||||
import { features } from "@budibase/pro"
|
import { features } from "@budibase/pro"
|
||||||
import {
|
import {
|
||||||
helpers,
|
helpers,
|
||||||
CONSTANT_EXTERNAL_ROW_COLS,
|
PROTECTED_EXTERNAL_COLUMNS,
|
||||||
CONSTANT_INTERNAL_ROW_COLS,
|
PROTECTED_INTERNAL_COLUMNS,
|
||||||
} from "@budibase/shared-core"
|
} from "@budibase/shared-core"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
|
||||||
|
@ -148,8 +148,8 @@ export function allowedFields(view: View | ViewV2) {
|
||||||
const fieldSchema = view.schema![key]
|
const fieldSchema = view.schema![key]
|
||||||
return fieldSchema.visible && !fieldSchema.readonly
|
return fieldSchema.visible && !fieldSchema.readonly
|
||||||
}),
|
}),
|
||||||
...CONSTANT_EXTERNAL_ROW_COLS,
|
...PROTECTED_EXTERNAL_COLUMNS,
|
||||||
...CONSTANT_INTERNAL_ROW_COLS,
|
...PROTECTED_INTERNAL_COLUMNS,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export const CONSTANT_INTERNAL_ROW_COLS = [
|
export const PROTECTED_INTERNAL_COLUMNS = [
|
||||||
"_id",
|
"_id",
|
||||||
"_rev",
|
"_rev",
|
||||||
"type",
|
"type",
|
||||||
|
@ -7,8 +7,8 @@ export const CONSTANT_INTERNAL_ROW_COLS = [
|
||||||
"tableId",
|
"tableId",
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
export const CONSTANT_EXTERNAL_ROW_COLS = ["_id", "_rev", "tableId"] as const
|
export const PROTECTED_EXTERNAL_COLUMNS = ["_id", "_rev", "tableId"] as const
|
||||||
|
|
||||||
export function isInternalColumnName(name: string): boolean {
|
export function isInternalColumnName(name: string): boolean {
|
||||||
return (CONSTANT_INTERNAL_ROW_COLS as readonly string[]).includes(name)
|
return (PROTECTED_INTERNAL_COLUMNS as readonly string[]).includes(name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { FieldType, Table } from "@budibase/types"
|
import { FieldType, Table } from "@budibase/types"
|
||||||
import { CONSTANT_INTERNAL_ROW_COLS } from "./constants"
|
import { PROTECTED_INTERNAL_COLUMNS } from "./constants"
|
||||||
|
|
||||||
const allowDisplayColumnByType: Record<FieldType, boolean> = {
|
const allowDisplayColumnByType: Record<FieldType, boolean> = {
|
||||||
[FieldType.STRING]: true,
|
[FieldType.STRING]: true,
|
||||||
|
@ -73,7 +73,7 @@ export function findDuplicateInternalColumns(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!opts?.ignoreProtectedColumnNames) {
|
if (!opts?.ignoreProtectedColumnNames) {
|
||||||
for (let internalColumn of CONSTANT_INTERNAL_ROW_COLS) {
|
for (let internalColumn of PROTECTED_INTERNAL_COLUMNS) {
|
||||||
if (casedKeys.find(key => key === internalColumn)) {
|
if (casedKeys.find(key => key === internalColumn)) {
|
||||||
duplicates.push(internalColumn)
|
duplicates.push(internalColumn)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue