[REFACTOR] twenty-shared multi barrel and CJS/ESM build with preconstruct (#11083)
# Introduction In this PR we've migrated `twenty-shared` from a `vite` app [libary-mode](https://vite.dev/guide/build#library-mode) to a [preconstruct](https://preconstruct.tools/) "atomic" application ( in the future would like to introduce preconstruct to handle of all our atomic dependencies such as `twenty-emails` `twenty-ui` etc it will be integrated at the monorepo's root directly, would be to invasive in the first, starting incremental via `twenty-shared`) For more information regarding the motivations please refer to nor: - https://github.com/twentyhq/core-team-issues/issues/587 - https://github.com/twentyhq/core-team-issues/issues/281#issuecomment-2630949682 close https://github.com/twentyhq/core-team-issues/issues/589 close https://github.com/twentyhq/core-team-issues/issues/590 ## How to test In order to ease the review this PR will ship all the codegen at the very end, the actual meaning full diff is `+2,411 −114` In order to migrate existing dependent packages to `twenty-shared` multi barrel new arch you need to run in local: ```sh yarn tsx packages/twenty-shared/scripts/migrateFromSingleToMultiBarrelImport.ts && \ npx nx run-many -t lint --fix -p twenty-front twenty-ui twenty-server twenty-emails twenty-shared twenty-zapier ``` Note that `migrateFromSingleToMultiBarrelImport` is idempotent, it's atm included in the PR but should not be merged. ( such as codegen will be added before merging this script will be removed ) ## Misc - related opened issue preconstruct https://github.com/preconstruct/preconstruct/issues/617 ## Closed related PR - https://github.com/twentyhq/twenty/pull/11028 - https://github.com/twentyhq/twenty/pull/10993 - https://github.com/twentyhq/twenty/pull/10960 ## Upcoming enhancement: ( in others dedicated PRs ) - 1/ refactor generate barrel to export atomic module instead of `*` - 2/ generate barrel own package with several files and tests - 3/ Migration twenty-ui the same way - 4/ Use `preconstruct` at monorepo global level ## Conclusion As always any suggestions are welcomed !
This commit is contained in:
@ -20,7 +20,7 @@ runs:
|
||||
id: cache-primary-key-builder
|
||||
shell: bash
|
||||
run: |
|
||||
echo "CACHE_PRIMARY_KEY_PREFIX=${{ inputs.key }}-${{ github.ref_name }}" >> "${GITHUB_OUTPUT}"
|
||||
echo "CACHE_PRIMARY_KEY_PREFIX=v2-${{ inputs.key }}-${{ github.ref_name }}" >> "${GITHUB_OUTPUT}"
|
||||
- name: Restore cache
|
||||
uses: actions/cache/restore@v4
|
||||
id: restore-cache
|
||||
|
||||
@ -25,8 +25,8 @@ runs:
|
||||
id: cache-node-modules
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
key: ${{ steps.globals.outputs.CACHE_KEY_PREFIX }}-${{github.sha}}
|
||||
restore-keys: ${{ steps.globals.outputs.CACHE_KEY_PREFIX }}-
|
||||
key: v2-${{ steps.globals.outputs.CACHE_KEY_PREFIX }}-${{github.sha}}
|
||||
restore-keys: v2-${{ steps.globals.outputs.CACHE_KEY_PREFIX }}-
|
||||
path: ${{ steps.globals.outputs.PATH_TO_CACHE }}
|
||||
- name: Install Dependencies
|
||||
if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' && steps.cache-node-modules.outputs.cache-matched-key == '' }}
|
||||
|
||||
26
.yarn/patches/@preconstruct-cli-npm-2.8.11-030abfa6ae.patch
Normal file
26
.yarn/patches/@preconstruct-cli-npm-2.8.11-030abfa6ae.patch
Normal file
@ -0,0 +1,26 @@
|
||||
diff --git a/cli/dist/preconstruct-cli-cli.cjs.js b/cli/dist/preconstruct-cli-cli.cjs.js
|
||||
index 8fbd4efc8ee4d98bc72d16344ff6f6ab4e5e2736..cf451d99128fd06053426d1a265f4e305380dd7b 100644
|
||||
--- a/cli/dist/preconstruct-cli-cli.cjs.js
|
||||
+++ b/cli/dist/preconstruct-cli-cli.cjs.js
|
||||
@@ -1509,7 +1509,7 @@ let memoizedGetProgram = weakMemoize(typescript => memoize(async configFileName
|
||||
return nonMemoizedGetProgram(typescript, configFileName);
|
||||
}));
|
||||
async function getProgram(dirname, pkgName, ts) {
|
||||
- let configFileName = ts.findConfigFile(dirname, ts.sys.fileExists);
|
||||
+ let configFileName = ts.findConfigFile(dirname, ts.sys.fileExists, 'tsconfig.lib.json');
|
||||
if (!configFileName) {
|
||||
throw new FatalError("an entrypoint source file ends with the .ts or tsx extension but no TypeScript config exists, please create one.", pkgName);
|
||||
}
|
||||
diff --git a/cli/dist/preconstruct-cli-cli.esm.js b/cli/dist/preconstruct-cli-cli.esm.js
|
||||
index 0045392b46c8928753af564f67681886e0f15bed..164a9bfbae85f1a8f41fffc87c6a3c4014cb9d33 100644
|
||||
--- a/cli/dist/preconstruct-cli-cli.esm.js
|
||||
+++ b/cli/dist/preconstruct-cli-cli.esm.js
|
||||
@@ -1460,7 +1460,7 @@ let memoizedGetProgram = weakMemoize(typescript => memoize(async configFileName
|
||||
return nonMemoizedGetProgram(typescript, configFileName);
|
||||
}));
|
||||
async function getProgram(dirname, pkgName, ts) {
|
||||
- let configFileName = ts.findConfigFile(dirname, ts.sys.fileExists);
|
||||
+ let configFileName = ts.findConfigFile(dirname, ts.sys.fileExists, 'tsconfig.lib.json');
|
||||
if (!configFileName) {
|
||||
throw new FatalError("an entrypoint source file ends with the .ts or tsx extension but no TypeScript config exists, please create one.", pkgName);
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
// Open options page programmatically in a new tab.
|
||||
// chrome.runtime.onInstalled.addListener((details) => {
|
||||
// if (details.reason === 'install') {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
interface CustomDiv extends HTMLDivElement {
|
||||
onClickHandler: (newHandler: () => void) => void;
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { createDefaultButton } from '~/contentScript/createButton';
|
||||
import changeSidePanelUrl from '~/contentScript/utils/changeSidepanelUrl';
|
||||
import extractCompanyLinkedinLink from '~/contentScript/utils/extractCompanyLinkedinLink';
|
||||
import extractDomain from '~/contentScript/utils/extractDomain';
|
||||
import { createCompany, fetchCompany } from '~/db/company.db';
|
||||
import { CompanyInput } from '~/db/types/company.types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const checkIfCompanyExists = async () => {
|
||||
const { tab: activeTab } = await chrome.runtime.sendMessage({
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { createDefaultButton } from '~/contentScript/createButton';
|
||||
import changeSidePanelUrl from '~/contentScript/utils/changeSidepanelUrl';
|
||||
import extractFirstAndLastName from '~/contentScript/utils/extractFirstAndLastName';
|
||||
import { createPerson, fetchPerson } from '~/db/person.db';
|
||||
import { PersonInput } from '~/db/types/person.types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const checkIfPersonExists = async () => {
|
||||
const { tab: activeTab } = await chrome.runtime.sendMessage({
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { insertButtonForCompany } from '~/contentScript/extractCompanyProfile';
|
||||
import { insertButtonForPerson } from '~/contentScript/extractPersonProfile';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
// Inject buttons into the DOM when SPA is reloaded on the resource url.
|
||||
// e.g. reload the page when on https://www.linkedin.com/in/mabdullahabaid/
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
const btn = document.getElementById('twenty-settings-btn');
|
||||
if (!isDefined(btn)) {
|
||||
const div = document.createElement('div');
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
const changeSidePanelUrl = async (url: string) => {
|
||||
if (isDefined(url)) {
|
||||
chrome.storage.local.set({ navigateSidepanel: 'sidepanel' });
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
// Extract "https://www.linkedin.com/company/twenty/" from any of the following urls, which the user can visit while on the company page.
|
||||
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
// "https://www.linkedin.com/company/twenty/" "https://www.linkedin.com/company/twenty/about/" "https://www.linkedin.com/company/twenty/people/".
|
||||
const extractCompanyLinkedinLink = (activeTabUrl: string) => {
|
||||
// Regular expression to match the company ID
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import {
|
||||
ExchangeAuthCodeInput,
|
||||
ExchangeAuthCodeResponse,
|
||||
@ -6,6 +5,7 @@ import {
|
||||
} from '~/db/types/auth.types';
|
||||
import { EXCHANGE_AUTHORIZATION_CODE } from '~/graphql/auth/mutations';
|
||||
import { callMutation } from '~/utils/requestDb';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const exchangeAuthorizationCode = async (
|
||||
exchangeAuthCodeInput: ExchangeAuthCodeInput,
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import {
|
||||
CompanyInput,
|
||||
CreateCompanyResponse,
|
||||
@ -9,6 +8,7 @@ import { CREATE_COMPANY } from '~/graphql/company/mutations';
|
||||
import { FIND_COMPANY } from '~/graphql/company/queries';
|
||||
|
||||
import { callMutation, callQuery } from '../utils/requestDb';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const fetchCompany = async (
|
||||
companyfilerInput: CompanyFilterInput,
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import {
|
||||
CreatePersonResponse,
|
||||
FindPersonResponse,
|
||||
@ -9,6 +8,7 @@ import { CREATE_PERSON } from '~/graphql/person/mutations';
|
||||
import { FIND_PERSON } from '~/graphql/person/queries';
|
||||
|
||||
import { callMutation, callQuery } from '../utils/requestDb';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const fetchPerson = async (
|
||||
personFilterData: PersonFilterInput,
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
||||
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { Tokens } from '~/db/types/auth.types';
|
||||
import { RENEW_TOKEN } from '~/graphql/auth/mutations';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const renewToken = async (
|
||||
appToken: string,
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import Settings from '~/options/Settings';
|
||||
import Sidepanel from '~/options/Sidepanel';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const App = () => {
|
||||
const [currentScreen, setCurrentScreen] = useState('');
|
||||
|
||||
@ -3,8 +3,8 @@ import { useEffect, useState } from 'react';
|
||||
|
||||
import { MainButton } from '@/ui/input/button/MainButton';
|
||||
import { TextInput } from '@/ui/input/components/TextInput';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { clearStore } from '~/utils/apolloClient';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const StyledWrapper = styled.div`
|
||||
align-items: center;
|
||||
|
||||
@ -2,7 +2,7 @@ import styled from '@emotion/styled';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { MainButton } from '@/ui/input/button/MainButton';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const StyledIframe = styled.iframe`
|
||||
display: block;
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import styled from '@emotion/styled';
|
||||
import { motion } from 'framer-motion';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export type ToggleSize = 'small' | 'medium';
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { ApolloClient, from, HttpLink, InMemoryCache } from '@apollo/client';
|
||||
import { setContext } from '@apollo/client/link/context';
|
||||
import { onError } from '@apollo/client/link/error';
|
||||
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const clearStore = () => {
|
||||
chrome.storage.local.remove([
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { OperationVariables } from '@apollo/client';
|
||||
import { DocumentNode } from 'graphql';
|
||||
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import getApolloClient from '~/utils/apolloClient';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const callQuery = async <T>(
|
||||
query: DocumentNode,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { defineConfig } from '@lingui/conf';
|
||||
import { formatter } from '@lingui/format-po';
|
||||
import { APP_LOCALES } from 'twenty-shared';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
|
||||
export default defineConfig({
|
||||
sourceLocale: 'en',
|
||||
|
||||
@ -5,7 +5,6 @@ import { PropsWithChildren } from 'react';
|
||||
|
||||
import { BaseHead } from 'src/components/BaseHead';
|
||||
import { Logo } from 'src/components/Logo';
|
||||
import { APP_LOCALES, SOURCE_LOCALE } from 'twenty-shared';
|
||||
import { messages as afMessages } from '../locales/generated/af-ZA';
|
||||
import { messages as arMessages } from '../locales/generated/ar-SA';
|
||||
import { messages as caMessages } from '../locales/generated/ca-ES';
|
||||
@ -37,6 +36,7 @@ import { messages as ukMessages } from '../locales/generated/uk-UA';
|
||||
import { messages as viMessages } from '../locales/generated/vi-VN';
|
||||
import { messages as zhHansMessages } from '../locales/generated/zh-CN';
|
||||
import { messages as zhHantMessages } from '../locales/generated/zh-TW';
|
||||
import { APP_LOCALES, SOURCE_LOCALE } from 'twenty-shared/translations';
|
||||
|
||||
type BaseEmailProps = PropsWithChildren<{
|
||||
width?: number;
|
||||
|
||||
@ -3,7 +3,7 @@ import { BaseEmail } from 'src/components/BaseEmail';
|
||||
import { CallToAction } from 'src/components/CallToAction';
|
||||
import { MainText } from 'src/components/MainText';
|
||||
import { Title } from 'src/components/Title';
|
||||
import { APP_LOCALES } from 'twenty-shared';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
|
||||
type CleanSuspendedWorkspaceEmailProps = {
|
||||
daysSinceInactive: number;
|
||||
|
||||
@ -4,7 +4,7 @@ import { CallToAction } from 'src/components/CallToAction';
|
||||
import { Link } from 'src/components/Link';
|
||||
import { MainText } from 'src/components/MainText';
|
||||
import { Title } from 'src/components/Title';
|
||||
import { APP_LOCALES } from 'twenty-shared';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
|
||||
type PasswordResetLinkEmailProps = {
|
||||
duration: string;
|
||||
|
||||
@ -6,7 +6,7 @@ import { BaseEmail } from 'src/components/BaseEmail';
|
||||
import { CallToAction } from 'src/components/CallToAction';
|
||||
import { MainText } from 'src/components/MainText';
|
||||
import { Title } from 'src/components/Title';
|
||||
import { APP_LOCALES } from 'twenty-shared';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
|
||||
type PasswordUpdateNotifyEmailProps = {
|
||||
userName: string;
|
||||
|
||||
@ -5,7 +5,7 @@ import { CallToAction } from 'src/components/CallToAction';
|
||||
import { Footer } from 'src/components/Footer';
|
||||
import { MainText } from 'src/components/MainText';
|
||||
import { Title } from 'src/components/Title';
|
||||
import { APP_LOCALES } from 'twenty-shared';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
|
||||
type SendEmailVerificationLinkEmailProps = {
|
||||
link: string;
|
||||
|
||||
@ -11,7 +11,8 @@ import { MainText } from 'src/components/MainText';
|
||||
import { Title } from 'src/components/Title';
|
||||
import { WhatIsTwenty } from 'src/components/WhatIsTwenty';
|
||||
import { capitalize } from 'src/utils/capitalize';
|
||||
import { APP_LOCALES, getImageAbsoluteURI } from 'twenty-shared';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
import { getImageAbsoluteURI } from 'twenty-shared/utils';
|
||||
|
||||
type SendInviteLinkEmailProps = {
|
||||
link: string;
|
||||
|
||||
@ -12,7 +12,8 @@ import { MainText } from 'src/components/MainText';
|
||||
import { Title } from 'src/components/Title';
|
||||
import { WhatIsTwenty } from 'src/components/WhatIsTwenty';
|
||||
import { capitalize } from 'src/utils/capitalize';
|
||||
import { APP_LOCALES, getImageAbsoluteURI } from 'twenty-shared';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
import { getImageAbsoluteURI } from 'twenty-shared/utils';
|
||||
|
||||
type SendApprovedAccessDomainValidationProps = {
|
||||
link: string;
|
||||
|
||||
@ -3,7 +3,7 @@ import { BaseEmail } from 'src/components/BaseEmail';
|
||||
import { CallToAction } from 'src/components/CallToAction';
|
||||
import { MainText } from 'src/components/MainText';
|
||||
import { Title } from 'src/components/Title';
|
||||
import { APP_LOCALES } from 'twenty-shared';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
|
||||
type WarnSuspendedWorkspaceEmailProps = {
|
||||
daysSinceInactive: number;
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { lingui } from '@lingui/vite-plugin';
|
||||
import react from '@vitejs/plugin-react-swc';
|
||||
import * as path from 'path';
|
||||
import { APP_LOCALES } from 'twenty-shared';
|
||||
import { defineConfig } from 'vite';
|
||||
import dts from 'vite-plugin-dts';
|
||||
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
|
||||
export default defineConfig({
|
||||
root: __dirname,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { defineConfig } from '@lingui/conf';
|
||||
import { formatter } from '@lingui/format-po';
|
||||
import { APP_LOCALES } from 'twenty-shared';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
|
||||
export default defineConfig({
|
||||
sourceLocale: 'en',
|
||||
|
||||
@ -2,7 +2,7 @@ import { matchPath, useLocation } from 'react-router-dom';
|
||||
|
||||
import { AppBasePath } from '@/types/AppBasePath';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useIsMatchingLocation = () => {
|
||||
const location = useLocation();
|
||||
|
||||
@ -7,9 +7,10 @@ import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { useIsWorkspaceActivationStatusEqualsTo } from '@/workspace/hooks/useIsWorkspaceActivationStatusEqualsTo';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { WorkspaceActivationStatus, isDefined } from 'twenty-shared';
|
||||
import { OnboardingStatus } from '~/generated/graphql';
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const usePageChangeEffectNavigateLocation = () => {
|
||||
const { isMatchingLocation } = useIsMatchingLocation();
|
||||
|
||||
@ -5,7 +5,7 @@ import { scrollWrapperInstanceComponentState } from '@/ui/utilities/scroll/state
|
||||
import { scrollWrapperScrollTopComponentState } from '@/ui/utilities/scroll/states/scrollWrapperScrollTopComponentState';
|
||||
import { useRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentStateV2';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
/**
|
||||
* @deprecated We should now use useScrollToPosition instead
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { CalendarChannel } from '@/accounts/types/CalendarChannel';
|
||||
|
||||
import { ConnectedAccountProvider } from 'twenty-shared';
|
||||
import { MessageChannel } from './MessageChannel';
|
||||
import { ConnectedAccountProvider } from 'twenty-shared/types';
|
||||
|
||||
export type ConnectedAccount = {
|
||||
id: string;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ConnectedAccountProvider } from 'twenty-shared';
|
||||
import { MessageChannelVisibility } from '~/generated/graphql';
|
||||
import { ConnectedAccountProvider } from 'twenty-shared/types';
|
||||
|
||||
export enum MessageChannelContactAutoCreationPolicy {
|
||||
SENT_AND_RECEIVED = 'SENT_AND_RECEIVED',
|
||||
|
||||
@ -10,8 +10,8 @@ import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadat
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { FeatureFlagKey } from '~/generated/graphql';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const RecordActionMenuEntriesSetter = () => {
|
||||
const localContextStoreCurrentObjectMetadataItemId =
|
||||
|
||||
@ -18,8 +18,8 @@ import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModa
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { getOsControlSymbol } from 'twenty-ui';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useDeleteMultipleRecordsAction: ActionHookWithObjectMetadataItem =
|
||||
({ objectMetadataItem }) => {
|
||||
|
||||
@ -18,7 +18,7 @@ import { useHasObjectReadOnlyPermission } from '@/settings/roles/hooks/useHasObj
|
||||
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useDestroyMultipleRecordsAction: ActionHookWithObjectMetadataItem =
|
||||
({ objectMetadataItem }) => {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
import { ActionHookWithObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||
import { contextStoreCurrentViewIdComponentState } from '@/context-store/states/contextStoreCurrentViewIdComponentState';
|
||||
@ -19,6 +18,7 @@ import { getRecordIndexIdFromObjectNamePluralAndViewId } from '@/object-record/u
|
||||
import { useHasObjectReadOnlyPermission } from '@/settings/roles/hooks/useHasObjectReadOnlyPermission';
|
||||
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useRestoreMultipleRecordsAction: ActionHookWithObjectMetadataItem =
|
||||
({ objectMetadataItem }) => {
|
||||
|
||||
@ -5,7 +5,7 @@ import { useFavorites } from '@/favorites/hooks/useFavorites';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { isNull } from '@sniptt/guards';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useAddToFavoritesSingleRecordAction: ActionHookWithObjectMetadataItem =
|
||||
({ objectMetadataItem }) => {
|
||||
|
||||
@ -11,8 +11,8 @@ import { t } from '@lingui/core/macro';
|
||||
import { isNull } from '@sniptt/guards';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { getOsControlSymbol } from 'twenty-ui';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useDeleteSingleRecordAction: ActionHookWithObjectMetadataItem = ({
|
||||
objectMetadataItem,
|
||||
|
||||
@ -8,8 +8,8 @@ import { AppPath } from '@/types/AppPath';
|
||||
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useDestroySingleRecordAction: ActionHookWithObjectMetadataItem = ({
|
||||
objectMetadataItem,
|
||||
|
||||
@ -5,7 +5,7 @@ import { recordStoreFamilyState } from '@/object-record/record-store/states/reco
|
||||
import { BlockNoteEditor } from '@blocknote/core';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useExportNoteAction: ActionHookWithObjectMetadataItem = ({
|
||||
objectMetadataItem,
|
||||
|
||||
@ -2,7 +2,7 @@ import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions
|
||||
import { ActionHookWithObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||
import { useDeleteFavorite } from '@/favorites/hooks/useDeleteFavorite';
|
||||
import { useFavorites } from '@/favorites/hooks/useFavorites';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useRemoveFromFavoritesSingleRecordAction: ActionHookWithObjectMetadataItem =
|
||||
({ objectMetadataItem }) => {
|
||||
|
||||
@ -11,7 +11,7 @@ import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModa
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useRestoreSingleRecordAction: ActionHookWithObjectMetadataItem = ({
|
||||
objectMetadataItem,
|
||||
|
||||
@ -2,7 +2,7 @@ import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions
|
||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||
import { useActivateWorkflowVersion } from '@/workflow/hooks/useActivateWorkflowVersion';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useActivateWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -2,7 +2,7 @@ import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions
|
||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||
import { useDeactivateWorkflowVersion } from '@/workflow/hooks/useDeactivateWorkflowVersion';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useDeactivateWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -2,7 +2,7 @@ import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions
|
||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||
import { useDeleteOneWorkflowVersion } from '@/workflow/hooks/useDeleteOneWorkflowVersion';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useDiscardDraftWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -4,8 +4,8 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { useActiveWorkflowVersion } from '@/workflow/hooks/useActiveWorkflowVersion';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useSeeActiveVersionWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -4,8 +4,8 @@ import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlur
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useSeeRunsWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -4,8 +4,8 @@ import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlur
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useSeeVersionsWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -2,7 +2,7 @@ import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions
|
||||
import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook';
|
||||
import { useRunWorkflowVersion } from '@/workflow/hooks/useRunWorkflowVersion';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useTestWorkflowSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -6,8 +6,8 @@ import { AppPath } from '@/types/AppPath';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useSeeRunsWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -6,8 +6,8 @@ import { AppPath } from '@/types/AppPath';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useSeeVersionsWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -8,8 +8,8 @@ import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { openOverrideWorkflowDraftConfirmationModalState } from '@/workflow/states/openOverrideWorkflowDraftConfirmationModalState';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useUseAsDraftWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem =
|
||||
() => {
|
||||
|
||||
@ -12,8 +12,9 @@ import { useRunWorkflowVersion } from '@/workflow/hooks/useRunWorkflowVersion';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { capitalize, isDefined } from 'twenty-shared';
|
||||
import { IconSettingsAutomation } from 'twenty-ui';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useWorkflowRunRecordActions = ({
|
||||
objectMetadataItem,
|
||||
}: {
|
||||
|
||||
@ -6,10 +6,9 @@ import { useActiveWorkflowVersionsWithManualTrigger } from '@/workflow/hooks/use
|
||||
import { useRunWorkflowVersion } from '@/workflow/hooks/useRunWorkflowVersion';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { capitalize, isDefined } from 'twenty-shared';
|
||||
import { IconSettingsAutomation } from 'twenty-ui';
|
||||
import { FeatureFlagKey } from '~/generated/graphql';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useRunWorkflowActions = () => {
|
||||
const isWorkflowEnabled = useIsFeatureEnabled(
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ActionMenuEntry } from '@/action-menu/types/ActionMenuEntry';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const wrapActionInCallbacks = ({
|
||||
action,
|
||||
|
||||
@ -10,8 +10,8 @@ import { contextStoreCurrentObjectMetadataItemIdComponentState } from '@/context
|
||||
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { FeatureFlagKey } from '~/generated-metadata/graphql';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const RecordShowRightDrawerActionMenu = () => {
|
||||
const contextStoreCurrentObjectMetadataItemId = useRecoilComponentValueV2(
|
||||
|
||||
@ -2,7 +2,7 @@ import { actionMenuEntriesComponentState } from '@/action-menu/states/actionMenu
|
||||
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
||||
import { ActionMenuEntry } from '@/action-menu/types/ActionMenuEntry';
|
||||
import { createComponentSelectorV2 } from '@/ui/utilities/state/component-state/utils/createComponentSelectorV2';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const actionMenuEntriesComponentSelector = createComponentSelectorV2<
|
||||
ActionMenuEntry[]
|
||||
|
||||
@ -2,14 +2,13 @@ import { createReactBlockSpec } from '@blocknote/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { ChangeEvent, useRef } from 'react';
|
||||
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { Button } from 'twenty-ui';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
import { AttachmentIcon } from '../../files/components/AttachmentIcon';
|
||||
import { AttachmentType } from '../../files/types/Attachment';
|
||||
import { getFileType } from '../../files/utils/getFileType';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const StyledFileInput = styled.input`
|
||||
display: none;
|
||||
|
||||
@ -11,7 +11,6 @@ import { getCalendarEventStartDate } from '@/activities/calendar/utils/getCalend
|
||||
import { hasCalendarEventEnded } from '@/activities/calendar/utils/hasCalendarEventEnded';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { useOpenCalendarEventInCommandMenu } from '@/command-menu/hooks/useOpenCalendarEventInCommandMenu';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
@ -24,6 +23,7 @@ import {
|
||||
CalendarChannelVisibility,
|
||||
TimelineCalendarEvent,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
type CalendarEventRowProps = {
|
||||
calendarEvent: TimelineCalendarEvent;
|
||||
|
||||
@ -3,10 +3,10 @@ import { useMemo, useState } from 'react';
|
||||
|
||||
import { findUpcomingCalendarEvent } from '@/activities/calendar/utils/findUpcomingCalendarEvent';
|
||||
import { getCalendarEventStartDate } from '@/activities/calendar/utils/getCalendarEventStartDate';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { TimelineCalendarEvent } from '~/generated/graphql';
|
||||
import { groupArrayItemsBy } from '~/utils/array/groupArrayItemsBy';
|
||||
import { sortDesc } from '~/utils/sort';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useCalendarEvents = (calendarEvents: TimelineCalendarEvent[]) => {
|
||||
const calendarEventsByDayTime = groupArrayItemsBy(
|
||||
|
||||
@ -21,7 +21,6 @@ import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
|
||||
import { isNonTextWritingKey } from '@/ui/utilities/hotkey/utils/isNonTextWritingKey';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { Key } from 'ts-key-enum';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
|
||||
import { ActivityRichTextEditorChangeOnActivityIdEffect } from '@/activities/components/ActivityRichTextEditorChangeOnActivityIdEffect';
|
||||
@ -34,6 +33,7 @@ import '@blocknote/mantine/style.css';
|
||||
import { useCreateBlockNote } from '@blocknote/react';
|
||||
import '@blocknote/react/style.css';
|
||||
import { isArray, isNonEmptyString } from '@sniptt/guards';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
type ActivityRichTextEditorProps = {
|
||||
activityId: string;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
import { EmailThreadMessageParticipant } from '@/activities/emails/types/EmailThreadMessageParticipant';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const getDisplayNameFromParticipant = ({
|
||||
participant,
|
||||
|
||||
@ -15,7 +15,7 @@ import { TextInput } from '@/ui/input/components/TextInput';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { useState } from 'react';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import {
|
||||
IconCalendar,
|
||||
OverflowingTextWithTooltip,
|
||||
|
||||
@ -18,7 +18,7 @@ import { useAttachments } from '@/activities/files/hooks/useAttachments';
|
||||
import { useUploadAttachmentFile } from '@/activities/files/hooks/useUploadAttachmentFile';
|
||||
import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity';
|
||||
import { useHasObjectReadOnlyPermission } from '@/settings/roles/hooks/useHasObjectReadOnlyPermission';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const StyledAttachmentsContainer = styled.div`
|
||||
display: flex;
|
||||
|
||||
@ -9,7 +9,7 @@ import { TaskTarget } from '@/activities/types/TaskTarget';
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useActivityTargetObjectRecords = (
|
||||
activityRecordId?: string,
|
||||
|
||||
@ -16,7 +16,7 @@ import { NoteTarget } from '@/activities/types/NoteTarget';
|
||||
import { TaskTarget } from '@/activities/types/TaskTarget';
|
||||
import { getJoinObjectNameSingular } from '@/activities/utils/getJoinObjectNameSingular';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { capitalize } from 'twenty-shared';
|
||||
import { capitalize } from 'twenty-shared/utils';
|
||||
|
||||
export const useCreateActivityInDB = ({
|
||||
activityObjectNameSingular,
|
||||
|
||||
@ -13,8 +13,8 @@ import { useGetRecordFromCache } from '@/object-record/cache/hooks/useGetRecordF
|
||||
import { useUpsertFindManyRecordsQueryInCache } from '@/object-record/cache/hooks/useUpsertFindManyRecordsQueryInCache';
|
||||
import { getRecordFromCache } from '@/object-record/cache/utils/getRecordFromCache';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { sortByAscString } from '~/utils/array/sortByAscString';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const usePrepareFindManyActivitiesQuery = ({
|
||||
activityObjectNameSingular,
|
||||
|
||||
@ -3,7 +3,7 @@ import { useRecoilValue } from 'recoil';
|
||||
import { usePrepareFindManyActivitiesQuery } from '@/activities/hooks/usePrepareFindManyActivitiesQuery';
|
||||
import { objectShowPageTargetableObjectState } from '@/activities/timeline-activities/states/objectShowPageTargetableObjectIdState';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
// This hook should only be executed if the normalized cache is up-to-date
|
||||
// It will take a targetableObject and prepare the queries for the activities
|
||||
|
||||
@ -2,8 +2,8 @@ import { BLOCK_SCHEMA } from '@/activities/blocks/constants/Schema';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useReplaceActivityBlockEditorContent = (
|
||||
editor: typeof BLOCK_SCHEMA.BlockNoteEditor,
|
||||
|
||||
@ -9,7 +9,7 @@ import { Note } from '@/activities/types/Note';
|
||||
import { Task } from '@/activities/types/Task';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useUpsertActivity = ({
|
||||
activityObjectNameSingular,
|
||||
|
||||
@ -11,8 +11,8 @@ import { RecordPickerPickableMorphItem } from '@/object-record/record-picker/typ
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { isNull } from '@sniptt/guards';
|
||||
import { useRecoilCallback, useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { v4 } from 'uuid';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
type UpdateActivityTargetFromInlineCellProps = {
|
||||
recordPickerInstanceId: string;
|
||||
|
||||
@ -7,13 +7,13 @@ import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
|
||||
import { useUpsertRecordsInStore } from '@/object-record/record-store/hooks/useUpsertRecordsInStore';
|
||||
import { UserContext } from '@/users/contexts/UserContext';
|
||||
import { useContext } from 'react';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import {
|
||||
formatToHumanReadableDay,
|
||||
formatToHumanReadableMonth,
|
||||
formatToHumanReadableTime,
|
||||
} from '~/utils/format/formatDate';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const StyledEventCardCalendarEventContainer = styled.div`
|
||||
cursor: pointer;
|
||||
|
||||
@ -5,7 +5,7 @@ import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { useSetRecordValue } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const EventFieldDiffValueEffect = ({
|
||||
diffArtificialRecordStoreId,
|
||||
|
||||
@ -7,7 +7,7 @@ import { EventCardMessageNotShared } from '@/activities/timeline-activities/rows
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
|
||||
import { useUpsertRecordsInStore } from '@/object-record/record-store/hooks/useUpsertRecordsInStore';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const StyledEventCardMessageContainer = styled.div`
|
||||
display: flex;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { TimelineActivity } from '@/activities/timeline-activities/types/TimelineActivity';
|
||||
import { CurrentWorkspaceMember } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const getTimelineActivityAuthorFullName = (
|
||||
event: TimelineActivity,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { TimelineActivity } from '@/activities/timeline-activities/types/TimelineActivity';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export type EventGroup = {
|
||||
month: number;
|
||||
|
||||
@ -10,7 +10,6 @@ import { previousUrlState } from '@/auth/states/previousUrlState';
|
||||
import { tokenPairState } from '@/auth/states/tokenPairState';
|
||||
import { workspacesState } from '@/auth/states/workspaces';
|
||||
import { isDebugModeState } from '@/client-config/states/isDebugModeState';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
import { useUpdateEffect } from '~/hooks/useUpdateEffect';
|
||||
@ -18,6 +17,7 @@ import { useUpdateEffect } from '~/hooks/useUpdateEffect';
|
||||
import { currentUserWorkspaceState } from '@/auth/states/currentUserWorkspaceState';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { ApolloFactory, Options } from '../services/apollo.factory';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useApolloFactory = (options: Partial<Options<any>> = {}) => {
|
||||
// eslint-disable-next-line @nx/workspace-no-state-useref
|
||||
|
||||
@ -4,8 +4,8 @@ import { ReadFieldFunction } from '@apollo/client/cache/core/types/common';
|
||||
import { RecordGqlRefEdge } from '@/object-record/cache/types/RecordGqlRefEdge';
|
||||
import { RecordGqlOperationOrderBy } from '@/object-record/graphql/types/RecordGqlOperationOrderBy';
|
||||
import { OrderBy } from '@/types/OrderBy';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { sortAsc, sortDesc, sortNullsFirst, sortNullsLast } from '~/utils/sort';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const sortCachedObjectEdges = ({
|
||||
edges,
|
||||
|
||||
@ -2,7 +2,7 @@ import { ApolloCache, StoreObject } from '@apollo/client';
|
||||
|
||||
import { RecordGqlRefEdge } from '@/object-record/cache/types/RecordGqlRefEdge';
|
||||
import { isObjectRecordConnectionWithRefs } from '@/object-record/cache/utils/isObjectRecordConnectionWithRefs';
|
||||
import { capitalize, isDefined } from 'twenty-shared';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const triggerAttachRelationOptimisticEffect = ({
|
||||
cache,
|
||||
|
||||
@ -13,8 +13,8 @@ import { CachedObjectRecordQueryVariables } from '@/apollo/types/CachedObjectRec
|
||||
import { encodeCursor } from '@/apollo/utils/encodeCursor';
|
||||
import { getRecordFromCache } from '@/object-record/cache/utils/getRecordFromCache';
|
||||
import { getRecordNodeFromRecord } from '@/object-record/cache/utils/getRecordNodeFromRecord';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { parseApolloStoreFieldName } from '~/utils/parseApolloStoreFieldName';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
/*
|
||||
TODO: for now new records are added to all cached record lists, no matter what the variables (filters, orderBy, etc.) are.
|
||||
|
||||
@ -5,7 +5,7 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { RecordGqlRefEdge } from '@/object-record/cache/types/RecordGqlRefEdge';
|
||||
import { isObjectRecordConnectionWithRefs } from '@/object-record/cache/utils/isObjectRecordConnectionWithRefs';
|
||||
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const triggerDestroyRecordsOptimisticEffect = ({
|
||||
cache,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ApolloCache, StoreObject } from '@apollo/client';
|
||||
|
||||
import { isObjectRecordConnectionWithRefs } from '@/object-record/cache/utils/isObjectRecordConnectionWithRefs';
|
||||
import { capitalize } from 'twenty-shared';
|
||||
import { capitalize } from 'twenty-shared/utils';
|
||||
|
||||
export const triggerDetachRelationOptimisticEffect = ({
|
||||
cache,
|
||||
|
||||
@ -9,8 +9,8 @@ import { getEdgeTypename } from '@/object-record/cache/utils/getEdgeTypename';
|
||||
import { isObjectRecordConnectionWithRefs } from '@/object-record/cache/utils/isObjectRecordConnectionWithRefs';
|
||||
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
|
||||
import { isRecordMatchingFilter } from '@/object-record/record-filter/utils/isRecordMatchingFilter';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { parseApolloStoreFieldName } from '~/utils/parseApolloStoreFieldName';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
// TODO: add extensive unit tests for this function
|
||||
// That will also serve as documentation
|
||||
|
||||
@ -9,8 +9,8 @@ import { getEdgeTypename } from '@/object-record/cache/utils/getEdgeTypename';
|
||||
import { isObjectRecordConnectionWithRefs } from '@/object-record/cache/utils/isObjectRecordConnectionWithRefs';
|
||||
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
|
||||
import { isRecordMatchingFilter } from '@/object-record/record-filter/utils/isRecordMatchingFilter';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { parseApolloStoreFieldName } from '~/utils/parseApolloStoreFieldName';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
// TODO: add extensive unit tests for this function
|
||||
// That will also serve as documentation
|
||||
|
||||
@ -9,9 +9,9 @@ import { RecordGqlConnection } from '@/object-record/graphql/types/RecordGqlConn
|
||||
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
|
||||
import { ApolloCache } from '@apollo/client';
|
||||
import { isArray } from '@sniptt/guards';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
type triggerUpdateRelationsOptimisticEffectArgs = {
|
||||
cache: ApolloCache<unknown>;
|
||||
|
||||
@ -13,7 +13,6 @@ import { createUploadLink } from 'apollo-upload-client';
|
||||
|
||||
import { renewToken } from '@/auth/services/AuthService';
|
||||
import { CurrentWorkspaceMember } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { AuthTokenPair } from '~/generated/graphql';
|
||||
import { logDebug } from '~/utils/logDebug';
|
||||
|
||||
@ -21,6 +20,7 @@ import { i18n } from '@lingui/core';
|
||||
import { GraphQLFormattedError } from 'graphql';
|
||||
import { ApolloManager } from '../types/apolloManager.interface';
|
||||
import { loggerLink } from '../utils/loggerLink';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const logger = loggerLink(() => 'Twenty');
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
import { Buffer } from 'buffer';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const encodeCursor = (record: ObjectRecord) => {
|
||||
if (!('id' in record) || !isDefined(record.id)) {
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import { ApolloLink, gql, Operation } from '@apollo/client';
|
||||
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { logDebug } from '~/utils/logDebug';
|
||||
import { logError } from '~/utils/logError';
|
||||
|
||||
import formatTitle from './formatTitle';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const getGroup = (collapsed: boolean) =>
|
||||
collapsed
|
||||
|
||||
@ -21,10 +21,10 @@ import { AppPath } from '@/types/AppPath';
|
||||
import { PageHotkeyScope } from '@/types/PageHotkeyScope';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
import { usePageChangeEffectNavigateLocation } from '~/hooks/usePageChangeEffectNavigateLocation';
|
||||
import { isCaptchaRequiredForPath } from '@/captcha/utils/isCaptchaRequiredForPath';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
// TODO: break down into smaller functions and / or hooks
|
||||
// - moved usePageChangeEffectNavigateLocation into dedicated hook
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import styled from '@emotion/styled';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
import { getImageAbsoluteURI } from 'twenty-shared';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import { getImageAbsoluteURI } from 'twenty-shared/utils';
|
||||
|
||||
type LogoProps = {
|
||||
primaryLogo?: string | null;
|
||||
|
||||
@ -6,8 +6,8 @@ import { useVerifyLogin } from '@/auth/hooks/useVerifyLogin';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const VerifyEffect = () => {
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
@ -2,7 +2,6 @@ import { i18n } from '@lingui/core';
|
||||
import { I18nProvider } from '@lingui/react';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
import { SOURCE_LOCALE } from 'twenty-shared';
|
||||
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
@ -12,6 +11,8 @@ import { useAuth } from '../useAuth';
|
||||
import { useVerifyLogin } from '../useVerifyLogin';
|
||||
|
||||
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
|
||||
import { SOURCE_LOCALE } from 'twenty-shared/translations';
|
||||
|
||||
jest.mock('../useAuth', () => ({
|
||||
useAuth: jest.fn(),
|
||||
}));
|
||||
|
||||
@ -20,7 +20,6 @@ import { clientConfigApiStatusState } from '@/client-config/states/clientConfigA
|
||||
import { isDebugModeState } from '@/client-config/states/isDebugModeState';
|
||||
import { supportChatState } from '@/client-config/states/supportChatState';
|
||||
import { ColorScheme } from '@/workspace-member/types/WorkspaceMember';
|
||||
import { APP_LOCALES, isDefined } from 'twenty-shared';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import {
|
||||
useCheckUserExistsLazyQuery,
|
||||
@ -65,6 +64,8 @@ import { i18n } from '@lingui/core';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { getWorkspaceUrl } from '~/utils/getWorkspaceUrl';
|
||||
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
|
||||
import { APP_LOCALES } from 'twenty-shared/translations';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useAuth = () => {
|
||||
const setTokenPair = useSetRecoilState(tokenPairState);
|
||||
|
||||
@ -7,7 +7,6 @@ import {
|
||||
} from '@apollo/client';
|
||||
|
||||
import { loggerLink } from '@/apollo/utils/loggerLink';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import {
|
||||
AuthTokenPair,
|
||||
RenewTokenDocument,
|
||||
@ -15,6 +14,7 @@ import {
|
||||
RenewTokenMutationVariables,
|
||||
} from '~/generated/graphql';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const logger = loggerLink(() => 'Twenty-Refresh');
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { Controller, useFormContext } from 'react-hook-form';
|
||||
import styled from '@emotion/styled';
|
||||
import { motion } from 'framer-motion';
|
||||
import { Form } from '@/auth/sign-in-up/hooks/useSignInUpForm';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const StyledFullWidthMotionDiv = styled(motion.div)`
|
||||
width: 100%;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user