Move FieldMetadataType to twenty-shared (#9482)

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Marie
2025-01-09 18:43:30 +01:00
committed by GitHub
parent c39af5f063
commit 71a4593ba4
163 changed files with 341 additions and 388 deletions

View File

@ -1,19 +1,15 @@
{
"name": "twenty-zapier",
"version": "2.0.0",
"version": "2.0.1",
"description": "Effortlessly sync Twenty with 3000+ apps. Automate tasks, boost productivity, and supercharge your customer relationships!",
"main": "src/index.ts",
"scripts": {
"nx": "NX_DEFAULT_PROJECT=twenty-zapier node ../../node_modules/nx/bin/nx.js",
"format": "prettier . --write \"!build\"",
"test": "yarn build && jest --testTimeout 10000 --rootDir ./lib/test",
"build": "yarn clean && tsc",
"deploy": "yarn build && zapier push",
"validate": "yarn build && zapier validate",
"versions": "yarn build && zapier versions",
"clean": "rimraf ./lib ./build",
"watch": "yarn clean && tsc --watch",
"_zapier-build": "yarn build"
"watch": "yarn clean && npx tsc --watch"
},
"engines": {
"node": "^18.17.1",

View File

@ -0,0 +1,32 @@
{
"name": "twenty-zapier",
"projectType": "application",
"tags": ["scope:zapier"],
"targets": {
"build": {
"outputs": ["{projectRoot}/lib"],
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"commands": ["nx run twenty-zapier:clean && tsc"]
},
"dependsOn": ["^build"]
},
"clean": {
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"commands": ["rimraf ./lib ./build"]
}
},
"deploy": {
"executor": "nx:run-commands",
"options": {
"cwd": "{projectRoot}",
"commands": [
"nx run twenty-zapier:build && cp -r ../twenty-shared/ node_modules/twenty-shared && zapier push --skip-npm-install"
]
}
}
}
}

View File

@ -1,8 +1,8 @@
import { Bundle, ZObject } from 'zapier-platform-core';
import { capitalize } from 'twenty-shared';
import { findObjectNamesSingularKey } from '../triggers/find_object_names_singular';
import { listRecordIdsKey } from '../triggers/list_record_ids';
import { capitalize } from '../utils/capitalize';
import { computeInputFields } from '../utils/computeInputFields';
import { InputData } from '../utils/data.types';
import handleQueryParams from '../utils/handleQueryParams';

View File

@ -1,8 +0,0 @@
import { capitalize } from '../../utils/capitalize';
describe('capitalize', () => {
test('should capitalize properly', () => {
expect(capitalize('word')).toEqual('Word');
expect(capitalize('word word')).toEqual('Word word');
});
});

View File

@ -1,5 +1,6 @@
import { FieldMetadataType } from 'twenty-shared';
import { computeInputFields } from '../../utils/computeInputFields';
import { FieldMetadataType, InputField } from '../../utils/data.types';
import { InputField } from '../../utils/data.types';
describe('computeInputFields', () => {
test('should create Person input fields properly', () => {
@ -89,16 +90,6 @@ describe('computeInputFields', () => {
defaultValue: null,
},
},
{
node: {
type: FieldMetadataType.LINK,
name: 'xLink',
label: 'X',
description: 'Contacts X/Twitter account',
isNullable: true,
defaultValue: null,
},
},
{
node: {
type: FieldMetadataType.LINKS,
@ -109,18 +100,6 @@ describe('computeInputFields', () => {
defaultValue: null,
},
},
{
node: {
type: FieldMetadataType.EMAIL,
name: 'email',
label: 'Email',
description: 'Contacts Email',
isNullable: false,
defaultValue: {
value: '',
},
},
},
{
node: {
type: FieldMetadataType.UUID,

View File

@ -1,3 +0,0 @@
export const capitalize = (word: string): string => {
return word.charAt(0).toUpperCase() + word.slice(1);
};

View File

@ -1,9 +1,5 @@
import {
FieldMetadataType,
InputField,
Node,
NodeField,
} from '../utils/data.types';
import { FieldMetadataType } from 'twenty-shared';
import { InputField, Node, NodeField } from '../utils/data.types';
const getListFromFieldMetadataType = (fieldMetadataType: FieldMetadataType) => {
return fieldMetadataType === FieldMetadataType.ARRAY;
@ -16,9 +12,6 @@ const getTypeFromFieldMetadataType = (
case FieldMetadataType.UUID:
case FieldMetadataType.TEXT:
case FieldMetadataType.RICH_TEXT:
case FieldMetadataType.PHONE:
case FieldMetadataType.EMAIL:
case FieldMetadataType.LINK:
case FieldMetadataType.ARRAY:
case FieldMetadataType.RATING:
return 'string';
@ -59,25 +52,6 @@ const get_subfieldsFromField = (nodeField: NodeField): NodeField[] => {
};
return [firstName, lastName];
}
case FieldMetadataType.LINK: {
const url: NodeField = {
type: FieldMetadataType.TEXT,
name: 'url',
label: 'Url',
description: 'Link Url',
isNullable: true,
defaultValue: null,
};
const label: NodeField = {
type: FieldMetadataType.TEXT,
name: 'label',
label: 'Label',
description: 'Link Label',
isNullable: true,
defaultValue: null,
};
return [url, label];
}
case FieldMetadataType.CURRENCY: {
const amountMicros: NodeField = {
type: FieldMetadataType.NUMBER,
@ -244,7 +218,6 @@ export const computeInputFields = (
const nodeField = field.node;
switch (nodeField.type) {
case FieldMetadataType.FULL_NAME:
case FieldMetadataType.LINK:
case FieldMetadataType.CURRENCY:
case FieldMetadataType.PHONES:
case FieldMetadataType.EMAILS:
@ -266,8 +239,6 @@ export const computeInputFields = (
case FieldMetadataType.UUID:
case FieldMetadataType.TEXT:
case FieldMetadataType.RICH_TEXT:
case FieldMetadataType.PHONE:
case FieldMetadataType.EMAIL:
case FieldMetadataType.DATE_TIME:
case FieldMetadataType.DATE:
case FieldMetadataType.BOOLEAN:

View File

@ -1,3 +1,5 @@
import { FieldMetadataType } from 'twenty-shared';
export type InputData = { [x: string]: any };
export type NodeField = {
@ -32,37 +34,6 @@ export type InputField = {
placeholder?: string;
};
export enum FieldMetadataType {
UUID = 'UUID',
TEXT = 'TEXT',
PHONE = 'PHONE',
PHONES = 'PHONES',
EMAIL = 'EMAIL',
EMAILS = 'EMAILS',
DATE_TIME = 'DATE_TIME',
DATE = 'DATE',
BOOLEAN = 'BOOLEAN',
NUMBER = 'NUMBER',
NUMERIC = 'NUMERIC',
LINK = 'LINK',
LINKS = 'LINKS',
CURRENCY = 'CURRENCY',
FULL_NAME = 'FULL_NAME',
RATING = 'RATING',
SELECT = 'SELECT',
MULTI_SELECT = 'MULTI_SELECT',
POSITION = 'POSITION',
ADDRESS = 'ADDRESS',
RICH_TEXT = 'RICH_TEXT',
ARRAY = 'ARRAY',
// Ignored fieldTypes
RELATION = 'RELATION',
RAW_JSON = 'RAW_JSON',
ACTOR = 'ACTOR',
TS_VECTOR = 'TS_VECTOR',
}
export type Schema = {
data: {
objects: {

View File

@ -8,7 +8,7 @@
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
"skipLibCheck": true,
},
"exclude": [
"jest.config.ts"