Skip to content

The open alternative to Salesforce, designed for AI.

Fix initial code step functionInput (#18002)

martmulle3fcff00b06b
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx
index 77d94c5904b..610530bad3e 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx
@@ -37,7 +37,7 @@ import { CODE_ACTION } from '@/workflow/workflow-steps/workflow-actions/constant
import { type Monaco } from '@monaco-editor/react';
import { type editor } from 'monaco-editor';
import { AutoTypings } from 'monaco-editor-auto-typings';
-import { useEffect, useState } from 'react';
+import { useState } from 'react';
import { useRecoilState } from 'recoil';
import { Key } from 'ts-key-enum';
import { isDefined } from 'twenty-shared/utils';
@@ -49,7 +49,7 @@ import { IconCode, IconPlayerPlay } from 'twenty-ui/display';
import { CodeEditor } from 'twenty-ui/input';
import { useIsMobile } from 'twenty-ui/utilities';
import { useDebouncedCallback } from 'use-debounce';
-import { getFunctionInputFromInputSchema } from '@/workflow/workflow-steps/workflow-actions/code-action/utils/getFunctionInputFromInputSchema';
+import { getFunctionInputFromInputSchema } from 'twenty-shared/workflow';
const CODE_EDITOR_MIN_HEIGHT = 343;
@@ -290,10 +290,6 @@ export const WorkflowEditActionCode = ({
},
];
- useEffect(() => {
- setFunctionInput(action.settings.input.logicFunctionInput);
- }, [action]);
-
useHotkeysOnFocusedElement({
keys: [Key.Escape],
callback: () => {
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCodeFields.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCodeFields.tsx
index 8832687c9a9..b4e45ad04e4 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCodeFields.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCodeFields.tsx
@@ -2,7 +2,7 @@ import { FormNestedFieldInputContainer } from '@/object-record/record-field/ui/f
import { FormTextFieldInput } from '@/object-record/record-field/ui/form-types/components/FormTextFieldInput';
import { type VariablePickerComponent } from '@/object-record/record-field/ui/form-types/types/VariablePickerComponent';
import { InputLabel } from '@/ui/input/components/InputLabel';
-import { type FunctionInput } from '@/workflow/workflow-steps/workflow-actions/code-action/types/FunctionInput';
+import { type FunctionInput } from 'twenty-shared/workflow';
import styled from '@emotion/styled';
import { t } from '@lingui/core/macro';
import { isObject } from '@sniptt/guards';
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/mergeDefaultFunctionInputAndFunctionInput.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/mergeDefaultFunctionInputAndFunctionInput.ts
index 57a51165956..2f0d3634d2d 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/mergeDefaultFunctionInputAndFunctionInput.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/mergeDefaultFunctionInputAndFunctionInput.ts
@@ -1,4 +1,4 @@
-import { type FunctionInput } from '@/workflow/workflow-steps/workflow-actions/code-action/types/FunctionInput';
+import { type FunctionInput } from 'twenty-shared/workflow';
import { isObject } from '@sniptt/guards';
export const mergeDefaultFunctionInputAndFunctionInput = ({
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/utils/getHttpRequestOutputSchema.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/utils/getHttpRequestOutputSchema.ts
index b006d58c137..14331d9b2fa 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/utils/getHttpRequestOutputSchema.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/utils/getHttpRequestOutputSchema.ts
@@ -1,5 +1,7 @@
-import { type InputSchemaPropertyType } from '@/workflow/types/InputSchema';
-import { type BaseOutputSchemaV2 } from 'twenty-shared/workflow';
+import {
+ type InputSchemaPropertyType,
+ type BaseOutputSchemaV2,
+} from 'twenty-shared/workflow';
const getValueType = (value: unknown): InputSchemaPropertyType => {
if (value === null || value === undefined) {
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/logic-function-action/components/WorkflowEditActionLogicFunction.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/logic-function-action/components/WorkflowEditActionLogicFunction.tsx
index ab2ac93f70b..17c2183b83b 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/logic-function-action/components/WorkflowEditActionLogicFunction.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/logic-function-action/components/WorkflowEditActionLogicFunction.tsx
@@ -1,4 +1,4 @@
-import { getFunctionInputFromInputSchema } from '@/workflow/workflow-steps/workflow-actions/code-action/utils/getFunctionInputFromInputSchema';
+import { getFunctionInputFromInputSchema } from 'twenty-shared/workflow';
import { mergeDefaultFunctionInputAndFunctionInput } from '@/workflow/workflow-steps/workflow-actions/code-action/utils/mergeDefaultFunctionInputAndFunctionInput';
import { useGetOneLogicFunction } from '@/logic-functions/hooks/useGetOneLogicFunction';
import { type WorkflowLogicFunctionAction } from '@/workflow/types/Workflow';
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdown.tsx b/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdown.tsx
index fdcf37dd48b..fc2d7aed38c 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdown.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdown.tsx
@@ -3,7 +3,7 @@ import { StyledDropdownButtonContainer } from '@/ui/layout/dropdown/components/S
import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState';
import { useRecoilComponentValue } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValue';
-import { type InputSchemaPropertyType } from '@/workflow/types/InputSchema';
+import { type InputSchemaPropertyType } from 'twenty-shared/workflow';
import { WorkflowVariablesDropdownStepItems } from '@/workflow/workflow-variables/components/WorkflowVariablesDropdownStepItems';
import { WorkflowVariablesDropdownSteps } from '@/workflow/workflow-variables/components/WorkflowVariablesDropdownSteps';
import { SEARCH_VARIABLES_DROPDOWN_ID } from '@/workflow/workflow-variables/constants/SearchVariablesDropdownId';
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useAvailableVariablesInWorkflowStep.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useAvailableVariablesInWorkflowStep.ts
index 26e4f78407e..c4b070b7ec4 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useAvailableVariablesInWorkflowStep.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useAvailableVariablesInWorkflowStep.ts
@@ -1,14 +1,16 @@
import { useRecoilComponentValue } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValue';
import { useFlowOrThrow } from '@/workflow/hooks/useFlowOrThrow';
import { stepsOutputSchemaFamilySelector } from '@/workflow/states/selectors/stepsOutputSchemaFamilySelector';
-import { type InputSchemaPropertyType } from '@/workflow/types/InputSchema';
+import {
+ type InputSchemaPropertyType,
+ TRIGGER_STEP_ID,
+} from 'twenty-shared/workflow';
import { workflowSelectedNodeComponentState } from '@/workflow/workflow-diagram/states/workflowSelectedNodeComponentState';
import { getPreviousSteps } from '@/workflow/workflow-steps/utils/getWorkflowPreviousSteps';
import { type StepOutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
import { filterOutputSchema } from '@/workflow/workflow-variables/utils/filterOutputSchema';
import { useRecoilValue } from 'recoil';
import { isDefined, isEmptyObject } from 'twenty-shared/utils';
-import { TRIGGER_STEP_ID } from 'twenty-shared/workflow';
export const useAvailableVariablesInWorkflowStep = ({
shouldDisplayRecordFields,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/filterOutputSchema.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/filterOutputSchema.ts
index 7032d783909..6d45e8cc878 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/filterOutputSchema.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/filterOutputSchema.ts
@@ -1,4 +1,8 @@
-import { type InputSchemaPropertyType } from '@/workflow/types/InputSchema';
+import {
+ type InputSchemaPropertyType,
+ type BaseOutputSchemaV2,
+ type Node,
+} from 'twenty-shared/workflow';
import {
type FieldOutputSchemaV2,
type RecordOutputSchemaV2,
@@ -9,7 +13,6 @@ import { isLinkOutputSchema } from '@/workflow/workflow-variables/types/guards/i
import { isRecordOutputSchemaV2 } from '@/workflow/workflow-variables/types/guards/isRecordOutputSchemaV2';
import { isFieldTypeCompatibleWithRecordId } from '@/workflow/workflow-variables/utils/isFieldTypeCompatibleWithRecordId';
import { isDefined } from 'twenty-shared/utils';
-import { type BaseOutputSchemaV2, type Node } from 'twenty-shared/workflow';
const isValidRecordOutputSchema = ({
shouldDisplayRecordFields,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/getStepItemIcon.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/getStepItemIcon.ts
index d5be1e397f0..ff7968751fe 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/getStepItemIcon.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/getStepItemIcon.ts
@@ -1,4 +1,4 @@
-import { type InputSchemaPropertyType } from '@/workflow/types/InputSchema';
+import { type InputSchemaPropertyType } from 'twenty-shared/workflow';
import { FieldMetadataType } from 'twenty-shared/types';
export const getStepItemIcon = ({
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/isFieldTypeCompatibleWithRecordId.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/isFieldTypeCompatibleWithRecordId.ts
index 9324f7aa4c0..05ed58e2306 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/isFieldTypeCompatibleWithRecordId.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/isFieldTypeCompatibleWithRecordId.ts
@@ -1,4 +1,4 @@
-import { type InputSchemaPropertyType } from '@/workflow/types/InputSchema';
+import { type InputSchemaPropertyType } from 'twenty-shared/workflow';
import { FieldMetadataType } from '~/generated-metadata/graphql';
export const isFieldTypeCompatibleWithRecordId = (
diff --git a/packages/twenty-sdk/scripts/front-component-stories/build-source-examples.ts b/packages/twenty-sdk/scripts/front-component-stories/build-source-examples.ts
index 54fa2522dab..9591eff6bf6 100644
--- a/packages/twenty-sdk/scripts/front-component-stories/build-source-examples.ts
+++ b/packages/twenty-sdk/scripts/front-component-stories/build-source-examples.ts
@@ -26,10 +26,7 @@ const twentyUiIndividualIndex = path.resolve(
'../../../twenty-ui/dist/individual/individual-entry.js',
);
-const sdkIndividualIndex = path.resolve(
- dirname,
- '../../dist/sdk/index.js',
-);
+const sdkIndividualIndex = path.resolve(dirname, '../../dist/sdk/index.js');
const twentySharedIndividualDir = path.resolve(
dirname,
@@ -107,19 +104,12 @@ type BundleSizeEntry = {
const collectBundleSizes = (): BundleSizeEntry[] =>
STORY_COMPONENTS.map((name) => {
const reactFile = path.join(exampleSourcesBuiltDir, `${name}.mjs`);
- const preactFile = path.join(
- exampleSourcesBuiltPreactDir,
- `${name}.mjs`,
- );
+ const preactFile = path.join(exampleSourcesBuiltPreactDir, `${name}.mjs`);
return {
name,
- reactBytes: fs.existsSync(reactFile)
- ? fs.statSync(reactFile).size
- : 0,
- preactBytes: fs.existsSync(preactFile)
- ? fs.statSync(preactFile).size
- : 0,
+ reactBytes: fs.existsSync(reactFile) ? fs.statSync(reactFile).size : 0,
+ preactBytes: fs.existsSync(preactFile) ? fs.statSync(preactFile).size : 0,
};
});
diff --git a/packages/twenty-server/src/engine/api/common/common-query-runners/types/group-by-field.types.ts b/packages/twenty-server/src/engine/api/common/common-query-runners/types/group-by-field.types.ts
index 147665e8e04..f1ac8be658b 100644
--- a/packages/twenty-server/src/engine/api/common/common-query-runners/types/group-by-field.types.ts
+++ b/packages/twenty-server/src/engine/api/common/common-query-runners/types/group-by-field.types.ts
@@ -1,5 +1,7 @@
-import { type ObjectRecordGroupByDateGranularity } from 'twenty-shared/types';
-import { type FirstDayOfTheWeek } from 'twenty-shared/utils';
+import {
+ type FirstDayOfTheWeek,
+ type ObjectRecordGroupByDateGranularity,
+} from 'twenty-shared/types';
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
diff --git a/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/group-by/resolvers/types/date-field-group-by-definition.type.ts b/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/group-by/resolvers/types/date-field-group-by-definition.type.ts
index 06028db725c..86214e128f6 100644
--- a/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/group-by/resolvers/types/date-field-group-by-definition.type.ts
+++ b/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/group-by/resolvers/types/date-field-group-by-definition.type.ts
@@ -1,5 +1,7 @@
-import { type ObjectRecordGroupByDateGranularity } from 'twenty-shared/types';
-import { type FirstDayOfTheWeek } from 'twenty-shared/utils';
+import {
+ type ObjectRecordGroupByDateGranularity,
+ type FirstDayOfTheWeek,
+} from 'twenty-shared/types';
export type DateFieldGroupByDefinition = {
granularity: ObjectRecordGroupByDateGranularity;
diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface.ts b/packages/twenty-server/src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface.ts
index eed8f96fa1b..9014aefe064 100644
--- a/packages/twenty-server/src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface.ts
+++ b/packages/twenty-server/src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface.ts
@@ -3,8 +3,8 @@ import {
type ObjectRecordGroupByDateGranularity,
type ObjectRecordOrderByForCompositeField,
type ObjectRecordOrderByForScalarField,
+ type FirstDayOfTheWeek,
} from 'twenty-shared/types';
-import { type FirstDayOfTheWeek } from 'twenty-shared/utils';
export type ObjectRecordFilter = Partial<{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/utils/process-one-dimensional-results.util.ts b/packages/twenty-server/src/modules/dashboard/chart-data/utils/process-one-dimensional-results.util.ts
index 534efc02b3f..9290d374c02 100644
--- a/packages/twenty-server/src/modules/dashboard/chart-data/utils/process-one-dimensional-results.util.ts
+++ b/packages/twenty-server/src/modules/dashboard/chart-data/utils/process-one-dimensional-results.util.ts
@@ -1,5 +1,8 @@
-import { type ObjectRecordGroupByDateGranularity } from 'twenty-shared/types';
-import { type FirstDayOfTheWeek, isDefined } from 'twenty-shared/utils';
+import {
+ type ObjectRecordGroupByDateGranularity,
+ type FirstDayOfTheWeek,
+} from 'twenty-shared/types';
+import { isDefined } from 'twenty-shared/utils';
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
import { type GroupByRawResult } from 'src/modules/dashboard/chart-data/types/group-by-raw-result.type';
diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/utils/process-two-dimensional-results.util.ts b/packages/twenty-server/src/modules/dashboard/chart-data/utils/process-two-dimensional-results.util.ts
index 45a9d800ae7..1c91dc0797b 100644
--- a/packages/twenty-server/src/modules/dashboard/chart-data/utils/process-two-dimensional-results.util.ts
+++ b/packages/twenty-server/src/modules/dashboard/chart-data/utils/process-two-dimensional-results.util.ts
@@ -1,5 +1,8 @@
-import { type ObjectRecordGroupByDateGranularity } from 'twenty-shared/types';
-import { type FirstDayOfTheWeek, isDefined } from 'twenty-shared/utils';
+import {
+ type ObjectRecordGroupByDateGranularity,
+ type FirstDayOfTheWeek,
+} from 'twenty-shared/types';
+import { isDefined } from 'twenty-shared/utils';
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
import { type GroupByRawResult } from 'src/modules/dashboard/chart-data/types/group-by-raw-result.type';
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts
index 3ced764bd08..abfab6a2aa5 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts
@@ -9,6 +9,7 @@ import {
import { isDefined, isValidUuid } from 'twenty-shared/utils';
import {
IF_ELSE_BRANCH_POSITION_OFFSETS,
+ getFunctionInputFromInputSchema,
type StepIfElseBranch,
} from 'twenty-shared/workflow';
import { Repository } from 'typeorm';
@@ -181,7 +182,11 @@ export class WorkflowVersionStepOperationsWorkspaceService {
},
input: {
logicFunctionId: newLogicFunction.id,
- logicFunctionInput: newLogicFunction.toolInputSchema ?? {},
+ logicFunctionInput: isDefined(newLogicFunction.toolInputSchema)
+ ? (getFunctionInputFromInputSchema([
+ newLogicFunction.toolInputSchema,
+ ])[0] ?? {})
+ : {},
},
},
},
diff --git a/packages/twenty-shared/src/logic-function/__tests__/get-input-schema-from-source-code.test.ts b/packages/twenty-shared/src/logic-function/__tests__/get-input-schema-from-source-code.test.ts
index fc0d82e0b34..6d7b4a6582f 100644
--- a/packages/twenty-shared/src/logic-function/__tests__/get-input-schema-from-source-code.test.ts
+++ b/packages/twenty-shared/src/logic-function/__tests__/get-input-schema-from-source-code.test.ts
@@ -1,5 +1,5 @@
import { getInputSchemaFromSourceCode } from '@/logic-function/get-input-schema-from-source-code';
-import { DEFAULT_TOOL_INPUT_SCHEMA } from '@/logic-function/constants/default-tool-input-schema';
+import { DEFAULT_TOOL_INPUT_SCHEMA } from '@/logic-function/constants/DefaultToolInputSchema';
describe('getInputSchemaFromSourceCode', () => {
it('should return empty input if not parameter', async () => {
diff --git a/packages/twenty-shared/src/logic-function/constants/default-tool-input-schema.ts b/packages/twenty-shared/src/logic-function/constants/DefaultToolInputSchema.ts
similarity index 100%
rename from packages/twenty-shared/src/logic-function/constants/default-tool-input-schema.ts
rename to packages/twenty-shared/src/logic-function/constants/DefaultToolInputSchema.ts
diff --git a/packages/twenty-shared/src/logic-function/constants/seed-logic-function-input-schema.ts b/packages/twenty-shared/src/logic-function/constants/SeedLogicFunctionInputSchema.ts
similarity index 100%
rename from packages/twenty-shared/src/logic-function/constants/seed-logic-function-input-schema.ts
rename to packages/twenty-shared/src/logic-function/constants/SeedLogicFunctionInputSchema.ts
diff --git a/packages/twenty-shared/src/logic-function/index.ts b/packages/twenty-shared/src/logic-function/index.ts
index 23f5e1b2925..083dbdbd46c 100644
--- a/packages/twenty-shared/src/logic-function/index.ts
+++ b/packages/twenty-shared/src/logic-function/index.ts
@@ -7,8 +7,8 @@
* |___/
*/
-export { DEFAULT_TOOL_INPUT_SCHEMA } from './constants/default-tool-input-schema';
-export { SEED_LOGIC_FUNCTION_INPUT_SCHEMA } from './constants/seed-logic-function-input-schema';
+export { DEFAULT_TOOL_INPUT_SCHEMA } from './constants/DefaultToolInputSchema';
+export { SEED_LOGIC_FUNCTION_INPUT_SCHEMA } from './constants/SeedLogicFunctionInputSchema';
export { getInputSchemaFromSourceCode } from './get-input-schema-from-source-code';
export { getOutputSchemaFromValue } from './get-output-schema-from-value';
export type { InputJsonSchema } from './input-json-schema.type';
diff --git a/packages/twenty-shared/src/utils/date/__tests__/dateConversions.test.ts b/packages/twenty-shared/src/utils/date/__tests__/dateConversions.test.ts
index 83ba8f04d26..b247e1fddd5 100644
--- a/packages/twenty-shared/src/utils/date/__tests__/dateConversions.test.ts
+++ b/packages/twenty-shared/src/utils/date/__tests__/dateConversions.test.ts
@@ -44,10 +44,7 @@ describe('turnJSDateToPlainDate', () => {
describe('turnPlainDateIntoUserTimeZoneInstantString', () => {
it('should convert a PlainDate to an instant string in the given timezone', () => {
const plainDate = Temporal.PlainDate.from('2024-03-15');
- const result = turnPlainDateIntoUserTimeZoneInstantString(
- plainDate,
- 'UTC',
- );
+ const result = turnPlainDateIntoUserTimeZoneInstantString(plainDate, 'UTC');
expect(result).toBe('2024-03-15T00:00:00Z');
});
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/addUnitToZonedDateTime.test.ts b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/addUnitToZonedDateTime.test.ts
index 4fb022ef263..30cfcca16b5 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/addUnitToZonedDateTime.test.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/addUnitToZonedDateTime.test.ts
@@ -3,9 +3,7 @@ import { Temporal } from 'temporal-polyfill';
import { addUnitToZonedDateTime } from '@/utils/filter/dates/utils/addUnitToZonedDateTime';
describe('addUnitToZonedDateTime', () => {
- const baseZdt = Temporal.ZonedDateTime.from(
- '2024-03-15T12:00:00[UTC]',
- );
+ const baseZdt = Temporal.ZonedDateTime.from('2024-03-15T12:00:00[UTC]');
it('should add days', () => {
const result = addUnitToZonedDateTime(baseZdt, 'DAY', 3);
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/relativeDateFilterStringifiedSchema.test.ts b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/relativeDateFilterStringifiedSchema.test.ts
index 4ed0b337f22..49cec63a0d7 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/relativeDateFilterStringifiedSchema.test.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/relativeDateFilterStringifiedSchema.test.ts
@@ -14,7 +14,8 @@ describe('relativeDateFilterStringifiedSchema', () => {
});
it('should parse a valid NEXT filter string', () => {
- const result = relativeDateFilterStringifiedSchema.safeParse('NEXT_30_MINUTE');
+ const result =
+ relativeDateFilterStringifiedSchema.safeParse('NEXT_30_MINUTE');
expect(result.success).toBe(true);
@@ -26,7 +27,8 @@ describe('relativeDateFilterStringifiedSchema', () => {
});
it('should parse a THIS filter string', () => {
- const result = relativeDateFilterStringifiedSchema.safeParse('THIS_1_MONTH');
+ const result =
+ relativeDateFilterStringifiedSchema.safeParse('THIS_1_MONTH');
expect(result.success).toBe(true);
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/resolveRelativeDateFilter.test.ts b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/resolveRelativeDateFilter.test.ts
index 87955f7e7ed..a08c0697e62 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/resolveRelativeDateFilter.test.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/resolveRelativeDateFilter.test.ts
@@ -3,9 +3,7 @@ import { Temporal } from 'temporal-polyfill';
import { resolveRelativeDateFilter } from '@/utils/filter/dates/utils/resolveRelativeDateFilter';
describe('resolveRelativeDateFilter', () => {
- const referenceZdt = Temporal.ZonedDateTime.from(
- '2024-03-15T12:00:00[UTC]',
- );
+ const referenceZdt = Temporal.ZonedDateTime.from('2024-03-15T12:00:00[UTC]');
describe('NEXT direction', () => {
it('should compute start and end for NEXT 7 DAY', () => {
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/resolveRelativeDateTimeFilter.test.ts b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/resolveRelativeDateTimeFilter.test.ts
index 2658624a213..181040cae3d 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/resolveRelativeDateTimeFilter.test.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/resolveRelativeDateTimeFilter.test.ts
@@ -3,9 +3,7 @@ import { Temporal } from 'temporal-polyfill';
import { resolveRelativeDateTimeFilter } from '@/utils/filter/dates/utils/resolveRelativeDateTimeFilter';
describe('resolveRelativeDateTimeFilter', () => {
- const referenceZdt = Temporal.ZonedDateTime.from(
- '2024-03-15T12:00:00[UTC]',
- );
+ const referenceZdt = Temporal.ZonedDateTime.from('2024-03-15T12:00:00[UTC]');
describe('NEXT direction', () => {
it('should compute for sub-day unit (HOUR)', () => {
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/subUnitFromZonedDateTime.test.ts b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/subUnitFromZonedDateTime.test.ts
index 8007f56d964..9b16f21e3ce 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/subUnitFromZonedDateTime.test.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/__tests__/subUnitFromZonedDateTime.test.ts
@@ -3,9 +3,7 @@ import { Temporal } from 'temporal-polyfill';
import { subUnitFromZonedDateTime } from '@/utils/filter/dates/utils/subUnitFromZonedDateTime';
describe('subUnitFromZonedDateTime', () => {
- const baseZdt = Temporal.ZonedDateTime.from(
- '2024-03-15T12:00:00[UTC]',
- );
+ const baseZdt = Temporal.ZonedDateTime.from('2024-03-15T12:00:00[UTC]');
it('should subtract days', () => {
const result = subUnitFromZonedDateTime(baseZdt, 'DAY', 3);
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/firstDayOfWeekSchema.ts b/packages/twenty-shared/src/utils/filter/dates/utils/firstDayOfWeekSchema.ts
index f18afa4049e..d3fcb0d82bd 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/firstDayOfWeekSchema.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/firstDayOfWeekSchema.ts
@@ -1,10 +1,10 @@
-import { FirstDayOfTheWeek as FirstDayOfTheWeekEnum } from '@/types/FirstDayOfTheWeek';
+import { FirstDayOfTheWeek } from '@/types';
import z from 'zod';
export const firstDayOfWeekSchema = z.enum([
- FirstDayOfTheWeekEnum.MONDAY,
- FirstDayOfTheWeekEnum.SATURDAY,
- FirstDayOfTheWeekEnum.SUNDAY,
+ FirstDayOfTheWeek.MONDAY,
+ FirstDayOfTheWeek.SATURDAY,
+ FirstDayOfTheWeek.SUNDAY,
]);
-export type FirstDayOfTheWeek = z.infer<typeof firstDayOfWeekSchema>;
+export type FirstDayOfTheWeekSchema = z.infer<typeof firstDayOfWeekSchema>;
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/getFirstDayOfTheWeekAsANumberForDateFNS.ts b/packages/twenty-shared/src/utils/filter/dates/utils/getFirstDayOfTheWeekAsANumberForDateFNS.ts
index af1ca254aaf..6c5130bbf82 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/getFirstDayOfTheWeekAsANumberForDateFNS.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/getFirstDayOfTheWeekAsANumberForDateFNS.ts
@@ -1,16 +1,16 @@
-import { FirstDayOfTheWeek as FirstDayOfTheWeekEnum } from '@/types/FirstDayOfTheWeek';
+import { FirstDayOfTheWeek } from '@/types';
import { assertUnreachable } from '@/utils/assertUnreachable';
-import { type FirstDayOfTheWeek } from '@/utils/filter/dates/utils/firstDayOfWeekSchema';
+import { type FirstDayOfTheWeekSchema } from '@/utils/filter/dates/utils/firstDayOfWeekSchema';
export const getFirstDayOfTheWeekAsANumberForDateFNS = (
- firstDayOfTheWeek: FirstDayOfTheWeek,
+ firstDayOfTheWeek: FirstDayOfTheWeekSchema,
): 0 | 1 | 6 => {
switch (firstDayOfTheWeek) {
- case FirstDayOfTheWeekEnum.MONDAY:
+ case FirstDayOfTheWeek.MONDAY:
return 1;
- case FirstDayOfTheWeekEnum.SATURDAY:
+ case FirstDayOfTheWeek.SATURDAY:
return 6;
- case FirstDayOfTheWeekEnum.SUNDAY:
+ case FirstDayOfTheWeek.SUNDAY:
return 0;
default:
return assertUnreachable(firstDayOfTheWeek);
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/getFirstDayOfTheWeekAsISONumber.ts b/packages/twenty-shared/src/utils/filter/dates/utils/getFirstDayOfTheWeekAsISONumber.ts
index fc10a7fcfda..4ffd3f43cdc 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/getFirstDayOfTheWeekAsISONumber.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/getFirstDayOfTheWeekAsISONumber.ts
@@ -1,16 +1,16 @@
-import { FirstDayOfTheWeek as FirstDayOfTheWeekEnum } from '@/types/FirstDayOfTheWeek';
+import { FirstDayOfTheWeek } from '@/types';
import { assertUnreachable } from '@/utils/assertUnreachable';
-import { type FirstDayOfTheWeek } from '@/utils/filter/dates/utils/firstDayOfWeekSchema';
+import { type FirstDayOfTheWeekSchema } from '@/utils/filter/dates/utils/firstDayOfWeekSchema';
export const getFirstDayOfTheWeekAsISONumber = (
- firstDayOfTheWeek: FirstDayOfTheWeek,
+ firstDayOfTheWeek: FirstDayOfTheWeekSchema,
): 1 | 6 | 7 => {
switch (firstDayOfTheWeek) {
- case FirstDayOfTheWeekEnum.MONDAY:
+ case FirstDayOfTheWeek.MONDAY:
return 1;
- case FirstDayOfTheWeekEnum.SATURDAY:
+ case FirstDayOfTheWeek.SATURDAY:
return 6;
- case FirstDayOfTheWeekEnum.SUNDAY:
+ case FirstDayOfTheWeek.SUNDAY:
return 7;
default:
return assertUnreachable(firstDayOfTheWeek);
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/getNextPeriodStart.ts b/packages/twenty-shared/src/utils/filter/dates/utils/getNextPeriodStart.ts
index 4933478e78f..61dd1e04d8a 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/getNextPeriodStart.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/getNextPeriodStart.ts
@@ -1,7 +1,7 @@
import { type Nullable } from '@/types';
import { assertUnreachable } from '@/utils/assertUnreachable';
import { type DateTimePeriod } from '@/utils/filter/dates/types/DateTimePeriod';
-import { type FirstDayOfTheWeek } from '@/utils/filter/dates/utils/firstDayOfWeekSchema';
+import { type FirstDayOfTheWeekSchema } from '@/utils/filter/dates/utils/firstDayOfWeekSchema';
import { getPeriodStart } from '@/utils/filter/dates/utils/getPeriodStart';
import { type Temporal } from 'temporal-polyfill';
@@ -10,7 +10,7 @@ export const FIRST_DAY_OF_WEEK_ISO_8601_MONDAY = 1;
export const getNextPeriodStart = (
dateTime: Temporal.ZonedDateTime,
unit: DateTimePeriod,
- firstDayOfTheWeek?: Nullable<FirstDayOfTheWeek>,
+ firstDayOfTheWeek?: Nullable<FirstDayOfTheWeekSchema>,
) => {
switch (unit) {
case 'DAY':
diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/getPeriodStart.ts b/packages/twenty-shared/src/utils/filter/dates/utils/getPeriodStart.ts
index 3eaac00739e..7c8b9b031df 100644
--- a/packages/twenty-shared/src/utils/filter/dates/utils/getPeriodStart.ts
+++ b/packages/twenty-shared/src/utils/filter/dates/utils/getPeriodStart.ts
@@ -1,7 +1,7 @@
import { type Nullable } from '@/types';
import { assertUnreachable, type DateTimePeriod } from '@/utils';
-import { type FirstDayOfTheWeek } from '@/utils/filter/dates/utils/firstDayOfWeekSchema';
+import { type FirstDayOfTheWeekSchema } from '@/utils/filter/dates/utils/firstDayOfWeekSchema';
import { getFirstDayOfTheWeekAsISONumber } from '@/utils/filter/dates/utils/getFirstDayOfTheWeekAsISONumber';
import { FIRST_DAY_OF_WEEK_ISO_8601_MONDAY } from '@/utils/filter/dates/utils/getNextPeriodStart';
import { isDefined } from '@/utils/validation';
@@ -10,7 +10,7 @@ import { type Temporal } from 'temporal-polyfill';
export const getPeriodStart = (
dateTime: Temporal.ZonedDateTime,
unit: DateTimePeriod,
- firstDayOfTheWeek?: Nullable<FirstDayOfTheWeek>,
+ firstDayOfTheWeek?: Nullable<FirstDayOfTheWeekSchema>,
) => {
switch (unit) {
case 'DAY':
diff --git a/packages/twenty-shared/src/utils/index.ts b/packages/twenty-shared/src/utils/index.ts
index 0f936d029f5..7c30247d06c 100644
--- a/packages/twenty-shared/src/utils/index.ts
+++ b/packages/twenty-shared/src/utils/index.ts
@@ -56,7 +56,7 @@ export { addUnitToDateTime } from './filter/dates/utils/addUnitToDateTime';
export { addUnitToZonedDateTime } from './filter/dates/utils/addUnitToZonedDateTime';
export { convertCalendarStartDayNonIsoNumberToFirstDayOfTheWeek } from './filter/dates/utils/convertCalendarStartDayNonIsoNumberToFirstDayOfTheWeek';
export { convertFirstDayOfTheWeekToCalendarStartDayNumber } from './filter/dates/utils/convertFirstDayOfTheWeekToCalendarStartDayNumber';
-export type { FirstDayOfTheWeek } from './filter/dates/utils/firstDayOfWeekSchema';
+export type { FirstDayOfTheWeekSchema } from './filter/dates/utils/firstDayOfWeekSchema';
export { firstDayOfWeekSchema } from './filter/dates/utils/firstDayOfWeekSchema';
export { getFirstDayOfTheWeekAsANumberForDateFNS } from './filter/dates/utils/getFirstDayOfTheWeekAsANumberForDateFNS';
export { getFirstDayOfTheWeekAsISONumber } from './filter/dates/utils/getFirstDayOfTheWeekAsISONumber';
diff --git a/packages/twenty-shared/src/workflow/index.ts b/packages/twenty-shared/src/workflow/index.ts
index 3d2aa040308..6ad1bce9a8d 100644
--- a/packages/twenty-shared/src/workflow/index.ts
+++ b/packages/twenty-shared/src/workflow/index.ts
@@ -67,6 +67,12 @@ export { workflowRunStatusSchema } from './schemas/workflow-run-status-schema';
export { workflowRunStepStatusSchema } from './schemas/workflow-run-step-status-schema';
export { workflowTriggerSchema } from './schemas/workflow-trigger-schema';
export type { EmailRecipients } from './types/EmailRecipients';
+export type { FunctionInput } from './types/FunctionInput';
+export type {
+ InputSchemaPropertyType,
+ InputSchemaProperty,
+ InputSchema,
+} from './types/InputSchema';
export type { StepIfElseBranch } from './types/StepIfElseBranch';
export type { BodyType } from './types/workflowHttpRequestStep';
export type {
@@ -76,6 +82,7 @@ export type {
export { StepStatus } from './types/WorkflowRunStateStepInfos';
export { canObjectBeManagedByWorkflow } from './utils/canObjectBeManagedByWorkflow';
export { extractRawVariableNamePart } from './utils/extractRawVariableNameParts';
+export { getFunctionInputFromInputSchema } from './utils/getFunctionInputFromInputSchema';
export { getWorkflowRunContext } from './utils/getWorkflowRunContext';
export { parseBooleanFromStringValue } from './utils/parseBooleanFromStringValue';
export { parseDataFromContentType } from './utils/parseDataFromContentType';
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/types/FunctionInput.ts b/packages/twenty-shared/src/workflow/types/FunctionInput.ts
similarity index 100%
rename from packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/types/FunctionInput.ts
rename to packages/twenty-shared/src/workflow/types/FunctionInput.ts
diff --git a/packages/twenty-front/src/modules/workflow/types/InputSchema.ts b/packages/twenty-shared/src/workflow/types/InputSchema.ts
similarity index 70%
rename from packages/twenty-front/src/modules/workflow/types/InputSchema.ts
rename to packages/twenty-shared/src/workflow/types/InputSchema.ts
index f53d56aded1..726019a14af 100644
--- a/packages/twenty-front/src/modules/workflow/types/InputSchema.ts
+++ b/packages/twenty-shared/src/workflow/types/InputSchema.ts
@@ -1,5 +1,5 @@
-import { type LeafType, type NodeType } from 'twenty-shared/workflow';
-import { type FieldMetadataType } from '~/generated-metadata/graphql';
+import { type LeafType, type NodeType } from '@/workflow';
+import { type FieldMetadataType } from '@/types';
export type InputSchemaPropertyType = LeafType | NodeType | FieldMetadataType;
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/__tests__/getDefaultFunctionInputFromInputSchema.test.ts b/packages/twenty-shared/src/workflow/utils/__tests__/getDefaultFunctionInputFromInputSchema.test.ts
similarity index 81%
rename from packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/__tests__/getDefaultFunctionInputFromInputSchema.test.ts
rename to packages/twenty-shared/src/workflow/utils/__tests__/getDefaultFunctionInputFromInputSchema.test.ts
index ea48c02d4d0..19bd5ea1f23 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/__tests__/getDefaultFunctionInputFromInputSchema.test.ts
+++ b/packages/twenty-shared/src/workflow/utils/__tests__/getDefaultFunctionInputFromInputSchema.test.ts
@@ -1,5 +1,4 @@
-import { type InputSchema } from '@/workflow/types/InputSchema';
-import { getFunctionInputFromInputSchema } from '@/workflow/workflow-steps/workflow-actions/code-action/utils/getFunctionInputFromInputSchema';
+import { getFunctionInputFromInputSchema, type InputSchema } from '@/workflow';
describe('getDefaultFunctionInputFromInputSchema', () => {
it('should init function input properly', () => {
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/getFunctionInputFromInputSchema.ts b/packages/twenty-shared/src/workflow/utils/getFunctionInputFromInputSchema.ts
similarity index 71%
rename from packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/getFunctionInputFromInputSchema.ts
rename to packages/twenty-shared/src/workflow/utils/getFunctionInputFromInputSchema.ts
index 693366c2f57..c2bdb3555e5 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/utils/getFunctionInputFromInputSchema.ts
+++ b/packages/twenty-shared/src/workflow/utils/getFunctionInputFromInputSchema.ts
@@ -1,7 +1,6 @@
-import { type InputSchema } from '@/workflow/types/InputSchema';
-import { type FunctionInput } from '@/workflow/workflow-steps/workflow-actions/code-action/types/FunctionInput';
-import { isDefined } from 'twenty-shared/utils';
-import type { InputJsonSchema } from 'twenty-shared/logic-function';
+import { type InputSchema, type FunctionInput } from '@/workflow';
+import { type InputJsonSchema } from '@/logic-function';
+import { isDefined } from '@/utils';
export const getFunctionInputFromInputSchema = (
inputSchema: InputSchema | InputJsonSchema[],
diff --git a/packages/twenty-shared/vite.config.individual.ts b/packages/twenty-shared/vite.config.individual.ts
index c1c3d5413da..e30ea557940 100644
--- a/packages/twenty-shared/vite.config.individual.ts
+++ b/packages/twenty-shared/vite.config.individual.ts
@@ -1,8 +1,6 @@
-// @ts-ignore
import path from 'path';
import { type UserConfig, defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
-// @ts-ignore
import packageJson from './package.json';
const submodules = Object.keys((packageJson as any).exports || {})
diff --git a/packages/twenty-ui/src/display/icon/components/ThinkingOrbitLoaderIcon.tsx b/packages/twenty-ui/src/display/icon/components/ThinkingOrbitLoaderIcon.tsx
index 76f97c79cdc..af791e4b0b4 100644
--- a/packages/twenty-ui/src/display/icon/components/ThinkingOrbitLoaderIcon.tsx
+++ b/packages/twenty-ui/src/display/icon/components/ThinkingOrbitLoaderIcon.tsx
@@ -1,6 +1,9 @@
import { type IconComponentProps } from '@ui/display/icon/types/IconComponent';
-type ThinkingOrbitLoaderIconProps = Pick<IconComponentProps, 'className' | 'size'>;
+type ThinkingOrbitLoaderIconProps = Pick<
+ IconComponentProps,
+ 'className' | 'size'
+>;
export const ThinkingOrbitLoaderIcon = ({
className,
diff --git a/packages/twenty-ui/src/individual-entry.ts b/packages/twenty-ui/src/individual-entry.ts
index 9b6774b5272..034b27cedc1 100644
--- a/packages/twenty-ui/src/individual-entry.ts
+++ b/packages/twenty-ui/src/individual-entry.ts
@@ -13,4 +13,3 @@ export * from './layout';
export * from './navigation';
export * from './theme';
export * from './utilities';
-
diff --git a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemAvatar.tsx b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemAvatar.tsx
index 73d58c74bdb..c8a9e10227f 100644
--- a/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemAvatar.tsx
+++ b/packages/twenty-ui/src/navigation/menu/menu-item/components/MenuItemAvatar.tsx
@@ -1,5 +1,8 @@
import { Avatar, type AvatarProps } from '@ui/display';
-import { type MenuItemIconButton, MenuItem } from '@ui/navigation/menu/menu-item/components/MenuItem';
+import {
+ type MenuItemIconButton,
+ MenuItem,
+} from '@ui/navigation/menu/menu-item/components/MenuItem';
import { type MouseEvent, type ReactNode } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { type MenuItemAccent } from '../types/MenuItemAccent';