Add default relation to standard object on custom object in manifest (#18033)
add default relation fields when creating an object from an application --------- Co-authored-by: prastoin <paul@twenty.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export const API_CLIENT_DIR = 'api-client';
|
||||
@@ -1,10 +1,10 @@
|
||||
import { type SyncableEntityOptions } from '@/application/syncableEntityOptionsType';
|
||||
import {
|
||||
type FieldMetadataDefaultValue,
|
||||
type FieldMetadataOptions,
|
||||
type FieldMetadataType,
|
||||
type FieldMetadataUniversalSettings,
|
||||
type RelationAndMorphRelationFieldMetadataType,
|
||||
FieldMetadataDefaultValue,
|
||||
FieldMetadataOptions,
|
||||
FieldMetadataType,
|
||||
FieldMetadataUniversalSettings,
|
||||
RelationAndMorphRelationFieldMetadataType
|
||||
} from '@/types';
|
||||
|
||||
export type RegularFieldManifest<
|
||||
@@ -25,20 +25,27 @@ export type RegularFieldManifest<
|
||||
objectUniversalIdentifier: string;
|
||||
};
|
||||
|
||||
// Both sides of a relation must be declared explicitly in the manifest.
|
||||
// Relation-specific universal settings (relationType, onDelete, joinColumnName)
|
||||
// are provided through the `universalSettings` field.
|
||||
export type RelationFieldManifest<
|
||||
T extends
|
||||
RelationAndMorphRelationFieldMetadataType = RelationAndMorphRelationFieldMetadataType,
|
||||
> = RegularFieldManifest<T> & {
|
||||
> = Omit<RegularFieldManifest<T>, 'universalSettings' | 'type'> & {
|
||||
type: T;
|
||||
relationTargetFieldMetadataUniversalIdentifier: string;
|
||||
relationTargetObjectMetadataUniversalIdentifier: string;
|
||||
};
|
||||
universalSettings: FieldMetadataUniversalSettings<T>;
|
||||
} & ([T] extends [FieldMetadataType.MORPH_RELATION]
|
||||
? {
|
||||
morphId: string;
|
||||
}
|
||||
: {
|
||||
morphId?: undefined;
|
||||
});
|
||||
|
||||
export type FieldManifest<
|
||||
T extends FieldMetadataType = Exclude<
|
||||
FieldMetadataType,
|
||||
RelationAndMorphRelationFieldMetadataType
|
||||
>,
|
||||
> = RegularFieldManifest<T> | RelationFieldManifest;
|
||||
export type FieldManifest<T extends FieldMetadataType = FieldMetadataType> =
|
||||
T extends RelationAndMorphRelationFieldMetadataType
|
||||
? RelationFieldManifest<
|
||||
Extract<T, RelationAndMorphRelationFieldMetadataType>
|
||||
>
|
||||
: RegularFieldManifest<
|
||||
Exclude<T, RelationAndMorphRelationFieldMetadataType>
|
||||
>;
|
||||
|
||||
@@ -13,6 +13,7 @@ export type {
|
||||
} from './applicationType';
|
||||
export type { ApplicationVariables } from './applicationVariablesType';
|
||||
export type { AssetManifest } from './assetManifestType';
|
||||
export { API_CLIENT_DIR } from './constants/ApiClientDirectory';
|
||||
export { ASSETS_DIR } from './constants/AssetDirectory';
|
||||
export { DEFAULT_API_KEY_NAME } from './constants/DefaultApiKeyName';
|
||||
export { DEFAULT_API_URL_NAME } from './constants/DefaultApiUrlName';
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { type FieldManifest } from '@/application/fieldManifestType';
|
||||
import type { FieldMetadataType } from '@/types';
|
||||
|
||||
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown
|
||||
? Omit<T, K>
|
||||
: never;
|
||||
|
||||
export type ObjectFieldManifest<
|
||||
T extends FieldMetadataType = Exclude<
|
||||
FieldMetadataType,
|
||||
FieldMetadataType.RELATION
|
||||
>,
|
||||
> = Omit<FieldManifest<T>, 'objectUniversalIdentifier'>;
|
||||
T extends FieldMetadataType = FieldMetadataType,
|
||||
> = DistributiveOmit<FieldManifest<T>, 'objectUniversalIdentifier'>;
|
||||
|
||||
Reference in New Issue
Block a user