Fix more types
This commit is contained in:
parent
6c328109b6
commit
1f1ebc82e5
|
@ -6,6 +6,8 @@ import * as setup from "./utilities"
|
|||
import { context, InternalTable, roles, tenancy } from "@budibase/backend-core"
|
||||
import { quotas } from "@budibase/pro"
|
||||
import {
|
||||
AutoFieldSubTypes,
|
||||
FieldSchema,
|
||||
FieldType,
|
||||
FieldTypeSubtypes,
|
||||
MonthlyQuotaName,
|
||||
|
@ -171,7 +173,7 @@ describe.each([
|
|||
"Row ID": {
|
||||
name: "Row ID",
|
||||
type: FieldType.NUMBER,
|
||||
subtype: "autoID",
|
||||
subtype: AutoFieldSubTypes.AUTO_ID,
|
||||
icon: "ri-magic-line",
|
||||
autocolumn: true,
|
||||
constraints: {
|
||||
|
@ -272,27 +274,27 @@ describe.each([
|
|||
|
||||
isInternal &&
|
||||
it("row values are coerced", async () => {
|
||||
const str = {
|
||||
const str: FieldSchema = {
|
||||
type: FieldType.STRING,
|
||||
name: "str",
|
||||
constraints: { type: "string", presence: false },
|
||||
}
|
||||
const attachment = {
|
||||
const attachment: FieldSchema = {
|
||||
type: FieldType.ATTACHMENT,
|
||||
name: "attachment",
|
||||
constraints: { type: "array", presence: false },
|
||||
}
|
||||
const bool = {
|
||||
const bool: FieldSchema = {
|
||||
type: FieldType.BOOLEAN,
|
||||
name: "boolean",
|
||||
constraints: { type: "boolean", presence: false },
|
||||
}
|
||||
const number = {
|
||||
const number: FieldSchema = {
|
||||
type: FieldType.NUMBER,
|
||||
name: "str",
|
||||
constraints: { type: "number", presence: false },
|
||||
}
|
||||
const datetime = {
|
||||
const datetime: FieldSchema = {
|
||||
type: FieldType.DATETIME,
|
||||
name: "datetime",
|
||||
constraints: {
|
||||
|
@ -301,7 +303,7 @@ describe.each([
|
|||
datetime: { earliest: "", latest: "" },
|
||||
},
|
||||
}
|
||||
const arrayField = {
|
||||
const arrayField: FieldSchema = {
|
||||
type: FieldType.ARRAY,
|
||||
constraints: {
|
||||
type: "array",
|
||||
|
@ -311,8 +313,7 @@ describe.each([
|
|||
name: "Sample Tags",
|
||||
sortable: false,
|
||||
}
|
||||
const optsField = {
|
||||
fieldName: "Sample Opts",
|
||||
const optsField: FieldSchema = {
|
||||
name: "Sample Opts",
|
||||
type: FieldType.OPTIONS,
|
||||
constraints: {
|
||||
|
@ -1534,7 +1535,7 @@ describe.each([
|
|||
describe.each([
|
||||
[
|
||||
"relationship fields",
|
||||
() => ({
|
||||
(): Record<string, FieldSchema> => ({
|
||||
user: {
|
||||
name: "user",
|
||||
relationshipType: RelationshipType.ONE_TO_MANY,
|
||||
|
@ -1563,19 +1564,19 @@ describe.each([
|
|||
],
|
||||
[
|
||||
"bb reference fields",
|
||||
() => ({
|
||||
(): Record<string, FieldSchema> => ({
|
||||
user: {
|
||||
name: "user",
|
||||
relationshipType: RelationshipType.ONE_TO_MANY,
|
||||
type: FieldType.BB_REFERENCE,
|
||||
subtype: FieldTypeSubtypes.BB_REFERENCE.USER,
|
||||
},
|
||||
} as any,
|
||||
users: {
|
||||
name: "users",
|
||||
type: FieldType.BB_REFERENCE,
|
||||
subtype: FieldTypeSubtypes.BB_REFERENCE.USER,
|
||||
relationshipType: RelationshipType.MANY_TO_MANY,
|
||||
},
|
||||
} as any,
|
||||
}),
|
||||
() => config.createUser(),
|
||||
(row: Row) => ({
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import { generator } from "@budibase/backend-core/tests"
|
||||
import { events, context } from "@budibase/backend-core"
|
||||
import { FieldType, Table, ViewCalculation } from "@budibase/types"
|
||||
import {
|
||||
FieldType,
|
||||
RelationshipType,
|
||||
Table,
|
||||
ViewCalculation,
|
||||
} from "@budibase/types"
|
||||
import { checkBuilderEndpoint } from "./utilities/TestFunctions"
|
||||
import * as setup from "./utilities"
|
||||
const { basicTable } = setup.structures
|
||||
|
@ -352,6 +357,7 @@ describe("/tables", () => {
|
|||
},
|
||||
TestTable: {
|
||||
type: FieldType.LINK,
|
||||
relationshipType: RelationshipType.ONE_TO_MANY,
|
||||
name: "TestTable",
|
||||
fieldName: "TestTable",
|
||||
tableId: testTable._id!,
|
||||
|
|
|
@ -111,7 +111,7 @@ describe("postgres integrations", () => {
|
|||
fieldName: oneToManyRelationshipInfo.fieldName,
|
||||
name: "oneToManyRelation",
|
||||
relationshipType: RelationshipType.ONE_TO_MANY,
|
||||
tableId: oneToManyRelationshipInfo.table._id,
|
||||
tableId: oneToManyRelationshipInfo.table._id!,
|
||||
main: true,
|
||||
},
|
||||
manyToOneRelation: {
|
||||
|
@ -122,7 +122,7 @@ describe("postgres integrations", () => {
|
|||
fieldName: manyToOneRelationshipInfo.fieldName,
|
||||
name: "manyToOneRelation",
|
||||
relationshipType: RelationshipType.MANY_TO_ONE,
|
||||
tableId: manyToOneRelationshipInfo.table._id,
|
||||
tableId: manyToOneRelationshipInfo.table._id!,
|
||||
main: true,
|
||||
},
|
||||
manyToManyRelation: {
|
||||
|
@ -133,7 +133,7 @@ describe("postgres integrations", () => {
|
|||
fieldName: manyToManyRelationshipInfo.fieldName,
|
||||
name: "manyToManyRelation",
|
||||
relationshipType: RelationshipType.MANY_TO_MANY,
|
||||
tableId: manyToManyRelationshipInfo.table._id,
|
||||
tableId: manyToManyRelationshipInfo.table._id!,
|
||||
main: true,
|
||||
},
|
||||
},
|
||||
|
@ -250,6 +250,7 @@ describe("postgres integrations", () => {
|
|||
id: {
|
||||
name: "id",
|
||||
type: FieldType.AUTO,
|
||||
autocolumn: true,
|
||||
},
|
||||
},
|
||||
sourceId: postgresDatasource._id,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { populateExternalTableSchemas } from "../validation"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import { Datasource, Table } from "@budibase/types"
|
||||
import { AutoReason, Datasource, Table } from "@budibase/types"
|
||||
import { isEqual } from "lodash"
|
||||
|
||||
const SCHEMA = {
|
||||
|
@ -109,7 +109,7 @@ describe("validation and update of external table schemas", () => {
|
|||
const response = populateExternalTableSchemas(cloneDeep(SCHEMA) as any)
|
||||
const foreignKey = getForeignKeyColumn(response)
|
||||
expect(foreignKey.autocolumn).toBe(true)
|
||||
expect(foreignKey.autoReason).toBe("foreign_key")
|
||||
expect(foreignKey.autoReason).toBe(AutoReason.FOREIGN_KEY)
|
||||
noOtherTableChanges(response)
|
||||
})
|
||||
|
||||
|
|
|
@ -24,14 +24,14 @@ interface BaseRelationshipFieldMetadata extends BaseFieldSchema {
|
|||
export interface ManyToManyRelationshipFieldMetadata
|
||||
extends BaseRelationshipFieldMetadata {
|
||||
relationshipType: RelationshipType.MANY_TO_MANY
|
||||
through: string
|
||||
throughFrom: string
|
||||
throughTo: string
|
||||
through?: string
|
||||
throughFrom?: string
|
||||
throughTo?: string
|
||||
}
|
||||
export interface OneToManyRelationshipFieldMetadata
|
||||
extends BaseRelationshipFieldMetadata {
|
||||
relationshipType: RelationshipType.ONE_TO_MANY
|
||||
foreignKey: string
|
||||
foreignKey?: string
|
||||
}
|
||||
export interface ManyToOneRelationshipFieldMetadata
|
||||
extends BaseRelationshipFieldMetadata {
|
||||
|
@ -46,7 +46,7 @@ export type RelationshipFieldMetadata =
|
|||
export interface AutoColumnFieldMetadata extends BaseFieldSchema {
|
||||
type: FieldType.AUTO
|
||||
autocolumn: true
|
||||
subtype: AutoFieldSubTypes
|
||||
subtype?: AutoFieldSubTypes
|
||||
lastID?: number
|
||||
// if the column was turned to an auto-column for SQL, explains why (primary, foreign etc)
|
||||
autoReason?: AutoReason
|
||||
|
@ -121,7 +121,7 @@ interface BaseFieldSchema extends UIFieldMetadata {
|
|||
subtype?: string
|
||||
}
|
||||
|
||||
interface OtherFieldMetadata extends BaseFieldSchema {
|
||||
export interface OtherFieldMetadata extends BaseFieldSchema {
|
||||
type: Exclude<
|
||||
FieldType,
|
||||
| FieldType.DATETIME
|
||||
|
|
Loading…
Reference in New Issue