1
0
Fork 0
mirror of synced 2024-09-30 17:18:14 +13:00

Undo type changes

This commit is contained in:
Adria Navarro 2024-03-20 23:16:41 +01:00
parent 0827cc6bda
commit 4def299172

View file

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