[BREAKING_CHANGE_NESTED_WORKSPACE]Refactor FlatEntity typing in aim of introducing UniversalFlatEntity (#16701)
# Introduction
Added a `WorkspaceRelated` and `AllNonWorkspaceRelatedEntity` to
simplify the `FlatEntityFrom` that now do not expect a string literal to
omit and itself builds the related many to one entities foreign key
aggregators
We now have the type grain over relation to syncable or just workspace
related entities
Added a migrations that sets the fk on missing entities
## Next
In upcoming PR we will be able to introduce such below type
```ts
import { type CastRecordTypeOrmDatePropertiesToString } from 'src/engine/metadata-modules/flat-entity/types/cast-record-typeorm-date-properties-to-string.type';
import { type ExtractEntityManyToOneEntityRelationProperties } from 'src/engine/metadata-modules/flat-entity/types/extract-entity-many-to-one-entity-relation-properties.type';
import { type ExtractEntityOneToManyEntityRelationProperties } from 'src/engine/metadata-modules/flat-entity/types/extract-entity-one-to-many-entity-relation-properties.type';
import { type ExtractEntityRelatedEntityProperties } from 'src/engine/metadata-modules/flat-entity/types/extract-entity-related-entity-properties.type';
import { type RemoveSuffix } from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/types/remove-suffix.type';
import { type SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
export type UniversalFlatEntityFrom<TEntity extends SyncableEntity> = Omit<
TEntity,
| `${ExtractEntityManyToOneEntityRelationProperties<TEntity> & string}Id`
| ExtractEntityRelatedEntityProperties<TEntity>
| 'application'
| 'workspaceId'
| 'applicationId'
| keyof CastRecordTypeOrmDatePropertiesToString<TEntity>
> &
CastRecordTypeOrmDatePropertiesToString<TEntity> & {
[P in ExtractEntityManyToOneEntityRelationProperties<TEntity> &
string as `${RemoveSuffix<P, 's'>}UniversalIdentifier`]: string;
} & {
[P in ExtractEntityOneToManyEntityRelationProperties<
TEntity,
SyncableEntity
> &
string as `${RemoveSuffix<P, 's'>}UniversalIdentifiers`]: string[];
};
```
This commit is contained in:
@@ -20,7 +20,7 @@ runs:
|
||||
id: cache-primary-key-builder
|
||||
shell: bash
|
||||
run: |
|
||||
echo "CACHE_PRIMARY_KEY_PREFIX=v3-${{ inputs.key }}-${{ github.ref_name }}" >> "${GITHUB_OUTPUT}"
|
||||
echo "CACHE_PRIMARY_KEY_PREFIX=v4-${{ inputs.key }}-${{ github.ref_name }}" >> "${GITHUB_OUTPUT}"
|
||||
- name: Restore cache
|
||||
uses: actions/cache/restore@v4
|
||||
id: restore-cache
|
||||
@@ -32,4 +32,4 @@ runs:
|
||||
.nx
|
||||
node_modules/.cache
|
||||
packages/*/node_modules/.cache
|
||||
${{ inputs.additional-paths }}
|
||||
${{ inputs.additional-paths }}
|
||||
|
||||
@@ -202,8 +202,6 @@ export type ApiKey = {
|
||||
revokedAt?: Maybe<Scalars['DateTime']>;
|
||||
role: Role;
|
||||
updatedAt: Scalars['DateTime'];
|
||||
workspace: Workspace;
|
||||
workspaceId: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type ApiKeyForRole = {
|
||||
@@ -1303,7 +1301,6 @@ export type FeatureFlag = {
|
||||
id: Scalars['UUID'];
|
||||
key: FeatureFlagKey;
|
||||
value: Scalars['Boolean'];
|
||||
workspaceId: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type FeatureFlagDto = {
|
||||
@@ -4678,8 +4675,6 @@ export type UserWorkspace = {
|
||||
updatedAt: Scalars['DateTime'];
|
||||
user: User;
|
||||
userId: Scalars['UUID'];
|
||||
workspace?: Maybe<Workspace>;
|
||||
workspaceId: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type ValidateApprovedAccessDomainInput = {
|
||||
@@ -4785,8 +4780,6 @@ export type Webhook = {
|
||||
secret: Scalars['String'];
|
||||
targetUrl: Scalars['String'];
|
||||
updatedAt: Scalars['DateTime'];
|
||||
workspace: Workspace;
|
||||
workspaceId: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type WidgetConfiguration = AggregateChartConfiguration | BarChartConfiguration | GaugeChartConfiguration | IframeConfiguration | LineChartConfiguration | PieChartConfiguration | StandaloneRichTextConfiguration;
|
||||
|
||||
@@ -202,8 +202,6 @@ export type ApiKey = {
|
||||
revokedAt?: Maybe<Scalars['DateTime']>;
|
||||
role: Role;
|
||||
updatedAt: Scalars['DateTime'];
|
||||
workspace: Workspace;
|
||||
workspaceId: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type ApiKeyForRole = {
|
||||
@@ -1286,7 +1284,6 @@ export type FeatureFlag = {
|
||||
id: Scalars['UUID'];
|
||||
key: FeatureFlagKey;
|
||||
value: Scalars['Boolean'];
|
||||
workspaceId: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type FeatureFlagDto = {
|
||||
@@ -4497,8 +4494,6 @@ export type UserWorkspace = {
|
||||
updatedAt: Scalars['DateTime'];
|
||||
user: User;
|
||||
userId: Scalars['UUID'];
|
||||
workspace?: Maybe<Workspace>;
|
||||
workspaceId: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type ValidateApprovedAccessDomainInput = {
|
||||
@@ -4604,8 +4599,6 @@ export type Webhook = {
|
||||
secret: Scalars['String'];
|
||||
targetUrl: Scalars['String'];
|
||||
updatedAt: Scalars['DateTime'];
|
||||
workspace: Workspace;
|
||||
workspaceId: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type WidgetConfiguration = AggregateChartConfiguration | BarChartConfiguration | GaugeChartConfiguration | IframeConfiguration | LineChartConfiguration | PieChartConfiguration | StandaloneRichTextConfiguration;
|
||||
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
import { type MigrationInterface, type QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddWorkspaceForeignKeys1767002571103
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddWorkspaceForeignKeys1767002571103';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."indexMetadata" ADD CONSTRAINT "FK_5c988136a6d6f25a100c1064789" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."roleTarget" ADD CONSTRAINT "FK_a86894bed7b7e1cc8b3f1d6186f" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."role" ADD CONSTRAINT "FK_d2532f520d84f8c22ee45681c5a" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."fieldMetadata" ADD CONSTRAINT "FK_9ce5ba7878f498bcf79e447a9a6" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."objectMetadata" ADD CONSTRAINT "FK_d82a05a204136c01388ea80bc7a" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."cronTrigger" ADD CONSTRAINT "FK_058c319eeb9799a4637908ce362" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."databaseEventTrigger" ADD CONSTRAINT "FK_cf158c3199dcf2d52b0da05c33b" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."routeTrigger" ADD CONSTRAINT "FK_5e004929fcf5e67398544b43885" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."serverlessFunction" ADD CONSTRAINT "FK_ef5dde6a681970b9c1e10563498" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."dataSource" ADD CONSTRAINT "FK_e1914827ee8b22fba4254578311" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."objectPermission" ADD CONSTRAINT "FK_edcd87df18d3284141757bf6e16" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."permissionFlag" ADD CONSTRAINT "FK_835bc9f7ef959debfc5cd268049" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."serverlessFunctionLayer" ADD CONSTRAINT "FK_ca0699c3c906e903d7381c6a771" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."workspaceMigration" ADD CONSTRAINT "FK_bebfcf8dcb299fd39ad04ed4c7f" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."remoteTable" ADD CONSTRAINT "FK_30b429b14ddc6aab7495fa884f3" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."remoteServer" ADD CONSTRAINT "FK_d1293835c5a0bb89fc0ed45713f" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."remoteServer" DROP CONSTRAINT "FK_d1293835c5a0bb89fc0ed45713f"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."remoteTable" DROP CONSTRAINT "FK_30b429b14ddc6aab7495fa884f3"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."workspaceMigration" DROP CONSTRAINT "FK_bebfcf8dcb299fd39ad04ed4c7f"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."serverlessFunctionLayer" DROP CONSTRAINT "FK_ca0699c3c906e903d7381c6a771"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."permissionFlag" DROP CONSTRAINT "FK_835bc9f7ef959debfc5cd268049"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."objectPermission" DROP CONSTRAINT "FK_edcd87df18d3284141757bf6e16"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."dataSource" DROP CONSTRAINT "FK_e1914827ee8b22fba4254578311"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."serverlessFunction" DROP CONSTRAINT "FK_ef5dde6a681970b9c1e10563498"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."routeTrigger" DROP CONSTRAINT "FK_5e004929fcf5e67398544b43885"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."databaseEventTrigger" DROP CONSTRAINT "FK_cf158c3199dcf2d52b0da05c33b"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."cronTrigger" DROP CONSTRAINT "FK_058c319eeb9799a4637908ce362"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."objectMetadata" DROP CONSTRAINT "FK_d82a05a204136c01388ea80bc7a"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."fieldMetadata" DROP CONSTRAINT "FK_9ce5ba7878f498bcf79e447a9a6"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."role" DROP CONSTRAINT "FK_d2532f520d84f8c22ee45681c5a"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."roleTarget" DROP CONSTRAINT "FK_a86894bed7b7e1cc8b3f1d6186f"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."indexMetadata" DROP CONSTRAINT "FK_5c988136a6d6f25a100c1064789"`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,20 +6,17 @@ import {
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Index('IDX_API_KEY_WORKSPACE_ID', ['workspaceId'])
|
||||
@Entity({ name: 'apiKey', schema: 'core' })
|
||||
@ObjectType('ApiKey')
|
||||
export class ApiKeyEntity {
|
||||
export class ApiKeyEntity extends WorkspaceRelatedEntity {
|
||||
@IDField(() => UUIDScalarType)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
@@ -36,10 +33,6 @@ export class ApiKeyEntity {
|
||||
@Column({ type: 'timestamptz', nullable: true })
|
||||
revokedAt?: Date | null;
|
||||
|
||||
@Field(() => UUIDScalarType)
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@Field(() => Date)
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
@@ -47,11 +40,4 @@ export class ApiKeyEntity {
|
||||
@Field(() => Date)
|
||||
@UpdateDateColumn({ type: 'timestamptz' })
|
||||
updatedAt: Date;
|
||||
|
||||
@Field(() => WorkspaceEntity)
|
||||
@ManyToOne(() => WorkspaceEntity, (workspace) => workspace.apiKeys, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
}
|
||||
|
||||
@@ -6,20 +6,18 @@ import {
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { RoleDTO } from 'src/engine/metadata-modules/role/dtos/role.dto';
|
||||
import { ApplicationVariableEntity } from 'src/engine/core-modules/applicationVariable/application-variable.entity';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { AgentEntity } from 'src/engine/metadata-modules/ai/ai-agent/entities/agent.entity';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { RoleDTO } from 'src/engine/metadata-modules/role/dtos/role.dto';
|
||||
import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity({ name: 'application', schema: 'core' })
|
||||
@ObjectType('Application')
|
||||
@@ -32,7 +30,7 @@ import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless
|
||||
where: '"deletedAt" IS NULL AND "universalIdentifier" IS NOT NULL',
|
||||
},
|
||||
)
|
||||
export class ApplicationEntity {
|
||||
export class ApplicationEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -55,9 +53,6 @@ export class ApplicationEntity {
|
||||
@Column({ nullable: false, type: 'text' })
|
||||
sourcePath: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@Column({ nullable: true, type: 'uuid' })
|
||||
serverlessFunctionLayerId: string | null;
|
||||
|
||||
@@ -70,12 +65,6 @@ export class ApplicationEntity {
|
||||
@Column({ nullable: false, type: 'boolean', default: true })
|
||||
canBeUninstalled: boolean;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@OneToMany(() => AgentEntity, (agent) => agent.application, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
+2
-19
@@ -4,16 +4,12 @@ import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/relation.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity({ name: 'approvedAccessDomain', schema: 'core' })
|
||||
@ObjectType('ApprovedAccessDomain')
|
||||
@@ -21,7 +17,7 @@ import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.ent
|
||||
'domain',
|
||||
'workspaceId',
|
||||
])
|
||||
export class ApprovedAccessDomainEntity {
|
||||
export class ApprovedAccessDomainEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -36,17 +32,4 @@ export class ApprovedAccessDomainEntity {
|
||||
|
||||
@Column({ type: 'boolean', default: false, nullable: false })
|
||||
isValidated: boolean;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(
|
||||
() => WorkspaceEntity,
|
||||
(workspace) => workspace.approvedAccessDomains,
|
||||
{
|
||||
onDelete: 'CASCADE',
|
||||
},
|
||||
)
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
}
|
||||
|
||||
+6
-4
@@ -7,6 +7,7 @@ import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
@@ -16,10 +17,14 @@ import {
|
||||
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
||||
import { BillingEntitlementEntity } from 'src/engine/core-modules/billing/entities/billing-entitlement.entity';
|
||||
import { BillingSubscriptionEntity } from 'src/engine/core-modules/billing/entities/billing-subscription.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity({ name: 'billingCustomer', schema: 'core' })
|
||||
@ObjectType('BillingCustomer')
|
||||
export class BillingCustomerEntity {
|
||||
@Index('IDX_BILLING_CUSTOMER_WORKSPACE_ID_UNIQUE', ['workspaceId'], {
|
||||
unique: true,
|
||||
})
|
||||
export class BillingCustomerEntity extends WorkspaceRelatedEntity {
|
||||
@IDField(() => UUIDScalarType)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
@@ -33,9 +38,6 @@ export class BillingCustomerEntity {
|
||||
@UpdateDateColumn({ type: 'timestamptz' })
|
||||
updatedAt: Date;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid', unique: true })
|
||||
workspaceId: string;
|
||||
|
||||
@Column({ nullable: false, unique: true })
|
||||
stripeCustomerId: string;
|
||||
|
||||
|
||||
+3
-5
@@ -18,13 +18,15 @@ import {
|
||||
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
||||
import { BillingCustomerEntity } from 'src/engine/core-modules/billing/entities/billing-customer.entity';
|
||||
import { BillingEntitlementKey } from 'src/engine/core-modules/billing/enums/billing-entitlement-key.enum';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity({ name: 'billingEntitlement', schema: 'core' })
|
||||
@ObjectType('BillingEntitlement')
|
||||
@Unique('IDX_BILLING_ENTITLEMENT_KEY_WORKSPACE_ID_UNIQUE', [
|
||||
'key',
|
||||
'workspaceId',
|
||||
])
|
||||
export class BillingEntitlementEntity {
|
||||
export class BillingEntitlementEntity extends WorkspaceRelatedEntity {
|
||||
@IDField(() => UUIDScalarType)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
@@ -33,10 +35,6 @@ export class BillingEntitlementEntity {
|
||||
@Column({ nullable: false, type: 'text' })
|
||||
key: BillingEntitlementKey;
|
||||
|
||||
@Field(() => UUIDScalarType)
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
stripeCustomerId: string;
|
||||
|
||||
|
||||
+2
-4
@@ -44,6 +44,7 @@ import { BillingSubscriptionItemEntity } from 'src/engine/core-modules/billing/e
|
||||
import { BillingSubscriptionCollectionMethod } from 'src/engine/core-modules/billing/enums/billing-subscription-collection-method.enum';
|
||||
import { SubscriptionInterval } from 'src/engine/core-modules/billing/enums/billing-subscription-interval.enum';
|
||||
import { SubscriptionStatus } from 'src/engine/core-modules/billing/enums/billing-subscription-status.enum';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
registerEnumType(SubscriptionStatus, { name: 'SubscriptionStatus' });
|
||||
registerEnumType(SubscriptionInterval, { name: 'SubscriptionInterval' });
|
||||
@@ -54,7 +55,7 @@ registerEnumType(SubscriptionInterval, { name: 'SubscriptionInterval' });
|
||||
where: `status IN ('trialing', 'active', 'past_due')`,
|
||||
})
|
||||
@ObjectType('BillingSubscription')
|
||||
export class BillingSubscriptionEntity {
|
||||
export class BillingSubscriptionEntity extends WorkspaceRelatedEntity {
|
||||
@IDField(() => UUIDScalarType)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
@@ -68,9 +69,6 @@ export class BillingSubscriptionEntity {
|
||||
@UpdateDateColumn({ type: 'timestamptz' })
|
||||
updatedAt: Date;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
stripeCustomerId: string;
|
||||
|
||||
|
||||
+2
-15
@@ -4,21 +4,17 @@ import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/relation.interface';
|
||||
|
||||
import {
|
||||
EmailingDomainDriver,
|
||||
EmailingDomainStatus,
|
||||
} from 'src/engine/core-modules/emailing-domain/drivers/types/emailing-domain';
|
||||
import { VerificationRecord } from 'src/engine/core-modules/emailing-domain/drivers/types/verifications-record';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity({ name: 'emailingDomain', schema: 'core' })
|
||||
@ObjectType('EmailingDomain')
|
||||
@@ -26,7 +22,7 @@ import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.ent
|
||||
'domain',
|
||||
'workspaceId',
|
||||
])
|
||||
export class EmailingDomainEntity {
|
||||
export class EmailingDomainEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -59,13 +55,4 @@ export class EmailingDomainEntity {
|
||||
|
||||
@Column({ type: 'timestamptz', nullable: true })
|
||||
verifiedAt: Date | null;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, (workspace) => workspace.emailingDomains, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
}
|
||||
|
||||
@@ -5,21 +5,19 @@ import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity({ name: 'featureFlag', schema: 'core' })
|
||||
@ObjectType('FeatureFlag')
|
||||
@Unique('IDX_FEATURE_FLAG_KEY_WORKSPACE_ID_UNIQUE', ['key', 'workspaceId'])
|
||||
export class FeatureFlagEntity {
|
||||
export class FeatureFlagEntity extends WorkspaceRelatedEntity {
|
||||
@IDField(() => UUIDScalarType)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
@@ -28,15 +26,6 @@ export class FeatureFlagEntity {
|
||||
@Column({ nullable: false, type: 'text' })
|
||||
key: FeatureFlagKey;
|
||||
|
||||
@Field(() => UUIDScalarType)
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, (workspace) => workspace.featureFlags, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@Field()
|
||||
@Column({ nullable: false })
|
||||
value: boolean;
|
||||
|
||||
@@ -5,18 +5,15 @@ import {
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
} from 'typeorm';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity('file')
|
||||
@ObjectType('File')
|
||||
@Index('IDX_FILE_WORKSPACE_ID', ['workspaceId'])
|
||||
export class FileEntity {
|
||||
export class FileEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -32,15 +29,6 @@ export class FileEntity {
|
||||
@Column({ nullable: false })
|
||||
type: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
+4
-18
@@ -1,20 +1,18 @@
|
||||
import { ObjectType } from '@nestjs/graphql';
|
||||
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
Relation,
|
||||
} from 'typeorm';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity({ name: 'postgresCredentials', schema: 'core' })
|
||||
@ObjectType('PostgresCredentials')
|
||||
export class PostgresCredentialsEntity {
|
||||
export class PostgresCredentialsEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -32,16 +30,4 @@ export class PostgresCredentialsEntity {
|
||||
|
||||
@Column({ nullable: true, type: 'timestamptz' })
|
||||
deletedAt: Date;
|
||||
|
||||
@ManyToOne(
|
||||
() => WorkspaceEntity,
|
||||
(workspace) => workspace.allPostgresCredentials,
|
||||
{
|
||||
onDelete: 'CASCADE',
|
||||
},
|
||||
)
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
}
|
||||
|
||||
+2
-15
@@ -4,19 +4,15 @@ import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/relation.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity({ name: 'publicDomain', schema: 'core' })
|
||||
@ObjectType('PublicDomain')
|
||||
export class PublicDomainEntity {
|
||||
export class PublicDomainEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -31,13 +27,4 @@ export class PublicDomainEntity {
|
||||
|
||||
@Column({ type: 'boolean', default: false, nullable: false })
|
||||
isValidated: boolean;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, (workspace) => workspace.publicDomains, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
}
|
||||
|
||||
+2
-18
@@ -7,15 +7,12 @@ import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
export enum IdentityProviderType {
|
||||
OIDC = 'OIDC',
|
||||
@@ -46,7 +43,7 @@ registerEnumType(SSOIdentityProviderStatus, {
|
||||
|
||||
@Entity({ name: 'workspaceSSOIdentityProvider', schema: 'core' })
|
||||
@ObjectType('WorkspaceSSOIdentityProvider')
|
||||
export class WorkspaceSSOIdentityProviderEntity {
|
||||
export class WorkspaceSSOIdentityProviderEntity extends WorkspaceRelatedEntity {
|
||||
// COMMON
|
||||
@IDField(() => UUIDScalarType)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
@@ -62,19 +59,6 @@ export class WorkspaceSSOIdentityProviderEntity {
|
||||
})
|
||||
status: SSOIdentityProviderStatus;
|
||||
|
||||
@ManyToOne(
|
||||
() => WorkspaceEntity,
|
||||
(workspace) => workspace.workspaceSSOIdentityProviders,
|
||||
{
|
||||
onDelete: 'CASCADE',
|
||||
},
|
||||
)
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
+3
-14
@@ -2,8 +2,8 @@ import { Field, ObjectType, registerEnumType } from '@nestjs/graphql';
|
||||
|
||||
import { IDField } from '@ptc-org/nestjs-query-graphql';
|
||||
import {
|
||||
PermissionsOnAllObjectRecords,
|
||||
PermissionFlagType,
|
||||
PermissionsOnAllObjectRecords,
|
||||
} from 'twenty-shared/constants';
|
||||
import { type APP_LOCALES, SOURCE_LOCALE } from 'twenty-shared/translations';
|
||||
import {
|
||||
@@ -24,8 +24,8 @@ import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/
|
||||
import { TwoFactorAuthenticationMethodSummaryDto } from 'src/engine/core-modules/two-factor-authentication/dto/two-factor-authentication-method.dto';
|
||||
import { TwoFactorAuthenticationMethodEntity } from 'src/engine/core-modules/two-factor-authentication/entities/two-factor-authentication-method.entity';
|
||||
import { UserEntity } from 'src/engine/core-modules/user/user.entity';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { ObjectPermissionDTO } from 'src/engine/metadata-modules/object-permission/dtos/object-permission.dto';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
registerEnumType(PermissionFlagType, {
|
||||
name: 'PermissionFlagType',
|
||||
@@ -47,7 +47,7 @@ registerEnumType(PermissionsOnAllObjectRecords, {
|
||||
)
|
||||
@Index('IDX_USER_WORKSPACE_USER_ID', ['userId'])
|
||||
@Index('IDX_USER_WORKSPACE_WORKSPACE_ID', ['workspaceId'])
|
||||
export class UserWorkspaceEntity {
|
||||
export class UserWorkspaceEntity extends WorkspaceRelatedEntity {
|
||||
@IDField(() => UUIDScalarType)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
@@ -63,17 +63,6 @@ export class UserWorkspaceEntity {
|
||||
@Column()
|
||||
userId: string;
|
||||
|
||||
@Field(() => WorkspaceEntity, { nullable: true })
|
||||
@ManyToOne(() => WorkspaceEntity, (workspace) => workspace.workspaceUsers, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@Field(() => UUIDScalarType, { nullable: false })
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
defaultAvatarUrl: string;
|
||||
|
||||
|
||||
@@ -7,20 +7,17 @@ import {
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Index('IDX_WEBHOOK_WORKSPACE_ID', ['workspaceId'])
|
||||
@Entity({ name: 'webhook', schema: 'core' })
|
||||
@ObjectType('Webhook')
|
||||
export class WebhookEntity {
|
||||
export class WebhookEntity extends WorkspaceRelatedEntity {
|
||||
@IDField(() => UUIDScalarType)
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
@@ -41,10 +38,6 @@ export class WebhookEntity {
|
||||
@Column()
|
||||
secret: string;
|
||||
|
||||
@Field(() => UUIDScalarType)
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@Field()
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
@@ -56,11 +49,4 @@ export class WebhookEntity {
|
||||
@Field({ nullable: true })
|
||||
@DeleteDateColumn({ type: 'timestamptz' })
|
||||
deletedAt?: Date;
|
||||
|
||||
@Field(() => WorkspaceEntity)
|
||||
@ManyToOne(() => WorkspaceEntity, (workspace) => workspace.webhooks, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ export class WorkspaceEntity {
|
||||
|
||||
@OneToMany(
|
||||
() => UserWorkspaceEntity,
|
||||
(userWorkspace: UserWorkspaceEntity) => userWorkspace.workspace,
|
||||
(userWorkspace) => userWorkspace.workspace,
|
||||
{
|
||||
onDelete: 'CASCADE',
|
||||
},
|
||||
|
||||
+1
-15
@@ -4,16 +4,11 @@ import {
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/relation.interface';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { AgentResponseFormat } from 'src/engine/metadata-modules/ai/ai-agent/types/agent-response-format.type';
|
||||
import { ModelConfiguration } from 'src/engine/metadata-modules/ai/ai-agent/types/modelConfiguration';
|
||||
import {
|
||||
@@ -59,18 +54,9 @@ export class AgentEntity
|
||||
@Column({ nullable: true, type: 'jsonb', default: { type: 'text' } })
|
||||
responseFormat: AgentResponseFormat;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@Column({ default: false })
|
||||
isCustom: boolean;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, (workspace) => workspace.agents, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
+1
-7
@@ -10,19 +10,13 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { CronTriggerEntityRelationProperties } from 'src/engine/metadata-modules/cron-trigger/types/flat-cron-trigger.type';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
|
||||
export type CronTriggerSettings = {
|
||||
pattern: string;
|
||||
};
|
||||
|
||||
export const CRON_TRIGGER_ENTITY_RELATION_PROPERTIES = [
|
||||
'serverlessFunction',
|
||||
] as const satisfies readonly CronTriggerEntityRelationProperties[];
|
||||
|
||||
@Entity({ name: 'cronTrigger', schema: 'core' })
|
||||
@Index('IDX_CRON_TRIGGER_WORKSPACE_ID', ['workspaceId'])
|
||||
export class CronTriggerEntity
|
||||
|
||||
+8
-7
@@ -6,11 +6,9 @@ import { Repository } from 'typeorm';
|
||||
|
||||
import { WorkspaceCacheProvider } from 'src/engine/workspace-cache/interfaces/workspace-cache-provider.service';
|
||||
|
||||
import {
|
||||
CRON_TRIGGER_ENTITY_RELATION_PROPERTIES,
|
||||
CronTriggerEntity,
|
||||
} from 'src/engine/metadata-modules/cron-trigger/entities/cron-trigger.entity';
|
||||
import { CronTriggerEntity } from 'src/engine/metadata-modules/cron-trigger/entities/cron-trigger.entity';
|
||||
import { FlatCronTrigger } from 'src/engine/metadata-modules/cron-trigger/types/flat-cron-trigger.type';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { createEmptyFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/constant/create-empty-flat-entity-maps.constant';
|
||||
import { FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';
|
||||
import { WorkspaceCache } from 'src/engine/workspace-cache/decorators/workspace-cache.decorator';
|
||||
@@ -41,9 +39,12 @@ export class WorkspaceFlatCronTriggerMapCacheService extends WorkspaceCacheProvi
|
||||
|
||||
for (const cronTriggerEntity of cronTriggers) {
|
||||
const flatCronTrigger = {
|
||||
...removePropertiesFromRecord(cronTriggerEntity, [
|
||||
...CRON_TRIGGER_ENTITY_RELATION_PROPERTIES,
|
||||
]),
|
||||
...removePropertiesFromRecord(
|
||||
cronTriggerEntity,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.cronTrigger,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.cronTrigger)[],
|
||||
),
|
||||
universalIdentifier:
|
||||
cronTriggerEntity.universalIdentifier ?? cronTriggerEntity.id,
|
||||
createdAt: cronTriggerEntity.createdAt.toISOString(),
|
||||
|
||||
+1
-13
@@ -1,16 +1,4 @@
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type CronTriggerEntity } from 'src/engine/metadata-modules/cron-trigger/entities/cron-trigger.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type CronTriggerEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
CronTriggerEntity,
|
||||
ServerlessFunctionEntity | WorkspaceEntity
|
||||
>;
|
||||
|
||||
export type FlatCronTrigger = FlatEntityFrom<
|
||||
CronTriggerEntity,
|
||||
CronTriggerEntityRelationProperties
|
||||
>;
|
||||
export type FlatCronTrigger = FlatEntityFrom<CronTriggerEntity>;
|
||||
|
||||
+2
-4
@@ -10,12 +10,13 @@ import {
|
||||
} from 'typeorm';
|
||||
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
export type DataSourceType = DataSourceOptions['type'];
|
||||
|
||||
@Entity('dataSource')
|
||||
@Index('IDX_DATA_SOURCE_WORKSPACE_ID_CREATED_AT', ['workspaceId', 'createdAt'])
|
||||
export class DataSourceEntity {
|
||||
export class DataSourceEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -39,9 +40,6 @@ export class DataSourceEntity {
|
||||
})
|
||||
objects: ObjectMetadataEntity[];
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
+1
-7
@@ -10,19 +10,13 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { DatabaseEventTriggerEntityRelationProperties } from 'src/engine/metadata-modules/database-event-trigger/types/flat-database-event-trigger.type';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
|
||||
export type DatabaseEventTriggerSettings = {
|
||||
eventName: string;
|
||||
};
|
||||
|
||||
export const DATABASE_EVENT_TRIGGER_ENTITY_RELATION_PROPERTIES = [
|
||||
'serverlessFunction',
|
||||
] as const satisfies readonly DatabaseEventTriggerEntityRelationProperties[];
|
||||
|
||||
@Entity('databaseEventTrigger')
|
||||
@Index('IDX_DATABASE_EVENT_TRIGGER_WORKSPACE_ID', ['workspaceId'])
|
||||
export class DatabaseEventTriggerEntity
|
||||
|
||||
+8
-7
@@ -6,11 +6,9 @@ import { Repository } from 'typeorm';
|
||||
|
||||
import { WorkspaceCacheProvider } from 'src/engine/workspace-cache/interfaces/workspace-cache-provider.service';
|
||||
|
||||
import {
|
||||
DATABASE_EVENT_TRIGGER_ENTITY_RELATION_PROPERTIES,
|
||||
DatabaseEventTriggerEntity,
|
||||
} from 'src/engine/metadata-modules/database-event-trigger/entities/database-event-trigger.entity';
|
||||
import { DatabaseEventTriggerEntity } from 'src/engine/metadata-modules/database-event-trigger/entities/database-event-trigger.entity';
|
||||
import { FlatDatabaseEventTrigger } from 'src/engine/metadata-modules/database-event-trigger/types/flat-database-event-trigger.type';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { createEmptyFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/constant/create-empty-flat-entity-maps.constant';
|
||||
import { FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';
|
||||
import { WorkspaceCache } from 'src/engine/workspace-cache/decorators/workspace-cache.decorator';
|
||||
@@ -42,9 +40,12 @@ export class WorkspaceFlatDatabaseEventTriggerMapCacheService extends WorkspaceC
|
||||
|
||||
for (const databaseEventTriggerEntity of databaseEventTriggers) {
|
||||
const flatDatabaseEventTrigger = {
|
||||
...removePropertiesFromRecord(databaseEventTriggerEntity, [
|
||||
...DATABASE_EVENT_TRIGGER_ENTITY_RELATION_PROPERTIES,
|
||||
]),
|
||||
...removePropertiesFromRecord(
|
||||
databaseEventTriggerEntity,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.databaseEventTrigger,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.databaseEventTrigger)[],
|
||||
),
|
||||
universalIdentifier:
|
||||
databaseEventTriggerEntity.universalIdentifier ??
|
||||
databaseEventTriggerEntity.id,
|
||||
|
||||
+2
-13
@@ -1,16 +1,5 @@
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type DatabaseEventTriggerEntity } from 'src/engine/metadata-modules/database-event-trigger/entities/database-event-trigger.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type DatabaseEventTriggerEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
DatabaseEventTriggerEntity,
|
||||
ServerlessFunctionEntity | WorkspaceEntity
|
||||
>;
|
||||
|
||||
export type FlatDatabaseEventTrigger = FlatEntityFrom<
|
||||
DatabaseEventTriggerEntity,
|
||||
DatabaseEventTriggerEntityRelationProperties
|
||||
>;
|
||||
export type FlatDatabaseEventTrigger =
|
||||
FlatEntityFrom<DatabaseEventTriggerEntity>;
|
||||
|
||||
+2
-5
@@ -20,7 +20,6 @@ import {
|
||||
} from 'typeorm';
|
||||
|
||||
import { FieldMetadataDefaultValue } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-default-value.interface';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { type FieldStandardOverridesDTO } from 'src/engine/metadata-modules/field-metadata/dtos/field-standard-overrides.dto';
|
||||
import { AssignIfIsGivenFieldMetadataType } from 'src/engine/metadata-modules/field-metadata/types/assign-if-is-given-field-metadata-type.type';
|
||||
@@ -31,6 +30,7 @@ import { FieldPermissionEntity } from 'src/engine/metadata-modules/object-permis
|
||||
import { ViewFieldEntity } from 'src/engine/metadata-modules/view-field/entities/view-field.entity';
|
||||
import { ViewFilterEntity } from 'src/engine/metadata-modules/view-filter/entities/view-filter.entity';
|
||||
import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
|
||||
@Entity('fieldMetadata')
|
||||
@Check(
|
||||
@@ -52,6 +52,7 @@ import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entit
|
||||
'objectMetadataId',
|
||||
'workspaceId',
|
||||
])
|
||||
@Index('IDX_FIELD_METADATA_WORKSPACE_ID', ['workspaceId'])
|
||||
export class FieldMetadataEntity<
|
||||
TFieldMetadataType extends FieldMetadataType = FieldMetadataType,
|
||||
>
|
||||
@@ -125,10 +126,6 @@ export class FieldMetadataEntity<
|
||||
@Column({ nullable: true, default: false, type: 'boolean' })
|
||||
isUnique: boolean | null;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
@Index('IDX_FIELD_METADATA_WORKSPACE_ID', ['workspaceId'])
|
||||
workspaceId: string;
|
||||
|
||||
@Column({ default: false })
|
||||
isLabelSyncedWithName: boolean;
|
||||
|
||||
|
||||
+1
-12
@@ -1,17 +1,6 @@
|
||||
import { type AgentEntity } from 'src/engine/metadata-modules/ai/ai-agent/entities/agent.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
|
||||
export const agentEntityRelationProperties = [
|
||||
'workspace',
|
||||
'application',
|
||||
] as const;
|
||||
|
||||
export type AgentEntityRelationProperties =
|
||||
(typeof agentEntityRelationProperties)[number];
|
||||
|
||||
export type FlatAgent = FlatEntityFrom<
|
||||
AgentEntity,
|
||||
AgentEntityRelationProperties
|
||||
>;
|
||||
export type FlatAgent = FlatEntityFrom<AgentEntity>;
|
||||
|
||||
export type FlatAgentWithRoleId = FlatAgent & { roleId: string | null };
|
||||
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
import { type AllMetadataName } from 'twenty-shared/metadata';
|
||||
|
||||
import { type ExtractEntityRelatedEntityProperties } from 'src/engine/metadata-modules/flat-entity/types/extract-entity-related-entity-properties.type';
|
||||
import { type MetadataEntity } from 'src/engine/metadata-modules/flat-entity/types/metadata-entity.type';
|
||||
|
||||
export const ALL_METADATA_RELATION_PROPERTIES = {
|
||||
agent: {
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
fieldMetadata: {
|
||||
relationTargetFieldMetadata: true,
|
||||
relationTargetObjectMetadata: true,
|
||||
fieldPermissions: true,
|
||||
indexFieldMetadatas: true,
|
||||
object: true,
|
||||
viewFields: true,
|
||||
viewFilters: true,
|
||||
kanbanAggregateOperationViews: true,
|
||||
calendarViews: true,
|
||||
mainGroupByFieldMetadataViews: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
objectMetadata: {
|
||||
fields: true,
|
||||
indexMetadatas: true,
|
||||
targetRelationFields: true,
|
||||
dataSource: true,
|
||||
objectPermissions: true,
|
||||
fieldPermissions: true,
|
||||
views: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
view: {
|
||||
objectMetadata: true,
|
||||
viewFields: true,
|
||||
viewFilters: true,
|
||||
viewFilterGroups: true,
|
||||
viewGroups: true,
|
||||
viewSorts: true,
|
||||
workspace: true,
|
||||
createdBy: true,
|
||||
application: true,
|
||||
calendarFieldMetadata: true,
|
||||
kanbanAggregateOperationFieldMetadata: true,
|
||||
mainGroupByFieldMetadata: true,
|
||||
},
|
||||
viewField: {
|
||||
fieldMetadata: true,
|
||||
view: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
viewFilter: {
|
||||
fieldMetadata: true,
|
||||
view: true,
|
||||
viewFilterGroup: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
viewGroup: {
|
||||
view: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
index: {
|
||||
objectMetadata: true,
|
||||
indexFieldMetadatas: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
serverlessFunction: {
|
||||
cronTriggers: true,
|
||||
databaseEventTriggers: true,
|
||||
routeTriggers: true,
|
||||
serverlessFunctionLayer: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
cronTrigger: {
|
||||
serverlessFunction: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
databaseEventTrigger: {
|
||||
serverlessFunction: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
routeTrigger: {
|
||||
serverlessFunction: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
role: {
|
||||
roleTargets: true,
|
||||
objectPermissions: true,
|
||||
permissionFlags: true,
|
||||
fieldPermissions: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
roleTarget: {
|
||||
role: true,
|
||||
apiKey: true,
|
||||
workspace: true,
|
||||
application: true,
|
||||
},
|
||||
pageLayout: {
|
||||
workspace: true,
|
||||
objectMetadata: true,
|
||||
tabs: true,
|
||||
application: true,
|
||||
},
|
||||
pageLayoutTab: {
|
||||
workspace: true,
|
||||
pageLayout: true,
|
||||
widgets: true,
|
||||
application: true,
|
||||
},
|
||||
pageLayoutWidget: {
|
||||
workspace: true,
|
||||
pageLayoutTab: true,
|
||||
objectMetadata: true,
|
||||
application: true,
|
||||
},
|
||||
} as const satisfies {
|
||||
[TName in AllMetadataName]: {
|
||||
[P in ExtractEntityRelatedEntityProperties<MetadataEntity<TName>>]: true;
|
||||
};
|
||||
};
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { type Relation } from 'typeorm';
|
||||
|
||||
import { type AllNonWorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/all-non-workspace-related-entity.type';
|
||||
import { type WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
export type ExtractEntityManyToOneEntityRelationProperties<
|
||||
T,
|
||||
TTarget = WorkspaceRelatedEntity | AllNonWorkspaceRelatedEntity,
|
||||
> = NonNullable<
|
||||
{
|
||||
[P in keyof T]: [NonNullable<T[P]>] extends [never]
|
||||
? never
|
||||
: NonNullable<T[P]> extends Relation<TTarget>
|
||||
? P
|
||||
: never;
|
||||
}[keyof T]
|
||||
>;
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { type Relation } from 'typeorm';
|
||||
|
||||
import { type AllNonWorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/all-non-workspace-related-entity.type';
|
||||
import { type WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
export type ExtractEntityOneToManyEntityRelationProperties<
|
||||
T,
|
||||
TTarget = WorkspaceRelatedEntity | AllNonWorkspaceRelatedEntity,
|
||||
> = NonNullable<
|
||||
{
|
||||
[P in keyof T]: NonNullable<T[P]> extends Array<infer U>
|
||||
? U extends Relation<TTarget>
|
||||
? P
|
||||
: never
|
||||
: never;
|
||||
}[keyof T]
|
||||
>;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { type ExtractEntityManyToOneEntityRelationProperties } from 'src/engine/metadata-modules/flat-entity/types/extract-entity-many-to-one-entity-relation-properties.type';
|
||||
import { type ExtractEntityOneToManyEntityRelationProperties } from 'src/engine/metadata-modules/flat-entity/types/extract-entity-one-to-many-entity-relation-properties.type';
|
||||
import { type AllNonWorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/all-non-workspace-related-entity.type';
|
||||
import { type WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
export type ExtractEntityRelatedEntityProperties<
|
||||
T,
|
||||
TTarget = WorkspaceRelatedEntity | AllNonWorkspaceRelatedEntity,
|
||||
> =
|
||||
| ExtractEntityManyToOneEntityRelationProperties<T, TTarget>
|
||||
| ExtractEntityOneToManyEntityRelationProperties<T, TTarget>;
|
||||
+15
-9
@@ -1,22 +1,28 @@
|
||||
import { type SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { type CastRecordTypeOrmDatePropertiesToString } from 'src/engine/metadata-modules/flat-entity/types/cast-record-typeorm-date-properties-to-string.type';
|
||||
import { type ExtractEntityOneToManyEntityRelationProperties } from 'src/engine/metadata-modules/flat-entity/types/extract-entity-one-to-many-entity-relation-properties.type';
|
||||
import { type ExtractEntityRelatedEntityProperties } from 'src/engine/metadata-modules/flat-entity/types/extract-entity-related-entity-properties.type';
|
||||
import { type RemoveSuffix } from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/types/remove-suffix.type';
|
||||
import { type SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { type NonNullableProperties } from 'src/types/non-nullable-properties.type';
|
||||
|
||||
export type SyncableFlatEntity = NonNullableProperties<
|
||||
Omit<SyncableEntity, 'application' | 'applicationId'>
|
||||
Omit<SyncableEntity, 'application' | 'applicationId' | 'workspace'>
|
||||
> & {
|
||||
id: string;
|
||||
applicationId: string | null;
|
||||
};
|
||||
|
||||
export type FlatEntityFrom<
|
||||
export type FlatEntityFrom<TEntity> = Omit<
|
||||
TEntity,
|
||||
TEntityRelationProperties extends keyof TEntity,
|
||||
> = Omit<
|
||||
TEntity,
|
||||
| TEntityRelationProperties
|
||||
| ExtractEntityRelatedEntityProperties<TEntity>
|
||||
| 'application'
|
||||
| 'workspace'
|
||||
| keyof CastRecordTypeOrmDatePropertiesToString<TEntity>
|
||||
> &
|
||||
CastRecordTypeOrmDatePropertiesToString<TEntity>;
|
||||
CastRecordTypeOrmDatePropertiesToString<TEntity> & {
|
||||
[P in ExtractEntityOneToManyEntityRelationProperties<
|
||||
TEntity,
|
||||
SyncableEntity
|
||||
> &
|
||||
string as `${RemoveSuffix<P, 's'>}Ids`]: string[];
|
||||
};
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { type AllMetadataName } from 'twenty-shared/metadata';
|
||||
|
||||
import { type AllFlatEntityTypesByMetadataName } from 'src/engine/metadata-modules/flat-entity/types/all-flat-entity-types-by-metadata-name';
|
||||
import { type SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
|
||||
export type FromMetadataEntityToMetadataName<T extends SyncableEntity> = {
|
||||
[P in AllMetadataName]: AllFlatEntityTypesByMetadataName[P] extends {
|
||||
entity: T;
|
||||
}
|
||||
? P
|
||||
: never;
|
||||
}[AllMetadataName];
|
||||
+5
-25
@@ -3,32 +3,12 @@ import { type FieldMetadataType } from 'twenty-shared/types';
|
||||
import { type FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
|
||||
export const FIELD_METADATA_RELATION_PROPERTIES = [
|
||||
'relationTargetFieldMetadata',
|
||||
'relationTargetObjectMetadata',
|
||||
'fieldPermissions',
|
||||
'indexFieldMetadatas',
|
||||
'object',
|
||||
'viewFields',
|
||||
'application',
|
||||
'viewFilters',
|
||||
'kanbanAggregateOperationViews',
|
||||
'calendarViews',
|
||||
'mainGroupByFieldMetadataViews',
|
||||
] as const satisfies (keyof FieldMetadataEntity)[];
|
||||
|
||||
export type FieldMetadataEntityRelationProperties =
|
||||
(typeof FIELD_METADATA_RELATION_PROPERTIES)[number];
|
||||
|
||||
export type FlatFieldMetadata<T extends FieldMetadataType = FieldMetadataType> =
|
||||
FlatEntityFrom<
|
||||
FieldMetadataEntity<T>,
|
||||
FieldMetadataEntityRelationProperties
|
||||
Omit<
|
||||
FieldMetadataEntity<T>,
|
||||
'relationTargetFieldMetadata' | 'relationTargetObjectMetadata'
|
||||
>
|
||||
> & {
|
||||
universalIdentifier: string;
|
||||
viewFieldIds: string[];
|
||||
viewFilterIds: string[];
|
||||
kanbanAggregateOperationViewIds: string[];
|
||||
calendarViewIds: string[];
|
||||
mainGroupByFieldMetadataViewIds: string[];
|
||||
universalIdentifier: string; // TODO remove once universalIdentifier is required on entity directly
|
||||
};
|
||||
|
||||
+5
-5
@@ -2,10 +2,8 @@ import { type FieldMetadataType } from 'twenty-shared/types';
|
||||
import { removePropertiesFromRecord } from 'twenty-shared/utils';
|
||||
|
||||
import { type FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import {
|
||||
type FlatFieldMetadata,
|
||||
FIELD_METADATA_RELATION_PROPERTIES,
|
||||
} from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
|
||||
export const fromFieldMetadataEntityToFlatFieldMetadata = <
|
||||
T extends FieldMetadataType,
|
||||
@@ -15,7 +13,9 @@ export const fromFieldMetadataEntityToFlatFieldMetadata = <
|
||||
): FlatFieldMetadata => {
|
||||
const fieldMetadataWithoutRelations = removePropertiesFromRecord(
|
||||
fieldMetadataEntity,
|
||||
FIELD_METADATA_RELATION_PROPERTIES,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.fieldMetadata,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.fieldMetadata)[],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
import { type IndexMetadataRelationProperties } from 'src/engine/metadata-modules/flat-index-metadata/types/flat-index-metadata.type';
|
||||
|
||||
export const INDEX_METADATA_ENTITY_RELATION_PROPERTIES = [
|
||||
'objectMetadata',
|
||||
'indexFieldMetadatas',
|
||||
] as const satisfies readonly IndexMetadataRelationProperties[];
|
||||
+2
-22
@@ -1,30 +1,10 @@
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-field-metadata.entity';
|
||||
import { type IndexMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-metadata.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
import { type MetadataEntitiesRelationTarget } from 'src/engine/workspace-manager/workspace-migration-v2/types/metadata-entities-relation-targets.type';
|
||||
|
||||
export type IndexMetadataRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
IndexMetadataEntity,
|
||||
MetadataEntitiesRelationTarget
|
||||
>;
|
||||
export type FlatIndexFieldMetadata = FlatEntityFrom<IndexFieldMetadataEntity>;
|
||||
|
||||
export type IndexFieldMetadataEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
IndexFieldMetadataEntity,
|
||||
MetadataEntitiesRelationTarget
|
||||
>;
|
||||
|
||||
export type FlatIndexFieldMetadata = FlatEntityFrom<
|
||||
IndexFieldMetadataEntity,
|
||||
IndexFieldMetadataEntityRelationProperties
|
||||
>;
|
||||
|
||||
export type FlatIndexMetadata = FlatEntityFrom<
|
||||
IndexMetadataEntity,
|
||||
IndexMetadataRelationProperties
|
||||
> & {
|
||||
export type FlatIndexMetadata = FlatEntityFrom<IndexMetadataEntity> & {
|
||||
universalIdentifier: string;
|
||||
flatIndexFieldMetadatas: FlatIndexFieldMetadata[];
|
||||
};
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
import { removePropertiesFromRecord } from 'twenty-shared/utils';
|
||||
|
||||
import { INDEX_METADATA_ENTITY_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-index-metadata/constants/index-metadata-entity-relation-properties.constant';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { type FlatIndexMetadata } from 'src/engine/metadata-modules/flat-index-metadata/types/flat-index-metadata.type';
|
||||
import { type IndexMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-metadata.entity';
|
||||
|
||||
@@ -9,7 +9,9 @@ export const fromIndexMetadataEntityToFlatIndexMetadata = (
|
||||
): FlatIndexMetadata => {
|
||||
const indexMetadataEntityWithoutRelations = removePropertiesFromRecord(
|
||||
indexMetadataEntity,
|
||||
[...INDEX_METADATA_ENTITY_RELATION_PROPERTIES],
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.index,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.index)[],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
+1
-22
@@ -1,29 +1,8 @@
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
import { type MetadataEntitiesRelationTarget } from 'src/engine/workspace-manager/workspace-migration-v2/types/metadata-entities-relation-targets.type';
|
||||
|
||||
export const objectMetadataEntityRelationProperties = [
|
||||
'fields',
|
||||
'indexMetadatas',
|
||||
'targetRelationFields',
|
||||
'dataSource',
|
||||
'application',
|
||||
'objectPermissions',
|
||||
'fieldPermissions',
|
||||
'views',
|
||||
] as const satisfies ObjectMetadataRelationProperties[];
|
||||
|
||||
type ObjectMetadataRelationProperties = ExtractRecordTypeOrmRelationProperties<
|
||||
ObjectMetadataEntity,
|
||||
MetadataEntitiesRelationTarget
|
||||
>;
|
||||
|
||||
export type FlatObjectMetadata = FlatEntityFrom<
|
||||
ObjectMetadataEntity,
|
||||
ObjectMetadataRelationProperties | 'dataSourceId'
|
||||
Omit<ObjectMetadataEntity, 'targetRelationFields' | 'dataSourceId' | 'fields'>
|
||||
> & {
|
||||
fieldMetadataIds: string[];
|
||||
indexMetadataIds: string[];
|
||||
viewIds: string[];
|
||||
};
|
||||
|
||||
+5
-5
@@ -1,9 +1,7 @@
|
||||
import { removePropertiesFromRecord } from 'twenty-shared/utils';
|
||||
|
||||
import {
|
||||
type FlatObjectMetadata,
|
||||
objectMetadataEntityRelationProperties,
|
||||
} from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
|
||||
export const fromObjectMetadataEntityToFlatObjectMetadata = (
|
||||
@@ -11,7 +9,9 @@ export const fromObjectMetadataEntityToFlatObjectMetadata = (
|
||||
): FlatObjectMetadata => {
|
||||
const objectMetadataEntityWithoutRelations = removePropertiesFromRecord(
|
||||
objectMetadataEntity,
|
||||
objectMetadataEntityRelationProperties,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.objectMetadata,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.objectMetadata)[],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
+1
-16
@@ -1,19 +1,4 @@
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type PageLayoutTabEntity } from 'src/engine/metadata-modules/page-layout-tab/entities/page-layout-tab.entity';
|
||||
|
||||
export const pageLayoutTabEntityRelationProperties = [
|
||||
'workspace',
|
||||
'pageLayout',
|
||||
'widgets',
|
||||
'application',
|
||||
] as const satisfies (keyof PageLayoutTabEntity)[];
|
||||
|
||||
export type PageLayoutTabEntityRelationProperties =
|
||||
(typeof pageLayoutTabEntityRelationProperties)[number];
|
||||
|
||||
export type FlatPageLayoutTab = FlatEntityFrom<
|
||||
PageLayoutTabEntity,
|
||||
PageLayoutTabEntityRelationProperties
|
||||
> & {
|
||||
widgetIds: string[];
|
||||
};
|
||||
export type FlatPageLayoutTab = FlatEntityFrom<PageLayoutTabEntity>;
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import { type PageLayoutWidgetEntityRelationProperties } from 'src/engine/metadata-modules/flat-page-layout-widget/types/flat-page-layout-widget.type';
|
||||
|
||||
export const PAGE_LAYOUT_WIDGET_ENTITY_RELATION_PROPERTIES = [
|
||||
'workspace',
|
||||
'pageLayoutTab',
|
||||
'objectMetadata',
|
||||
'application',
|
||||
] as const satisfies PageLayoutWidgetEntityRelationProperties[];
|
||||
+1
-18
@@ -1,21 +1,4 @@
|
||||
import { type ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type PageLayoutTabEntity } from 'src/engine/metadata-modules/page-layout-tab/entities/page-layout-tab.entity';
|
||||
import { type PageLayoutWidgetEntity } from 'src/engine/metadata-modules/page-layout-widget/entities/page-layout-widget.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type PageLayoutWidgetEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
PageLayoutWidgetEntity,
|
||||
| PageLayoutTabEntity
|
||||
| ObjectMetadataEntity
|
||||
| WorkspaceEntity
|
||||
| ApplicationEntity
|
||||
>;
|
||||
|
||||
export type FlatPageLayoutWidget = FlatEntityFrom<
|
||||
PageLayoutWidgetEntity,
|
||||
PageLayoutWidgetEntityRelationProperties
|
||||
>;
|
||||
export type FlatPageLayoutWidget = FlatEntityFrom<PageLayoutWidgetEntity>;
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
import { removePropertiesFromRecord } from 'twenty-shared/utils';
|
||||
|
||||
import { PAGE_LAYOUT_WIDGET_ENTITY_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-page-layout-widget/constants/page-layout-widget-entity-relation-properties.constant';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { type FlatPageLayoutWidget } from 'src/engine/metadata-modules/flat-page-layout-widget/types/flat-page-layout-widget.type';
|
||||
import { type PageLayoutWidgetEntity } from 'src/engine/metadata-modules/page-layout-widget/entities/page-layout-widget.entity';
|
||||
|
||||
@@ -9,7 +9,9 @@ export const fromPageLayoutWidgetEntityToFlatPageLayoutWidget = (
|
||||
): FlatPageLayoutWidget => {
|
||||
const pageLayoutWidgetEntityWithoutRelations = removePropertiesFromRecord(
|
||||
pageLayoutWidgetEntity,
|
||||
PAGE_LAYOUT_WIDGET_ENTITY_RELATION_PROPERTIES,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.pageLayoutWidget,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.pageLayoutWidget)[],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
+1
-16
@@ -1,19 +1,4 @@
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type PageLayoutEntity } from 'src/engine/metadata-modules/page-layout/entities/page-layout.entity';
|
||||
|
||||
export const pageLayoutEntityRelationProperties = [
|
||||
'workspace',
|
||||
'objectMetadata',
|
||||
'tabs',
|
||||
'application',
|
||||
] as const satisfies (keyof PageLayoutEntity)[];
|
||||
|
||||
export type PageLayoutEntityRelationProperties =
|
||||
(typeof pageLayoutEntityRelationProperties)[number];
|
||||
|
||||
export type FlatPageLayout = FlatEntityFrom<
|
||||
PageLayoutEntity,
|
||||
PageLayoutEntityRelationProperties
|
||||
> & {
|
||||
tabIds: string[];
|
||||
};
|
||||
export type FlatPageLayout = FlatEntityFrom<PageLayoutEntity>;
|
||||
|
||||
+1
-9
@@ -1,12 +1,4 @@
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type RoleTargetEntity } from 'src/engine/metadata-modules/role-target/role-target.entity';
|
||||
|
||||
export const roleTargetsEntityRelationProperties = ['role', 'apiKey'] as const;
|
||||
|
||||
export type RoleTargetsEntityRelationProperties =
|
||||
(typeof roleTargetsEntityRelationProperties)[number];
|
||||
|
||||
export type FlatRoleTarget = FlatEntityFrom<
|
||||
RoleTargetEntity,
|
||||
RoleTargetsEntityRelationProperties
|
||||
>;
|
||||
export type FlatRoleTarget = FlatEntityFrom<RoleTargetEntity>;
|
||||
|
||||
+2
-21
@@ -1,27 +1,8 @@
|
||||
import { type ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type FieldPermissionEntity } from 'src/engine/metadata-modules/object-permission/field-permission/field-permission.entity';
|
||||
import { type ObjectPermissionEntity } from 'src/engine/metadata-modules/object-permission/object-permission.entity';
|
||||
import { type PermissionFlagEntity } from 'src/engine/metadata-modules/permission-flag/permission-flag.entity';
|
||||
import { type RoleTargetEntity } from 'src/engine/metadata-modules/role-target/role-target.entity';
|
||||
import { type RoleEntity } from 'src/engine/metadata-modules/role/role.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type RoleEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
RoleEntity,
|
||||
| RoleTargetEntity
|
||||
| ObjectPermissionEntity
|
||||
| PermissionFlagEntity
|
||||
| FieldPermissionEntity
|
||||
| ApplicationEntity
|
||||
>;
|
||||
|
||||
export type FlatRole = FlatEntityFrom<
|
||||
RoleEntity,
|
||||
RoleEntityRelationProperties
|
||||
> & {
|
||||
roleTargetIds: string[];
|
||||
export type FlatRole = FlatEntityFrom<RoleEntity> & {
|
||||
// TODO remove once objectPermission permissionFlag fieldPermission have been migrated to v2
|
||||
objectPermissionIds: string[];
|
||||
permissionFlagIds: string[];
|
||||
fieldPermissionIds: string[];
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import { type ViewFieldEntityRelationProperties } from 'src/engine/metadata-modules/flat-view-field/types/flat-view-field.type';
|
||||
|
||||
export const VIEW_FIELD_ENTITY_RELATION_PROPERTIES = [
|
||||
'fieldMetadata',
|
||||
'view',
|
||||
'workspace',
|
||||
] as const satisfies ViewFieldEntityRelationProperties[];
|
||||
+1
-14
@@ -1,17 +1,4 @@
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type ViewFieldEntity } from 'src/engine/metadata-modules/view-field/entities/view-field.entity';
|
||||
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type ViewFieldEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
ViewFieldEntity,
|
||||
FieldMetadataEntity | ViewEntity | WorkspaceEntity
|
||||
>;
|
||||
|
||||
export type FlatViewField = FlatEntityFrom<
|
||||
ViewFieldEntity,
|
||||
ViewFieldEntityRelationProperties
|
||||
>;
|
||||
export type FlatViewField = FlatEntityFrom<ViewFieldEntity>;
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
import { removePropertiesFromRecord } from 'twenty-shared/utils';
|
||||
|
||||
import { VIEW_FIELD_ENTITY_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-view-field/constants/view-field-entity-relation-properties.constant';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { type FlatViewField } from 'src/engine/metadata-modules/flat-view-field/types/flat-view-field.type';
|
||||
import { type ViewFieldEntity } from 'src/engine/metadata-modules/view-field/entities/view-field.entity';
|
||||
|
||||
@@ -9,7 +9,9 @@ export const fromViewFieldEntityToFlatViewField = (
|
||||
): FlatViewField => {
|
||||
const viewFieldEntityWithoutRelations = removePropertiesFromRecord(
|
||||
viewFieldEntity,
|
||||
VIEW_FIELD_ENTITY_RELATION_PROPERTIES,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.viewField,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.viewField)[],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import { type ViewFilterEntityRelationProperties } from 'src/engine/metadata-modules/flat-view-filter/types/flat-view-filter.type';
|
||||
|
||||
export const VIEW_FILTER_ENTITY_RELATION_PROPERTIES = [
|
||||
'fieldMetadata',
|
||||
'view',
|
||||
'viewFilterGroup',
|
||||
'workspace',
|
||||
] as const satisfies ViewFilterEntityRelationProperties[];
|
||||
+2
-13
@@ -1,18 +1,7 @@
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type ViewFilterGroupEntity } from 'src/engine/metadata-modules/view-filter-group/entities/view-filter-group.entity';
|
||||
import { type ViewFilterEntity } from 'src/engine/metadata-modules/view-filter/entities/view-filter.entity';
|
||||
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type ViewFilterEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
ViewFilterEntity,
|
||||
FieldMetadataEntity | ViewEntity | ViewFilterGroupEntity | WorkspaceEntity
|
||||
>;
|
||||
|
||||
export type FlatViewFilter = FlatEntityFrom<
|
||||
ViewFilterEntity,
|
||||
ViewFilterEntityRelationProperties
|
||||
// TODO remove once viewFilterGroups have been migrated to v2
|
||||
Omit<ViewFilterEntity, 'viewFilterGroup'>
|
||||
>;
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
import { removePropertiesFromRecord } from 'twenty-shared/utils';
|
||||
|
||||
import { VIEW_FILTER_ENTITY_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-view-filter/constants/view-filter-entity-relation-properties.constant';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { type FlatViewFilter } from 'src/engine/metadata-modules/flat-view-filter/types/flat-view-filter.type';
|
||||
import { type ViewFilterEntity } from 'src/engine/metadata-modules/view-filter/entities/view-filter.entity';
|
||||
|
||||
@@ -9,7 +9,9 @@ export const fromViewFilterEntityToFlatViewFilter = (
|
||||
): FlatViewFilter => {
|
||||
const viewFilterEntityWithoutRelations = removePropertiesFromRecord(
|
||||
viewFilterEntity,
|
||||
VIEW_FILTER_ENTITY_RELATION_PROPERTIES,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.viewFilter,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.viewFilter)[],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
import { type ViewGroupEntityRelationProperties } from 'src/engine/metadata-modules/flat-view-group/types/flat-view-group.type';
|
||||
|
||||
export const VIEW_GROUP_ENTITY_RELATION_PROPERTIES = [
|
||||
'view',
|
||||
'workspace',
|
||||
] as const satisfies ViewGroupEntityRelationProperties[];
|
||||
+1
-14
@@ -1,17 +1,4 @@
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type ViewGroupEntity } from 'src/engine/metadata-modules/view-group/entities/view-group.entity';
|
||||
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type ViewGroupEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
ViewGroupEntity,
|
||||
FieldMetadataEntity | ViewEntity | WorkspaceEntity
|
||||
>;
|
||||
|
||||
export type FlatViewGroup = FlatEntityFrom<
|
||||
ViewGroupEntity,
|
||||
ViewGroupEntityRelationProperties
|
||||
>;
|
||||
export type FlatViewGroup = FlatEntityFrom<ViewGroupEntity>;
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
import { removePropertiesFromRecord } from 'twenty-shared/utils';
|
||||
|
||||
import { VIEW_GROUP_ENTITY_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-view-group/constants/view-group-entity-relation-properties.constant';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { type FlatViewGroup } from 'src/engine/metadata-modules/flat-view-group/types/flat-view-group.type';
|
||||
import { type ViewGroupEntity } from 'src/engine/metadata-modules/view-group/entities/view-group.entity';
|
||||
|
||||
@@ -9,7 +9,9 @@ export const fromViewGroupEntityToFlatViewGroup = (
|
||||
): FlatViewGroup => {
|
||||
const viewGroupEntityWithoutRelations = removePropertiesFromRecord(
|
||||
viewGroupEntity,
|
||||
VIEW_GROUP_ENTITY_RELATION_PROPERTIES,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.viewGroup,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.viewGroup)[],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
import { type ViewEntityRelationProperties } from 'src/engine/metadata-modules/flat-view/types/flat-view.type';
|
||||
|
||||
export const VIEW_ENTITY_RELATION_PROPERTIES = [
|
||||
'objectMetadata',
|
||||
'viewFields',
|
||||
'viewFilters',
|
||||
'viewFilterGroups',
|
||||
'viewGroups',
|
||||
'viewSorts',
|
||||
'workspace',
|
||||
'createdBy',
|
||||
'application',
|
||||
] as const satisfies ViewEntityRelationProperties[];
|
||||
+3
-33
@@ -1,37 +1,7 @@
|
||||
import { type ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
|
||||
import { type UserWorkspaceEntity } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type ViewFieldEntity } from 'src/engine/metadata-modules/view-field/entities/view-field.entity';
|
||||
import { type ViewFilterGroupEntity } from 'src/engine/metadata-modules/view-filter-group/entities/view-filter-group.entity';
|
||||
import { type ViewFilterEntity } from 'src/engine/metadata-modules/view-filter/entities/view-filter.entity';
|
||||
import { type ViewGroupEntity } from 'src/engine/metadata-modules/view-group/entities/view-group.entity';
|
||||
import { type ViewSortEntity } from 'src/engine/metadata-modules/view-sort/entities/view-sort.entity';
|
||||
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type ViewEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
ViewEntity,
|
||||
| ObjectMetadataEntity
|
||||
| ViewFieldEntity
|
||||
| ViewSortEntity
|
||||
| ViewFilterEntity
|
||||
| ViewGroupEntity
|
||||
| ViewFilterGroupEntity
|
||||
| WorkspaceEntity
|
||||
| FieldMetadataEntity
|
||||
| UserWorkspaceEntity
|
||||
| ApplicationEntity
|
||||
>;
|
||||
|
||||
export type FlatView = FlatEntityFrom<
|
||||
ViewEntity,
|
||||
ViewEntityRelationProperties
|
||||
> & {
|
||||
viewFieldIds: string[];
|
||||
viewFilterIds: string[];
|
||||
viewGroupIds: string[];
|
||||
};
|
||||
// TODO remove once viewSorts and viewFilterGroups have been migrated to v2
|
||||
Omit<ViewEntity, 'viewSorts' | 'viewFilterGroups'>
|
||||
>;
|
||||
|
||||
+4
-2
@@ -1,13 +1,15 @@
|
||||
import { removePropertiesFromRecord } from 'twenty-shared/utils';
|
||||
|
||||
import { VIEW_ENTITY_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-view/constants/view-entity-relation-properties.constant';
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { type FlatView } from 'src/engine/metadata-modules/flat-view/types/flat-view.type';
|
||||
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
|
||||
export const fromViewEntityToFlatView = (viewEntity: ViewEntity): FlatView => {
|
||||
const viewEntityWithoutRelations = removePropertiesFromRecord(
|
||||
viewEntity,
|
||||
VIEW_ENTITY_RELATION_PROPERTIES,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.view,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.view)[],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
+1
-2
@@ -12,8 +12,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-field-metadata.entity';
|
||||
import { IndexType } from 'src/engine/metadata-modules/index-metadata/types/indexType.types';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
|
||||
+1
-2
@@ -10,8 +10,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { type WorkspaceEntityDuplicateCriteria } from 'src/engine/api/graphql/workspace-query-builder/types/workspace-entity-duplicate-criteria.type';
|
||||
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
|
||||
+2
-9
@@ -12,10 +12,10 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { RoleEntity } from 'src/engine/metadata-modules/role/role.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity('fieldPermission')
|
||||
@Unique('IDX_FIELD_PERMISSION_FIELD_METADATA_ID_ROLE_ID_UNIQUE', [
|
||||
@@ -23,7 +23,7 @@ import { RoleEntity } from 'src/engine/metadata-modules/role/role.entity';
|
||||
'roleId',
|
||||
])
|
||||
@Index('IDX_FIELD_PERMISSION_WORKSPACE_ID_ROLE_ID', ['workspaceId', 'roleId'])
|
||||
export class FieldPermissionEntity {
|
||||
export class FieldPermissionEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -75,13 +75,6 @@ export class FieldPermissionEntity {
|
||||
@Column({ nullable: true, type: 'boolean' })
|
||||
canUpdateFieldValue?: boolean | null;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
+2
-4
@@ -13,6 +13,7 @@ import {
|
||||
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { RoleEntity } from 'src/engine/metadata-modules/role/role.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity('objectPermission')
|
||||
@Unique('IDX_OBJECT_PERMISSION_OBJECT_METADATA_ID_ROLE_ID_UNIQUE', [
|
||||
@@ -20,7 +21,7 @@ import { RoleEntity } from 'src/engine/metadata-modules/role/role.entity';
|
||||
'roleId',
|
||||
])
|
||||
@Index('IDX_OBJECT_PERMISSION_WORKSPACE_ID_ROLE_ID', ['workspaceId', 'roleId'])
|
||||
export class ObjectPermissionEntity {
|
||||
export class ObjectPermissionEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -58,9 +59,6 @@ export class ObjectPermissionEntity {
|
||||
@Column({ nullable: true, type: 'boolean' })
|
||||
canDestroyObjectRecords?: boolean;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
+1
-12
@@ -14,9 +14,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { PageLayoutWidgetEntity } from 'src/engine/metadata-modules/page-layout-widget/entities/page-layout-widget.entity';
|
||||
import { PageLayoutEntity } from 'src/engine/metadata-modules/page-layout/entities/page-layout.entity';
|
||||
|
||||
@@ -37,15 +35,6 @@ export class PageLayoutTabEntity
|
||||
@Column({ nullable: false })
|
||||
title: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@Column({ nullable: false, type: 'float', default: 0 })
|
||||
position: number;
|
||||
|
||||
|
||||
+1
-12
@@ -13,9 +13,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { PageLayoutTabEntity } from 'src/engine/metadata-modules/page-layout-tab/entities/page-layout-tab.entity';
|
||||
import { WidgetType } from 'src/engine/metadata-modules/page-layout-widget/enums/widget-type.enum';
|
||||
@@ -39,15 +37,6 @@ export class PageLayoutWidgetEntity
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
pageLayoutTabId: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@ManyToOne(() => PageLayoutTabEntity, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
+1
-12
@@ -14,9 +14,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { PageLayoutTabEntity } from 'src/engine/metadata-modules/page-layout-tab/entities/page-layout-tab.entity';
|
||||
import { PageLayoutType } from 'src/engine/metadata-modules/page-layout/enums/page-layout-type.enum';
|
||||
@@ -38,15 +36,6 @@ export class PageLayoutEntity
|
||||
@Column({ nullable: false })
|
||||
name: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: Object.values(PageLayoutType),
|
||||
|
||||
+3
-5
@@ -1,3 +1,4 @@
|
||||
import { PermissionFlagType } from 'twenty-shared/constants';
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
@@ -9,13 +10,13 @@ import {
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { PermissionFlagType } from 'twenty-shared/constants';
|
||||
|
||||
import { RoleEntity } from 'src/engine/metadata-modules/role/role.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity('permissionFlag')
|
||||
@Unique('IDX_PERMISSION_FLAG_FLAG_ROLE_ID_UNIQUE', ['flag', 'roleId'])
|
||||
export class PermissionFlagEntity {
|
||||
export class PermissionFlagEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -31,9 +32,6 @@ export class PermissionFlagEntity {
|
||||
@Column({ nullable: false, type: 'varchar' })
|
||||
flag: PermissionFlagType;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
+4
-4
@@ -11,6 +11,7 @@ import {
|
||||
|
||||
import { RemoteTableEntity } from 'src/engine/metadata-modules/remote-server/remote-table/remote-table.entity';
|
||||
import { UserMappingOptions } from 'src/engine/metadata-modules/remote-server/types/user-mapping-options';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
export enum RemoteServerType {
|
||||
POSTGRES_FDW = 'postgres_fdw',
|
||||
@@ -35,7 +36,9 @@ export type ForeignDataWrapperOptions<T extends RemoteServerType> =
|
||||
: never;
|
||||
|
||||
@Entity('remoteServer')
|
||||
export class RemoteServerEntity<T extends RemoteServerType> {
|
||||
export class RemoteServerEntity<
|
||||
T extends RemoteServerType,
|
||||
> extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -58,9 +61,6 @@ export class RemoteServerEntity<T extends RemoteServerType> {
|
||||
@Column({ type: 'text', nullable: true })
|
||||
schema: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@OneToMany(() => RemoteTableEntity, (table) => table.server, {
|
||||
cascade: true,
|
||||
})
|
||||
|
||||
+5
-7
@@ -1,21 +1,22 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import {
|
||||
RemoteServerEntity,
|
||||
type RemoteServerType,
|
||||
} from 'src/engine/metadata-modules/remote-server/remote-server.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity('remoteTable')
|
||||
export class RemoteTableEntity {
|
||||
export class RemoteTableEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -25,9 +26,6 @@ export class RemoteTableEntity {
|
||||
@Column({ nullable: false })
|
||||
localTableName: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
remoteServerId: string;
|
||||
|
||||
|
||||
+1
-2
@@ -12,8 +12,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { ApiKeyEntity } from 'src/engine/core-modules/api-key/api-key.entity';
|
||||
import { RoleEntity } from 'src/engine/metadata-modules/role/role.entity';
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { FieldPermissionEntity } from 'src/engine/metadata-modules/object-permission/field-permission/field-permission.entity';
|
||||
import { ObjectPermissionEntity } from 'src/engine/metadata-modules/object-permission/object-permission.entity';
|
||||
import { PermissionFlagEntity } from 'src/engine/metadata-modules/permission-flag/permission-flag.entity';
|
||||
|
||||
+2
-11
@@ -1,3 +1,4 @@
|
||||
import { HTTPMethod } from 'twenty-shared/types';
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
@@ -9,17 +10,10 @@ import {
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { HTTPMethod } from 'twenty-shared/types';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { RouteTriggerEntityRelationProperties } from 'src/engine/metadata-modules/route-trigger/types/flat-route-trigger.type';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
|
||||
export const ROUTE_TRIGGER_ENTITY_RELATION_PROPERTIES = [
|
||||
'serverlessFunction',
|
||||
] as const satisfies readonly RouteTriggerEntityRelationProperties[];
|
||||
|
||||
@Entity({ name: 'routeTrigger', schema: 'core' })
|
||||
@Unique('IDX_ROUTE_TRIGGER_PATH_HTTP_METHOD_WORKSPACE_ID_UNIQUE', [
|
||||
'path',
|
||||
@@ -58,9 +52,6 @@ export class RouteTriggerEntity
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
serverlessFunctionId: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
+9
-7
@@ -6,12 +6,10 @@ import { Repository } from 'typeorm';
|
||||
|
||||
import { WorkspaceCacheProvider } from 'src/engine/workspace-cache/interfaces/workspace-cache-provider.service';
|
||||
|
||||
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
|
||||
import { createEmptyFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/constant/create-empty-flat-entity-maps.constant';
|
||||
import { FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';
|
||||
import {
|
||||
ROUTE_TRIGGER_ENTITY_RELATION_PROPERTIES,
|
||||
RouteTriggerEntity,
|
||||
} from 'src/engine/metadata-modules/route-trigger/route-trigger.entity';
|
||||
import { RouteTriggerEntity } from 'src/engine/metadata-modules/route-trigger/route-trigger.entity';
|
||||
import { FlatRouteTrigger } from 'src/engine/metadata-modules/route-trigger/types/flat-route-trigger.type';
|
||||
import { WorkspaceCache } from 'src/engine/workspace-cache/decorators/workspace-cache.decorator';
|
||||
import { addFlatEntityToFlatEntityMapsThroughMutationOrThrow } from 'src/engine/workspace-manager/workspace-migration-v2/utils/add-flat-entity-to-flat-entity-maps-through-mutation-or-throw.util';
|
||||
@@ -40,10 +38,14 @@ export class WorkspaceFlatRouteTriggerMapCacheService extends WorkspaceCacheProv
|
||||
const flatRouteTriggerMaps = createEmptyFlatEntityMaps();
|
||||
|
||||
for (const routeTriggerEntity of routeTriggers) {
|
||||
const routeTriggerEntityWithoutRelations = removePropertiesFromRecord(
|
||||
routeTriggerEntity,
|
||||
Object.keys(
|
||||
ALL_METADATA_RELATION_PROPERTIES.routeTrigger,
|
||||
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.routeTrigger)[],
|
||||
);
|
||||
const flatRouteTrigger = {
|
||||
...removePropertiesFromRecord(routeTriggerEntity, [
|
||||
...ROUTE_TRIGGER_ENTITY_RELATION_PROPERTIES,
|
||||
]),
|
||||
...routeTriggerEntityWithoutRelations,
|
||||
createdAt: routeTriggerEntity.createdAt.toISOString(),
|
||||
updatedAt: routeTriggerEntity.updatedAt.toISOString(),
|
||||
universalIdentifier:
|
||||
|
||||
+1
-13
@@ -1,16 +1,4 @@
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type RouteTriggerEntity } from 'src/engine/metadata-modules/route-trigger/route-trigger.entity';
|
||||
import { type ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type RouteTriggerEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
RouteTriggerEntity,
|
||||
ServerlessFunctionEntity | WorkspaceEntity
|
||||
>;
|
||||
|
||||
export type FlatRouteTrigger = FlatEntityFrom<
|
||||
RouteTriggerEntity,
|
||||
RouteTriggerEntityRelationProperties
|
||||
>;
|
||||
export type FlatRouteTrigger = FlatEntityFrom<RouteTriggerEntity>;
|
||||
|
||||
+2
-9
@@ -13,7 +13,7 @@ import {
|
||||
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity('searchFieldMetadata')
|
||||
@Unique('IDX_SEARCH_FIELD_METADATA_OBJECT_FIELD_UNIQUE', [
|
||||
@@ -22,7 +22,7 @@ import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.ent
|
||||
])
|
||||
@Index('IDX_SEARCH_FIELD_METADATA_WORKSPACE_ID', ['workspaceId'])
|
||||
@Index('IDX_SEARCH_FIELD_METADATA_OBJECT_METADATA_ID', ['objectMetadataId'])
|
||||
export class SearchFieldMetadataEntity {
|
||||
export class SearchFieldMetadataEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -45,11 +45,4 @@ export class SearchFieldMetadataEntity {
|
||||
|
||||
@UpdateDateColumn({ type: 'timestamptz' })
|
||||
updatedAt: Date;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
}
|
||||
|
||||
+3
-5
@@ -1,3 +1,4 @@
|
||||
import { PackageJson } from 'twenty-shared/application';
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
@@ -7,12 +8,12 @@ import {
|
||||
Relation,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { PackageJson } from 'twenty-shared/application';
|
||||
|
||||
import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Entity('serverlessFunctionLayer')
|
||||
export class ServerlessFunctionLayerEntity {
|
||||
export class ServerlessFunctionLayerEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -25,9 +26,6 @@ export class ServerlessFunctionLayerEntity {
|
||||
@Column({ type: 'text', nullable: false })
|
||||
checksum: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@OneToMany(
|
||||
() => ServerlessFunctionEntity,
|
||||
(serverlessFunction) => serverlessFunction.serverlessFunctionLayer,
|
||||
|
||||
+1
-9
@@ -13,13 +13,11 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { CronTriggerEntity } from 'src/engine/metadata-modules/cron-trigger/entities/cron-trigger.entity';
|
||||
import { DatabaseEventTriggerEntity } from 'src/engine/metadata-modules/database-event-trigger/entities/database-event-trigger.entity';
|
||||
import { RouteTriggerEntity } from 'src/engine/metadata-modules/route-trigger/route-trigger.entity';
|
||||
import { ServerlessFunctionLayerEntity } from 'src/engine/metadata-modules/serverless-function-layer/serverless-function-layer.entity';
|
||||
import { ServerlessFunctionEntityRelationProperties } from 'src/engine/metadata-modules/serverless-function/types/flat-serverless-function.type';
|
||||
|
||||
const DEFAULT_SERVERLESS_TIMEOUT_SECONDS = 300; // 5 minutes
|
||||
|
||||
@@ -31,12 +29,6 @@ export enum ServerlessFunctionRuntime {
|
||||
export const DEFAULT_HANDLER_PATH = 'src/index.ts';
|
||||
export const DEFAULT_HANDLER_NAME = 'main';
|
||||
|
||||
export const SERVERLESS_FUNCTION_ENTITY_RELATION_PROPERTIES = [
|
||||
'cronTriggers',
|
||||
'databaseEventTriggers',
|
||||
'routeTriggers',
|
||||
] as const satisfies readonly ServerlessFunctionEntityRelationProperties[];
|
||||
|
||||
@Entity('serverlessFunction')
|
||||
@Index('IDX_SERVERLESS_FUNCTION_ID_DELETED_AT', ['id', 'deletedAt'])
|
||||
export class ServerlessFunctionEntity
|
||||
|
||||
+4
-25
@@ -1,30 +1,9 @@
|
||||
import { type Sources } from 'twenty-shared/types';
|
||||
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type CronTriggerEntity } from 'src/engine/metadata-modules/cron-trigger/entities/cron-trigger.entity';
|
||||
import { type DatabaseEventTriggerEntity } from 'src/engine/metadata-modules/database-event-trigger/entities/database-event-trigger.entity';
|
||||
import { type FlatEntityFrom } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
|
||||
import { type RouteTriggerEntity } from 'src/engine/metadata-modules/route-trigger/route-trigger.entity';
|
||||
import { type ServerlessFunctionLayerEntity } from 'src/engine/metadata-modules/serverless-function-layer/serverless-function-layer.entity';
|
||||
import { type ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';
|
||||
import { type ExtractRecordTypeOrmRelationProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-relation-properties.type';
|
||||
|
||||
export type ServerlessFunctionEntityRelationProperties =
|
||||
ExtractRecordTypeOrmRelationProperties<
|
||||
ServerlessFunctionEntity,
|
||||
| CronTriggerEntity
|
||||
| DatabaseEventTriggerEntity
|
||||
| RouteTriggerEntity
|
||||
| WorkspaceEntity
|
||||
| ServerlessFunctionLayerEntity
|
||||
>;
|
||||
|
||||
export type FlatServerlessFunction = FlatEntityFrom<
|
||||
ServerlessFunctionEntity,
|
||||
ServerlessFunctionEntityRelationProperties
|
||||
> & {
|
||||
databaseEventTriggerIds: string[];
|
||||
cronTriggerIds: string[];
|
||||
routeTriggerIds: string[];
|
||||
code?: Sources;
|
||||
};
|
||||
export type FlatServerlessFunction =
|
||||
FlatEntityFrom<ServerlessFunctionEntity> & {
|
||||
code?: Sources;
|
||||
};
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import { type FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { type FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { type FieldMetadataEntityRelationProperties } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
|
||||
export type CachedFieldMetadataEntity<
|
||||
T extends FieldMetadataType = FieldMetadataType,
|
||||
> = Omit<FieldMetadataEntity<T>, FieldMetadataEntityRelationProperties>;
|
||||
+1
-10
@@ -11,10 +11,8 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
|
||||
@@ -67,9 +65,6 @@ export class ViewFieldEntity
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
viewId: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -79,10 +74,6 @@ export class ViewFieldEntity
|
||||
@DeleteDateColumn({ type: 'timestamptz' })
|
||||
deletedAt: Date | null;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@ManyToOne(() => ViewEntity, (view) => view.viewFields, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
+1
-10
@@ -12,9 +12,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { ViewFilterGroupLogicalOperator } from 'src/engine/metadata-modules/view-filter-group/enums/view-filter-group-logical-operator';
|
||||
import { ViewFilterEntity } from 'src/engine/metadata-modules/view-filter/entities/view-filter.entity';
|
||||
import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
@@ -45,9 +43,6 @@ export class ViewFilterGroupEntity extends SyncableEntity {
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
viewId: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -57,10 +52,6 @@ export class ViewFilterGroupEntity extends SyncableEntity {
|
||||
@DeleteDateColumn({ type: 'timestamptz' })
|
||||
deletedAt?: Date | null;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@ManyToOne(() => ViewEntity, (view) => view.viewFilterGroups, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
+1
-10
@@ -12,9 +12,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { ViewFilterGroupEntity } from 'src/engine/metadata-modules/view-filter-group/entities/view-filter-group.entity';
|
||||
import { ViewFilterValue } from 'src/engine/metadata-modules/view-filter/types/view-filter-value.type';
|
||||
@@ -65,9 +63,6 @@ export class ViewFilterEntity
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
viewId: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -77,10 +72,6 @@ export class ViewFilterEntity
|
||||
@DeleteDateColumn({ type: 'timestamptz' })
|
||||
deletedAt: Date | null;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@ManyToOne(() => ViewEntity, (view) => view.viewFilters, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
+1
-10
@@ -11,9 +11,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
|
||||
@Entity({ name: 'viewGroup', schema: 'core' })
|
||||
@@ -40,9 +38,6 @@ export class ViewGroupEntity
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
viewId: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -52,10 +47,6 @@ export class ViewGroupEntity
|
||||
@DeleteDateColumn({ type: 'timestamptz' })
|
||||
deletedAt: Date | null;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@ManyToOne(() => ViewEntity, (view) => view.viewGroups, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
+1
-10
@@ -11,9 +11,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { ViewSortDirection } from 'src/engine/metadata-modules/view-sort/enums/view-sort-direction';
|
||||
import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
@@ -55,9 +53,6 @@ export class ViewSortEntity extends SyncableEntity {
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
viewId: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -67,10 +62,6 @@ export class ViewSortEntity extends SyncableEntity {
|
||||
@DeleteDateColumn({ type: 'timestamptz' })
|
||||
deletedAt?: Date | null;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@ManyToOne(() => ViewEntity, (view) => view.viewSorts, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
@@ -13,11 +13,9 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/types/syncable-entity.interface';
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { UserWorkspaceEntity } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ViewFieldEntity } from 'src/engine/metadata-modules/view-field/entities/view-field.entity';
|
||||
@@ -155,9 +153,6 @@ export class ViewEntity extends SyncableEntity implements Required<ViewEntity> {
|
||||
@Column({ nullable: false, default: false, type: 'boolean' })
|
||||
shouldHideEmptyGroups: boolean;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
|
||||
@@ -187,12 +182,6 @@ export class ViewEntity extends SyncableEntity implements Required<ViewEntity> {
|
||||
@JoinColumn({ name: 'createdByUserWorkspaceId' })
|
||||
createdBy: Relation<UserWorkspaceEntity>;
|
||||
|
||||
@ManyToOne(() => WorkspaceEntity, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
|
||||
@OneToMany(() => ViewFieldEntity, (viewField) => viewField.view)
|
||||
viewFields: Relation<ViewFieldEntity[]>;
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import {
|
||||
} from 'src/engine/metadata-modules/workspace-migration/workspace-migration.exception';
|
||||
|
||||
// TODO: could we export this to GraphQL ?
|
||||
// TOOD: once this module is removed, replace existing usages with CompositeFieldMetadataType from composite-field-metadata-type.type.ts
|
||||
// TODO: once this module is removed, replace existing usages with CompositeFieldMetadataType from composite-field-metadata-type.type.ts
|
||||
export type CompositeFieldMetadataType =
|
||||
| FieldMetadataType.ADDRESS
|
||||
| FieldMetadataType.CURRENCY
|
||||
|
||||
+3
-5
@@ -1,12 +1,13 @@
|
||||
import { type RelationOnDeleteAction } from 'twenty-shared/types';
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { type RelationOnDeleteAction } from 'twenty-shared/types';
|
||||
|
||||
import { type IndexType } from 'src/engine/metadata-modules/index-metadata/types/indexType.types';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
export enum WorkspaceMigrationColumnActionType {
|
||||
CREATE = 'CREATE',
|
||||
@@ -129,7 +130,7 @@ export type WorkspaceMigrationTableAction = {
|
||||
};
|
||||
|
||||
@Entity('workspaceMigration')
|
||||
export class WorkspaceMigrationEntity {
|
||||
export class WorkspaceMigrationEntity extends WorkspaceRelatedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@@ -145,9 +146,6 @@ export class WorkspaceMigrationEntity {
|
||||
@Column({ nullable: true, type: 'timestamptz' })
|
||||
appliedAt?: Date;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { type FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { type CachedFieldMetadataEntity } from 'src/engine/metadata-modules/types/cached-field-metadata-entity';
|
||||
|
||||
export function isCachedFieldMetadataEntityOfType<
|
||||
Field extends CachedFieldMetadataEntity<FieldMetadataType>,
|
||||
Type extends FieldMetadataType,
|
||||
>(
|
||||
fieldMetadata: Pick<Field, 'type'>,
|
||||
type: Type,
|
||||
): fieldMetadata is CachedFieldMetadataEntity &
|
||||
CachedFieldMetadataEntity<Type> {
|
||||
return fieldMetadata.type === type;
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
import { type Relation } from 'typeorm';
|
||||
|
||||
export type ExtractRecordTypeOrmRelationProperties<T, TRelationTargets> =
|
||||
NonNullable<
|
||||
{
|
||||
[P in keyof T]: NonNullable<T[P]> extends Relation<
|
||||
TRelationTargets | TRelationTargets[]
|
||||
>
|
||||
? P
|
||||
: never;
|
||||
}[keyof T]
|
||||
>;
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
import { type ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
|
||||
import { type DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
|
||||
import { type FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { type IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-field-metadata.entity';
|
||||
import { type IndexMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-metadata.entity';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { type FieldPermissionEntity } from 'src/engine/metadata-modules/object-permission/field-permission/field-permission.entity';
|
||||
import { type ObjectPermissionEntity } from 'src/engine/metadata-modules/object-permission/object-permission.entity';
|
||||
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
|
||||
export type MetadataEntitiesRelationTarget =
|
||||
| ObjectMetadataEntity
|
||||
| FieldMetadataEntity
|
||||
| IndexFieldMetadataEntity
|
||||
| FieldPermissionEntity
|
||||
| DataSourceEntity
|
||||
| ApplicationEntity
|
||||
| IndexMetadataEntity
|
||||
| ObjectPermissionEntity
|
||||
| ViewEntity;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export type RemoveSuffix<
|
||||
T extends string,
|
||||
P extends string,
|
||||
> = T extends `${infer Prefix}${P}` ? Prefix : T;
|
||||
+1
@@ -10,6 +10,7 @@ export type PartialIndexMetadata = Omit<
|
||||
| 'universalIdentifier'
|
||||
| 'application'
|
||||
| 'applicationId'
|
||||
| 'workspace'
|
||||
> & {
|
||||
columns: string[];
|
||||
};
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
import { type ApplicationVariableEntity } from 'src/engine/core-modules/applicationVariable/application-variable.entity';
|
||||
import { type BillingMeterEntity } from 'src/engine/core-modules/billing/entities/billing-meter.entity';
|
||||
import { type BillingPriceEntity } from 'src/engine/core-modules/billing/entities/billing-price.entity';
|
||||
import { type BillingProductEntity } from 'src/engine/core-modules/billing/entities/billing-product.entity';
|
||||
import { type BillingSubscriptionItemEntity } from 'src/engine/core-modules/billing/entities/billing-subscription-item.entity';
|
||||
import { type TwoFactorAuthenticationMethodEntity } from 'src/engine/core-modules/two-factor-authentication/entities/two-factor-authentication-method.entity';
|
||||
import { type UserEntity } from 'src/engine/core-modules/user/user.entity';
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type AgentMessagePartEntity } from 'src/engine/metadata-modules/ai/ai-agent-execution/entities/agent-message-part.entity';
|
||||
import { type AgentMessageEntity } from 'src/engine/metadata-modules/ai/ai-agent-execution/entities/agent-message.entity';
|
||||
import { type AgentTurnEntity } from 'src/engine/metadata-modules/ai/ai-agent-execution/entities/agent-turn.entity';
|
||||
import { type AgentTurnEvaluationEntity } from 'src/engine/metadata-modules/ai/ai-agent-monitor/entities/agent-turn-evaluation.entity';
|
||||
import { type AgentChatThreadEntity } from 'src/engine/metadata-modules/ai/ai-chat/entities/agent-chat-thread.entity';
|
||||
import { type IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-field-metadata.entity';
|
||||
|
||||
/**
|
||||
* Union of all entities that don't have a direct `workspaceId` field
|
||||
* (i.e., they don't extend `WorkspaceRelatedEntity`).
|
||||
*
|
||||
* This type is used alongside `WorkspaceRelatedEntity` to enable TypeScript
|
||||
* to properly extract entity relation properties for dynamic typing purposes.
|
||||
*
|
||||
* @see ExtractEntityRelatedEntityProperties
|
||||
* @see ExtractEntityManyToOneEntityRelationProperties
|
||||
* @see ExtractEntityOneToManyEntityRelationProperties
|
||||
*/
|
||||
export type AllNonWorkspaceRelatedEntity =
|
||||
| AgentChatThreadEntity
|
||||
| AgentMessagePartEntity
|
||||
| AgentMessageEntity
|
||||
| AgentTurnEntity
|
||||
| AgentTurnEvaluationEntity
|
||||
| IndexFieldMetadataEntity
|
||||
| ApplicationVariableEntity
|
||||
| BillingMeterEntity
|
||||
| BillingPriceEntity
|
||||
| BillingProductEntity
|
||||
| BillingSubscriptionItemEntity
|
||||
| TwoFactorAuthenticationMethodEntity
|
||||
| UserEntity
|
||||
| WorkspaceEntity;
|
||||
+2
-1
@@ -1,11 +1,12 @@
|
||||
import { Column, Index, JoinColumn, ManyToOne, Relation } from 'typeorm';
|
||||
|
||||
import type { ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
|
||||
import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/workspace-sync/types/workspace-related-entity';
|
||||
|
||||
@Index(['workspaceId', 'universalIdentifier'], {
|
||||
unique: true,
|
||||
})
|
||||
export abstract class SyncableEntity {
|
||||
export abstract class SyncableEntity extends WorkspaceRelatedEntity {
|
||||
@Column({ nullable: true, type: 'uuid' })
|
||||
// TODO should not be nullable
|
||||
universalIdentifier: string;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { Column, JoinColumn, ManyToOne, Relation } from 'typeorm';
|
||||
|
||||
import type { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
|
||||
export abstract class WorkspaceRelatedEntity {
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
workspaceId: string;
|
||||
|
||||
@ManyToOne('WorkspaceEntity', { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'workspaceId' })
|
||||
workspace: Relation<WorkspaceEntity>;
|
||||
}
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
|
||||
import { type ObjectRecord } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { In, Raw } from 'typeorm';
|
||||
import {
|
||||
type ObjectRecordCreateEvent,
|
||||
type ObjectRecordDeleteEvent,
|
||||
type ObjectRecordDestroyEvent,
|
||||
type ObjectRecordNonDestructiveEvent,
|
||||
type ObjectRecordUpdateEvent,
|
||||
type ObjectRecordUpsertEvent,
|
||||
type ObjectRecordNonDestructiveEvent,
|
||||
} from 'twenty-shared/database-events';
|
||||
import { type ObjectRecord } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { In, Raw } from 'typeorm';
|
||||
|
||||
import { OnDatabaseBatchEvent } from 'src/engine/api/graphql/graphql-query-runner/decorators/on-database-batch-event.decorator';
|
||||
import { DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
|
||||
|
||||
@@ -2,6 +2,7 @@ import { faker } from '@faker-js/faker';
|
||||
import { type FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { type ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { type IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-field-metadata.entity';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
@@ -20,6 +21,7 @@ export const getMockFieldMetadataEntity = <
|
||||
overrides: GetMockFieldMetadataEntityOverride<T>,
|
||||
): FieldMetadataEntity => {
|
||||
return {
|
||||
workspace: {} as WorkspaceEntity,
|
||||
calendarViews: [],
|
||||
mainGroupByFieldMetadataViews: [],
|
||||
viewFilters: [],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
import { type ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
|
||||
import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { type DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
|
||||
@@ -17,6 +18,7 @@ export const getMockObjectMetadataEntity = (
|
||||
overrides: GetMockObjectMetadataEntityOverride,
|
||||
): ObjectMetadataEntity => {
|
||||
return {
|
||||
workspace: {} as WorkspaceEntity,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
dataSource: {} as DataSourceEntity,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user