Undo type changes

This commit is contained in:
Adria Navarro 2024-03-20 23:16:41 +01:00
parent 0827cc6bda
commit 4def299172
1 changed files with 24 additions and 18 deletions

View File

@ -17,14 +17,13 @@ export interface UIFieldMetadata {
}
interface BaseRelationshipFieldMetadata
extends BaseFieldSchema<
AutoFieldSubType.CREATED_BY | AutoFieldSubType.UPDATED_BY | undefined
> {
extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.LINK
main?: boolean
fieldName: string
tableId: string
tableRev?: string
subtype?: AutoFieldSubType.CREATED_BY | AutoFieldSubType.UPDATED_BY
}
// External tables use junction tables, internal tables don't require them
@ -61,17 +60,18 @@ export type RelationshipFieldMetadata =
| ManyToOneRelationshipFieldMetadata
export interface AutoColumnFieldMetadata
extends BaseFieldSchema<AutoFieldSubType | undefined> {
extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.AUTO
autocolumn: true
subtype?: AutoFieldSubType
lastID?: number
// if the column was turned to an auto-column for SQL, explains why (primary, foreign etc)
autoReason?: AutoReason
}
export interface NumberFieldMetadata
extends BaseFieldSchema<AutoFieldSubType.AUTO_ID | undefined> {
export interface NumberFieldMetadata extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.NUMBER
subtype?: AutoFieldSubType.AUTO_ID
lastID?: number
autoReason?: AutoReason.FOREIGN_KEY
// used specifically when Budibase generates external tables, this denotes if a number field
@ -82,18 +82,16 @@ export interface NumberFieldMetadata
}
}
export interface JsonFieldMetadata
extends BaseFieldSchema<JsonFieldSubType.ARRAY | undefined> {
export interface JsonFieldMetadata extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.JSON
subtype?: JsonFieldSubType.ARRAY
}
export interface DateFieldMetadata
extends BaseFieldSchema<
AutoFieldSubType.CREATED_AT | AutoFieldSubType.UPDATED_AT | undefined
> {
export interface DateFieldMetadata extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.DATETIME
ignoreTimezones?: boolean
timeOnly?: boolean
subtype?: AutoFieldSubType.CREATED_AT | AutoFieldSubType.UPDATED_AT
}
export interface LongFormFieldMetadata extends BaseFieldSchema {
@ -108,15 +106,16 @@ export interface FormulaFieldMetadata extends BaseFieldSchema {
}
export interface BBReferenceFieldMetadata
extends BaseFieldSchema<FieldSubtype.USER | FieldSubtype.USERS> {
extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.BB_REFERENCE
subtype: FieldSubtype.USER | FieldSubtype.USERS
relationshipType?: RelationshipType
}
export interface AttachmentFieldMetadata
extends BaseFieldSchema<FieldSubtype.SINGLE | undefined> {
extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.ATTACHMENT
subtype?: FieldSubtype.SINGLE
}
export interface FieldConstraints {
@ -143,7 +142,7 @@ export interface FieldConstraints {
}
}
interface BaseFieldSchema<TSubtype = never> extends UIFieldMetadata {
interface BaseFieldSchema extends UIFieldMetadata {
type: FieldType
name: string
sortable?: boolean
@ -152,7 +151,7 @@ interface BaseFieldSchema<TSubtype = never> extends UIFieldMetadata {
constraints?: FieldConstraints
autocolumn?: boolean
autoReason?: AutoReason.FOREIGN_KEY
subtype: TSubtype
subtype?: never
}
interface OtherFieldMetadata extends BaseFieldSchema {
@ -164,6 +163,7 @@ interface OtherFieldMetadata extends BaseFieldSchema {
| FieldType.FORMULA
| FieldType.NUMBER
| FieldType.LONGFORM
| FieldType.BB_REFERENCE
| FieldType.ATTACHMENT
>
}
@ -176,9 +176,9 @@ export type FieldSchema =
| FormulaFieldMetadata
| NumberFieldMetadata
| LongFormFieldMetadata
| AttachmentFieldMetadata
| BBReferenceFieldMetadata
| JsonFieldMetadata
| AttachmentFieldMetadata
export interface TableSchema {
[key: string]: FieldSchema
@ -213,3 +213,9 @@ export function isBBReferenceField(
): field is BBReferenceFieldMetadata {
return field.type === FieldType.BB_REFERENCE
}
export function isAttachmentField(
field: FieldSchema
): field is AttachmentFieldMetadata {
return field.type === FieldType.ATTACHMENT
}