feat: refactor schema builder and resolver builder (#2215)

* feat: wip refactor schema builder

* feat: wip store types and first queries generation

* feat: refactor schema-builder and resolver-builder

* fix: clean & small type fix

* fix: avoid breaking change

* fix: remove util from pg-graphql classes

* fix: required default fields

* Refactor frontend accordingly

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Jérémy M
2023-11-03 17:16:37 +01:00
committed by GitHub
parent aba3fd454b
commit 1ed4965a95
216 changed files with 3215 additions and 2028 deletions

View File

@@ -174,7 +174,7 @@ export type CreateFieldInput = {
label: Scalars['String']['input']; label: Scalars['String']['input'];
name: Scalars['String']['input']; name: Scalars['String']['input'];
objectId: Scalars['String']['input']; objectId: Scalars['String']['input'];
type: Scalars['String']['input']; type: FieldMetadataType;
}; };
export type CreateObjectInput = { export type CreateObjectInput = {
@@ -424,10 +424,24 @@ export type FieldDeleteResponse = {
name?: Maybe<Scalars['String']['output']>; name?: Maybe<Scalars['String']['output']>;
/** @deprecated Use label name instead */ /** @deprecated Use label name instead */
placeholder?: Maybe<Scalars['String']['output']>; placeholder?: Maybe<Scalars['String']['output']>;
type?: Maybe<Scalars['String']['output']>; type?: Maybe<FieldMetadataType>;
updatedAt?: Maybe<Scalars['DateTime']['output']>; updatedAt?: Maybe<Scalars['DateTime']['output']>;
}; };
/** Type of the field */
export enum FieldMetadataType {
Boolean = 'BOOLEAN',
Date = 'DATE',
Email = 'EMAIL',
Enum = 'ENUM',
Money = 'MONEY',
Number = 'NUMBER',
Phone = 'PHONE',
Text = 'TEXT',
Url = 'URL',
Uuid = 'UUID'
}
export type Mutation = { export type Mutation = {
__typename?: 'Mutation'; __typename?: 'Mutation';
createOneField: Field; createOneField: Field;
@@ -764,7 +778,7 @@ export type Field = {
name: Scalars['String']['output']; name: Scalars['String']['output'];
/** @deprecated Use label name instead */ /** @deprecated Use label name instead */
placeholder?: Maybe<Scalars['String']['output']>; placeholder?: Maybe<Scalars['String']['output']>;
type: Scalars['String']['output']; type: FieldMetadataType;
updatedAt: Scalars['DateTime']['output']; updatedAt: Scalars['DateTime']['output'];
}; };
@@ -818,7 +832,7 @@ export type CreateOneMetadataFieldMutationVariables = Exact<{
}>; }>;
export type CreateOneMetadataFieldMutation = { __typename?: 'Mutation', createOneField: { __typename?: 'field', id: string, type: string, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } }; export type CreateOneMetadataFieldMutation = { __typename?: 'Mutation', createOneField: { __typename?: 'field', id: string, type: FieldMetadataType, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } };
export type UpdateOneMetadataFieldMutationVariables = Exact<{ export type UpdateOneMetadataFieldMutationVariables = Exact<{
idToUpdate: Scalars['ID']['input']; idToUpdate: Scalars['ID']['input'];
@@ -826,7 +840,7 @@ export type UpdateOneMetadataFieldMutationVariables = Exact<{
}>; }>;
export type UpdateOneMetadataFieldMutation = { __typename?: 'Mutation', updateOneField: { __typename?: 'field', id: string, type: string, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } }; export type UpdateOneMetadataFieldMutation = { __typename?: 'Mutation', updateOneField: { __typename?: 'field', id: string, type: FieldMetadataType, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } };
export type UpdateOneObjectMetadataItemMutationVariables = Exact<{ export type UpdateOneObjectMetadataItemMutationVariables = Exact<{
idToUpdate: Scalars['ID']['input']; idToUpdate: Scalars['ID']['input'];
@@ -848,12 +862,12 @@ export type DeleteOneMetadataFieldMutationVariables = Exact<{
}>; }>;
export type DeleteOneMetadataFieldMutation = { __typename?: 'Mutation', deleteOneField: { __typename?: 'FieldDeleteResponse', id?: string | null, type?: string | null, name?: string | null, label?: string | null, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom?: boolean | null, isActive?: boolean | null, isNullable?: boolean | null, createdAt?: any | null, updatedAt?: any | null } }; export type DeleteOneMetadataFieldMutation = { __typename?: 'Mutation', deleteOneField: { __typename?: 'FieldDeleteResponse', id?: string | null, type?: FieldMetadataType | null, name?: string | null, label?: string | null, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom?: boolean | null, isActive?: boolean | null, isNullable?: boolean | null, createdAt?: any | null, updatedAt?: any | null } };
export type ObjectMetadataItemsQueryVariables = Exact<{ [key: string]: never; }>; export type ObjectMetadataItemsQueryVariables = Exact<{ [key: string]: never; }>;
export type ObjectMetadataItemsQuery = { __typename?: 'Query', objects: { __typename?: 'ObjectConnection', totalCount: number, edges: Array<{ __typename?: 'objectEdge', node: { __typename?: 'object', id: string, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any, fields: { __typename?: 'ObjectFieldsConnection', totalCount: number, edges: Array<{ __typename?: 'fieldEdge', node: { __typename?: 'field', id: string, type: string, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } }; export type ObjectMetadataItemsQuery = { __typename?: 'Query', objects: { __typename?: 'ObjectConnection', totalCount: number, edges: Array<{ __typename?: 'objectEdge', node: { __typename?: 'object', id: string, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any, fields: { __typename?: 'ObjectFieldsConnection', totalCount: number, edges: Array<{ __typename?: 'fieldEdge', node: { __typename?: 'field', id: string, type: FieldMetadataType, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } };
export const CreateOneObjectMetadataItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneObjectMetadataItem"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateOneObjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneObject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<CreateOneObjectMetadataItemMutation, CreateOneObjectMetadataItemMutationVariables>; export const CreateOneObjectMetadataItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneObjectMetadataItem"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateOneObjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneObject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<CreateOneObjectMetadataItemMutation, CreateOneObjectMetadataItemMutationVariables>;

View File

@@ -1309,10 +1309,24 @@ export type FieldDeleteResponse = {
name?: Maybe<Scalars['String']>; name?: Maybe<Scalars['String']>;
/** @deprecated Use label name instead */ /** @deprecated Use label name instead */
placeholder?: Maybe<Scalars['String']>; placeholder?: Maybe<Scalars['String']>;
type?: Maybe<Scalars['String']>; type?: Maybe<FieldMetadataType>;
updatedAt?: Maybe<Scalars['DateTime']>; updatedAt?: Maybe<Scalars['DateTime']>;
}; };
/** Type of the field */
export enum FieldMetadataType {
Boolean = 'BOOLEAN',
Date = 'DATE',
Email = 'EMAIL',
Enum = 'ENUM',
Money = 'MONEY',
Number = 'NUMBER',
Phone = 'PHONE',
Text = 'TEXT',
Url = 'URL',
Uuid = 'UUID'
}
export enum FileFolder { export enum FileFolder {
Attachment = 'Attachment', Attachment = 'Attachment',
PersonPicture = 'PersonPicture', PersonPicture = 'PersonPicture',
@@ -1377,7 +1391,6 @@ export type Mutation = {
createOneApiKey: ApiKeyToken; createOneApiKey: ApiKeyToken;
createOneComment: Comment; createOneComment: Comment;
createOneCompany: Company; createOneCompany: Company;
createOneField: Field;
createOneObject: Object; createOneObject: Object;
createOnePerson: Person; createOnePerson: Person;
createOnePipelineProgress: PipelineProgress; createOnePipelineProgress: PipelineProgress;
@@ -1389,7 +1402,6 @@ export type Mutation = {
deleteManyCompany: AffectedRows; deleteManyCompany: AffectedRows;
deleteManyPerson: AffectedRows; deleteManyPerson: AffectedRows;
deleteManyPipelineProgress: AffectedRows; deleteManyPipelineProgress: AffectedRows;
deleteOneField: FieldDeleteResponse;
deleteOneObject: ObjectDeleteResponse; deleteOneObject: ObjectDeleteResponse;
deleteOnePipelineStage: PipelineStage; deleteOnePipelineStage: PipelineStage;
deleteOneWebHook: WebHook; deleteOneWebHook: WebHook;
@@ -1402,7 +1414,6 @@ export type Mutation = {
updateOneActivity: Activity; updateOneActivity: Activity;
updateOneCompany?: Maybe<Company>; updateOneCompany?: Maybe<Company>;
updateOneFavorites: Favorite; updateOneFavorites: Favorite;
updateOneField: Field;
updateOneObject: Object; updateOneObject: Object;
updateOnePerson?: Maybe<Person>; updateOnePerson?: Maybe<Person>;
updateOnePipelineProgress?: Maybe<PipelineProgress>; updateOnePipelineProgress?: Maybe<PipelineProgress>;
@@ -2393,8 +2404,6 @@ export type Query = {
clientConfig: ClientConfig; clientConfig: ClientConfig;
currentUser: User; currentUser: User;
currentWorkspace: Workspace; currentWorkspace: Workspace;
field: Field;
fields: FieldConnection;
findFavorites: Array<Favorite>; findFavorites: Array<Favorite>;
findManyActivities: Array<Activity>; findManyActivities: Array<Activity>;
findManyApiKey: Array<ApiKey>; findManyApiKey: Array<ApiKey>;
@@ -3093,7 +3102,7 @@ export type Field = {
name: Scalars['String']; name: Scalars['String'];
/** @deprecated Use label name instead */ /** @deprecated Use label name instead */
placeholder?: Maybe<Scalars['String']>; placeholder?: Maybe<Scalars['String']>;
type: Scalars['String']; type: FieldMetadataType;
updatedAt: Scalars['DateTime']; updatedAt: Scalars['DateTime'];
}; };

View File

@@ -26,7 +26,7 @@ export const ActivityAssigneeEditableField = ({
fieldId: 'assignee', fieldId: 'assignee',
label: 'Assignee', label: 'Assignee',
Icon: IconUserCircle, Icon: IconUserCircle,
type: 'relation', type: 'RELATION',
metadata: { metadata: {
fieldName: 'assignee', fieldName: 'assignee',
relationType: Entity.User, relationType: Entity.User,

View File

@@ -24,7 +24,7 @@ export const ActivityEditorDateField = ({
fieldId: 'activityDueAt', fieldId: 'activityDueAt',
label: 'Due date', label: 'Due date',
Icon: IconCalendar, Icon: IconCalendar,
type: 'date', type: 'DATE',
metadata: { metadata: {
fieldName: 'dueAt', fieldName: 'dueAt',
}, },

View File

@@ -23,7 +23,7 @@ export const useCurrentUserTaskCount = () => {
displayValue: currentUser.displayName, displayValue: currentUser.displayName,
displayAvatarUrl: currentUser.avatarUrl ?? undefined, displayAvatarUrl: currentUser.avatarUrl ?? undefined,
definition: { definition: {
type: 'entity', type: 'ENTITY',
}, },
}) })
: {}), : {}),

View File

@@ -33,7 +33,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconBuildingSkyscraper, Icon: IconBuildingSkyscraper,
size: 180, size: 180,
position: 0, position: 0,
type: 'chip', type: 'CHIP',
metadata: { metadata: {
urlFieldName: 'domainName', urlFieldName: 'domainName',
contentFieldName: 'name', contentFieldName: 'name',
@@ -50,7 +50,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconLink, Icon: IconLink,
size: 100, size: 100,
position: 1, position: 1,
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'domainName', fieldName: 'domainName',
placeHolder: 'example.com', placeHolder: 'example.com',
@@ -65,7 +65,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconUserCircle, Icon: IconUserCircle,
size: 150, size: 150,
position: 2, position: 2,
type: 'relation', type: 'RELATION',
metadata: { metadata: {
fieldName: 'accountOwner', fieldName: 'accountOwner',
relationType: Entity.User, relationType: Entity.User,
@@ -87,7 +87,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconCalendarEvent, Icon: IconCalendarEvent,
size: 150, size: 150,
position: 3, position: 3,
type: 'date', type: 'DATE',
metadata: { metadata: {
fieldName: 'createdAt', fieldName: 'createdAt',
}, },
@@ -100,7 +100,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconUsers, Icon: IconUsers,
size: 150, size: 150,
position: 4, position: 4,
type: 'number', type: 'NUMBER',
metadata: { metadata: {
fieldName: 'employees', fieldName: 'employees',
isPositive: true, isPositive: true,
@@ -115,7 +115,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconBrandLinkedin, Icon: IconBrandLinkedin,
size: 170, size: 170,
position: 5, position: 5,
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'linkedinUrl', fieldName: 'linkedinUrl',
placeHolder: 'LinkedIn URL', placeHolder: 'LinkedIn URL',
@@ -129,7 +129,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconMap, Icon: IconMap,
size: 170, size: 170,
position: 6, position: 6,
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'address', fieldName: 'address',
placeHolder: 'Address', // Hack: Fake character to prevent password-manager from filling the field placeHolder: 'Address', // Hack: Fake character to prevent password-manager from filling the field
@@ -143,7 +143,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconTarget, Icon: IconTarget,
size: 150, size: 150,
position: 7, position: 7,
type: 'boolean', type: 'BOOLEAN',
metadata: { metadata: {
fieldName: 'idealCustomerProfile', fieldName: 'idealCustomerProfile',
}, },
@@ -157,7 +157,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconMoneybag, Icon: IconMoneybag,
size: 150, size: 150,
position: 8, position: 8,
type: 'moneyAmount', type: 'MONEY_AMOUNT',
metadata: { metadata: {
fieldName: 'annualRecurringRevenue', fieldName: 'annualRecurringRevenue',
placeHolder: 'ARR', placeHolder: 'ARR',
@@ -171,7 +171,7 @@ export const companiesAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>
Icon: IconBrandX, Icon: IconBrandX,
size: 150, size: 150,
position: 9, position: 9,
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'xUrl', fieldName: 'xUrl',
placeHolder: 'X', placeHolder: 'X',
@@ -189,7 +189,7 @@ export const suppliersAvailableColumnDefinitions: ColumnDefinition<FieldMetadata
Icon: IconBuildingSkyscraper, Icon: IconBuildingSkyscraper,
size: 180, size: 180,
position: 0, position: 0,
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'name', fieldName: 'name',
placeHolder: 'Company Name', placeHolder: 'Company Name',
@@ -204,7 +204,7 @@ export const suppliersAvailableColumnDefinitions: ColumnDefinition<FieldMetadata
Icon: IconBuildingSkyscraper, Icon: IconBuildingSkyscraper,
size: 180, size: 180,
position: 0, position: 0,
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'city', fieldName: 'city',
placeHolder: 'Company Name', placeHolder: 'Company Name',

View File

@@ -2,6 +2,7 @@ import { ApolloClient, useMutation } from '@apollo/client';
import { getOperationName } from '@apollo/client/utilities'; import { getOperationName } from '@apollo/client/utilities';
import { FieldType } from '@/ui/object/field/types/FieldType'; import { FieldType } from '@/ui/object/field/types/FieldType';
import { FieldMetadataType } from '~/generated/graphql';
import { import {
CreateOneMetadataFieldMutation, CreateOneMetadataFieldMutation,
CreateOneMetadataFieldMutationVariables, CreateOneMetadataFieldMutationVariables,
@@ -12,10 +13,12 @@ import { FIND_MANY_METADATA_OBJECTS } from '../graphql/queries';
import { useApolloMetadataClient } from './useApolloMetadataClient'; import { useApolloMetadataClient } from './useApolloMetadataClient';
type CreateOneMetadataFieldArgs = type CreateOneMetadataFieldArgs = Omit<
CreateOneMetadataFieldMutationVariables['input']['field'] & { CreateOneMetadataFieldMutationVariables['input']['field'],
type: FieldType; 'type'
}; > & {
type: FieldType;
};
export const useCreateOneMetadataField = () => { export const useCreateOneMetadataField = () => {
const apolloMetadataClient = useApolloMetadataClient(); const apolloMetadataClient = useApolloMetadataClient();
@@ -33,6 +36,7 @@ export const useCreateOneMetadataField = () => {
input: { input: {
field: { field: {
...input, ...input,
type: input.type as FieldMetadataType, // Todo improve typing once we have aligned backend and frontend
}, },
}, },
}, },

View File

@@ -1,44 +0,0 @@
import { isNonEmptyArray } from '~/utils/isNonEmptyArray';
import { useCreateOneMetadataField } from './useCreateOneMetadataField';
import { useCreateOneObjectMetadataItem } from './useCreateOneObjectMetadataItem';
export const useSeedCustomObjectsTemp = () => {
const { createOneObjectMetadataItem } = useCreateOneObjectMetadataItem();
const { createOneMetadataField } = useCreateOneMetadataField();
return async () => {
const { data: createdObjectMetadataItem, errors } =
await createOneObjectMetadataItem({
labelPlural: 'Suppliers',
labelSingular: 'Supplier',
nameSingular: 'supplier',
namePlural: 'suppliers',
description: 'Suppliers',
icon: 'IconBuilding',
});
if (!isNonEmptyArray(errors)) {
const supplierObjectId =
createdObjectMetadataItem?.createOneObject?.id ?? '';
await createOneMetadataField({
objectId: supplierObjectId,
name: 'name',
type: 'text',
description: 'Name',
label: 'Name',
icon: 'IconBuilding',
});
await createOneMetadataField({
objectId: supplierObjectId,
label: 'City',
name: 'city',
type: 'text',
description: 'City',
icon: 'IconMap',
});
}
};
};

View File

@@ -12,5 +12,5 @@ export const formatMetadataFieldAsFilterDefinition = ({
fieldId: field.id, fieldId: field.id,
label: field.label, label: field.label,
Icon: icons[field.icon ?? 'Icon123'], Icon: icons[field.icon ?? 'Icon123'],
type: 'text', type: 'TEXT',
}); });

View File

@@ -13,7 +13,7 @@ export const generateCreateOneObjectMutation = ({
return gql` return gql`
mutation CreateOne${capitalizedObjectName}($input: ${capitalizedObjectName}CreateInput!) { mutation CreateOne${capitalizedObjectName}($input: ${capitalizedObjectName}CreateInput!) {
createOne${capitalizedObjectName}(data: $input) { create${capitalizedObjectName}(data: $input) {
id id
} }
} }

View File

@@ -13,7 +13,7 @@ export const generateDeleteOneObjectMutation = ({
return gql` return gql`
mutation DeleteOne${capitalizedObjectName}($idToDelete: ID!) { mutation DeleteOne${capitalizedObjectName}($idToDelete: ID!) {
deleteOne${capitalizedObjectName}(id: $idToDelete) { delete${capitalizedObjectName}(id: $idToDelete) {
id id
} }
} }

View File

@@ -18,7 +18,7 @@ export const generateFindManyCustomObjectsQuery = ({
objectMetadataItem.nameSingular, objectMetadataItem.nameSingular,
)}FilterInput, $orderBy: ${capitalize( )}FilterInput, $orderBy: ${capitalize(
objectMetadataItem.nameSingular, objectMetadataItem.nameSingular,
)}OrderBy) { )}OrderByInput) {
${objectMetadataItem.namePlural}(filter: $filter, orderBy: $orderBy){ ${objectMetadataItem.namePlural}(filter: $filter, orderBy: $orderBy){
edges { edges {
node { node {

View File

@@ -13,7 +13,7 @@ export const generateUpdateOneObjectMutation = ({
return gql` return gql`
mutation UpdateOne${capitalizedObjectName}($idToUpdate: ID!, $input: ${capitalizedObjectName}UpdateInput!) { mutation UpdateOne${capitalizedObjectName}($idToUpdate: ID!, $input: ${capitalizedObjectName}UpdateInput!) {
updateOne${capitalizedObjectName}(id: $idToUpdate, data: $input) { update${capitalizedObjectName}(id: $idToUpdate, data: $input) {
id id
} }
} }

View File

@@ -7,20 +7,20 @@ export const mapFieldMetadataToGraphQLQuery = (field: Field) => {
const fieldIsSimpleValue = ( const fieldIsSimpleValue = (
[ [
'text', 'TEXT',
'phone', 'PHONE',
'date', 'DATE',
'email', 'EMAIL',
'number', 'NUMBER',
'boolean', 'BOOLEAN',
'date', 'DATE',
] as FieldType[] ] as FieldType[]
).includes(fieldType); ).includes(fieldType);
const fieldIsURL = fieldType === 'url' || fieldType === 'urlV2'; const fieldIsURL = fieldType === 'URL' || fieldType === 'URL_V2';
const fieldIsMoneyAmount = const fieldIsMoneyAmount =
fieldType === 'money' || fieldType === 'moneyAmountV2'; fieldType === 'MONEY' || fieldType === 'MONEY_AMOUNT_V2';
if (fieldIsSimpleValue) { if (fieldIsSimpleValue) {
return field.name; return field.name;

View File

@@ -2,11 +2,11 @@ import { FieldType } from '@/ui/object/field/types/FieldType';
export const parseFieldType = (fieldType: string): FieldType => { export const parseFieldType = (fieldType: string): FieldType => {
if (fieldType === 'url') { if (fieldType === 'url') {
return 'urlV2'; return 'URL_V2';
} }
if (fieldType === 'money') { if (fieldType === 'money') {
return 'moneyAmountV2'; return 'MONEY_AMOUNT_V2';
} }
return fieldType as FieldType; return fieldType as FieldType;

View File

@@ -32,7 +32,7 @@ export const peopleAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[]
Icon: IconUser, Icon: IconUser,
size: 210, size: 210,
position: 0, position: 0,
type: 'double-text-chip', type: 'DOUBLE_TEXT_CHIP',
metadata: { metadata: {
firstValueFieldName: 'firstName', firstValueFieldName: 'firstName',
secondValueFieldName: 'lastName', secondValueFieldName: 'lastName',
@@ -49,7 +49,7 @@ export const peopleAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[]
label: 'Email', label: 'Email',
Icon: IconMail, Icon: IconMail,
size: 150, size: 150,
type: 'email', type: 'EMAIL',
position: 1, position: 1,
metadata: { metadata: {
fieldName: 'email', fieldName: 'email',
@@ -63,7 +63,7 @@ export const peopleAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[]
Icon: IconBuildingSkyscraper, Icon: IconBuildingSkyscraper,
size: 150, size: 150,
position: 2, position: 2,
type: 'relation', type: 'RELATION',
metadata: { metadata: {
fieldName: 'company', fieldName: 'company',
relationType: Entity.Company, relationType: Entity.Company,
@@ -83,7 +83,7 @@ export const peopleAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[]
Icon: IconPhone, Icon: IconPhone,
size: 150, size: 150,
position: 3, position: 3,
type: 'phone', type: 'PHONE',
metadata: { metadata: {
fieldName: 'phone', fieldName: 'phone',
placeHolder: 'Phone', // Hack: Fake character to prevent password-manager from filling the field placeHolder: 'Phone', // Hack: Fake character to prevent password-manager from filling the field
@@ -96,7 +96,7 @@ export const peopleAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[]
Icon: IconCalendarEvent, Icon: IconCalendarEvent,
size: 150, size: 150,
position: 4, position: 4,
type: 'date', type: 'DATE',
metadata: { metadata: {
fieldName: 'createdAt', fieldName: 'createdAt',
}, },
@@ -108,7 +108,7 @@ export const peopleAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[]
Icon: IconMap, Icon: IconMap,
size: 150, size: 150,
position: 5, position: 5,
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'city', fieldName: 'city',
placeHolder: 'City', // Hack: Fake character to prevent password-manager from filling the field placeHolder: 'City', // Hack: Fake character to prevent password-manager from filling the field
@@ -121,7 +121,7 @@ export const peopleAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[]
Icon: IconBriefcase, Icon: IconBriefcase,
size: 150, size: 150,
position: 6, position: 6,
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'jobTitle', fieldName: 'jobTitle',
placeHolder: 'Job title', placeHolder: 'Job title',
@@ -134,7 +134,7 @@ export const peopleAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[]
Icon: IconBrandLinkedin, Icon: IconBrandLinkedin,
size: 150, size: 150,
position: 7, position: 7,
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'linkedinUrl', fieldName: 'linkedinUrl',
placeHolder: 'LinkedIn', placeHolder: 'LinkedIn',
@@ -147,7 +147,7 @@ export const peopleAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[]
Icon: IconBrandX, Icon: IconBrandX,
size: 150, size: 150,
position: 8, position: 8,
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'xUrl', fieldName: 'xUrl',
placeHolder: 'X', placeHolder: 'X',

View File

@@ -22,7 +22,7 @@ export const pipelineAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[
label: 'Close Date', label: 'Close Date',
Icon: IconCalendarEvent, Icon: IconCalendarEvent,
position: 0, position: 0,
type: 'date', type: 'DATE',
metadata: { metadata: {
fieldName: 'closeDate', fieldName: 'closeDate',
}, },
@@ -36,7 +36,7 @@ export const pipelineAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[
label: 'Amount', label: 'Amount',
Icon: IconCurrencyDollar, Icon: IconCurrencyDollar,
position: 1, position: 1,
type: 'number', type: 'NUMBER',
metadata: { metadata: {
fieldName: 'amount', fieldName: 'amount',
placeHolder: '0', placeHolder: '0',
@@ -50,7 +50,7 @@ export const pipelineAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[
label: 'Probability', label: 'Probability',
Icon: IconProgressCheck, Icon: IconProgressCheck,
position: 2, position: 2,
type: 'probability', type: 'PROBABILITY',
metadata: { metadata: {
fieldName: 'probability', fieldName: 'probability',
}, },
@@ -64,7 +64,7 @@ export const pipelineAvailableFieldDefinitions: ColumnDefinition<FieldMetadata>[
label: 'Point of Contact', label: 'Point of Contact',
Icon: IconUser, Icon: IconUser,
position: 3, position: 3,
type: 'relation', type: 'RELATION',
metadata: { metadata: {
fieldName: 'pointOfContact', fieldName: 'pointOfContact',
relationType: Entity.Person, relationType: Entity.Person,

View File

@@ -12,7 +12,7 @@ type SettingsObjectFieldTypeSelectSectionProps = {
}; };
// TODO: remove "relation" type for now, add it back when the backend is ready. // TODO: remove "relation" type for now, add it back when the backend is ready.
const { relation: _, ...dataTypesWithoutRelation } = dataTypes; const { RELATION: _, ...dataTypesWithoutRelation } = dataTypes;
export const SettingsObjectFieldTypeSelectSection = ({ export const SettingsObjectFieldTypeSelectSection = ({
disabled, disabled,

View File

@@ -9,7 +9,7 @@ const meta: Meta<typeof SettingsObjectFieldTypeSelectSection> = {
title: 'Modules/Settings/DataModel/SettingsObjectFieldTypeSelectSection', title: 'Modules/Settings/DataModel/SettingsObjectFieldTypeSelectSection',
component: SettingsObjectFieldTypeSelectSection, component: SettingsObjectFieldTypeSelectSection,
decorators: [ComponentDecorator], decorators: [ComponentDecorator],
args: { type: 'number' }, args: { type: 'NUMBER' },
}; };
export default meta; export default meta;

View File

@@ -13,9 +13,9 @@ export const dataTypes: Record<
MetadataFieldDataType, MetadataFieldDataType,
{ label: string; Icon: IconComponent } { label: string; Icon: IconComponent }
> = { > = {
number: { label: 'Number', Icon: IconNumbers }, NUMBER: { label: 'Number', Icon: IconNumbers },
text: { label: 'Text', Icon: IconTextSize }, TEXT: { label: 'Text', Icon: IconTextSize },
url: { label: 'Link', Icon: IconLink }, URL: { label: 'Link', Icon: IconLink },
boolean: { label: 'True/False', Icon: IconCheck }, BOOLEAN: { label: 'True/False', Icon: IconCheck },
relation: { label: 'Relation', Icon: IconPlug }, RELATION: { label: 'Relation', Icon: IconPlug },
}; };

View File

@@ -15,7 +15,7 @@ const StyledDataType = styled.div<{ value: MetadataFieldDataType }>`
padding: 0 ${({ theme }) => theme.spacing(2)}; padding: 0 ${({ theme }) => theme.spacing(2)};
${({ theme, value }) => ${({ theme, value }) =>
value === 'relation' value === 'RELATION'
? css` ? css`
border-color: ${theme.color.purple20}; border-color: ${theme.color.purple20};
color: ${theme.color.purple}; color: ${theme.color.purple};

View File

@@ -39,10 +39,10 @@ export const SettingsObjectFieldItemTableRow = ({
// TODO: parse with zod and merge types with FieldType (create a subset of FieldType for example) // TODO: parse with zod and merge types with FieldType (create a subset of FieldType for example)
const fieldDataTypeIsSupported = [ const fieldDataTypeIsSupported = [
'text', 'TEXT',
'number', 'NUMBER',
'boolean', 'BOOLEAN',
'url', 'URL',
].includes(fieldItem.type); ].includes(fieldItem.type);
if (!fieldDataTypeIsSupported) { if (!fieldDataTypeIsSupported) {

View File

@@ -1,6 +1,6 @@
export type MetadataFieldDataType = export type MetadataFieldDataType =
| 'boolean' | 'BOOLEAN'
| 'number' | 'NUMBER'
| 'relation' | 'RELATION'
| 'text' | 'TEXT'
| 'url'; | 'URL';

View File

@@ -33,7 +33,7 @@ const DateFieldDisplayWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'date', fieldId: 'date',
label: 'Date', label: 'Date',
type: 'date', type: 'DATE',
metadata: { metadata: {
fieldName: 'Date', fieldName: 'Date',
}, },

View File

@@ -40,7 +40,7 @@ const DoubleTextFieldDisplayWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'double-text', fieldId: 'double-text',
label: 'Double-Text', label: 'Double-Text',
type: 'double-text', type: 'DOUBLE_TEXT',
metadata: { metadata: {
firstValueFieldName: 'First-text', firstValueFieldName: 'First-text',
firstValuePlaceholder: 'First-text', firstValuePlaceholder: 'First-text',

View File

@@ -32,7 +32,7 @@ const EmailFieldDisplayWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'email', fieldId: 'email',
label: 'Email', label: 'Email',
type: 'email', type: 'EMAIL',
metadata: { metadata: {
fieldName: 'Email', fieldName: 'Email',
placeHolder: 'Email', placeHolder: 'Email',

View File

@@ -34,7 +34,7 @@ const MoneyFieldDisplayWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'money', fieldId: 'money',
label: 'Money', label: 'Money',
type: 'moneyAmount', type: 'MONEY_AMOUNT',
metadata: { metadata: {
fieldName: 'Amount', fieldName: 'Amount',
placeHolder: 'Amount', placeHolder: 'Amount',

View File

@@ -34,7 +34,7 @@ const NumberFieldDisplayWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'number', fieldId: 'number',
label: 'Number', label: 'Number',
type: 'number', type: 'NUMBER',
metadata: { metadata: {
fieldName: 'Number', fieldName: 'Number',
placeHolder: 'Number', placeHolder: 'Number',

View File

@@ -32,7 +32,7 @@ const PhoneFieldDisplayWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'phone', fieldId: 'phone',
label: 'Phone', label: 'Phone',
type: 'phone', type: 'PHONE',
metadata: { metadata: {
fieldName: 'Phone', fieldName: 'Phone',
placeHolder: 'Phone', placeHolder: 'Phone',

View File

@@ -34,7 +34,7 @@ const TextFieldDisplayWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'text', fieldId: 'text',
label: 'Text', label: 'Text',
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'Text', fieldName: 'Text',
placeHolder: 'Text', placeHolder: 'Text',

View File

@@ -32,7 +32,7 @@ const URLFieldDisplayWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'URL', fieldId: 'URL',
label: 'URL', label: 'URL',
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'URL', fieldName: 'URL',
placeHolder: 'URL', placeHolder: 'URL',

View File

@@ -9,7 +9,7 @@ import { isFieldBoolean } from '../../types/guards/isFieldBoolean';
export const useBooleanField = () => { export const useBooleanField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('boolean', isFieldBoolean, fieldDefinition); assertFieldMetadata('BOOLEAN', isFieldBoolean, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -10,7 +10,7 @@ import { isFieldChip } from '../../types/guards/isFieldChip';
export const useChipField = () => { export const useChipField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('chip', isFieldChip, fieldDefinition); assertFieldMetadata('CHIP', isFieldChip, fieldDefinition);
const contentFieldName = fieldDefinition.metadata.contentFieldName; const contentFieldName = fieldDefinition.metadata.contentFieldName;
const avatarUrlFieldName = fieldDefinition.metadata.urlFieldName; const avatarUrlFieldName = fieldDefinition.metadata.urlFieldName;

View File

@@ -9,7 +9,7 @@ import { isFieldDate } from '../../types/guards/isFieldDate';
export const useDateField = () => { export const useDateField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('date', isFieldDate, fieldDefinition); assertFieldMetadata('DATE', isFieldDate, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -11,7 +11,7 @@ export const useDoubleTextChipField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata( assertFieldMetadata(
'double-text-chip', 'DOUBLE_TEXT_CHIP',
isFieldDoubleTextChip, isFieldDoubleTextChip,
fieldDefinition, fieldDefinition,
); );

View File

@@ -10,7 +10,7 @@ import { isFieldDoubleText } from '../../types/guards/isFieldDoubleText';
export const useDoubleTextField = () => { export const useDoubleTextField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('double-text', isFieldDoubleText, fieldDefinition); assertFieldMetadata('DOUBLE_TEXT', isFieldDoubleText, fieldDefinition);
const [firstValue, setFirstValue] = useRecoilState<string>( const [firstValue, setFirstValue] = useRecoilState<string>(
entityFieldsFamilySelector({ entityFieldsFamilySelector({

View File

@@ -10,7 +10,7 @@ import { isFieldEmail } from '../../types/guards/isFieldEmail';
export const useEmailField = () => { export const useEmailField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('email', isFieldEmail, fieldDefinition); assertFieldMetadata('EMAIL', isFieldEmail, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -13,7 +13,7 @@ import { isFieldMoneyAmountV2Value } from '../../types/guards/isFieldMoneyAmount
export const useMoneyAmountV2Field = () => { export const useMoneyAmountV2Field = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('moneyAmountV2', isFieldMoneyAmountV2, fieldDefinition); assertFieldMetadata('MONEY_AMOUNT_V2', isFieldMoneyAmountV2, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -16,7 +16,7 @@ import { isFieldMoney } from '../../types/guards/isFieldMoney';
export const useMoneyField = () => { export const useMoneyField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('moneyAmount', isFieldMoney, fieldDefinition); assertFieldMetadata('MONEY_AMOUNT', isFieldMoney, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -16,7 +16,7 @@ import { isFieldNumber } from '../../types/guards/isFieldNumber';
export const useNumberField = () => { export const useNumberField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('number', isFieldNumber, fieldDefinition); assertFieldMetadata('NUMBER', isFieldNumber, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -12,7 +12,7 @@ import { isFieldPhone } from '../../types/guards/isFieldPhone';
export const usePhoneField = () => { export const usePhoneField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('phone', isFieldPhone, fieldDefinition); assertFieldMetadata('PHONE', isFieldPhone, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -9,7 +9,7 @@ import { isFieldProbability } from '../../types/guards/isFieldProbability';
export const useProbabilityField = () => { export const useProbabilityField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('probability', isFieldProbability, fieldDefinition); assertFieldMetadata('PROBABILITY', isFieldProbability, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -11,7 +11,7 @@ import { isFieldRelation } from '../../types/guards/isFieldRelation';
export const useRelationField = () => { export const useRelationField = () => {
const { entityId, fieldDefinition } = useContext(FieldContext); const { entityId, fieldDefinition } = useContext(FieldContext);
assertFieldMetadata('relation', isFieldRelation, fieldDefinition); assertFieldMetadata('RELATION', isFieldRelation, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -10,7 +10,7 @@ import { isFieldText } from '../../types/guards/isFieldText';
export const useTextField = () => { export const useTextField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('text', isFieldText, fieldDefinition); assertFieldMetadata('TEXT', isFieldText, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -13,7 +13,7 @@ import { isFieldURL } from '../../types/guards/isFieldURL';
export const useURLField = () => { export const useURLField = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('url', isFieldURL, fieldDefinition); assertFieldMetadata('URL', isFieldURL, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -13,7 +13,7 @@ import { isFieldURLV2Value } from '../../types/guards/isFieldURLV2Value';
export const useURLV2Field = () => { export const useURLV2Field = () => {
const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext); const { entityId, fieldDefinition, hotkeyScope } = useContext(FieldContext);
assertFieldMetadata('urlV2', isFieldURLV2, fieldDefinition); assertFieldMetadata('URL_V2', isFieldURLV2, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName; const fieldName = fieldDefinition.metadata.fieldName;

View File

@@ -36,7 +36,7 @@ const BooleanFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'boolean', fieldId: 'boolean',
label: 'Boolean', label: 'Boolean',
type: 'boolean', type: 'BOOLEAN',
metadata: { metadata: {
fieldName: 'Boolean', fieldName: 'Boolean',
}, },

View File

@@ -46,7 +46,7 @@ const ChipFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'chip', fieldId: 'chip',
label: 'Chip', label: 'Chip',
type: 'chip', type: 'CHIP',
metadata: { metadata: {
contentFieldName: 'name', contentFieldName: 'name',
urlFieldName: 'xURL', urlFieldName: 'xURL',

View File

@@ -46,7 +46,7 @@ const DateFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'date', fieldId: 'date',
label: 'Date', label: 'Date',
type: 'date', type: 'DATE',
metadata: { metadata: {
fieldName: 'Date', fieldName: 'Date',
}, },

View File

@@ -59,7 +59,7 @@ const DoubleTextChipFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'double-text-chip', fieldId: 'double-text-chip',
label: 'Double-Text-Chip', label: 'Double-Text-Chip',
type: 'double-text-chip', type: 'DOUBLE_TEXT_CHIP',
metadata: { metadata: {
firstValueFieldName: 'First-text', firstValueFieldName: 'First-text',
firstValuePlaceholder: 'First-text', firstValuePlaceholder: 'First-text',

View File

@@ -57,7 +57,7 @@ const DoubleTextFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'double-text', fieldId: 'double-text',
label: 'Double-Text', label: 'Double-Text',
type: 'double-text', type: 'DOUBLE_TEXT',
metadata: { metadata: {
firstValueFieldName: 'First-text', firstValueFieldName: 'First-text',
firstValuePlaceholder: 'First-text', firstValuePlaceholder: 'First-text',

View File

@@ -45,7 +45,7 @@ const EmailFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'email', fieldId: 'email',
label: 'Email', label: 'Email',
type: 'email', type: 'EMAIL',
metadata: { metadata: {
fieldName: 'email', fieldName: 'email',
placeHolder: 'username@email.com', placeHolder: 'username@email.com',

View File

@@ -45,7 +45,7 @@ const MoneyFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'moneyAmount', fieldId: 'moneyAmount',
label: 'MoneyAmout', label: 'MoneyAmout',
type: 'moneyAmount', type: 'MONEY_AMOUNT',
metadata: { metadata: {
fieldName: 'moneyAmount', fieldName: 'moneyAmount',
placeHolder: 'Enter Amount', placeHolder: 'Enter Amount',

View File

@@ -45,7 +45,7 @@ const NumberFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'number', fieldId: 'number',
label: 'Number', label: 'Number',
type: 'number', type: 'NUMBER',
metadata: { metadata: {
fieldName: 'number', fieldName: 'number',
placeHolder: 'Enter number', placeHolder: 'Enter number',

View File

@@ -45,7 +45,7 @@ const PhoneFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'phone', fieldId: 'phone',
label: 'Phone', label: 'Phone',
type: 'phone', type: 'PHONE',
metadata: { metadata: {
fieldName: 'Phone', fieldName: 'Phone',
placeHolder: 'Enter phone number', placeHolder: 'Enter phone number',

View File

@@ -43,7 +43,7 @@ const ProbabilityFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'probability', fieldId: 'probability',
label: 'Probability', label: 'Probability',
type: 'probability', type: 'PROBABILITY',
metadata: { metadata: {
fieldName: 'Probability', fieldName: 'Probability',
}, },

View File

@@ -48,7 +48,7 @@ const RelationFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'relation', fieldId: 'relation',
label: 'Relation', label: 'Relation',
type: 'relation', type: 'RELATION',
metadata: { metadata: {
fieldName: 'Relation', fieldName: 'Relation',
relationType: Entity.Person, relationType: Entity.Person,

View File

@@ -45,7 +45,7 @@ const TextFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'text', fieldId: 'text',
label: 'Text', label: 'Text',
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'Text', fieldName: 'Text',
placeHolder: 'Enter text', placeHolder: 'Enter text',

View File

@@ -45,7 +45,7 @@ const URLFieldInputWithContext = ({
fieldDefinition={{ fieldDefinition={{
fieldId: 'url', fieldId: 'url',
label: 'URL', label: 'URL',
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'URL', fieldName: 'URL',
placeHolder: 'Enter URL', placeHolder: 'Enter URL',

View File

@@ -1,17 +1,17 @@
export type FieldType = export type FieldType =
| 'text' | 'TEXT'
| 'relation' | 'RELATION'
| 'chip' | 'CHIP'
| 'double-text-chip' | 'DOUBLE_TEXT_CHIP'
| 'double-text' | 'DOUBLE_TEXT'
| 'number' | 'NUMBER'
| 'email' | 'EMAIL'
| 'boolean' | 'BOOLEAN'
| 'date' | 'DATE'
| 'phone' | 'PHONE'
| 'url' | 'URL'
| 'urlV2' | 'URL_V2'
| 'probability' | 'PROBABILITY'
| 'moneyAmountV2' | 'MONEY_AMOUNT_V2'
| 'moneyAmount' | 'MONEY_AMOUNT'
| 'money'; | 'MONEY';

View File

@@ -21,35 +21,35 @@ import { FieldType } from '../FieldType';
type AssertFieldMetadataFunction = < type AssertFieldMetadataFunction = <
E extends FieldType, E extends FieldType,
T extends E extends 'text' T extends E extends 'TEXT'
? FieldTextMetadata ? FieldTextMetadata
: E extends 'relation' : E extends 'RELATION'
? FieldRelationMetadata ? FieldRelationMetadata
: E extends 'chip' : E extends 'CHIP'
? FieldChipMetadata ? FieldChipMetadata
: E extends 'double-text-chip' : E extends 'DOUBLE_TEXT_CHIP'
? FieldDoubleTextChipMetadata ? FieldDoubleTextChipMetadata
: E extends 'double-text' : E extends 'DOUBLE_TEXT'
? FieldDoubleTextMetadata ? FieldDoubleTextMetadata
: E extends 'number' : E extends 'NUMBER'
? FieldNumberMetadata ? FieldNumberMetadata
: E extends 'email' : E extends 'EMAIL'
? FieldEmailMetadata ? FieldEmailMetadata
: E extends 'boolean' : E extends 'BOOLEAN'
? FieldBooleanMetadata ? FieldBooleanMetadata
: E extends 'date' : E extends 'DATE'
? FieldDateMetadata ? FieldDateMetadata
: E extends 'phone' : E extends 'PHONE'
? FieldPhoneMetadata ? FieldPhoneMetadata
: E extends 'url' : E extends 'URL'
? FieldURLMetadata ? FieldURLMetadata
: E extends 'urlV2' : E extends 'URL_V2'
? FieldURLV2Metadata ? FieldURLV2Metadata
: E extends 'probability' : E extends 'PROBABILITY'
? FieldProbabilityMetadata ? FieldProbabilityMetadata
: E extends 'moneyAmount' : E extends 'MONEY_AMOUNT'
? FieldMoneyMetadata ? FieldMoneyMetadata
: E extends 'moneyAmountV2' : E extends 'MONEY_AMOUNT_V2'
? FieldMoneyAmountV2Metadata ? FieldMoneyAmountV2Metadata
: never, : never,
>( >(

View File

@@ -3,4 +3,4 @@ import { FieldBooleanMetadata, FieldMetadata } from '../FieldMetadata';
export const isFieldBoolean = ( export const isFieldBoolean = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldBooleanMetadata> => field.type === 'boolean'; ): field is FieldDefinition<FieldBooleanMetadata> => field.type === 'BOOLEAN';

View File

@@ -3,4 +3,4 @@ import { FieldChipMetadata, FieldMetadata } from '../FieldMetadata';
export const isFieldChip = ( export const isFieldChip = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldChipMetadata> => field.type === 'chip'; ): field is FieldDefinition<FieldChipMetadata> => field.type === 'CHIP';

View File

@@ -3,4 +3,4 @@ import { FieldDateMetadata, FieldMetadata } from '../FieldMetadata';
export const isFieldDate = ( export const isFieldDate = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldDateMetadata> => field.type === 'date'; ): field is FieldDefinition<FieldDateMetadata> => field.type === 'DATE';

View File

@@ -4,4 +4,4 @@ import { FieldDoubleTextMetadata, FieldMetadata } from '../FieldMetadata';
export const isFieldDoubleText = ( export const isFieldDoubleText = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldDoubleTextMetadata> => ): field is FieldDefinition<FieldDoubleTextMetadata> =>
field.type === 'double-text'; field.type === 'DOUBLE_TEXT';

View File

@@ -4,4 +4,4 @@ import { FieldDoubleTextChipMetadata, FieldMetadata } from '../FieldMetadata';
export const isFieldDoubleTextChip = ( export const isFieldDoubleTextChip = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldDoubleTextChipMetadata> => ): field is FieldDefinition<FieldDoubleTextChipMetadata> =>
field.type === 'double-text-chip'; field.type === 'DOUBLE_TEXT_CHIP';

View File

@@ -3,4 +3,4 @@ import { FieldEmailMetadata, FieldMetadata } from '../FieldMetadata';
export const isFieldEmail = ( export const isFieldEmail = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldEmailMetadata> => field.type === 'email'; ): field is FieldDefinition<FieldEmailMetadata> => field.type === 'EMAIL';

View File

@@ -3,4 +3,5 @@ import { FieldMetadata, FieldMoneyMetadata } from '../FieldMetadata';
export const isFieldMoney = ( export const isFieldMoney = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldMoneyMetadata> => field.type === 'moneyAmount'; ): field is FieldDefinition<FieldMoneyMetadata> =>
field.type === 'MONEY_AMOUNT';

View File

@@ -4,4 +4,4 @@ import { FieldMetadata, FieldMoneyAmountV2Metadata } from '../FieldMetadata';
export const isFieldMoneyAmountV2 = ( export const isFieldMoneyAmountV2 = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldMoneyAmountV2Metadata> => ): field is FieldDefinition<FieldMoneyAmountV2Metadata> =>
field.type === 'moneyAmountV2'; field.type === 'MONEY_AMOUNT_V2';

View File

@@ -3,4 +3,4 @@ import { FieldMetadata, FieldNumberMetadata } from '../FieldMetadata';
export const isFieldNumber = ( export const isFieldNumber = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldNumberMetadata> => field.type === 'number'; ): field is FieldDefinition<FieldNumberMetadata> => field.type === 'NUMBER';

View File

@@ -3,4 +3,4 @@ import { FieldMetadata, FieldPhoneMetadata } from '../FieldMetadata';
export const isFieldPhone = ( export const isFieldPhone = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldPhoneMetadata> => field.type === 'phone'; ): field is FieldDefinition<FieldPhoneMetadata> => field.type === 'PHONE';

View File

@@ -4,4 +4,4 @@ import { FieldMetadata, FieldProbabilityMetadata } from '../FieldMetadata';
export const isFieldProbability = ( export const isFieldProbability = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldProbabilityMetadata> => ): field is FieldDefinition<FieldProbabilityMetadata> =>
field.type === 'probability'; field.type === 'PROBABILITY';

View File

@@ -3,4 +3,4 @@ import { FieldMetadata, FieldRelationMetadata } from '../FieldMetadata';
export const isFieldRelation = ( export const isFieldRelation = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldRelationMetadata> => field.type === 'relation'; ): field is FieldDefinition<FieldRelationMetadata> => field.type === 'RELATION';

View File

@@ -3,4 +3,4 @@ import { FieldMetadata, FieldTextMetadata } from '../FieldMetadata';
export const isFieldText = ( export const isFieldText = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldTextMetadata> => field.type === 'text'; ): field is FieldDefinition<FieldTextMetadata> => field.type === 'TEXT';

View File

@@ -3,4 +3,4 @@ import { FieldMetadata, FieldURLMetadata } from '../FieldMetadata';
export const isFieldURL = ( export const isFieldURL = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldURLMetadata> => field.type === 'url'; ): field is FieldDefinition<FieldURLMetadata> => field.type === 'URL';

View File

@@ -3,4 +3,4 @@ import { FieldMetadata, FieldURLV2Metadata } from '../FieldMetadata';
export const isFieldURLV2 = ( export const isFieldURLV2 = (
field: FieldDefinition<FieldMetadata>, field: FieldDefinition<FieldMetadata>,
): field is FieldDefinition<FieldURLV2Metadata> => field.type === 'urlV2'; ): field is FieldDefinition<FieldURLV2Metadata> => field.type === 'URL_V2';

View File

@@ -30,19 +30,19 @@ export const MultipleFiltersDropdownContent = () => {
<> <>
<ObjectFilterDropdownOperandButton /> <ObjectFilterDropdownOperandButton />
<DropdownMenuSeparator /> <DropdownMenuSeparator />
{filterDefinitionUsedInDropdown.type === 'text' && ( {filterDefinitionUsedInDropdown.type === 'TEXT' && (
<ObjectFilterDropdownTextSearchInput /> <ObjectFilterDropdownTextSearchInput />
)} )}
{filterDefinitionUsedInDropdown.type === 'number' && ( {filterDefinitionUsedInDropdown.type === 'NUMBER' && (
<ObjectFilterDropdownNumberSearchInput /> <ObjectFilterDropdownNumberSearchInput />
)} )}
{filterDefinitionUsedInDropdown.type === 'date' && ( {filterDefinitionUsedInDropdown.type === 'DATE' && (
<ObjectFilterDropdownDateSearchInput /> <ObjectFilterDropdownDateSearchInput />
)} )}
{filterDefinitionUsedInDropdown.type === 'entity' && ( {filterDefinitionUsedInDropdown.type === 'ENTITY' && (
<ObjectFilterDropdownEntitySearchInput /> <ObjectFilterDropdownEntitySearchInput />
)} )}
{filterDefinitionUsedInDropdown.type === 'entity' && ( {filterDefinitionUsedInDropdown.type === 'ENTITY' && (
<ObjectFilterDropdownEntitySelect /> <ObjectFilterDropdownEntitySelect />
)} )}
</> </>

View File

@@ -16,7 +16,7 @@ export const ObjectFilterDropdownButton = ({
const hasOnlyOneEntityFilter = const hasOnlyOneEntityFilter =
availableFilterDefinitions.length === 1 && availableFilterDefinitions.length === 1 &&
availableFilterDefinitions[0].type === 'entity'; availableFilterDefinitions[0].type === 'ENTITY';
if (!availableFilterDefinitions.length) { if (!availableFilterDefinitions.length) {
return <></>; return <></>;

View File

@@ -6,7 +6,7 @@ import { useFilter } from '../hooks/useFilter';
export const ObjectFilterDropdownEntitySelect = () => { export const ObjectFilterDropdownEntitySelect = () => {
const { filterDefinitionUsedInDropdown } = useFilter(); const { filterDefinitionUsedInDropdown } = useFilter();
if (filterDefinitionUsedInDropdown?.type !== 'entity') { if (filterDefinitionUsedInDropdown?.type !== 'ENTITY') {
return null; return null;
} }

View File

@@ -25,7 +25,7 @@ export const ObjectFilterDropdownFilterSelect = () => {
onClick={() => { onClick={() => {
setFilterDefinitionUsedInDropdown(availableFilterDefinition); setFilterDefinitionUsedInDropdown(availableFilterDefinition);
if (availableFilterDefinition.type === 'entity') { if (availableFilterDefinition.type === 'ENTITY') {
setHotkeyScope(RelationPickerHotkeyScope.RelationPicker); setHotkeyScope(RelationPickerHotkeyScope.RelationPicker);
} }

View File

@@ -1 +1 @@
export type FilterType = 'text' | 'date' | 'entity' | 'number'; export type FilterType = 'TEXT' | 'DATE' | 'ENTITY' | 'NUMBER';

View File

@@ -6,12 +6,12 @@ export const getOperandsForFilterType = (
filterType: FilterType | null | undefined, filterType: FilterType | null | undefined,
): ViewFilterOperand[] => { ): ViewFilterOperand[] => {
switch (filterType) { switch (filterType) {
case 'text': case 'TEXT':
return [ViewFilterOperand.Contains, ViewFilterOperand.DoesNotContain]; return [ViewFilterOperand.Contains, ViewFilterOperand.DoesNotContain];
case 'number': case 'NUMBER':
case 'date': case 'DATE':
return [ViewFilterOperand.GreaterThan, ViewFilterOperand.LessThan]; return [ViewFilterOperand.GreaterThan, ViewFilterOperand.LessThan];
case 'entity': case 'ENTITY':
return [ViewFilterOperand.Is, ViewFilterOperand.IsNot]; return [ViewFilterOperand.Is, ViewFilterOperand.IsNot];
default: default:
return []; return [];

View File

@@ -24,7 +24,7 @@ export const turnFilterIntoWhereClause = (
}; };
default: default:
switch (filter.definition.type) { switch (filter.definition.type) {
case 'text': case 'TEXT':
switch (filter.operand) { switch (filter.operand) {
case ViewFilterOperand.Contains: case ViewFilterOperand.Contains:
return { return {
@@ -47,7 +47,7 @@ export const turnFilterIntoWhereClause = (
`Unknown operand ${filter.operand} for ${filter.definition.type} filter`, `Unknown operand ${filter.operand} for ${filter.definition.type} filter`,
); );
} }
case 'number': case 'NUMBER':
switch (filter.operand) { switch (filter.operand) {
case ViewFilterOperand.GreaterThan: case ViewFilterOperand.GreaterThan:
return { return {
@@ -66,7 +66,7 @@ export const turnFilterIntoWhereClause = (
`Unknown operand ${filter.operand} for ${filter.definition.type} filter`, `Unknown operand ${filter.operand} for ${filter.definition.type} filter`,
); );
} }
case 'date': case 'DATE':
switch (filter.operand) { switch (filter.operand) {
case ViewFilterOperand.GreaterThan: case ViewFilterOperand.GreaterThan:
return { return {
@@ -85,7 +85,7 @@ export const turnFilterIntoWhereClause = (
`Unknown operand ${filter.operand} for ${filter.definition.type} filter`, `Unknown operand ${filter.operand} for ${filter.definition.type} filter`,
); );
} }
case 'entity': case 'ENTITY':
switch (filter.operand) { switch (filter.operand) {
case ViewFilterOperand.Is: case ViewFilterOperand.Is:
return { return {

View File

@@ -26,7 +26,7 @@ export const turnFiltersIntoWhereClauseV2 = (
} }
switch (filter.definition.type) { switch (filter.definition.type) {
case 'text': case 'TEXT':
switch (filter.operand) { switch (filter.operand) {
case ViewFilterOperand.Contains: case ViewFilterOperand.Contains:
whereClause[correspondingField.name] = { whereClause[correspondingField.name] = {

View File

@@ -25,7 +25,7 @@ export const companyShowFieldDefinitions: FieldDefinition<FieldMetadata>[] = [
fieldId: 'domainName', fieldId: 'domainName',
label: 'Domain name', label: 'Domain name',
Icon: IconLink, Icon: IconLink,
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'domainName', fieldName: 'domainName',
placeHolder: 'URL', placeHolder: 'URL',
@@ -35,7 +35,7 @@ export const companyShowFieldDefinitions: FieldDefinition<FieldMetadata>[] = [
fieldId: 'accountOwner', fieldId: 'accountOwner',
label: 'Account owner', label: 'Account owner',
Icon: IconUserCircle, Icon: IconUserCircle,
type: 'relation', type: 'RELATION',
metadata: { metadata: {
fieldName: 'accountOwner', fieldName: 'accountOwner',
relationType: Entity.User, relationType: Entity.User,
@@ -52,7 +52,7 @@ export const companyShowFieldDefinitions: FieldDefinition<FieldMetadata>[] = [
fieldId: 'employees', fieldId: 'employees',
label: 'Employees', label: 'Employees',
Icon: IconUsers, Icon: IconUsers,
type: 'number', type: 'NUMBER',
metadata: { metadata: {
fieldName: 'employees', fieldName: 'employees',
placeHolder: 'Employees', placeHolder: 'Employees',
@@ -62,7 +62,7 @@ export const companyShowFieldDefinitions: FieldDefinition<FieldMetadata>[] = [
fieldId: 'address', fieldId: 'address',
label: 'Address', label: 'Address',
Icon: IconMap, Icon: IconMap,
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'address', fieldName: 'address',
placeHolder: 'Address', placeHolder: 'Address',
@@ -72,7 +72,7 @@ export const companyShowFieldDefinitions: FieldDefinition<FieldMetadata>[] = [
fieldId: 'idealCustomerProfile', fieldId: 'idealCustomerProfile',
label: 'ICP', label: 'ICP',
Icon: IconTarget, Icon: IconTarget,
type: 'boolean', type: 'BOOLEAN',
metadata: { metadata: {
fieldName: 'idealCustomerProfile', fieldName: 'idealCustomerProfile',
}, },
@@ -81,7 +81,7 @@ export const companyShowFieldDefinitions: FieldDefinition<FieldMetadata>[] = [
fieldId: 'xUrl', fieldId: 'xUrl',
label: 'Twitter', label: 'Twitter',
Icon: IconBrandX, Icon: IconBrandX,
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'xUrl', fieldName: 'xUrl',
placeHolder: 'X', placeHolder: 'X',
@@ -91,7 +91,7 @@ export const companyShowFieldDefinitions: FieldDefinition<FieldMetadata>[] = [
fieldId: 'createdAt', fieldId: 'createdAt',
label: 'Created at', label: 'Created at',
Icon: IconCalendar, Icon: IconCalendar,
type: 'date', type: 'DATE',
metadata: { metadata: {
fieldName: 'createdAt', fieldName: 'createdAt',
}, },

View File

@@ -16,37 +16,37 @@ export const companyTableFilterDefinitions: FilterDefinitionByEntity<Company>[]
fieldId: 'name', fieldId: 'name',
label: 'Name', label: 'Name',
Icon: IconBuildingSkyscraper, Icon: IconBuildingSkyscraper,
type: 'text', type: 'TEXT',
}, },
{ {
fieldId: 'employees', fieldId: 'employees',
label: 'Employees', label: 'Employees',
Icon: IconUsers, Icon: IconUsers,
type: 'number', type: 'NUMBER',
}, },
{ {
fieldId: 'domainName', fieldId: 'domainName',
label: 'URL', label: 'URL',
Icon: IconLink, Icon: IconLink,
type: 'text', type: 'TEXT',
}, },
{ {
fieldId: 'address', fieldId: 'address',
label: 'Address', label: 'Address',
Icon: IconMap, Icon: IconMap,
type: 'text', type: 'TEXT',
}, },
{ {
fieldId: 'createdAt', fieldId: 'createdAt',
label: 'Created at', label: 'Created at',
Icon: IconCalendarEvent, Icon: IconCalendarEvent,
type: 'date', type: 'DATE',
}, },
{ {
fieldId: 'accountOwnerId', fieldId: 'accountOwnerId',
label: 'Account owner', label: 'Account owner',
Icon: IconUser, Icon: IconUser,
type: 'entity', type: 'ENTITY',
entitySelectComponent: <FilterDropdownUserSearchSelect />, entitySelectComponent: <FilterDropdownUserSearchSelect />,
}, },
]; ];

View File

@@ -16,26 +16,26 @@ export const opportunityBoardFilterDefinitions: FilterDefinitionByEntity<Pipelin
fieldId: 'amount', fieldId: 'amount',
label: 'Amount', label: 'Amount',
Icon: IconCurrencyDollar, Icon: IconCurrencyDollar,
type: 'number', type: 'NUMBER',
}, },
{ {
fieldId: 'closeDate', fieldId: 'closeDate',
label: 'Close date', label: 'Close date',
Icon: IconCalendarEvent, Icon: IconCalendarEvent,
type: 'date', type: 'DATE',
}, },
{ {
fieldId: 'companyId', fieldId: 'companyId',
label: 'Company', label: 'Company',
Icon: IconBuildingSkyscraper, Icon: IconBuildingSkyscraper,
type: 'entity', type: 'ENTITY',
entitySelectComponent: <FilterDropdownCompanySearchSelect />, entitySelectComponent: <FilterDropdownCompanySearchSelect />,
}, },
{ {
fieldId: 'pointOfContactId', fieldId: 'pointOfContactId',
label: 'Point of contact', label: 'Point of contact',
Icon: IconUser, Icon: IconUser,
type: 'entity', type: 'ENTITY',
entitySelectComponent: <FilterDropdownPeopleSearchSelect />, entitySelectComponent: <FilterDropdownPeopleSearchSelect />,
}, },
]; ];

View File

@@ -26,7 +26,7 @@ export const personShowFieldDefinition: FieldDefinition<FieldMetadata>[] = [
fieldId: 'email', fieldId: 'email',
label: 'Email', label: 'Email',
Icon: IconMail, Icon: IconMail,
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'email', fieldName: 'email',
placeHolder: 'Email', placeHolder: 'Email',
@@ -36,7 +36,7 @@ export const personShowFieldDefinition: FieldDefinition<FieldMetadata>[] = [
fieldId: 'company', fieldId: 'company',
label: 'Company', label: 'Company',
Icon: IconBuildingSkyscraper, Icon: IconBuildingSkyscraper,
type: 'relation', type: 'RELATION',
metadata: { metadata: {
fieldName: 'company', fieldName: 'company',
relationType: Entity.Company, relationType: Entity.Company,
@@ -53,7 +53,7 @@ export const personShowFieldDefinition: FieldDefinition<FieldMetadata>[] = [
fieldId: 'phone', fieldId: 'phone',
label: 'Phone', label: 'Phone',
Icon: IconPhone, Icon: IconPhone,
type: 'phone', type: 'PHONE',
metadata: { metadata: {
fieldName: 'phone', fieldName: 'phone',
placeHolder: 'Phone', placeHolder: 'Phone',
@@ -63,7 +63,7 @@ export const personShowFieldDefinition: FieldDefinition<FieldMetadata>[] = [
fieldId: 'jobTitle', fieldId: 'jobTitle',
label: 'Job Title', label: 'Job Title',
Icon: IconBriefcase, Icon: IconBriefcase,
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'jobTitle', fieldName: 'jobTitle',
placeHolder: 'Job Title', placeHolder: 'Job Title',
@@ -73,7 +73,7 @@ export const personShowFieldDefinition: FieldDefinition<FieldMetadata>[] = [
fieldId: 'city', fieldId: 'city',
label: 'City', label: 'City',
Icon: IconMap, Icon: IconMap,
type: 'text', type: 'TEXT',
metadata: { metadata: {
fieldName: 'city', fieldName: 'city',
placeHolder: 'City', placeHolder: 'City',
@@ -83,7 +83,7 @@ export const personShowFieldDefinition: FieldDefinition<FieldMetadata>[] = [
fieldId: 'linkedinUrl', fieldId: 'linkedinUrl',
label: 'Linkedin URL', label: 'Linkedin URL',
Icon: IconBrandLinkedin, Icon: IconBrandLinkedin,
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'linkedinUrl', fieldName: 'linkedinUrl',
placeHolder: 'Linkedin URL', placeHolder: 'Linkedin URL',
@@ -93,7 +93,7 @@ export const personShowFieldDefinition: FieldDefinition<FieldMetadata>[] = [
fieldId: 'xUrl', fieldId: 'xUrl',
label: 'X URL', label: 'X URL',
Icon: IconBrandX, Icon: IconBrandX,
type: 'url', type: 'URL',
metadata: { metadata: {
fieldName: 'xUrl', fieldName: 'xUrl',
placeHolder: 'X URL', placeHolder: 'X URL',
@@ -103,7 +103,7 @@ export const personShowFieldDefinition: FieldDefinition<FieldMetadata>[] = [
fieldId: 'createdAt', fieldId: 'createdAt',
label: 'Created at', label: 'Created at',
Icon: IconCalendar, Icon: IconCalendar,
type: 'date', type: 'DATE',
metadata: { metadata: {
fieldName: 'createdAt', fieldName: 'createdAt',
}, },

View File

@@ -16,25 +16,25 @@ export const personTableFilterDefinitions: FilterDefinitionByEntity<Person>[] =
fieldId: 'firstName', fieldId: 'firstName',
label: 'First name', label: 'First name',
Icon: IconUser, Icon: IconUser,
type: 'text', type: 'TEXT',
}, },
{ {
fieldId: 'lastName', fieldId: 'lastName',
label: 'Last name', label: 'Last name',
Icon: IconUser, Icon: IconUser,
type: 'text', type: 'TEXT',
}, },
{ {
fieldId: 'email', fieldId: 'email',
label: 'Email', label: 'Email',
Icon: IconMail, Icon: IconMail,
type: 'text', type: 'TEXT',
}, },
{ {
fieldId: 'companyId', fieldId: 'companyId',
label: 'Company', label: 'Company',
Icon: IconBuildingSkyscraper, Icon: IconBuildingSkyscraper,
type: 'entity', type: 'ENTITY',
// TODO: replace this with a component that selects the dropdown to use based on the entity type // TODO: replace this with a component that selects the dropdown to use based on the entity type
entitySelectComponent: <FilterDropdownCompanySearchSelect />, entitySelectComponent: <FilterDropdownCompanySearchSelect />,
}, },
@@ -42,18 +42,18 @@ export const personTableFilterDefinitions: FilterDefinitionByEntity<Person>[] =
fieldId: 'phone', fieldId: 'phone',
label: 'Phone', label: 'Phone',
Icon: IconPhone, Icon: IconPhone,
type: 'text', type: 'TEXT',
}, },
{ {
fieldId: 'createdAt', fieldId: 'createdAt',
label: 'Created at', label: 'Created at',
Icon: IconCalendarEvent, Icon: IconCalendarEvent,
type: 'date', type: 'DATE',
}, },
{ {
fieldId: 'city', fieldId: 'city',
label: 'City', label: 'City',
Icon: IconMap, Icon: IconMap,
type: 'text', type: 'TEXT',
}, },
]; ];

View File

@@ -40,7 +40,7 @@ export const SettingsObjectNewFieldStep2 = () => {
icon: string; icon: string;
label: string; label: string;
type: MetadataFieldDataType; type: MetadataFieldDataType;
}>({ icon: 'IconUsers', label: '', type: 'number' }); }>({ icon: 'IconUsers', label: '', type: 'NUMBER' });
const [objectViews, setObjectViews] = useState<View[]>([]); const [objectViews, setObjectViews] = useState<View[]>([]);

View File

@@ -8,7 +8,7 @@ export const tasksFilterDefinitions: FilterDefinitionByEntity<Activity>[] = [
fieldId: 'assigneeId', fieldId: 'assigneeId',
label: 'Assignee', label: 'Assignee',
Icon: IconUser, Icon: IconUser,
type: 'entity', type: 'ENTITY',
entitySelectComponent: <FilterDropdownUserSearchSelect />, entitySelectComponent: <FilterDropdownUserSearchSelect />,
selectAllLabel: 'All assignees', selectAllLabel: 'All assignees',
SelectAllIcon: IconUserCircle, SelectAllIcon: IconUserCircle,

View File

@@ -19,7 +19,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '5db475e7-8208-402d-97a1-62c9ce344dd4', id: '5db475e7-8208-402d-97a1-62c9ce344dd4',
type: 'text', type: 'TEXT',
name: 'objectId', name: 'objectId',
label: 'Object Id', label: 'Object Id',
description: 'View target object', description: 'View target object',
@@ -35,7 +35,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: 'ddc89a56-9add-4110-aa53-4ecdbba36767', id: 'ddc89a56-9add-4110-aa53-4ecdbba36767',
type: 'text', type: 'TEXT',
name: 'type', name: 'type',
label: 'Type', label: 'Type',
description: 'View type', description: 'View type',
@@ -51,7 +51,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '35fa806b-5d9d-446d-bd0e-1a6874b871ee', id: '35fa806b-5d9d-446d-bd0e-1a6874b871ee',
type: 'text', type: 'TEXT',
name: 'name', name: 'name',
label: 'Name', label: 'Name',
description: 'View name', description: 'View name',
@@ -94,7 +94,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '1d718fcf-5a17-4694-91a4-4d3968a51aa4', id: '1d718fcf-5a17-4694-91a4-4d3968a51aa4',
type: 'text', type: 'TEXT',
name: 'viewId', name: 'viewId',
label: 'View Id', label: 'View Id',
description: 'View Field related view', description: 'View Field related view',
@@ -110,7 +110,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '8ead2e86-7b60-4a47-9b4f-ad008e744d52', id: '8ead2e86-7b60-4a47-9b4f-ad008e744d52',
type: 'number', type: 'NUMBER',
name: 'position', name: 'position',
label: 'Position', label: 'Position',
description: 'View Field position', description: 'View Field position',
@@ -126,7 +126,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '4d77c2dd-2b04-4989-b11e-cb0e386d1b4d', id: '4d77c2dd-2b04-4989-b11e-cb0e386d1b4d',
type: 'text', type: 'TEXT',
name: 'fieldId', name: 'fieldId',
label: 'Field Id', label: 'Field Id',
description: 'View Field target field', description: 'View Field target field',
@@ -142,7 +142,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '0f5ab566-9fc4-44b7-85c5-1e05db9f6b49', id: '0f5ab566-9fc4-44b7-85c5-1e05db9f6b49',
type: 'boolean', type: 'BOOLEAN',
name: 'isVisible', name: 'isVisible',
label: 'Visible', label: 'Visible',
description: 'View Field visibility', description: 'View Field visibility',
@@ -158,7 +158,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '21268ece-7002-4b04-a442-f25278f8ca13', id: '21268ece-7002-4b04-a442-f25278f8ca13',
type: 'number', type: 'NUMBER',
name: 'size', name: 'size',
label: 'Size', label: 'Size',
description: 'View Field size', description: 'View Field size',
@@ -201,7 +201,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '397eabc0-c5a1-4550-8e68-839c878a8d0e', id: '397eabc0-c5a1-4550-8e68-839c878a8d0e',
type: 'text', type: 'TEXT',
name: 'name', name: 'name',
label: 'Name', label: 'Name',
description: 'The company name.', description: 'The company name.',
@@ -217,8 +217,8 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '7ad234c7-f3b9-4efc-813c-43dc97070b07', id: '7ad234c7-f3b9-4efc-813c-43dc97070b07',
type: 'url', type: 'URL',
name: 'url', name: 'URL',
label: 'URL', label: 'URL',
description: description:
'The company website URL. We use this url to fetch the company icon.', 'The company website URL. We use this url to fetch the company icon.',
@@ -234,7 +234,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: 'a578ffb2-13db-483c-ace7-5c30a13dff2d', id: 'a578ffb2-13db-483c-ace7-5c30a13dff2d',
type: 'relation', type: 'RELATION',
name: 'accountOwner', name: 'accountOwner',
label: 'Account Owner', label: 'Account Owner',
description: description:
@@ -251,7 +251,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: 'b7fd622d-7d8b-4f5a-b148-a7e9fd2c4660', id: 'b7fd622d-7d8b-4f5a-b148-a7e9fd2c4660',
type: 'number', type: 'NUMBER',
name: 'employees', name: 'employees',
label: 'Employees', label: 'Employees',
description: 'Number of employees in the company.', description: 'Number of employees in the company.',
@@ -267,7 +267,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '60ab27ed-a959-471e-b583-887387f7accd', id: '60ab27ed-a959-471e-b583-887387f7accd',
type: 'url', type: 'URL',
name: 'linkedin', name: 'linkedin',
label: 'Linkedin', label: 'Linkedin',
description: null, description: null,
@@ -283,7 +283,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: '6daadb98-83ca-4c85-bca5-7792a7d958ad', id: '6daadb98-83ca-4c85-bca5-7792a7d958ad',
type: 'boolean', type: 'BOOLEAN',
name: 'prioritySupport', name: 'prioritySupport',
label: 'Priority Support', label: 'Priority Support',
description: 'Whether the company has priority support.', description: 'Whether the company has priority support.',
@@ -326,7 +326,7 @@ export const mockedObjectMetadataItems = {
{ {
node: { node: {
id: 'f955402c-9e8f-4b91-a82c-95f6de392b99', id: 'f955402c-9e8f-4b91-a82c-95f6de392b99',
type: 'text', type: 'TEXT',
name: 'slug', name: 'slug',
label: 'Slug', label: 'Slug',
description: null, description: null,

View File

@@ -43,6 +43,7 @@
"@aws-sdk/credential-providers": "^3.363.0", "@aws-sdk/credential-providers": "^3.363.0",
"@casl/ability": "^6.5.0", "@casl/ability": "^6.5.0",
"@casl/prisma": "1.4.0", "@casl/prisma": "1.4.0",
"@graphql-tools/schema": "^10.0.0",
"@graphql-yoga/nestjs": "^2.1.0", "@graphql-yoga/nestjs": "^2.1.0",
"@nestjs/apollo": "^11.0.5", "@nestjs/apollo": "^11.0.5",
"@nestjs/common": "^9.0.0", "@nestjs/common": "^9.0.0",
@@ -78,6 +79,7 @@
"graphql": "16.8.0", "graphql": "16.8.0",
"graphql-fields": "^2.0.3", "graphql-fields": "^2.0.3",
"graphql-subscriptions": "2.0.0", "graphql-subscriptions": "2.0.0",
"graphql-tag": "^2.12.6",
"graphql-type-json": "^0.3.2", "graphql-type-json": "^0.3.2",
"graphql-upload": "^13.0.0", "graphql-upload": "^13.0.0",
"graphql-yoga": "^4.0.4", "graphql-yoga": "^4.0.4",

View File

@@ -30,7 +30,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'name', name: 'name',
label: 'Name', label: 'Name',
targetColumnMap: { targetColumnMap: {
@@ -45,7 +45,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'domainName', name: 'domainName',
label: 'Domain Name', label: 'Domain Name',
targetColumnMap: { targetColumnMap: {
@@ -60,7 +60,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'address', name: 'address',
label: 'Address', label: 'Address',
targetColumnMap: { targetColumnMap: {
@@ -75,7 +75,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'employees', name: 'employees',
label: 'Employees', label: 'Employees',
targetColumnMap: { targetColumnMap: {
@@ -91,7 +91,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'name', name: 'name',
label: 'Name', label: 'Name',
targetColumnMap: { targetColumnMap: {
@@ -106,7 +106,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'objectId', name: 'objectId',
label: 'Object Id', label: 'Object Id',
targetColumnMap: { targetColumnMap: {
@@ -121,7 +121,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'type', name: 'type',
label: 'Type', label: 'Type',
targetColumnMap: { targetColumnMap: {
@@ -137,7 +137,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'fieldId', name: 'fieldId',
label: 'Field Id', label: 'Field Id',
targetColumnMap: { targetColumnMap: {
@@ -152,7 +152,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'viewId', name: 'viewId',
label: 'View Id', label: 'View Id',
targetColumnMap: { targetColumnMap: {
@@ -167,7 +167,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'boolean', type: 'BOOLEAN',
name: 'isVisible', name: 'isVisible',
label: 'Visible', label: 'Visible',
targetColumnMap: { targetColumnMap: {
@@ -182,7 +182,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'number', type: 'NUMBER',
name: 'size', name: 'size',
label: 'Size', label: 'Size',
targetColumnMap: { targetColumnMap: {
@@ -197,7 +197,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'number', type: 'NUMBER',
name: 'position', name: 'position',
label: 'Position', label: 'Position',
targetColumnMap: { targetColumnMap: {
@@ -213,7 +213,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'fieldId', name: 'fieldId',
label: 'Field Id', label: 'Field Id',
targetColumnMap: { targetColumnMap: {
@@ -228,7 +228,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'viewId', name: 'viewId',
label: 'View Id', label: 'View Id',
targetColumnMap: { targetColumnMap: {
@@ -243,7 +243,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'operand', name: 'operand',
label: 'Operand', label: 'Operand',
targetColumnMap: { targetColumnMap: {
@@ -258,7 +258,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'value', name: 'value',
label: 'Value', label: 'Value',
targetColumnMap: { targetColumnMap: {
@@ -273,7 +273,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'displayValue', name: 'displayValue',
label: 'Display Value', label: 'Display Value',
targetColumnMap: { targetColumnMap: {
@@ -289,7 +289,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'fieldId', name: 'fieldId',
label: 'Field Id', label: 'Field Id',
targetColumnMap: { targetColumnMap: {
@@ -304,7 +304,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'viewId', name: 'viewId',
label: 'View Id', label: 'View Id',
targetColumnMap: { targetColumnMap: {
@@ -319,7 +319,7 @@ export const seedFieldMetadata = async (
isCustom: false, isCustom: false,
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
isActive: true, isActive: true,
type: 'text', type: 'TEXT',
name: 'direction', name: 'direction',
label: 'Direction', label: 'Direction',
targetColumnMap: { targetColumnMap: {

View File

@@ -14,6 +14,9 @@ import { EnvironmentService } from './integrations/environment/environment.servi
const bootstrap = async () => { const bootstrap = async () => {
const app = await NestFactory.create(AppModule, { const app = await NestFactory.create(AppModule, {
cors: true, cors: true,
logger: process.env.DEBUG_MODE
? ['error', 'warn', 'log', 'verbose', 'debug']
: ['error', 'warn', 'log'],
}); });
// Apply validation pipes globally // Apply validation pipes globally

View File

@@ -8,6 +8,8 @@ import {
IsUUID, IsUUID,
} from 'class-validator'; } from 'class-validator';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
@InputType() @InputType()
export class CreateFieldInput { export class CreateFieldInput {
@IsString() @IsString()
@@ -20,20 +22,10 @@ export class CreateFieldInput {
@Field() @Field()
label: string; label: string;
// Todo: use a type enum and share with typeorm entity @IsEnum(FieldMetadataType)
@IsEnum([
'text',
'phone',
'email',
'number',
'boolean',
'date',
'url',
'money',
])
@IsNotEmpty() @IsNotEmpty()
@Field() @Field(() => FieldMetadataType)
type: string; type: FieldMetadataType;
@IsUUID() @IsUUID()
@Field() @Field()

View File

@@ -1,4 +1,4 @@
import { Field, ID, ObjectType } from '@nestjs/graphql'; import { Field, ID, ObjectType, registerEnumType } from '@nestjs/graphql';
import { import {
Column, Column,
@@ -17,13 +17,31 @@ import {
QueryOptions, QueryOptions,
} from '@ptc-org/nestjs-query-graphql'; } from '@ptc-org/nestjs-query-graphql';
import { FieldMetadataInterface } from 'src/tenant/schema-builder/interfaces/field-metadata.interface';
import { ObjectMetadata } from 'src/metadata/object-metadata/object-metadata.entity'; import { ObjectMetadata } from 'src/metadata/object-metadata/object-metadata.entity';
import { BeforeCreateOneField } from './hooks/before-create-one-field.hook'; import { BeforeCreateOneField } from './hooks/before-create-one-field.hook';
import { FieldMetadataTargetColumnMap } from './interfaces/field-metadata-target-column-map.interface';
export enum FieldMetadataType {
UUID = 'uuid',
TEXT = 'TEXT',
PHONE = 'PHONE',
EMAIL = 'EMAIL',
DATE = 'DATE',
BOOLEAN = 'BOOLEAN',
NUMBER = 'NUMBER',
ENUM = 'ENUM',
URL = 'URL',
MONEY = 'MONEY',
}
registerEnumType(FieldMetadataType, {
name: 'FieldMetadataType',
description: 'Type of the field',
});
export type FieldMetadataTargetColumnMap = {
[key: string]: string;
};
@Entity('field_metadata') @Entity('field_metadata')
@ObjectType('field') @ObjectType('field')
@BeforeCreateOne(BeforeCreateOneField) @BeforeCreateOne(BeforeCreateOneField)
@@ -43,7 +61,7 @@ export type FieldMetadataTargetColumnMap = {
'objectId', 'objectId',
'workspaceId', 'workspaceId',
]) ])
export class FieldMetadata { export class FieldMetadata implements FieldMetadataInterface {
@IDField(() => ID) @IDField(() => ID)
@PrimaryGeneratedColumn('uuid') @PrimaryGeneratedColumn('uuid')
id: string; id: string;
@@ -51,9 +69,9 @@ export class FieldMetadata {
@Column({ nullable: false, name: 'object_id' }) @Column({ nullable: false, name: 'object_id' })
objectId: string; objectId: string;
@Field() @Field(() => FieldMetadataType)
@Column({ nullable: false }) @Column({ nullable: false })
type: string; type: FieldMetadataType;
@Field() @Field()
@Column({ nullable: false }) @Column({ nullable: false })

View File

@@ -0,0 +1,35 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
export interface FieldMetadataTargetColumnMapValue {
value: string;
}
export interface FieldMetadataTargetColumnMapUrl {
text: string;
link: string;
}
export interface FieldMetadataTargetColumnMapMoney {
value: number;
currency: string;
}
type AllFieldMetadataTypes = {
[key: string]: any;
};
type FieldMetadataTypeMapping = {
[FieldMetadataType.URL]: FieldMetadataTargetColumnMapUrl;
[FieldMetadataType.MONEY]: FieldMetadataTargetColumnMapMoney;
};
type TypeByFieldMetadata<T extends FieldMetadataType | 'default'> =
T extends keyof FieldMetadataTypeMapping
? FieldMetadataTypeMapping[T]
: T extends 'default'
? AllFieldMetadataTypes
: FieldMetadataTargetColumnMapValue;
export type FieldMetadataTargetColumnMap<
T extends FieldMetadataType | 'default' = 'default',
> = TypeByFieldMetadata<T>;

View File

@@ -1,9 +1,11 @@
import { v4 } from 'uuid'; import { v4 } from 'uuid';
import { FieldMetadataTargetColumnMap } from 'src/metadata/field-metadata/interfaces/field-metadata-target-column-map.interface';
import { uuidToBase36 } from 'src/metadata/data-source/data-source.util'; import { uuidToBase36 } from 'src/metadata/data-source/data-source.util';
import { import {
FieldMetadata, FieldMetadata,
FieldMetadataTargetColumnMap, FieldMetadataType,
} from 'src/metadata/field-metadata/field-metadata.entity'; } from 'src/metadata/field-metadata/field-metadata.entity';
import { TenantMigrationColumnAction } from 'src/metadata/tenant-migration/tenant-migration.entity'; import { TenantMigrationColumnAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
@@ -25,24 +27,24 @@ export function generateColumnName(name: string): string {
* @returns FieldMetadataTargetColumnMap * @returns FieldMetadataTargetColumnMap
*/ */
export function generateTargetColumnMap( export function generateTargetColumnMap(
type: string, type: FieldMetadataType,
): FieldMetadataTargetColumnMap { ): FieldMetadataTargetColumnMap {
switch (type) { switch (type) {
case 'text': case FieldMetadataType.TEXT:
case 'phone': case FieldMetadataType.PHONE:
case 'email': case FieldMetadataType.EMAIL:
case 'number': case FieldMetadataType.NUMBER:
case 'boolean': case FieldMetadataType.BOOLEAN:
case 'date': case FieldMetadataType.DATE:
return { return {
value: `column_${uuidToBase36(v4())}`, value: `column_${uuidToBase36(v4())}`,
}; };
case 'url': case FieldMetadataType.URL:
return { return {
text: `column_${uuidToBase36(v4())}`, text: `column_${uuidToBase36(v4())}`,
link: `column_${uuidToBase36(v4())}`, link: `column_${uuidToBase36(v4())}`,
}; };
case 'money': case FieldMetadataType.MONEY:
return { return {
amount: `column_${uuidToBase36(v4())}`, amount: `column_${uuidToBase36(v4())}`,
currency: `column_${uuidToBase36(v4())}`, currency: `column_${uuidToBase36(v4())}`,
@@ -56,7 +58,7 @@ export function convertFieldMetadataToColumnActions(
fieldMetadata: FieldMetadata, fieldMetadata: FieldMetadata,
): TenantMigrationColumnAction[] { ): TenantMigrationColumnAction[] {
switch (fieldMetadata.type) { switch (fieldMetadata.type) {
case 'text': case FieldMetadataType.TEXT:
return [ return [
{ {
name: fieldMetadata.targetColumnMap.value, name: fieldMetadata.targetColumnMap.value,
@@ -64,8 +66,8 @@ export function convertFieldMetadataToColumnActions(
type: 'text', type: 'text',
}, },
]; ];
case 'phone': case FieldMetadataType.PHONE:
case 'email': case FieldMetadataType.EMAIL:
return [ return [
{ {
name: fieldMetadata.targetColumnMap.value, name: fieldMetadata.targetColumnMap.value,
@@ -73,7 +75,7 @@ export function convertFieldMetadataToColumnActions(
type: 'varchar', type: 'varchar',
}, },
]; ];
case 'number': case FieldMetadataType.NUMBER:
return [ return [
{ {
name: fieldMetadata.targetColumnMap.value, name: fieldMetadata.targetColumnMap.value,
@@ -81,7 +83,7 @@ export function convertFieldMetadataToColumnActions(
type: 'integer', type: 'integer',
}, },
]; ];
case 'boolean': case FieldMetadataType.BOOLEAN:
return [ return [
{ {
name: fieldMetadata.targetColumnMap.value, name: fieldMetadata.targetColumnMap.value,
@@ -89,7 +91,7 @@ export function convertFieldMetadataToColumnActions(
type: 'boolean', type: 'boolean',
}, },
]; ];
case 'date': case FieldMetadataType.DATE:
return [ return [
{ {
name: fieldMetadata.targetColumnMap.value, name: fieldMetadata.targetColumnMap.value,
@@ -97,7 +99,7 @@ export function convertFieldMetadataToColumnActions(
type: 'timestamp', type: 'timestamp',
}, },
]; ];
case 'url': case FieldMetadataType.URL:
return [ return [
{ {
name: fieldMetadata.targetColumnMap.text, name: fieldMetadata.targetColumnMap.text,
@@ -110,7 +112,7 @@ export function convertFieldMetadataToColumnActions(
type: 'varchar', type: 'varchar',
}, },
]; ];
case 'money': case FieldMetadataType.MONEY:
return [ return [
{ {
name: fieldMetadata.targetColumnMap.amount, name: fieldMetadata.targetColumnMap.amount,
@@ -127,24 +129,3 @@ export function convertFieldMetadataToColumnActions(
throw new Error(`Unknown type ${fieldMetadata.type}`); throw new Error(`Unknown type ${fieldMetadata.type}`);
} }
} }
// Deprecated with target_column_name deprecation
export function convertMetadataTypeToColumnType(type: string) {
switch (type) {
case 'text':
case 'url':
case 'phone':
case 'email':
return 'text';
case 'number':
return 'int';
case 'boolean':
return 'boolean';
case 'date':
return 'timestamp';
case 'money':
return 'integer';
default:
throw new Error('Invalid type');
}
}

View File

@@ -0,0 +1,25 @@
import { TableColumnOptions } from 'typeorm';
export const customTableDefaultColumns: TableColumnOptions[] = [
{
name: 'id',
type: 'uuid',
isPrimary: true,
default: 'public.uuid_generate_v4()',
},
{
name: 'createdAt',
type: 'timestamp',
default: 'now()',
},
{
name: 'updatedAt',
type: 'timestamp',
default: 'now()',
},
{
name: 'deletedAt',
type: 'timestamp',
isNullable: true,
},
];

Some files were not shown because too many files have changed in this diff Show More