2024-08-29 19:16:50 +03:00
|
|
|
/* eslint-disable no-console */
|
2024-11-07 20:11:51 +03:00
|
|
|
import { isNonEmptyString } from '@sniptt/guards';
|
2023-12-10 18:22:43 +03:00
|
|
|
import react from '@vitejs/plugin-react-swc';
|
2024-06-12 17:31:07 +03:00
|
|
|
import wyw from '@wyw-in-js/vite';
|
2024-04-17 19:06:02 +03:00
|
|
|
import path from 'path';
|
2024-08-07 12:12:33 +03:00
|
|
|
import { defineConfig, loadEnv, searchForWorkspaceRoot } from 'vite';
|
2024-01-10 19:42:11 +03:00
|
|
|
import checker from 'vite-plugin-checker';
|
2023-12-10 18:22:43 +03:00
|
|
|
import svgr from 'vite-plugin-svgr';
|
2024-01-10 19:42:11 +03:00
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
|
|
|
|
|
|
type Checkers = Parameters<typeof checker>[0];
|
2023-12-10 18:22:43 +03:00
|
|
|
|
2024-01-10 19:42:11 +03:00
|
|
|
export default defineConfig(({ command, mode }) => {
|
|
|
|
const env = loadEnv(mode, process.cwd(), '');
|
2023-12-10 18:22:43 +03:00
|
|
|
|
2024-08-26 17:35:09 +03:00
|
|
|
const {
|
|
|
|
REACT_APP_SERVER_BASE_URL,
|
|
|
|
VITE_BUILD_SOURCEMAP,
|
|
|
|
VITE_DISABLE_TYPESCRIPT_CHECKER,
|
|
|
|
VITE_DISABLE_ESLINT_CHECKER,
|
2024-11-07 20:11:51 +03:00
|
|
|
REACT_APP_PORT
|
2024-08-26 17:35:09 +03:00
|
|
|
} = env;
|
2024-01-10 19:42:11 +03:00
|
|
|
|
2024-11-07 20:11:51 +03:00
|
|
|
const port = isNonEmptyString(REACT_APP_PORT) ? parseInt(REACT_APP_PORT) : 3001;
|
|
|
|
|
2024-01-10 19:42:11 +03:00
|
|
|
const isBuildCommand = command === 'build';
|
|
|
|
|
2024-08-20 12:05:13 +03:00
|
|
|
const tsConfigPath = isBuildCommand
|
|
|
|
? path.resolve(__dirname, './tsconfig.build.json')
|
|
|
|
: path.resolve(__dirname, './tsconfig.dev.json');
|
|
|
|
|
2024-01-10 19:42:11 +03:00
|
|
|
const checkers: Checkers = {
|
2024-01-22 16:19:22 +03:00
|
|
|
overlay: false,
|
2024-01-10 19:42:11 +03:00
|
|
|
};
|
|
|
|
|
2024-08-27 18:06:39 +03:00
|
|
|
if (VITE_DISABLE_TYPESCRIPT_CHECKER === 'true') {
|
|
|
|
console.log(
|
|
|
|
`VITE_DISABLE_TYPESCRIPT_CHECKER: ${VITE_DISABLE_TYPESCRIPT_CHECKER}`,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VITE_DISABLE_ESLINT_CHECKER === 'true') {
|
|
|
|
console.log(`VITE_DISABLE_ESLINT_CHECKER: ${VITE_DISABLE_ESLINT_CHECKER}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VITE_BUILD_SOURCEMAP === 'true') {
|
|
|
|
console.log(`VITE_BUILD_SOURCEMAP: ${VITE_BUILD_SOURCEMAP}`);
|
|
|
|
}
|
2024-08-27 15:13:05 +03:00
|
|
|
|
2024-08-26 17:35:09 +03:00
|
|
|
if (VITE_DISABLE_TYPESCRIPT_CHECKER !== 'true') {
|
|
|
|
checkers['typescript'] = {
|
|
|
|
tsconfigPath: tsConfigPath,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VITE_DISABLE_ESLINT_CHECKER !== 'true') {
|
2024-01-10 19:42:11 +03:00
|
|
|
checkers['eslint'] = {
|
|
|
|
lintCommand:
|
2024-10-20 21:20:19 +03:00
|
|
|
'cd ../.. && eslint packages/twenty-front --report-unused-disable-directives --max-warnings 0 --config .eslintrc.cjs',
|
2024-01-10 19:42:11 +03:00
|
|
|
};
|
|
|
|
}
|
2023-12-10 18:22:43 +03:00
|
|
|
|
|
|
|
return {
|
2024-04-04 16:38:01 +03:00
|
|
|
root: __dirname,
|
|
|
|
cacheDir: '../../node_modules/.vite/packages/twenty-front',
|
|
|
|
|
2023-12-10 18:22:43 +03:00
|
|
|
server: {
|
2024-11-07 20:11:51 +03:00
|
|
|
port,
|
2024-04-04 16:38:01 +03:00
|
|
|
host: 'localhost',
|
2024-08-07 12:12:33 +03:00
|
|
|
fs: {
|
|
|
|
allow: [
|
|
|
|
searchForWorkspaceRoot(process.cwd()),
|
|
|
|
'**/@blocknote/core/src/fonts/**',
|
|
|
|
],
|
|
|
|
},
|
2024-04-04 16:38:01 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
react({ jsxImportSource: '@emotion/react' }),
|
|
|
|
tsconfigPaths({
|
2024-04-12 16:30:48 +03:00
|
|
|
projects: ['tsconfig.json', '../twenty-ui/tsconfig.json'],
|
2024-04-04 16:38:01 +03:00
|
|
|
}),
|
|
|
|
svgr(),
|
|
|
|
checker(checkers),
|
2024-06-12 19:36:25 +03:00
|
|
|
// TODO: fix this, we have to restrict the include to only the components that are using linaria
|
|
|
|
// Otherwise the build will fail because wyw tries to include emotion styled components
|
2024-06-12 17:31:07 +03:00
|
|
|
wyw({
|
2024-06-12 19:36:25 +03:00
|
|
|
include: [
|
|
|
|
'**/CurrencyDisplay.tsx',
|
|
|
|
'**/EllipsisDisplay.tsx',
|
|
|
|
'**/ContactLink.tsx',
|
|
|
|
'**/BooleanDisplay.tsx',
|
|
|
|
'**/LinksDisplay.tsx',
|
|
|
|
'**/RoundedLink.tsx',
|
|
|
|
'**/OverflowingTextWithTooltip.tsx',
|
|
|
|
'**/Chip.tsx',
|
|
|
|
'**/Tag.tsx',
|
|
|
|
'**/MultiSelectFieldDisplay.tsx',
|
2024-06-17 18:27:19 +03:00
|
|
|
'**/RatingInput.tsx',
|
2024-06-30 22:54:11 +03:00
|
|
|
'**/RecordTableCellContainer.tsx',
|
|
|
|
'**/RecordTableCellDisplayContainer.tsx',
|
|
|
|
'**/Avatar.tsx',
|
2024-07-05 19:30:59 +03:00
|
|
|
'**/RecordTableBodyDroppable.tsx',
|
|
|
|
'**/RecordTableCellBaseContainer.tsx',
|
|
|
|
'**/RecordTableCellTd.tsx',
|
|
|
|
'**/RecordTableTd.tsx',
|
|
|
|
'**/RecordTableHeaderDragDropColumn.tsx',
|
feat: add new ACTOR field type and createdBy standard fields (#6324)
This pull request introduces a new `FieldMetadataType` called `ACTOR`.
The primary objective of this new type is to add an extra column to the
following objects: `person`, `company`, `opportunity`, `note`, `task`,
and all custom objects.
This composite type contains three properties:
- `source`
```typescript
export enum FieldActorSource {
EMAIL = 'EMAIL',
CALENDAR = 'CALENDAR',
API = 'API',
IMPORT = 'IMPORT',
MANUAL = 'MANUAL',
}
```
- `workspaceMemberId`
- This property can be `undefined` in some cases and refers to the
member who created the record.
- `name`
- Serves as a fallback if the `workspaceMember` is deleted and is used
for other source types like `API`.
### Functionality
The pre-hook system has been updated to allow real-time argument
updates. When a record is created, a pre-hook can now compute and update
the arguments accordingly. This enhancement enables the `createdBy`
field to be populated with the correct values based on the
`authContext`.
The `authContext` now includes:
- An optional User entity
- An optional ApiKey entity
- The workspace entity
This provides access to the necessary data for the `createdBy` field.
In the GraphQL API, only the `source` can be specified in the
`createdBy` input. This allows the front-end to specify the source when
creating records from a CSV file.
### Front-End Handling
On the front-end, `orderBy` and `filter` are only applied to the name
property of the `ACTOR` composite type. Currently, we are unable to
apply these operations to the workspace member relation. This means that
if a workspace member changes their first name or last name, there may
be a mismatch because the name will differ from the new one. The name
displayed on the screen is based on the workspace member entity when
available.
### Missing Components
Currently, this PR does not include a `createdBy` value for the `MAIL`
and `CALENDAR` sources. These records are created in a job, and at
present, we only have access to the workspaceId within the job. To
address this, we should use a function similar to
`loadServiceWithContext`, which was recently removed from `TwentyORM`.
This function would allow us to pass the `authContext` to the jobs
without disrupting existing jobs.
Another PR will be created to handle these cases.
### Related Issues
Fixes issue #5155.
### Additional Notes
This PR doesn't include the migrations of the current records and views.
Everything works properly when the database is reset but this part is
still missing for now. We'll add that in another PR.
- There is a minor issue: front-end tests are broken since this commit:
[https://github.com/twentyhq/twenty/commit/80c0fc7ff108d61c0e8d89fd334da64bd224f7aa](https://github.com/twentyhq/twenty/commit/80c0fc7ff108d61c0e8d89fd334da64bd224f7aa).
---------
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-03 16:43:31 +03:00
|
|
|
'**/ActorDisplay.tsx',
|
|
|
|
'**/AvatarChip.tsx',
|
2024-06-12 19:36:25 +03:00
|
|
|
],
|
2024-06-12 17:31:07 +03:00
|
|
|
babelOptions: {
|
|
|
|
presets: ['@babel/preset-typescript', '@babel/preset-react'],
|
|
|
|
},
|
|
|
|
}),
|
2024-04-04 16:38:01 +03:00
|
|
|
],
|
|
|
|
|
|
|
|
build: {
|
|
|
|
outDir: 'build',
|
2024-04-15 13:12:59 +03:00
|
|
|
sourcemap: VITE_BUILD_SOURCEMAP === 'true',
|
2023-12-10 18:22:43 +03:00
|
|
|
},
|
2024-04-04 16:38:01 +03:00
|
|
|
|
|
|
|
envPrefix: 'REACT_APP_',
|
|
|
|
|
2023-12-10 18:22:43 +03:00
|
|
|
define: {
|
2024-01-10 19:42:11 +03:00
|
|
|
'process.env': {
|
2023-12-10 18:22:43 +03:00
|
|
|
REACT_APP_SERVER_BASE_URL,
|
2024-01-10 19:42:11 +03:00
|
|
|
},
|
|
|
|
},
|
2024-05-24 19:53:37 +03:00
|
|
|
css: {
|
|
|
|
modules: {
|
|
|
|
localsConvention: 'camelCaseOnly',
|
|
|
|
},
|
|
|
|
},
|
2024-09-02 16:25:20 +03:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
path: 'rollup-plugin-node-polyfills/polyfills/path',
|
|
|
|
},
|
|
|
|
},
|
2024-01-10 19:42:11 +03:00
|
|
|
};
|
2023-12-10 18:22:43 +03:00
|
|
|
});
|