-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add default relation to standard object on custom object in manifest #18033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 21 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
ac4e5cc
Add missing fields
martmull ea71d29
Reorganize files
martmull 369ee28
Fix typing
martmull d5dac06
Add default relation fields
martmull b00c7e0
Remove TS_VECTOR and POSITION validation
martmull a889b3b
WIP
martmull cec2a65
Merge branch 'main' into fix-sync-2
martmull 0c6e16e
WIP
martmull c99a876
Merge branch 'main' into fix-sync-2
martmull 6d9dc34
WIP
martmull 51003c8
Merge branch 'main' into fix-sync-2
martmull 7a0d274
refactor(server): manifest sync build on dependency all flat entity maps
prastoin 959ee56
Set proper default relation fields
martmull a7b9f33
Merge branch 'main' into fix-sync-2
martmull 8c0b024
Merge branch 'main' into fix-sync-2
martmull 654d4bd
fix(server): dependency flat maps as from
prastoin bb586ac
fix
prastoin 0e3b13a
Fix wrong handlerName check
martmull ca8631e
fix(server): dependency flat entity maps
prastoin f4facfe
Merge branch 'main' into fix-sync-2
martmull 841afe3
fix(server): restore validators of fields position and ts_vector
prastoin a76ca26
refactor(server): simplify computeApplicationManifestAllUniversalFlat…
prastoin 9041474
refacotr(server): fieldManifest type
prastoin 7e26a7d
Merge branch 'main' into fix-sync-2
martmull c34db90
Fix test
martmull 4558f30
Merge branch 'main' into fix-sync-2
martmull 00bcb0c
Merge branch 'main' into fix-sync-2
martmull d9b7460
Fix test
martmull a5da69b
Refactor constants
martmull e50bfa4
Fix test
martmull 6830738
Fix lint
martmull f1629d1
Fix ci
martmull bfa862a
Merge branch 'main' into fix-sync-2
martmull 705ca73
Merge branch 'main' into fix-sync-2
martmull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
.../twenty-sdk/src/cli/utilities/build/manifest/utils/get-default-fields-in-object-fields.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import type { ObjectConfig } from '@/sdk/objects/object-config'; | ||
| import { getDefaultObjectFields } from '@/cli/utilities/build/manifest/utils/get-default-object-fields'; | ||
| import { getDefaultRelationObjectFields } from '@/cli/utilities/build/manifest/utils/get-default-relation-object-fields'; | ||
| import { | ||
| type FieldManifest, | ||
| type ObjectFieldManifest, | ||
| } from 'twenty-shared/application'; | ||
|
|
||
| export const getDefaultFieldsInObjectFields = ( | ||
| objectConfig: ObjectConfig, | ||
| ): { objectFields: ObjectFieldManifest[]; fields: FieldManifest[] } => { | ||
| const defaultObjectFields = getDefaultObjectFields(objectConfig); | ||
| const { objectFields: defaultRelationObjectFields, fields: reverseFields } = | ||
| getDefaultRelationObjectFields(objectConfig); | ||
|
|
||
| const objectConfigFieldNames = (objectConfig.fields ?? []).map((f) => f.name); | ||
|
|
||
| const objectFieldsWithDefaults = [...objectConfig.fields]; | ||
|
|
||
| for (const defaultField of defaultObjectFields) { | ||
| if (!objectConfigFieldNames.includes(defaultField.name)) { | ||
| objectFieldsWithDefaults.push(defaultField); | ||
| } | ||
| } | ||
|
|
||
| for (const defaultRelationField of defaultRelationObjectFields) { | ||
| if (!objectConfigFieldNames.includes(defaultRelationField.name)) { | ||
| objectFieldsWithDefaults.push(defaultRelationField); | ||
| } | ||
| } | ||
|
|
||
| return { objectFields: objectFieldsWithDefaults, fields: reverseFields }; | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: We should allow the user to configure an object without either any default relation field or default field
For example will be required in order to declare twenty-standard as an sdk app