Skip to content

The open alternative to Salesforce, designed for AI.

Record sharing 2/14: add the recordShare hidden standard object and its service (#25425)

martmull55a5e80a238c
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/2-40-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/2-40-upgrade-version-command.module.ts
new file mode 100644
index 00000000000..aad3d37bba6
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/2-40-upgrade-version-command.module.ts
@@ -0,0 +1,22 @@
+import { Module } from '@nestjs/common';
+
+import { WorkspaceIteratorModule } from 'src/database/commands/command-runners/workspace-iterator.module';
+import { SyncRecordShareObjectCommand } from 'src/database/commands/upgrade-version-command/2-40/2-40-workspace-command-1788794677636-sync-record-share-object.command';
+import { ApplicationModule } from 'src/engine/core-modules/application/application.module';
+import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module';
+import { WorkspaceMigrationRunnerModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/workspace-migration-runner.module';
+import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration.module';
+import { WorkspaceSchemaMigrationRunnerActionHandlersModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/workspace-schema-migration-runner-action-handlers.module';
+
+@Module({
+ imports: [
+ ApplicationModule,
+ WorkspaceCacheModule,
+ WorkspaceIteratorModule,
+ WorkspaceMigrationModule,
+ WorkspaceMigrationRunnerModule,
+ WorkspaceSchemaMigrationRunnerActionHandlersModule,
+ ],
+ providers: [SyncRecordShareObjectCommand],
+})
+export class V2_40_UpgradeVersionCommandModule {}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/2-40-workspace-command-1788794677636-sync-record-share-object.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/2-40-workspace-command-1788794677636-sync-record-share-object.command.ts
new file mode 100644
index 00000000000..fd512a1d53f
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/2-40-workspace-command-1788794677636-sync-record-share-object.command.ts
@@ -0,0 +1,152 @@
+import { Command } from 'nest-commander';
+import { STANDARD_OBJECTS } from 'twenty-shared/metadata';
+import { isDefined } from 'twenty-shared/utils';
+
+import { ProvisionedWorkspaceCommandRunner } from 'src/database/commands/command-runners/provisioned-workspace.command-runner';
+import { WorkspaceIteratorService } from 'src/database/commands/command-runners/workspace-iterator.service';
+import { type RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspace.command-runner';
+import { getStandardFlatEntitiesToCreateOrThrow } from 'src/database/commands/upgrade-version-command/2-10/utils/get-standard-flat-entities-to-create-or-throw.util';
+import { collectRecordShareStandardUniversalIdentifiers } from 'src/database/commands/upgrade-version-command/2-40/utils/collect-record-share-standard-universal-identifiers.util';
+import { ApplicationService } from 'src/engine/core-modules/application/application.service';
+import { RegisteredWorkspaceCommand } from 'src/engine/core-modules/upgrade/decorators/registered-workspace-command.decorator';
+import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
+import { type FlatIndexMetadata } from 'src/engine/metadata-modules/flat-index-metadata/types/flat-index-metadata.type';
+import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
+import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';
+import { computeTwentyStandardApplicationAllFlatEntityMaps } from 'src/engine/workspace-manager/twenty-standard-application/utils/twenty-standard-application-all-flat-entity-maps.constant';
+import { WorkspaceMigrationValidateBuildAndRunService } from 'src/engine/workspace-manager/workspace-migration/services/workspace-migration-validate-build-and-run-service';
+
+@RegisteredWorkspaceCommand('2.40.0', 1788794677636)
+@Command({
+ name: 'upgrade:2-40:sync-record-share-object',
+ description:
+ 'Create the recordShare standard object in existing workspaces',
+})
+export class SyncRecordShareObjectCommand extends ProvisionedWorkspaceCommandRunner {
+ constructor(
+ protected readonly workspaceIteratorService: WorkspaceIteratorService,
+ private readonly applicationService: ApplicationService,
+ private readonly workspaceCacheService: WorkspaceCacheService,
+ private readonly workspaceMigrationValidateBuildAndRunService: WorkspaceMigrationValidateBuildAndRunService,
+ ) {
+ super(workspaceIteratorService);
+ }
+
+ override async runOnWorkspace({
+ workspaceId,
+ options,
+ }: RunOnWorkspaceArgs): Promise<void> {
+ const isDryRun = options.dryRun ?? false;
+ const { flatObjectMetadataMaps, flatFieldMetadataMaps, flatIndexMaps } =
+ await this.workspaceCacheService.getOrRecompute(workspaceId, [
+ 'flatObjectMetadataMaps',
+ 'flatFieldMetadataMaps',
+ 'flatIndexMaps',
+ ]);
+
+ if (
+ !isDefined(
+ flatObjectMetadataMaps.byUniversalIdentifier[
+ STANDARD_OBJECTS.person.universalIdentifier
+ ],
+ )
+ ) {
+ this.logger.warn(
+ `person object not found for workspace ${workspaceId}, skipping recordShare object sync`,
+ );
+
+ return;
+ }
+
+ const { twentyStandardFlatApplication } =
+ await this.applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow(
+ { workspaceId },
+ );
+ const { allFlatEntityMaps: standardAllFlatEntityMaps } =
+ computeTwentyStandardApplicationAllFlatEntityMaps({
+ now: new Date().toISOString(),
+ workspaceId,
+ twentyStandardApplicationId: twentyStandardFlatApplication.id,
+ });
+ const universalIdentifiers = collectRecordShareStandardUniversalIdentifiers(
+ { standardAllFlatEntityMaps },
+ );
+ const allFlatEntityOperationByMetadataName = {
+ objectMetadata: {
+ flatEntityToCreate:
+ getStandardFlatEntitiesToCreateOrThrow<FlatObjectMetadata>({
+ standardFlatEntityMaps:
+ standardAllFlatEntityMaps.flatObjectMetadataMaps,
+ existingFlatEntityMaps: flatObjectMetadataMaps,
+ universalIdentifiers: universalIdentifiers.objectMetadata,
+ }),
+ flatEntityToDelete: [],
+ flatEntityToUpdate: [],
+ },
+ fieldMetadata: {
+ flatEntityToCreate:
+ getStandardFlatEntitiesToCreateOrThrow<FlatFieldMetadata>({
+ standardFlatEntityMaps:
+ standardAllFlatEntityMaps.flatFieldMetadataMaps,
+ existingFlatEntityMaps: flatFieldMetadataMaps,
+ universalIdentifiers: universalIdentifiers.fieldMetadata,
+ }),
+ flatEntityToDelete: [],
+ flatEntityToUpdate: [],
+ },
+ index: {
+ flatEntityToCreate:
+ getStandardFlatEntitiesToCreateOrThrow<FlatIndexMetadata>({
+ standardFlatEntityMaps: standardAllFlatEntityMaps.flatIndexMaps,
+ existingFlatEntityMaps: flatIndexMaps,
+ universalIdentifiers: universalIdentifiers.index,
+ }),
+ flatEntityToDelete: [],
+ flatEntityToUpdate: [],
+ },
+ };
+ const totalOperationCount = Object.values(
+ allFlatEntityOperationByMetadataName,
+ ).reduce(
+ (total, operations) => total + operations.flatEntityToCreate.length,
+ 0,
+ );
+
+ if (totalOperationCount === 0) {
+ this.logger.log(
+ `recordShare standard metadata already exists for workspace ${workspaceId}, skipping`,
+ );
+
+ return;
+ }
+
+ const creationSummary = `${allFlatEntityOperationByMetadataName.objectMetadata.flatEntityToCreate.length} recordShare object(s), ${allFlatEntityOperationByMetadataName.fieldMetadata.flatEntityToCreate.length} field(s) and ${allFlatEntityOperationByMetadataName.index.flatEntityToCreate.length} index(es)`;
+
+ if (isDryRun) {
+ this.logger.log(
+ `[DRY RUN] Would create ${creationSummary} for workspace ${workspaceId}`,
+ );
+
+ return;
+ }
+
+ const result =
+ await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunLegacyWorkspaceMigration(
+ {
+ allFlatEntityOperationByMetadataName,
+ workspaceId,
+ isSystemBuild: true,
+ applicationUniversalIdentifier:
+ twentyStandardFlatApplication.universalIdentifier,
+ },
+ );
+
+ if (result.status === 'fail') {
+ throw new Error(
+ `Failed to create the recordShare object for workspace ${workspaceId}: ${JSON.stringify(result, null, 2)}`,
+ );
+ }
+
+ this.logger.log(`Created ${creationSummary} for workspace ${workspaceId}`);
+ }
+}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/types/record-share-standard-universal-identifiers.type.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/types/record-share-standard-universal-identifiers.type.ts
new file mode 100644
index 00000000000..ab0fe7bd7c6
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/types/record-share-standard-universal-identifiers.type.ts
@@ -0,0 +1,5 @@
+export type RecordShareStandardUniversalIdentifiers = {
+ objectMetadata: string[];
+ fieldMetadata: string[];
+ index: string[];
+};
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/utils/__tests__/collect-record-share-standard-universal-identifiers.util.spec.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/utils/__tests__/collect-record-share-standard-universal-identifiers.util.spec.ts
new file mode 100644
index 00000000000..34f035eafd6
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/utils/__tests__/collect-record-share-standard-universal-identifiers.util.spec.ts
@@ -0,0 +1,69 @@
+import { STANDARD_OBJECTS } from 'twenty-shared/metadata';
+import { isDefined } from 'twenty-shared/utils';
+import { v4 } from 'uuid';
+
+import { collectRecordShareStandardUniversalIdentifiers } from 'src/database/commands/upgrade-version-command/2-40/utils/collect-record-share-standard-universal-identifiers.util';
+import { computeTwentyStandardApplicationAllFlatEntityMaps } from 'src/engine/workspace-manager/twenty-standard-application/utils/twenty-standard-application-all-flat-entity-maps.constant';
+
+describe('collectRecordShareStandardUniversalIdentifiers', () => {
+ const { allFlatEntityMaps: standardAllFlatEntityMaps } =
+ computeTwentyStandardApplicationAllFlatEntityMaps({
+ now: new Date().toISOString(),
+ workspaceId: v4(),
+ twentyStandardApplicationId: v4(),
+ });
+
+ const universalIdentifiers = collectRecordShareStandardUniversalIdentifiers(
+ { standardAllFlatEntityMaps },
+ );
+
+ it('should collect the recordShare standard object only', () => {
+ expect(universalIdentifiers.objectMetadata).toEqual([
+ STANDARD_OBJECTS.recordShare.universalIdentifier,
+ ]);
+ });
+
+ it('should collect every recordShare field declared in twenty-shared', () => {
+ const declaredFieldUniversalIdentifiers = Object.values(
+ STANDARD_OBJECTS.recordShare.fields,
+ ).map(({ universalIdentifier }) => universalIdentifier);
+
+ expect(universalIdentifiers.fieldMetadata).toHaveLength(
+ declaredFieldUniversalIdentifiers.length,
+ );
+ expect(universalIdentifiers.fieldMetadata).toEqual(
+ expect.arrayContaining(declaredFieldUniversalIdentifiers),
+ );
+ });
+
+ it('should collect every recordShare index declared in twenty-shared', () => {
+ const declaredIndexUniversalIdentifiers = Object.values(
+ STANDARD_OBJECTS.recordShare.indexes,
+ ).map(({ universalIdentifier }) => universalIdentifier);
+
+ expect(universalIdentifiers.index).toHaveLength(
+ declaredIndexUniversalIdentifiers.length,
+ );
+ expect(universalIdentifiers.index).toEqual(
+ expect.arrayContaining(declaredIndexUniversalIdentifiers),
+ );
+ });
+
+ it('should not collect metadata belonging to unrelated standard objects', () => {
+ const companyFieldUniversalIdentifiers = Object.values(
+ standardAllFlatEntityMaps.flatFieldMetadataMaps.byUniversalIdentifier,
+ )
+ .filter(isDefined)
+ .filter(
+ (flatFieldMetadata) =>
+ flatFieldMetadata.objectMetadataUniversalIdentifier ===
+ STANDARD_OBJECTS.company.universalIdentifier,
+ )
+ .map((flatFieldMetadata) => flatFieldMetadata.universalIdentifier);
+
+ expect(companyFieldUniversalIdentifiers.length).toBeGreaterThan(0);
+ expect(universalIdentifiers.fieldMetadata).toEqual(
+ expect.not.arrayContaining(companyFieldUniversalIdentifiers),
+ );
+ });
+});
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/utils/collect-record-share-standard-universal-identifiers.util.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/utils/collect-record-share-standard-universal-identifiers.util.ts
new file mode 100644
index 00000000000..079feef46d3
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-40/utils/collect-record-share-standard-universal-identifiers.util.ts
@@ -0,0 +1,42 @@
+import { STANDARD_OBJECTS } from 'twenty-shared/metadata';
+import { isDefined } from 'twenty-shared/utils';
+
+import { type RecordShareStandardUniversalIdentifiers } from 'src/database/commands/upgrade-version-command/2-40/types/record-share-standard-universal-identifiers.type';
+import { type TwentyStandardAllFlatEntityMaps } from 'src/engine/workspace-manager/twenty-standard-application/types/twenty-standard-all-flat-entity-maps.type';
+
+const RECORD_SHARE_OBJECT_UNIVERSAL_IDENTIFIER =
+ STANDARD_OBJECTS.recordShare.universalIdentifier;
+
+export const collectRecordShareStandardUniversalIdentifiers = ({
+ standardAllFlatEntityMaps,
+}: {
+ standardAllFlatEntityMaps: TwentyStandardAllFlatEntityMaps;
+}): RecordShareStandardUniversalIdentifiers => {
+ const fieldMetadata = Object.values(
+ standardAllFlatEntityMaps.flatFieldMetadataMaps.byUniversalIdentifier,
+ )
+ .filter(isDefined)
+ .filter(
+ (flatFieldMetadata) =>
+ flatFieldMetadata.objectMetadataUniversalIdentifier ===
+ RECORD_SHARE_OBJECT_UNIVERSAL_IDENTIFIER,
+ )
+ .map((flatFieldMetadata) => flatFieldMetadata.universalIdentifier);
+
+ const index = Object.values(
+ standardAllFlatEntityMaps.flatIndexMaps.byUniversalIdentifier,
+ )
+ .filter(isDefined)
+ .filter(
+ (flatIndexMetadata) =>
+ flatIndexMetadata.objectMetadataUniversalIdentifier ===
+ RECORD_SHARE_OBJECT_UNIVERSAL_IDENTIFIER,
+ )
+ .map((flatIndexMetadata) => flatIndexMetadata.universalIdentifier);
+
+ return {
+ objectMetadata: [RECORD_SHARE_OBJECT_UNIVERSAL_IDENTIFIER],
+ fieldMetadata,
+ index,
+ };
+};
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts
index 2a3ee4dc1e4..3c70e86659b 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts
@@ -32,6 +32,7 @@ import { V2_36_UpgradeVersionCommandModule } from 'src/database/commands/upgrade
import { V2_37_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-37/2-37-upgrade-version-command.module';
import { V2_38_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-38/2-38-upgrade-version-command.module';
import { V2_39_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-39/2-39-upgrade-version-command.module';
+import { V2_40_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-40/2-40-upgrade-version-command.module';
import { V2_4_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-4/2-4-upgrade-version-command.module';
import { V2_5_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-5/2-5-upgrade-version-command.module';
import { V2_7_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-7/2-7-upgrade-version-command.module';
@@ -77,6 +78,7 @@ import { V2_9_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-
V2_37_UpgradeVersionCommandModule,
V2_38_UpgradeVersionCommandModule,
V2_39_UpgradeVersionCommandModule,
+ V2_40_UpgradeVersionCommandModule,
],
})
export class WorkspaceCommandProviderModule {}
diff --git a/packages/twenty-server/src/engine/core-modules/core-engine.module.ts b/packages/twenty-server/src/engine/core-modules/core-engine.module.ts
index 739f950c134..819c064895f 100644
--- a/packages/twenty-server/src/engine/core-modules/core-engine.module.ts
+++ b/packages/twenty-server/src/engine/core-modules/core-engine.module.ts
@@ -73,6 +73,7 @@ import { AiModelsModule } from 'src/engine/metadata-modules/ai/ai-models/ai-mode
import { PageLayoutModule } from 'src/engine/metadata-modules/page-layout/page-layout.module';
import { RoleModule } from 'src/engine/metadata-modules/role/role.module';
import { RowLevelPermissionModule } from 'src/engine/metadata-modules/row-level-permission-predicate/row-level-permission.module';
+import { RecordShareModule } from 'src/engine/record-share/record-share.module';
import { SubscriptionsModule } from 'src/engine/subscriptions/subscriptions.module';
import { CodeInterpreterSessionCleanupModule } from 'src/engine/core-modules/code-interpreter/crons/code-interpreter-session-cleanup.module';
import { TrashCleanupModule } from 'src/engine/trash-cleanup/trash-cleanup.module';
@@ -100,6 +101,7 @@ import { FileModule } from './file/file.module';
ClientConfigModule,
FeatureFlagModule,
FileModule,
+ RecordShareModule,
RowLevelPermissionModule,
OpenApiModule,
WellKnownModule,
diff --git a/packages/twenty-server/src/engine/record-share/record-share.exception.ts b/packages/twenty-server/src/engine/record-share/record-share.exception.ts
new file mode 100644
index 00000000000..710d52e5e00
--- /dev/null
+++ b/packages/twenty-server/src/engine/record-share/record-share.exception.ts
@@ -0,0 +1,12 @@
+import { STANDARD_ERROR_MESSAGE } from 'src/engine/api/common/common-query-runners/errors/standard-error-message.constant';
+import { CustomException } from 'src/utils/custom-exception';
+
+export enum RecordShareExceptionCode {
+ TRANSACTION_SCOPE_WORKSPACE_MISMATCH = 'TRANSACTION_SCOPE_WORKSPACE_MISMATCH',
+}
+
+export class RecordShareException extends CustomException<RecordShareExceptionCode> {
+ constructor(message: string, code: RecordShareExceptionCode) {
+ super(message, code, { userFriendlyMessage: STANDARD_ERROR_MESSAGE });
+ }
+}
diff --git a/packages/twenty-server/src/engine/record-share/record-share.module.ts b/packages/twenty-server/src/engine/record-share/record-share.module.ts
new file mode 100644
index 00000000000..253406f701e
--- /dev/null
+++ b/packages/twenty-server/src/engine/record-share/record-share.module.ts
@@ -0,0 +1,11 @@
+import { Module } from '@nestjs/common';
+
+import { RecordShareService } from 'src/engine/record-share/services/record-share.service';
+import { TwentyOrmModule } from 'src/engine/twenty-orm/twenty-orm.module';
+
+@Module({
+ imports: [TwentyOrmModule],
+ providers: [RecordShareService],
+ exports: [RecordShareService],
+})
+export class RecordShareModule {}
diff --git a/packages/twenty-server/src/engine/record-share/services/record-share.service.ts b/packages/twenty-server/src/engine/record-share/services/record-share.service.ts
new file mode 100644
index 00000000000..f94932f73b8
--- /dev/null
+++ b/packages/twenty-server/src/engine/record-share/services/record-share.service.ts
@@ -0,0 +1,109 @@
+import { Injectable } from '@nestjs/common';
+
+import { isDefined } from 'twenty-shared/utils';
+
+import {
+ RecordShareException,
+ RecordShareExceptionCode,
+} from 'src/engine/record-share/record-share.exception';
+import { type RecordShareInput } from 'src/engine/record-share/types/record-share-input.type';
+import { type RecordShare } from 'src/engine/record-share/types/record-share.type';
+import { type WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace-repository';
+import { type WorkspaceTransactionScope } from 'src/engine/twenty-orm/types/workspace-transaction-scope.type';
+import { buildSystemAuthContext } from 'src/engine/twenty-orm/utils/build-system-auth-context.util';
+import { WorkspaceOrmManager } from 'src/engine/twenty-orm/workspace-orm.manager';
+
+const RECORD_SHARE_OBJECT_METADATA_NAME = 'recordShare';
+
+type RecordShareRepository = WorkspaceRepository<RecordShare>;
+
+@Injectable()
+export class RecordShareService {
+ constructor(private readonly workspaceOrmManager: WorkspaceOrmManager) {}
+
+ async insertMany({
+ workspaceId,
+ recordShares,
+ transactionScope,
+ }: {
+ workspaceId: string;
+ recordShares: RecordShareInput[];
+ transactionScope?: WorkspaceTransactionScope;
+ }): Promise<void> {
+ if (recordShares.length === 0) {
+ return;
+ }
+
+ await this.withRepository({ workspaceId, transactionScope }, (repository) =>
+ repository.insert(recordShares, { onConflictDoNothing: true }),
+ );
+ }
+
+ async deleteBySourceId({
+ workspaceId,
+ sourceId,
+ transactionScope,
+ }: {
+ workspaceId: string;
+ sourceId: string;
+ transactionScope?: WorkspaceTransactionScope;
+ }): Promise<void> {
+ await this.withRepository({ workspaceId, transactionScope }, (repository) =>
+ repository.delete({ sourceId }),
+ );
+ }
+
+ async findByRecord({
+ workspaceId,
+ objectMetadataId,
+ recordId,
+ }: {
+ workspaceId: string;
+ objectMetadataId: string;
+ recordId: string;
+ }): Promise<RecordShare[]> {
+ return this.withRepository({ workspaceId }, (repository) =>
+ repository.find({ where: { objectMetadataId, recordId } }),
+ );
+ }
+
+ private async withRepository<TResult>(
+ {
+ workspaceId,
+ transactionScope,
+ }: {
+ workspaceId: string;
+ transactionScope?: WorkspaceTransactionScope;
+ },
+ work: (repository: RecordShareRepository) => Promise<TResult>,
+ ): Promise<TResult> {
+ if (isDefined(transactionScope)) {
+ if (transactionScope.workspaceId !== workspaceId) {
+ throw new RecordShareException(
+ `Transaction scope of workspace ${transactionScope.workspaceId} cannot write record shares of workspace ${workspaceId}`,
+ RecordShareExceptionCode.TRANSACTION_SCOPE_WORKSPACE_MISMATCH,
+ );
+ }
+
+ return work(
+ transactionScope.getRepository<RecordShare>(
+ RECORD_SHARE_OBJECT_METADATA_NAME,
+ { shouldBypassPermissionChecks: true },
+ { shouldSkipEventEmission: true },
+ ),
+ );
+ }
+
+ return this.workspaceOrmManager.executeInWorkspaceContext(
+ () =>
+ work(
+ this.workspaceOrmManager.getRepository<RecordShare>(
+ RECORD_SHARE_OBJECT_METADATA_NAME,
+ { shouldBypassPermissionChecks: true },
+ { shouldSkipEventEmission: true },
+ ),
+ ),
+ buildSystemAuthContext(workspaceId),
+ );
+ }
+}
diff --git a/packages/twenty-server/src/engine/record-share/types/record-share-input.type.ts b/packages/twenty-server/src/engine/record-share/types/record-share-input.type.ts
new file mode 100644
index 00000000000..41405a7fe0a
--- /dev/null
+++ b/packages/twenty-server/src/engine/record-share/types/record-share-input.type.ts
@@ -0,0 +1,15 @@
+import {
+ type RecordShareAccessLevel,
+ type RecordSharePrincipalType,
+ type RecordShareRowCause,
+} from 'twenty-shared/types';
+
+export type RecordShareInput = {
+ recordId: string;
+ objectMetadataId: string;
+ principalId: string;
+ principalType: RecordSharePrincipalType;
+ accessLevel: RecordShareAccessLevel;
+ rowCause: RecordShareRowCause;
+ sourceId: string;
+};
diff --git a/packages/twenty-server/src/engine/record-share/types/record-share.type.ts b/packages/twenty-server/src/engine/record-share/types/record-share.type.ts
new file mode 100644
index 00000000000..a9d7f8fbee8
--- /dev/null
+++ b/packages/twenty-server/src/engine/record-share/types/record-share.type.ts
@@ -0,0 +1,5 @@
+import { type RecordShareInput } from 'src/engine/record-share/types/record-share-input.type';
+
+export type RecordShare = RecordShareInput & {
+ id: string;
+};
diff --git a/packages/twenty-server/src/engine/twenty-orm/datasource/workspace-data-source.ts b/packages/twenty-server/src/engine/twenty-orm/datasource/workspace-data-source.ts
index 6ab36b5762f..2c3102a351b 100644
--- a/packages/twenty-server/src/engine/twenty-orm/datasource/workspace-data-source.ts
+++ b/packages/twenty-server/src/engine/twenty-orm/datasource/workspace-data-source.ts
@@ -90,6 +90,7 @@ export class WorkspaceDataSource {
};
const result = await this.runInClientTransaction((executor) =>
work({
+ workspaceId: this.internalContext.workspaceId,
getRepository: <T extends ObjectLiteral = ObjectRecord>(
nameSingular: string,
rolePermissionConfig?: RolePermissionConfig,
diff --git a/packages/twenty-server/src/engine/twenty-orm/types/workspace-transaction-scope.type.ts b/packages/twenty-server/src/engine/twenty-orm/types/workspace-transaction-scope.type.ts
index b91a09e5543..53e5df4a125 100644
--- a/packages/twenty-server/src/engine/twenty-orm/types/workspace-transaction-scope.type.ts
+++ b/packages/twenty-server/src/engine/twenty-orm/types/workspace-transaction-scope.type.ts
@@ -6,6 +6,7 @@ import { type RolePermissionConfig } from 'src/engine/twenty-orm/types/role-perm
import { type WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace-repository';
export type WorkspaceTransactionScope = {
+ workspaceId: string;
getRepository: <T extends ObjectLiteral = ObjectRecord>(
objectMetadataName: string,
rolePermissionConfig?: RolePermissionConfig,
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/search-fields-by-standard-object-name.constant.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/search-fields-by-standard-object-name.constant.ts
index 740daec7178..456978975fb 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/search-fields-by-standard-object-name.constant.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/search-fields-by-standard-object-name.constant.ts
@@ -44,6 +44,7 @@ export const SEARCH_FIELDS_BY_STANDARD_OBJECT_NAME = {
{ name: 'phones', type: FieldMetadataType.PHONES },
{ name: 'jobTitle', type: FieldMetadataType.TEXT },
],
+ recordShare: [],
task: [
{ name: 'title', type: FieldMetadataType.TEXT },
{ name: 'bodyV2', type: FieldMetadataType.RICH_TEXT },
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/__snapshots__/get-standard-object-metadata-related-entity-ids.util.spec.ts.snap b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/__snapshots__/get-standard-object-metadata-related-entity-ids.util.spec.ts.snap
index 4d6f6e86cb0..54c79e8590e 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/__snapshots__/get-standard-object-metadata-related-entity-ids.util.spec.ts.snap
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/__snapshots__/get-standard-object-metadata-related-entity-ids.util.spec.ts.snap
@@ -2306,188 +2306,239 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
},
},
},
+ "recordShare": {
+ "fields": {
+ "accessLevel": {
+ "id": "00000000-0000-0000-0000-000000000701",
+ },
+ "createdAt": {
+ "id": "00000000-0000-0000-0000-000000000690",
+ },
+ "createdBy": {
+ "id": "00000000-0000-0000-0000-000000000693",
+ },
+ "deletedAt": {
+ "id": "00000000-0000-0000-0000-000000000692",
+ },
+ "id": {
+ "id": "00000000-0000-0000-0000-000000000689",
+ },
+ "objectMetadataId": {
+ "id": "00000000-0000-0000-0000-000000000698",
+ },
+ "position": {
+ "id": "00000000-0000-0000-0000-000000000695",
+ },
+ "principalId": {
+ "id": "00000000-0000-0000-0000-000000000699",
+ },
+ "principalType": {
+ "id": "00000000-0000-0000-0000-000000000700",
+ },
+ "recordId": {
+ "id": "00000000-0000-0000-0000-000000000697",
+ },
+ "rowCause": {
+ "id": "00000000-0000-0000-0000-000000000702",
+ },
+ "searchVector": {
+ "id": "00000000-0000-0000-0000-000000000696",
+ },
+ "sourceId": {
+ "id": "00000000-0000-0000-0000-000000000703",
+ },
+ "updatedAt": {
+ "id": "00000000-0000-0000-0000-000000000691",
+ },
+ "updatedBy": {
+ "id": "00000000-0000-0000-0000-000000000694",
+ },
+ },
+ "id": "00000000-0000-0000-0000-000000000704",
+ "views": {},
+ },
"task": {
"fields": {
"assignee": {
- "id": "00000000-0000-0000-0000-000000000703",
+ "id": "00000000-0000-0000-0000-000000000719",
},
"attachments": {
- "id": "00000000-0000-0000-0000-000000000702",
+ "id": "00000000-0000-0000-0000-000000000718",
},
"bodyV2": {
- "id": "00000000-0000-0000-0000-000000000698",
+ "id": "00000000-0000-0000-0000-000000000714",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000690",
+ "id": "00000000-0000-0000-0000-000000000706",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000693",
+ "id": "00000000-0000-0000-0000-000000000709",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000000692",
+ "id": "00000000-0000-0000-0000-000000000708",
},
"dueAt": {
- "id": "00000000-0000-0000-0000-000000000699",
+ "id": "00000000-0000-0000-0000-000000000715",
},
"id": {
- "id": "00000000-0000-0000-0000-000000000689",
+ "id": "00000000-0000-0000-0000-000000000705",
},
"position": {
- "id": "00000000-0000-0000-0000-000000000695",
+ "id": "00000000-0000-0000-0000-000000000711",
},
"searchVector": {
- "id": "00000000-0000-0000-0000-000000000696",
+ "id": "00000000-0000-0000-0000-000000000712",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000700",
+ "id": "00000000-0000-0000-0000-000000000716",
},
"taskTargets": {
- "id": "00000000-0000-0000-0000-000000000701",
+ "id": "00000000-0000-0000-0000-000000000717",
},
"timelineActivities": {
- "id": "00000000-0000-0000-0000-000000000704",
+ "id": "00000000-0000-0000-0000-000000000720",
},
"title": {
- "id": "00000000-0000-0000-0000-000000000697",
+ "id": "00000000-0000-0000-0000-000000000713",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000691",
+ "id": "00000000-0000-0000-0000-000000000707",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000694",
+ "id": "00000000-0000-0000-0000-000000000710",
},
},
- "id": "00000000-0000-0000-0000-000000000743",
+ "id": "00000000-0000-0000-0000-000000000759",
"views": {
"allTasks": {
- "id": "00000000-0000-0000-0000-000000000713",
+ "id": "00000000-0000-0000-0000-000000000729",
"viewFieldGroups": {},
"viewFields": {
"assignee": {
- "id": "00000000-0000-0000-0000-000000000710",
+ "id": "00000000-0000-0000-0000-000000000726",
},
"bodyV2": {
- "id": "00000000-0000-0000-0000-000000000711",
+ "id": "00000000-0000-0000-0000-000000000727",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000712",
+ "id": "00000000-0000-0000-0000-000000000728",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000708",
+ "id": "00000000-0000-0000-0000-000000000724",
},
"dueAt": {
- "id": "00000000-0000-0000-0000-000000000709",
+ "id": "00000000-0000-0000-0000-000000000725",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000706",
+ "id": "00000000-0000-0000-0000-000000000722",
},
"taskTargets": {
- "id": "00000000-0000-0000-0000-000000000707",
+ "id": "00000000-0000-0000-0000-000000000723",
},
"title": {
- "id": "00000000-0000-0000-0000-000000000705",
+ "id": "00000000-0000-0000-0000-000000000721",
},
},
"viewGroups": {},
},
"assignedToMe": {
- "id": "00000000-0000-0000-0000-000000000725",
+ "id": "00000000-0000-0000-0000-000000000741",
"viewFieldGroups": {},
"viewFields": {
"assignee": {
- "id": "00000000-0000-0000-0000-000000000718",
+ "id": "00000000-0000-0000-0000-000000000734",
},
"bodyV2": {
- "id": "00000000-0000-0000-0000-000000000719",
+ "id": "00000000-0000-0000-0000-000000000735",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000720",
+ "id": "00000000-0000-0000-0000-000000000736",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000716",
+ "id": "00000000-0000-0000-0000-000000000732",
},
"dueAt": {
- "id": "00000000-0000-0000-0000-000000000717",
+ "id": "00000000-0000-0000-0000-000000000733",
},
"taskTargets": {
- "id": "00000000-0000-0000-0000-000000000715",
+ "id": "00000000-0000-0000-0000-000000000731",
},
"title": {
- "id": "00000000-0000-0000-0000-000000000714",
+ "id": "00000000-0000-0000-0000-000000000730",
},
},
"viewGroups": {
"done": {
- "id": "00000000-0000-0000-0000-000000000723",
+ "id": "00000000-0000-0000-0000-000000000739",
},
"empty": {
- "id": "00000000-0000-0000-0000-000000000724",
+ "id": "00000000-0000-0000-0000-000000000740",
},
"inProgress": {
- "id": "00000000-0000-0000-0000-000000000722",
+ "id": "00000000-0000-0000-0000-000000000738",
},
"todo": {
- "id": "00000000-0000-0000-0000-000000000721",
+ "id": "00000000-0000-0000-0000-000000000737",
},
},
},
"byStatus": {
- "id": "00000000-0000-0000-0000-000000000734",
+ "id": "00000000-0000-0000-0000-000000000750",
"viewFieldGroups": {},
"viewFields": {
"assignee": {
- "id": "00000000-0000-0000-0000-000000000729",
+ "id": "00000000-0000-0000-0000-000000000745",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000730",
+ "id": "00000000-0000-0000-0000-000000000746",
},
"dueAt": {
- "id": "00000000-0000-0000-0000-000000000728",
+ "id": "00000000-0000-0000-0000-000000000744",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000727",
+ "id": "00000000-0000-0000-0000-000000000743",
},
"title": {
- "id": "00000000-0000-0000-0000-000000000726",
+ "id": "00000000-0000-0000-0000-000000000742",
},
},
"viewGroups": {
"done": {
- "id": "00000000-0000-0000-0000-000000000733",
+ "id": "00000000-0000-0000-0000-000000000749",
},
"inProgress": {
- "id": "00000000-0000-0000-0000-000000000732",
+ "id": "00000000-0000-0000-0000-000000000748",
},
"todo": {
- "id": "00000000-0000-0000-0000-000000000731",
+ "id": "00000000-0000-0000-0000-000000000747",
},
},
},
"taskRecordPageFields": {
- "id": "00000000-0000-0000-0000-000000000742",
+ "id": "00000000-0000-0000-0000-000000000758",
"viewFieldGroups": {
"general": {
- "id": "00000000-0000-0000-0000-000000000741",
+ "id": "00000000-0000-0000-0000-000000000757",
},
},
"viewFields": {
"assignee": {
- "id": "00000000-0000-0000-0000-000000000737",
+ "id": "00000000-0000-0000-0000-000000000753",
},
"attachments": {
- "id": "00000000-0000-0000-0000-000000000739",
+ "id": "00000000-0000-0000-0000-000000000755",
},
"dueAt": {
- "id": "00000000-0000-0000-0000-000000000735",
+ "id": "00000000-0000-0000-0000-000000000751",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000736",
+ "id": "00000000-0000-0000-0000-000000000752",
},
"taskTargets": {
- "id": "00000000-0000-0000-0000-000000000738",
+ "id": "00000000-0000-0000-0000-000000000754",
},
"timelineActivities": {
- "id": "00000000-0000-0000-0000-000000000740",
+ "id": "00000000-0000-0000-0000-000000000756",
},
},
"viewGroups": {},
@@ -2497,62 +2548,62 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"taskTarget": {
"fields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000745",
+ "id": "00000000-0000-0000-0000-000000000761",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000748",
+ "id": "00000000-0000-0000-0000-000000000764",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000000747",
+ "id": "00000000-0000-0000-0000-000000000763",
},
"id": {
- "id": "00000000-0000-0000-0000-000000000744",
+ "id": "00000000-0000-0000-0000-000000000760",
},
"position": {
- "id": "00000000-0000-0000-0000-000000000750",
+ "id": "00000000-0000-0000-0000-000000000766",
},
"searchVector": {
- "id": "00000000-0000-0000-0000-000000000751",
+ "id": "00000000-0000-0000-0000-000000000767",
},
"targetCompany": {
- "id": "00000000-0000-0000-0000-000000000754",
+ "id": "00000000-0000-0000-0000-000000000770",
},
"targetOpportunity": {
- "id": "00000000-0000-0000-0000-000000000755",
+ "id": "00000000-0000-0000-0000-000000000771",
},
"targetPerson": {
- "id": "00000000-0000-0000-0000-000000000753",
+ "id": "00000000-0000-0000-0000-000000000769",
},
"task": {
- "id": "00000000-0000-0000-0000-000000000752",
+ "id": "00000000-0000-0000-0000-000000000768",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000746",
+ "id": "00000000-0000-0000-0000-000000000762",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000749",
+ "id": "00000000-0000-0000-0000-000000000765",
},
},
- "id": "00000000-0000-0000-0000-000000000762",
+ "id": "00000000-0000-0000-0000-000000000778",
"views": {
"allTaskTargets": {
- "id": "00000000-0000-0000-0000-000000000761",
+ "id": "00000000-0000-0000-0000-000000000777",
"viewFieldGroups": {},
"viewFields": {
"id": {
- "id": "00000000-0000-0000-0000-000000000756",
+ "id": "00000000-0000-0000-0000-000000000772",
},
"targetCompany": {
- "id": "00000000-0000-0000-0000-000000000759",
+ "id": "00000000-0000-0000-0000-000000000775",
},
"targetOpportunity": {
- "id": "00000000-0000-0000-0000-000000000760",
+ "id": "00000000-0000-0000-0000-000000000776",
},
"targetPerson": {
- "id": "00000000-0000-0000-0000-000000000758",
+ "id": "00000000-0000-0000-0000-000000000774",
},
"task": {
- "id": "00000000-0000-0000-0000-000000000757",
+ "id": "00000000-0000-0000-0000-000000000773",
},
},
"viewGroups": {},
@@ -2562,128 +2613,128 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"timelineActivity": {
"fields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000764",
+ "id": "00000000-0000-0000-0000-000000000780",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000767",
+ "id": "00000000-0000-0000-0000-000000000783",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000000766",
+ "id": "00000000-0000-0000-0000-000000000782",
},
"happensAt": {
- "id": "00000000-0000-0000-0000-000000000773",
+ "id": "00000000-0000-0000-0000-000000000789",
},
"id": {
- "id": "00000000-0000-0000-0000-000000000763",
+ "id": "00000000-0000-0000-0000-000000000779",
},
"linkedObjectMetadataId": {
- "id": "00000000-0000-0000-0000-000000000789",
+ "id": "00000000-0000-0000-0000-000000000805",
},
"linkedRecordCachedName": {
- "id": "00000000-0000-0000-0000-000000000787",
+ "id": "00000000-0000-0000-0000-000000000803",
},
"linkedRecordId": {
- "id": "00000000-0000-0000-0000-000000000788",
+ "id": "00000000-0000-0000-0000-000000000804",
},
"position": {
- "id": "00000000-0000-0000-0000-000000000769",
+ "id": "00000000-0000-0000-0000-000000000785",
},
"properties": {
- "id": "00000000-0000-0000-0000-000000000774",
+ "id": "00000000-0000-0000-0000-000000000790",
},
"searchVector": {
- "id": "00000000-0000-0000-0000-000000000770",
+ "id": "00000000-0000-0000-0000-000000000786",
},
"targetCompany": {
- "id": "00000000-0000-0000-0000-000000000777",
+ "id": "00000000-0000-0000-0000-000000000793",
},
"targetDashboard": {
- "id": "00000000-0000-0000-0000-000000000784",
+ "id": "00000000-0000-0000-0000-000000000800",
},
"targetMessageCampaign": {
- "id": "00000000-0000-0000-0000-000000000786",
+ "id": "00000000-0000-0000-0000-000000000802",
},
"targetMessageList": {
- "id": "00000000-0000-0000-0000-000000000785",
+ "id": "00000000-0000-0000-0000-000000000801",
},
"targetNote": {
- "id": "00000000-0000-0000-0000-000000000780",
+ "id": "00000000-0000-0000-0000-000000000796",
},
"targetOpportunity": {
- "id": "00000000-0000-0000-0000-000000000778",
+ "id": "00000000-0000-0000-0000-000000000794",
},
"targetPerson": {
- "id": "00000000-0000-0000-0000-000000000776",
+ "id": "00000000-0000-0000-0000-000000000792",
},
"targetTask": {
- "id": "00000000-0000-0000-0000-000000000779",
+ "id": "00000000-0000-0000-0000-000000000795",
},
"targetWorkflow": {
- "id": "00000000-0000-0000-0000-000000000781",
+ "id": "00000000-0000-0000-0000-000000000797",
},
"targetWorkflowRun": {
- "id": "00000000-0000-0000-0000-000000000783",
+ "id": "00000000-0000-0000-0000-000000000799",
},
"targetWorkflowVersion": {
- "id": "00000000-0000-0000-0000-000000000782",
+ "id": "00000000-0000-0000-0000-000000000798",
},
"timelineActivityTypeId": {
- "id": "00000000-0000-0000-0000-000000000771",
+ "id": "00000000-0000-0000-0000-000000000787",
},
"timelineActivityTypeSnapshot": {
- "id": "00000000-0000-0000-0000-000000000772",
+ "id": "00000000-0000-0000-0000-000000000788",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000765",
+ "id": "00000000-0000-0000-0000-000000000781",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000768",
+ "id": "00000000-0000-0000-0000-000000000784",
},
"workspaceMember": {
- "id": "00000000-0000-0000-0000-000000000775",
+ "id": "00000000-0000-0000-0000-000000000791",
},
},
- "id": "00000000-0000-0000-0000-000000000803",
+ "id": "00000000-0000-0000-0000-000000000819",
"views": {
"allTimelineActivities": {
- "id": "00000000-0000-0000-0000-000000000802",
+ "id": "00000000-0000-0000-0000-000000000818",
"viewFieldGroups": {},
"viewFields": {
"happensAt": {
- "id": "00000000-0000-0000-0000-000000000791",
+ "id": "00000000-0000-0000-0000-000000000807",
},
"linkedRecordCachedName": {
- "id": "00000000-0000-0000-0000-000000000790",
+ "id": "00000000-0000-0000-0000-000000000806",
},
"targetCompany": {
- "id": "00000000-0000-0000-0000-000000000794",
+ "id": "00000000-0000-0000-0000-000000000810",
},
"targetDashboard": {
- "id": "00000000-0000-0000-0000-000000000801",
+ "id": "00000000-0000-0000-0000-000000000817",
},
"targetNote": {
- "id": "00000000-0000-0000-0000-000000000797",
+ "id": "00000000-0000-0000-0000-000000000813",
},
"targetOpportunity": {
- "id": "00000000-0000-0000-0000-000000000795",
+ "id": "00000000-0000-0000-0000-000000000811",
},
"targetPerson": {
- "id": "00000000-0000-0000-0000-000000000793",
+ "id": "00000000-0000-0000-0000-000000000809",
},
"targetTask": {
- "id": "00000000-0000-0000-0000-000000000796",
+ "id": "00000000-0000-0000-0000-000000000812",
},
"targetWorkflow": {
- "id": "00000000-0000-0000-0000-000000000798",
+ "id": "00000000-0000-0000-0000-000000000814",
},
"targetWorkflowRun": {
- "id": "00000000-0000-0000-0000-000000000800",
+ "id": "00000000-0000-0000-0000-000000000816",
},
"targetWorkflowVersion": {
- "id": "00000000-0000-0000-0000-000000000799",
+ "id": "00000000-0000-0000-0000-000000000815",
},
"workspaceMember": {
- "id": "00000000-0000-0000-0000-000000000792",
+ "id": "00000000-0000-0000-0000-000000000808",
},
},
"viewGroups": {},
@@ -2693,80 +2744,80 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"workflow": {
"fields": {
"attachments": {
- "id": "00000000-0000-0000-0000-000000000820",
+ "id": "00000000-0000-0000-0000-000000000836",
},
"automatedTriggers": {
- "id": "00000000-0000-0000-0000-000000000818",
+ "id": "00000000-0000-0000-0000-000000000834",
},
"coreWorkflowId": {
- "id": "00000000-0000-0000-0000-000000000814",
+ "id": "00000000-0000-0000-0000-000000000830",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000805",
+ "id": "00000000-0000-0000-0000-000000000821",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000808",
+ "id": "00000000-0000-0000-0000-000000000824",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000000807",
+ "id": "00000000-0000-0000-0000-000000000823",
},
"id": {
- "id": "00000000-0000-0000-0000-000000000804",
+ "id": "00000000-0000-0000-0000-000000000820",
},
"lastPublishedVersionId": {
- "id": "00000000-0000-0000-0000-000000000813",
+ "id": "00000000-0000-0000-0000-000000000829",
},
"name": {
- "id": "00000000-0000-0000-0000-000000000812",
+ "id": "00000000-0000-0000-0000-000000000828",
},
"position": {
- "id": "00000000-0000-0000-0000-000000000810",
+ "id": "00000000-0000-0000-0000-000000000826",
},
"runs": {
- "id": "00000000-0000-0000-0000-000000000817",
+ "id": "00000000-0000-0000-0000-000000000833",
},
"searchVector": {
- "id": "00000000-0000-0000-0000-000000000811",
+ "id": "00000000-0000-0000-0000-000000000827",
},
"statuses": {
- "id": "00000000-0000-0000-0000-000000000815",
+ "id": "00000000-0000-0000-0000-000000000831",
},
"timelineActivities": {
- "id": "00000000-0000-0000-0000-000000000819",
+ "id": "00000000-0000-0000-0000-000000000835",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000806",
+ "id": "00000000-0000-0000-0000-000000000822",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000809",
+ "id": "00000000-0000-0000-0000-000000000825",
},
"versions": {
- "id": "00000000-0000-0000-0000-000000000816",
+ "id": "00000000-0000-0000-0000-000000000832",
},
},
- "id": "00000000-0000-0000-0000-000000000828",
+ "id": "00000000-0000-0000-0000-000000000844",
"views": {
"allWorkflows": {
- "id": "00000000-0000-0000-0000-000000000827",
+ "id": "00000000-0000-0000-0000-000000000843",
"viewFieldGroups": {},
"viewFields": {
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000824",
+ "id": "00000000-0000-0000-0000-000000000840",
},
"name": {
- "id": "00000000-0000-0000-0000-000000000821",
+ "id": "00000000-0000-0000-0000-000000000837",
},
"runs": {
- "id": "00000000-0000-0000-0000-000000000826",
+ "id": "00000000-0000-0000-0000-000000000842",
},
"statuses": {
- "id": "00000000-0000-0000-0000-000000000822",
+ "id": "00000000-0000-0000-0000-000000000838",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000823",
+ "id": "00000000-0000-0000-0000-000000000839",
},
"versions": {
- "id": "00000000-0000-0000-0000-000000000825",
+ "id": "00000000-0000-0000-0000-000000000841",
},
},
"viewGroups": {},
@@ -2776,79 +2827,79 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"workflowAutomatedTrigger": {
"fields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000830",
+ "id": "00000000-0000-0000-0000-000000000846",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000833",
+ "id": "00000000-0000-0000-0000-000000000849",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000000832",
+ "id": "00000000-0000-0000-0000-000000000848",
},
"id": {
- "id": "00000000-0000-0000-0000-000000000829",
+ "id": "00000000-0000-0000-0000-000000000845",
},
"position": {
- "id": "00000000-0000-0000-0000-000000000835",
+ "id": "00000000-0000-0000-0000-000000000851",
},
"searchVector": {
- "id": "00000000-0000-0000-0000-000000000836",
+ "id": "00000000-0000-0000-0000-000000000852",
},
"settings": {
- "id": "00000000-0000-0000-0000-000000000838",
+ "id": "00000000-0000-0000-0000-000000000854",
},
"type": {
- "id": "00000000-0000-0000-0000-000000000837",
+ "id": "00000000-0000-0000-0000-000000000853",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000831",
+ "id": "00000000-0000-0000-0000-000000000847",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000834",
+ "id": "00000000-0000-0000-0000-000000000850",
},
"workflow": {
- "id": "00000000-0000-0000-0000-000000000839",
+ "id": "00000000-0000-0000-0000-000000000855",
},
},
- "id": "00000000-0000-0000-0000-000000000851",
+ "id": "00000000-0000-0000-0000-000000000867",
"views": {
"allWorkflowAutomatedTriggers": {
- "id": "00000000-0000-0000-0000-000000000843",
+ "id": "00000000-0000-0000-0000-000000000859",
"viewFieldGroups": {},
"viewFields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000842",
+ "id": "00000000-0000-0000-0000-000000000858",
},
"type": {
- "id": "00000000-0000-0000-0000-000000000840",
+ "id": "00000000-0000-0000-0000-000000000856",
},
"workflow": {
- "id": "00000000-0000-0000-0000-000000000841",
+ "id": "00000000-0000-0000-0000-000000000857",
},
},
"viewGroups": {},
},
"workflowAutomatedTriggerRecordPageFields": {
- "id": "00000000-0000-0000-0000-000000000850",
+ "id": "00000000-0000-0000-0000-000000000866",
"viewFieldGroups": {
"general": {
- "id": "00000000-0000-0000-0000-000000000848",
+ "id": "00000000-0000-0000-0000-000000000864",
},
"system": {
- "id": "00000000-0000-0000-0000-000000000849",
+ "id": "00000000-0000-0000-0000-000000000865",
},
},
"viewFields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000846",
+ "id": "00000000-0000-0000-0000-000000000862",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000847",
+ "id": "00000000-0000-0000-0000-000000000863",
},
"type": {
- "id": "00000000-0000-0000-0000-000000000844",
+ "id": "00000000-0000-0000-0000-000000000860",
},
"workflow": {
- "id": "00000000-0000-0000-0000-000000000845",
+ "id": "00000000-0000-0000-0000-000000000861",
},
},
"viewGroups": {},
@@ -2858,130 +2909,130 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"workflowRun": {
"fields": {
"coreWorkflowId": {
- "id": "00000000-0000-0000-0000-000000000869",
+ "id": "00000000-0000-0000-0000-000000000885",
},
"coreWorkflowVersionId": {
- "id": "00000000-0000-0000-0000-000000000870",
+ "id": "00000000-0000-0000-0000-000000000886",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000853",
+ "id": "00000000-0000-0000-0000-000000000869",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000856",
+ "id": "00000000-0000-0000-0000-000000000872",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000000855",
+ "id": "00000000-0000-0000-0000-000000000871",
},
"endedAt": {
- "id": "00000000-0000-0000-0000-000000000865",
+ "id": "00000000-0000-0000-0000-000000000881",
},
"enqueuedAt": {
- "id": "00000000-0000-0000-0000-000000000863",
+ "id": "00000000-0000-0000-0000-000000000879",
},
"id": {
- "id": "00000000-0000-0000-0000-000000000852",
+ "id": "00000000-0000-0000-0000-000000000868",
},
"name": {
- "id": "00000000-0000-0000-0000-000000000860",
+ "id": "00000000-0000-0000-0000-000000000876",
},
"position": {
- "id": "00000000-0000-0000-0000-000000000858",
+ "id": "00000000-0000-0000-0000-000000000874",
},
"searchVector": {
- "id": "00000000-0000-0000-0000-000000000859",
+ "id": "00000000-0000-0000-0000-000000000875",
},
"startedAt": {
- "id": "00000000-0000-0000-0000-000000000864",
+ "id": "00000000-0000-0000-0000-000000000880",
},
"state": {
- "id": "00000000-0000-0000-0000-000000000867",
+ "id": "00000000-0000-0000-0000-000000000883",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000866",
+ "id": "00000000-0000-0000-0000-000000000882",
},
"stepLogs": {
- "id": "00000000-0000-0000-0000-000000000868",
+ "id": "00000000-0000-0000-0000-000000000884",
},
"timelineActivities": {
- "id": "00000000-0000-0000-0000-000000000871",
+ "id": "00000000-0000-0000-0000-000000000887",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000854",
+ "id": "00000000-0000-0000-0000-000000000870",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000857",
+ "id": "00000000-0000-0000-0000-000000000873",
},
"workflow": {
- "id": "00000000-0000-0000-0000-000000000862",
+ "id": "00000000-0000-0000-0000-000000000878",
},
"workflowVersion": {
- "id": "00000000-0000-0000-0000-000000000861",
+ "id": "00000000-0000-0000-0000-000000000877",
},
},
- "id": "00000000-0000-0000-0000-000000000891",
+ "id": "00000000-0000-0000-0000-000000000907",
"views": {
"allWorkflowRuns": {
- "id": "00000000-0000-0000-0000-000000000875",
+ "id": "00000000-0000-0000-0000-000000000891",
"viewFieldGroups": {},
"viewFields": {
"name": {
- "id": "00000000-0000-0000-0000-000000000872",
+ "id": "00000000-0000-0000-0000-000000000888",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000874",
+ "id": "00000000-0000-0000-0000-000000000890",
},
"workflow": {
- "id": "00000000-0000-0000-0000-000000000873",
+ "id": "00000000-0000-0000-0000-000000000889",
},
},
"viewGroups": {},
},
"workflowRunRecordPageFields": {
- "id": "00000000-0000-0000-0000-000000000890",
+ "id": "00000000-0000-0000-0000-000000000906",
"viewFieldGroups": {
"general": {
- "id": "00000000-0000-0000-0000-000000000888",
+ "id": "00000000-0000-0000-0000-000000000904",
},
"system": {
- "id": "00000000-0000-0000-0000-000000000889",
+ "id": "00000000-0000-0000-0000-000000000905",
},
},
"viewFields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000881",
+ "id": "00000000-0000-0000-0000-000000000897",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000882",
+ "id": "00000000-0000-0000-0000-000000000898",
},
"endedAt": {
- "id": "00000000-0000-0000-0000-000000000880",
+ "id": "00000000-0000-0000-0000-000000000896",
},
"enqueuedAt": {
- "id": "00000000-0000-0000-0000-000000000883",
+ "id": "00000000-0000-0000-0000-000000000899",
},
"startedAt": {
- "id": "00000000-0000-0000-0000-000000000879",
+ "id": "00000000-0000-0000-0000-000000000895",
},
"state": {
- "id": "00000000-0000-0000-0000-000000000884",
+ "id": "00000000-0000-0000-0000-000000000900",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000876",
+ "id": "00000000-0000-0000-0000-000000000892",
},
"timelineActivities": {
- "id": "00000000-0000-0000-0000-000000000887",
+ "id": "00000000-0000-0000-0000-000000000903",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000885",
+ "id": "00000000-0000-0000-0000-000000000901",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000886",
+ "id": "00000000-0000-0000-0000-000000000902",
},
"workflow": {
- "id": "00000000-0000-0000-0000-000000000877",
+ "id": "00000000-0000-0000-0000-000000000893",
},
"workflowVersion": {
- "id": "00000000-0000-0000-0000-000000000878",
+ "id": "00000000-0000-0000-0000-000000000894",
},
},
"viewGroups": {},
@@ -2991,118 +3042,118 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"workflowVersion": {
"fields": {
"coreWorkflowVersionId": {
- "id": "00000000-0000-0000-0000-000000000906",
+ "id": "00000000-0000-0000-0000-000000000922",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000893",
+ "id": "00000000-0000-0000-0000-000000000909",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000896",
+ "id": "00000000-0000-0000-0000-000000000912",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000000895",
+ "id": "00000000-0000-0000-0000-000000000911",
},
"id": {
- "id": "00000000-0000-0000-0000-000000000892",
+ "id": "00000000-0000-0000-0000-000000000908",
},
"name": {
- "id": "00000000-0000-0000-0000-000000000900",
+ "id": "00000000-0000-0000-0000-000000000916",
},
"position": {
- "id": "00000000-0000-0000-0000-000000000898",
+ "id": "00000000-0000-0000-0000-000000000914",
},
"runs": {
- "id": "00000000-0000-0000-0000-000000000904",
+ "id": "00000000-0000-0000-0000-000000000920",
},
"searchVector": {
- "id": "00000000-0000-0000-0000-000000000899",
+ "id": "00000000-0000-0000-0000-000000000915",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000903",
+ "id": "00000000-0000-0000-0000-000000000919",
},
"steps": {
- "id": "00000000-0000-0000-0000-000000000905",
+ "id": "00000000-0000-0000-0000-000000000921",
},
"timelineActivities": {
- "id": "00000000-0000-0000-0000-000000000907",
+ "id": "00000000-0000-0000-0000-000000000923",
},
"trigger": {
- "id": "00000000-0000-0000-0000-000000000902",
+ "id": "00000000-0000-0000-0000-000000000918",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000894",
+ "id": "00000000-0000-0000-0000-000000000910",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000897",
+ "id": "00000000-0000-0000-0000-000000000913",
},
"workflow": {
- "id": "00000000-0000-0000-0000-000000000901",
+ "id": "00000000-0000-0000-0000-000000000917",
},
},
- "id": "00000000-0000-0000-0000-000000000927",
+ "id": "00000000-0000-0000-0000-000000000943",
"views": {
"allWorkflowVersions": {
- "id": "00000000-0000-0000-0000-000000000913",
+ "id": "00000000-0000-0000-0000-000000000929",
"viewFieldGroups": {},
"viewFields": {
"name": {
- "id": "00000000-0000-0000-0000-000000000908",
+ "id": "00000000-0000-0000-0000-000000000924",
},
"runs": {
- "id": "00000000-0000-0000-0000-000000000912",
+ "id": "00000000-0000-0000-0000-000000000928",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000910",
+ "id": "00000000-0000-0000-0000-000000000926",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000911",
+ "id": "00000000-0000-0000-0000-000000000927",
},
"workflow": {
- "id": "00000000-0000-0000-0000-000000000909",
+ "id": "00000000-0000-0000-0000-000000000925",
},
},
"viewGroups": {},
},
"workflowVersionRecordPageFields": {
- "id": "00000000-0000-0000-0000-000000000926",
+ "id": "00000000-0000-0000-0000-000000000942",
"viewFieldGroups": {
"general": {
- "id": "00000000-0000-0000-0000-000000000924",
+ "id": "00000000-0000-0000-0000-000000000940",
},
"system": {
- "id": "00000000-0000-0000-0000-000000000925",
+ "id": "00000000-0000-0000-0000-000000000941",
},
},
"viewFields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000917",
+ "id": "00000000-0000-0000-0000-000000000933",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000919",
+ "id": "00000000-0000-0000-0000-000000000935",
},
"runs": {
- "id": "00000000-0000-0000-0000-000000000922",
+ "id": "00000000-0000-0000-0000-000000000938",
},
"status": {
- "id": "00000000-0000-0000-0000-000000000914",
+ "id": "00000000-0000-0000-0000-000000000930",
},
"steps": {
- "id": "00000000-0000-0000-0000-000000000918",
+ "id": "00000000-0000-0000-0000-000000000934",
},
"timelineActivities": {
- "id": "00000000-0000-0000-0000-000000000923",
+ "id": "00000000-0000-0000-0000-000000000939",
},
"trigger": {
- "id": "00000000-0000-0000-0000-000000000916",
+ "id": "00000000-0000-0000-0000-000000000932",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000920",
+ "id": "00000000-0000-0000-0000-000000000936",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000921",
+ "id": "00000000-0000-0000-0000-000000000937",
},
"workflow": {
- "id": "00000000-0000-0000-0000-000000000915",
+ "id": "00000000-0000-0000-0000-000000000931",
},
},
"viewGroups": {},
@@ -3112,110 +3163,110 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"workspaceMember": {
"fields": {
"accountOwnerForCompanies": {
- "id": "00000000-0000-0000-0000-000000000947",
+ "id": "00000000-0000-0000-0000-000000000963",
},
"assignedTasks": {
- "id": "00000000-0000-0000-0000-000000000945",
+ "id": "00000000-0000-0000-0000-000000000961",
},
"avatarUrl": {
- "id": "00000000-0000-0000-0000-000000000941",
+ "id": "00000000-0000-0000-0000-000000000957",
},
"blocklist": {
- "id": "00000000-0000-0000-0000-000000000949",
+ "id": "00000000-0000-0000-0000-000000000965",
},
"calendarEventParticipants": {
- "id": "00000000-0000-0000-0000-000000000950",
+ "id": "00000000-0000-0000-0000-000000000966",
},
"calendarStartDay": {
- "id": "00000000-0000-0000-0000-000000000955",
+ "id": "00000000-0000-0000-0000-000000000971",
},
"colorScheme": {
- "id": "00000000-0000-0000-0000-000000000937",
+ "id": "00000000-0000-0000-0000-000000000953",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000929",
+ "id": "00000000-0000-0000-0000-000000000945",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000000932",
+ "id": "00000000-0000-0000-0000-000000000948",
},
"dateFormat": {
- "id": "00000000-0000-0000-0000-000000000953",
+ "id": "00000000-0000-0000-0000-000000000969",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000000931",
+ "id": "00000000-0000-0000-0000-000000000947",
},
"id": {
- "id": "00000000-0000-0000-0000-000000000928",
+ "id": "00000000-0000-0000-0000-000000000944",
},
"jobTitle": {
- "id": "00000000-0000-0000-0000-000000000943",
+ "id": "00000000-0000-0000-0000-000000000959",
},
"locale": {
- "id": "00000000-0000-0000-0000-000000000940",
+ "id": "00000000-0000-0000-0000-000000000956",
},
"messageParticipants": {
- "id": "00000000-0000-0000-0000-000000000948",
+ "id": "00000000-0000-0000-0000-000000000964",
},
"name": {
- "id": "00000000-0000-0000-0000-000000000936",
+ "id": "00000000-0000-0000-0000-000000000952",
},
"numberFormat": {
- "id": "00000000-0000-0000-0000-000000000956",
+ "id": "00000000-0000-0000-0000-000000000972",
},
"openRecordIn": {
- "id": "00000000-0000-0000-0000-000000000939",
+ "id": "00000000-0000-0000-0000-000000000955",
},
"ownedOpportunities": {
- "id": "00000000-0000-0000-0000-000000000946",
+ "id": "00000000-0000-0000-0000-000000000962",
},
"position": {
- "id": "00000000-0000-0000-0000-000000000934",
+ "id": "00000000-0000-0000-0000-000000000950",
},
"searchVector": {
- "id": "00000000-0000-0000-0000-000000000935",
+ "id": "00000000-0000-0000-0000-000000000951",
},
"timeFormat": {
- "id": "00000000-0000-0000-0000-000000000954",
+ "id": "00000000-0000-0000-0000-000000000970",
},
"timeZone": {
- "id": "00000000-0000-0000-0000-000000000952",
+ "id": "00000000-0000-0000-0000-000000000968",
},
"timelineActivities": {
- "id": "00000000-0000-0000-0000-000000000951",
+ "id": "00000000-0000-0000-0000-000000000967",
},
"uiScale": {
- "id": "00000000-0000-0000-0000-000000000938",
+ "id": "00000000-0000-0000-0000-000000000954",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000000930",
+ "id": "00000000-0000-0000-0000-000000000946",
},
"updatedBy": {
- "id": "00000000-0000-0000-0000-000000000933",
+ "id": "00000000-0000-0000-0000-000000000949",
},
"userEmail": {
- "id": "00000000-0000-0000-0000-000000000942",
+ "id": "00000000-0000-0000-0000-000000000958",
},
"userId": {
- "id": "00000000-0000-0000-0000-000000000944",
+ "id": "00000000-0000-0000-0000-000000000960",
},
},
- "id": "00000000-0000-0000-0000-000000000962",
+ "id": "00000000-0000-0000-0000-000000000978",
"views": {
"allWorkspaceMembers": {
- "id": "00000000-0000-0000-0000-000000000961",
+ "id": "00000000-0000-0000-0000-000000000977",
"viewFieldGroups": {},
"viewFields": {
"assignedTasks": {
- "id": "00000000-0000-0000-0000-000000000960",
+ "id": "00000000-0000-0000-0000-000000000976",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000000958",
+ "id": "00000000-0000-0000-0000-000000000974",
},
"name": {
- "id": "00000000-0000-0000-0000-000000000957",
+ "id": "00000000-0000-0000-0000-000000000973",
},
"ownedOpportunities": {
- "id": "00000000-0000-0000-0000-000000000959",
+ "id": "00000000-0000-0000-0000-000000000975",
},
},
"viewGroups": {},
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/compute-record-share-standard-metadata.spec.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/compute-record-share-standard-metadata.spec.ts
new file mode 100644
index 00000000000..2c24de821ea
--- /dev/null
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/compute-record-share-standard-metadata.spec.ts
@@ -0,0 +1,95 @@
+import { STANDARD_OBJECTS } from 'twenty-shared/metadata';
+import { MetadataReadability, MetadataWritability } from 'twenty-shared/types';
+import { isDefined } from 'twenty-shared/utils';
+
+import { computeTwentyStandardApplicationAllFlatEntityMaps } from 'src/engine/workspace-manager/twenty-standard-application/utils/twenty-standard-application-all-flat-entity-maps.constant';
+
+const WORKSPACE_ID = '20202020-1111-4111-8111-111111111111';
+const TWENTY_STANDARD_APPLICATION_ID = '20202020-2222-4222-8222-222222222222';
+const NOW = '2024-01-01T00:00:00.000Z';
+
+describe('RecordShare standard metadata build', () => {
+ const { allFlatEntityMaps } =
+ computeTwentyStandardApplicationAllFlatEntityMaps({
+ now: NOW,
+ workspaceId: WORKSPACE_ID,
+ twentyStandardApplicationId: TWENTY_STANDARD_APPLICATION_ID,
+ });
+
+ const recordShare =
+ allFlatEntityMaps.flatObjectMetadataMaps.byUniversalIdentifier[
+ STANDARD_OBJECTS.recordShare.universalIdentifier
+ ];
+
+ it('builds recordShare as a hidden system object with SYSTEM readability and writability', () => {
+ expect(recordShare).toMatchObject({
+ nameSingular: 'recordShare',
+ isSystem: true,
+ isSearchable: false,
+ isAuditLogged: false,
+ isUICreatable: false,
+ isUIEditable: false,
+ writability: MetadataWritability.SYSTEM,
+ readability: MetadataReadability.SYSTEM,
+ });
+ });
+
+ const getIndexedFieldUniversalIdentifiers = (
+ indexName: keyof typeof STANDARD_OBJECTS.recordShare.indexes,
+ ) =>
+ allFlatEntityMaps.flatIndexMaps.byUniversalIdentifier[
+ STANDARD_OBJECTS.recordShare.indexes[indexName].universalIdentifier
+ ]?.flatIndexFieldMetadatas
+ .map((indexField) =>
+ Object.values(
+ allFlatEntityMaps.flatFieldMetadataMaps.byUniversalIdentifier,
+ )
+ .filter(isDefined)
+ .find(
+ (flatFieldMetadata) =>
+ flatFieldMetadata.id === indexField.fieldMetadataId,
+ ),
+ )
+ .filter(isDefined)
+ .map((flatFieldMetadata) => flatFieldMetadata.universalIdentifier);
+
+ it('enforces one share row per object, record, principal, cause and source', () => {
+ expect(
+ allFlatEntityMaps.flatIndexMaps.byUniversalIdentifier[
+ STANDARD_OBJECTS.recordShare.indexes
+ .recordPrincipalCauseSourceUniqueIndex.universalIdentifier
+ ],
+ ).toMatchObject({ isUnique: true, indexWhereClause: null });
+ expect(
+ getIndexedFieldUniversalIdentifiers(
+ 'recordPrincipalCauseSourceUniqueIndex',
+ ),
+ ).toEqual([
+ STANDARD_OBJECTS.recordShare.fields.objectMetadataId.universalIdentifier,
+ STANDARD_OBJECTS.recordShare.fields.recordId.universalIdentifier,
+ STANDARD_OBJECTS.recordShare.fields.principalId.universalIdentifier,
+ STANDARD_OBJECTS.recordShare.fields.rowCause.universalIdentifier,
+ STANDARD_OBJECTS.recordShare.fields.sourceId.universalIdentifier,
+ ]);
+ });
+
+ it('indexes the lookups the read gate and the writers need', () => {
+ expect(getIndexedFieldUniversalIdentifiers('principalIdIndex')).toEqual([
+ STANDARD_OBJECTS.recordShare.fields.principalId.universalIdentifier,
+ ]);
+ expect(getIndexedFieldUniversalIdentifiers('sourceIdIndex')).toEqual([
+ STANDARD_OBJECTS.recordShare.fields.sourceId.universalIdentifier,
+ ]);
+ });
+
+ it('declares no view for recordShare', () => {
+ const recordShareViews = Object.values(
+ allFlatEntityMaps.flatViewMaps.byUniversalIdentifier,
+ )
+ .filter(isDefined)
+ .filter((view) => view.objectMetadataId === recordShare?.id);
+
+ expect(Object.keys(STANDARD_OBJECTS.recordShare.views)).toHaveLength(0);
+ expect(recordShareViews).toHaveLength(0);
+ });
+});
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/standard-object-readability.spec.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/standard-object-readability.spec.ts
index 86c0cac4b00..e5d9c7cac98 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/standard-object-readability.spec.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/standard-object-readability.spec.ts
@@ -1,4 +1,5 @@
-import { MetadataReadability } from 'twenty-shared/types';
+import { STANDARD_OBJECTS } from 'twenty-shared/metadata';
+import { MetadataReadability, MetadataWritability } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { computeTwentyStandardApplicationAllFlatEntityMaps } from 'src/engine/workspace-manager/twenty-standard-application/utils/twenty-standard-application-all-flat-entity-maps.constant';
@@ -19,14 +20,33 @@ describe('Standard object readability', () => {
allFlatEntityMaps.flatObjectMetadataMaps.byUniversalIdentifier,
).filter(isDefined);
- it('leaves every standard object OPEN', () => {
+ const recordShareFlatObjectMetadata = standardFlatObjectMetadatas.find(
+ (flatObjectMetadata) =>
+ flatObjectMetadata.universalIdentifier ===
+ STANDARD_OBJECTS.recordShare.universalIdentifier,
+ );
+
+ const otherStandardFlatObjectMetadatas = standardFlatObjectMetadatas.filter(
+ (flatObjectMetadata) =>
+ flatObjectMetadata.universalIdentifier !==
+ STANDARD_OBJECTS.recordShare.universalIdentifier,
+ );
+
+ it('declares recordShare SYSTEM for readability and writability', () => {
+ expect(recordShareFlatObjectMetadata).toMatchObject({
+ readability: MetadataReadability.SYSTEM,
+ writability: MetadataWritability.SYSTEM,
+ });
+ });
+
+ it('leaves every other standard object OPEN for readability', () => {
const readabilities = new Set(
- standardFlatObjectMetadatas.map(
+ otherStandardFlatObjectMetadatas.map(
(flatObjectMetadata) => flatObjectMetadata.readability,
),
);
- expect(standardFlatObjectMetadatas.length).toBeGreaterThan(0);
+ expect(otherStandardFlatObjectMetadatas.length).toBeGreaterThan(0);
expect([...readabilities]).toEqual([MetadataReadability.OPEN]);
});
});
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/standard-object-writability.spec.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/standard-object-writability.spec.ts
index 33e115cebba..95721a513c1 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/standard-object-writability.spec.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/standard-object-writability.spec.ts
@@ -14,6 +14,7 @@ const SYSTEM_WRITABILITY_STANDARD_OBJECT_NAMES = [
'calendarChannelEventAssociation',
'messageChannelMessageAssociation',
'messageChannelMessageAssociationMessageFolder',
+ 'recordShare',
'workflowAutomatedTrigger',
];
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/build-standard-flat-field-metadata-maps.util.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/build-standard-flat-field-metadata-maps.util.ts
index cf1f048d25d..042949489e2 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/build-standard-flat-field-metadata-maps.util.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/build-standard-flat-field-metadata-maps.util.ts
@@ -27,6 +27,7 @@ import { buildNoteStandardFlatFieldMetadatas } from 'src/engine/workspace-manage
import { buildNoteTargetStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-note-target-standard-flat-field-metadata.util';
import { buildOpportunityStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-opportunity-standard-flat-field-metadata.util';
import { buildPersonStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-person-standard-flat-field-metadata.util';
+import { buildRecordShareStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-record-share-standard-flat-field-metadata.util';
import { buildTaskStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-task-standard-flat-field-metadata.util';
import { buildTaskTargetStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-task-target-standard-flat-field-metadata.util';
import { buildTimelineActivityStandardFlatFieldMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-timeline-activity-standard-flat-field-metadata.util';
@@ -68,6 +69,7 @@ const STANDARD_FLAT_FIELD_METADATA_BUILDERS_BY_OBJECT_NAME = {
noteTarget: buildNoteTargetStandardFlatFieldMetadatas,
opportunity: buildOpportunityStandardFlatFieldMetadatas,
person: buildPersonStandardFlatFieldMetadatas,
+ recordShare: buildRecordShareStandardFlatFieldMetadatas,
task: buildTaskStandardFlatFieldMetadatas,
taskTarget: buildTaskTargetStandardFlatFieldMetadatas,
timelineActivity: buildTimelineActivityStandardFlatFieldMetadatas,
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-record-share-standard-flat-field-metadata.util.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-record-share-standard-flat-field-metadata.util.ts
new file mode 100644
index 00000000000..a6742bb7c9f
--- /dev/null
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-record-share-standard-flat-field-metadata.util.ts
@@ -0,0 +1,510 @@
+import { msg } from '@lingui/core/macro';
+import { i18nLabel } from 'src/engine/workspace-manager/twenty-standard-application/utils/i18n-label.util';
+import {
+ DateDisplayFormat,
+ FieldMetadataType,
+ RecordShareAccessLevel,
+ RecordSharePrincipalType,
+ RecordShareRowCause,
+} from 'twenty-shared/types';
+
+import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
+import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
+import {
+ type CreateStandardFieldArgs,
+ createStandardFieldFlatMetadata,
+} from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/create-standard-field-flat-metadata.util';
+
+export const buildRecordShareStandardFlatFieldMetadatas = ({
+ now,
+ objectName,
+ workspaceId,
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+}: Omit<
+ CreateStandardFieldArgs<'recordShare', FieldMetadataType>,
+ 'context'
+>): Record<AllStandardObjectFieldName<'recordShare'>, FlatFieldMetadata> => ({
+ id: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'id',
+ type: FieldMetadataType.UUID,
+ label: i18nLabel(msg({ message: `Id`, context: 'fieldMetadata.label' })),
+ description: i18nLabel(
+ msg({ message: `Id`, context: 'fieldMetadata.description' }),
+ ),
+ icon: 'Icon123',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ defaultValue: 'uuid',
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ createdAt: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'createdAt',
+ type: FieldMetadataType.DATE_TIME,
+ label: i18nLabel(
+ msg({ message: `Creation date`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({ message: `Creation date`, context: 'fieldMetadata.description' }),
+ ),
+ icon: 'IconCalendar',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ defaultValue: 'now',
+ settings: { displayFormat: DateDisplayFormat.RELATIVE },
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ updatedAt: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'updatedAt',
+ type: FieldMetadataType.DATE_TIME,
+ label: i18nLabel(
+ msg({ message: `Last update`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Last time the record was changed`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconCalendarClock',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ defaultValue: 'now',
+ settings: { displayFormat: DateDisplayFormat.RELATIVE },
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ deletedAt: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'deletedAt',
+ type: FieldMetadataType.DATE_TIME,
+ label: i18nLabel(
+ msg({ message: `Deleted at`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Date when the record was deleted`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconCalendarMinus',
+ isSystem: true,
+ isNullable: true,
+ isUIEditable: false,
+ settings: { displayFormat: DateDisplayFormat.RELATIVE },
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ recordId: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'recordId',
+ type: FieldMetadataType.UUID,
+ label: i18nLabel(
+ msg({ message: `Record ID`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Shared record`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconAbc',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ objectMetadataId: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'objectMetadataId',
+ type: FieldMetadataType.UUID,
+ label: i18nLabel(
+ msg({ message: `Object metadata ID`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Object of the shared record`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconAbc',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ principalId: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'principalId',
+ type: FieldMetadataType.UUID,
+ label: i18nLabel(
+ msg({ message: `Principal ID`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Who receives the access`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconAbc',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ principalType: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'principalType',
+ type: FieldMetadataType.SELECT,
+ label: i18nLabel(
+ msg({ message: `Principal type`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Kind of principal receiving the access`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconUsers',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ options: [
+ {
+ id: '9a4c4d0b-14f7-4732-a435-c5e24a10ff04',
+ value: RecordSharePrincipalType.EVERYONE,
+ label: i18nLabel(
+ msg({ message: `Everyone`, context: 'fieldMetadata.label' }),
+ ),
+ position: 0,
+ color: 'green',
+ },
+ {
+ id: 'be27402b-d26e-4609-8405-86a45a8f9500',
+ value: RecordSharePrincipalType.WORKSPACE_MEMBER,
+ label: i18nLabel(
+ msg({
+ message: `Workspace member`,
+ context: 'fieldMetadata.label',
+ }),
+ ),
+ position: 1,
+ color: 'blue',
+ },
+ {
+ id: '2a82dc80-3c8d-4e6c-918e-0cb868834e51',
+ value: RecordSharePrincipalType.ROLE,
+ label: i18nLabel(
+ msg({ message: `Role`, context: 'fieldMetadata.label' }),
+ ),
+ position: 2,
+ color: 'purple',
+ },
+ ],
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ accessLevel: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'accessLevel',
+ type: FieldMetadataType.SELECT,
+ label: i18nLabel(
+ msg({ message: `Access level`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `What the principal may do with the record`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconLock',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ options: [
+ {
+ id: 'bced0629-b044-40b2-9d89-d19f30caba50',
+ value: RecordShareAccessLevel.READ,
+ label: i18nLabel(
+ msg({ message: `Read`, context: 'fieldMetadata.label' }),
+ ),
+ position: 0,
+ color: 'sky',
+ },
+ {
+ id: '45f2d2a8-28d2-449a-bba0-0433b5da2c17',
+ value: RecordShareAccessLevel.READ_WRITE,
+ label: i18nLabel(
+ msg({ message: `Read and write`, context: 'fieldMetadata.label' }),
+ ),
+ position: 1,
+ color: 'blue',
+ },
+ {
+ id: '64ee2bb2-4c31-4944-b35c-75a993cb345f',
+ value: RecordShareAccessLevel.FULL,
+ label: i18nLabel(
+ msg({ message: `Full`, context: 'fieldMetadata.label' }),
+ ),
+ position: 2,
+ color: 'purple',
+ },
+ ],
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ rowCause: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'rowCause',
+ type: FieldMetadataType.SELECT,
+ label: i18nLabel(
+ msg({ message: `Row cause`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Why the access was granted`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconHistory',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ options: [
+ {
+ id: 'eb280688-c181-4e68-a61f-9d227e8be3f9',
+ value: RecordShareRowCause.OWNER,
+ label: i18nLabel(
+ msg({ message: `Owner`, context: 'fieldMetadata.label' }),
+ ),
+ position: 0,
+ color: 'green',
+ },
+ {
+ id: '09dcbe18-af99-40fe-a24b-fea0d20563aa',
+ value: RecordShareRowCause.MANUAL,
+ label: i18nLabel(
+ msg({ message: `Manual`, context: 'fieldMetadata.label' }),
+ ),
+ position: 1,
+ color: 'blue',
+ },
+ {
+ id: '60cb2015-6762-4a64-a400-68262eeb3b76',
+ value: RecordShareRowCause.RULE,
+ label: i18nLabel(
+ msg({ message: `Rule`, context: 'fieldMetadata.label' }),
+ ),
+ position: 2,
+ color: 'orange',
+ },
+ {
+ id: '427a975f-b87d-4b3d-a366-5cf4e6c43b90',
+ value: RecordShareRowCause.APPLICATION,
+ label: i18nLabel(
+ msg({ message: `Application`, context: 'fieldMetadata.label' }),
+ ),
+ position: 3,
+ color: 'gray',
+ },
+ ],
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ sourceId: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'sourceId',
+ type: FieldMetadataType.UUID,
+ label: i18nLabel(
+ msg({ message: `Source ID`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Owner, sharing rule or application that granted the access`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconAbc',
+ isSystem: true,
+ isNullable: false,
+ isUIEditable: false,
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ createdBy: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'createdBy',
+ type: FieldMetadataType.ACTOR,
+ label: i18nLabel(
+ msg({ message: `Created by`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `The creator of the record`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconCreativeCommonsSa',
+ isSystem: true,
+ isUIEditable: false,
+ isNullable: false,
+ defaultValue: {
+ source: "'MANUAL'",
+ name: "'System'",
+ workspaceMemberId: null,
+ },
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ updatedBy: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'updatedBy',
+ type: FieldMetadataType.ACTOR,
+ label: i18nLabel(
+ msg({ message: `Updated by`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `The workspace member who last updated the record`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconUserCircle',
+ isSystem: true,
+ isUIEditable: false,
+ isNullable: false,
+ defaultValue: {
+ source: "'MANUAL'",
+ name: "'System'",
+ workspaceMemberId: null,
+ },
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ position: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'position',
+ type: FieldMetadataType.POSITION,
+ label: i18nLabel(
+ msg({ message: `Position`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Record share position`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconHierarchy2',
+ isSystem: true,
+ isNullable: false,
+ defaultValue: 0,
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ searchVector: createStandardFieldFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ fieldName: 'searchVector',
+ type: FieldMetadataType.TS_VECTOR,
+ label: i18nLabel(
+ msg({ message: `Search vector`, context: 'fieldMetadata.label' }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Field used for full-text search`,
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconUser',
+ isSystem: true,
+ isNullable: true,
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+});
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/index/build-standard-flat-index-metadata-maps.util.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/index/build-standard-flat-index-metadata-maps.util.ts
index d78990e6e51..74bee2e8e74 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/index/build-standard-flat-index-metadata-maps.util.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/index/build-standard-flat-index-metadata-maps.util.ts
@@ -23,6 +23,7 @@ import { buildNoteStandardFlatIndexMetadatas } from 'src/engine/workspace-manage
import { buildNoteTargetStandardFlatIndexMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/index/compute-note-target-standard-flat-index-metadata.util';
import { buildOpportunityStandardFlatIndexMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/index/compute-opportunity-standard-flat-index-metadata.util';
import { buildPersonStandardFlatIndexMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/index/compute-person-standard-flat-index-metadata.util';
+import { buildRecordShareStandardFlatIndexMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/index/compute-record-share-standard-flat-index-metadata.util';
import { buildTaskStandardFlatIndexMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/index/compute-task-standard-flat-index-metadata.util';
import { buildTaskTargetStandardFlatIndexMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/index/compute-task-target-standard-flat-index-metadata.util';
import { buildTimelineActivityStandardFlatIndexMetadatas } from 'src/engine/workspace-manager/twenty-standard-application/utils/index/compute-timeline-activity-standard-flat-index-metadata.util';
@@ -62,6 +63,7 @@ const STANDARD_FLAT_INDEX_METADATA_BUILDERS_BY_OBJECT_NAME = {
noteTarget: buildNoteTargetStandardFlatIndexMetadatas,
opportunity: buildOpportunityStandardFlatIndexMetadatas,
person: buildPersonStandardFlatIndexMetadatas,
+ recordShare: buildRecordShareStandardFlatIndexMetadatas,
task: buildTaskStandardFlatIndexMetadatas,
taskTarget: buildTaskTargetStandardFlatIndexMetadatas,
timelineActivity: buildTimelineActivityStandardFlatIndexMetadatas,
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/index/compute-record-share-standard-flat-index-metadata.util.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/index/compute-record-share-standard-flat-index-metadata.util.ts
new file mode 100644
index 00000000000..feb19c52ef0
--- /dev/null
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/index/compute-record-share-standard-flat-index-metadata.util.ts
@@ -0,0 +1,62 @@
+import { type FlatIndexMetadata } from 'src/engine/metadata-modules/flat-index-metadata/types/flat-index-metadata.type';
+import { type AllStandardObjectIndexName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-index-name.type';
+import {
+ type CreateStandardIndexArgs,
+ createStandardIndexFlatMetadata,
+} from 'src/engine/workspace-manager/twenty-standard-application/utils/index/create-standard-index-flat-metadata.util';
+
+export const buildRecordShareStandardFlatIndexMetadatas = ({
+ now,
+ objectName,
+ workspaceId,
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+}: Omit<CreateStandardIndexArgs<'recordShare'>, 'context'>): Record<
+ AllStandardObjectIndexName<'recordShare'>,
+ FlatIndexMetadata
+> => ({
+ recordPrincipalCauseSourceUniqueIndex: createStandardIndexFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ indexName: 'recordPrincipalCauseSourceUniqueIndex',
+ relatedFieldNames: [
+ 'objectMetadataId',
+ 'recordId',
+ 'principalId',
+ 'rowCause',
+ 'sourceId',
+ ],
+ isUnique: true,
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ principalIdIndex: createStandardIndexFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ indexName: 'principalIdIndex',
+ relatedFieldNames: ['principalId'],
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+ sourceIdIndex: createStandardIndexFlatMetadata({
+ objectName,
+ workspaceId,
+ context: {
+ indexName: 'sourceIdIndex',
+ relatedFieldNames: ['sourceId'],
+ },
+ standardObjectMetadataRelatedEntityIds,
+ dependencyFlatEntityMaps,
+ twentyStandardApplicationId,
+ now,
+ }),
+});
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/object-metadata/create-standard-flat-object-metadata.util.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/object-metadata/create-standard-flat-object-metadata.util.ts
index e03ca211553..2f29f9a8207 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/object-metadata/create-standard-flat-object-metadata.util.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/object-metadata/create-standard-flat-object-metadata.util.ts
@@ -1,6 +1,10 @@
import { msg } from '@lingui/core/macro';
import { STANDARD_OBJECTS } from 'twenty-shared/metadata';
-import { MetadataWritability, ObjectOpenRecordIn } from 'twenty-shared/types';
+import {
+ MetadataReadability,
+ MetadataWritability,
+ ObjectOpenRecordIn,
+} from 'twenty-shared/types';
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
@@ -949,6 +953,53 @@ export const STANDARD_FLAT_OBJECT_METADATA_BUILDERS_BY_OBJECT_NAME = {
twentyStandardApplicationId,
now,
}),
+ recordShare: ({
+ now,
+ workspaceId,
+ standardObjectMetadataRelatedEntityIds,
+ twentyStandardApplicationId,
+ dependencyFlatEntityMaps,
+ }: Omit<CreateStandardObjectArgs<'recordShare'>, 'context' | 'objectName'>) =>
+ createStandardObjectFlatMetadata({
+ objectName: 'recordShare',
+ dependencyFlatEntityMaps,
+ context: {
+ universalIdentifier: STANDARD_OBJECTS.recordShare.universalIdentifier,
+ nameSingular: 'recordShare',
+ namePlural: 'recordShares',
+ labelSingular: i18nLabel(
+ msg({
+ message: `Record share`,
+ context: 'objectMetadata.labelSingular',
+ }),
+ ),
+ labelPlural: i18nLabel(
+ msg({
+ message: `Record shares`,
+ context: 'objectMetadata.labelPlural',
+ }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: `Who may read a record of a private object`,
+ context: 'objectMetadata.description',
+ }),
+ ),
+ icon: 'IconLock',
+ isSystem: true,
+ isSearchable: false,
+ isAuditLogged: false,
+ isUIEditable: false,
+ isUICreatable: false,
+ writability: MetadataWritability.SYSTEM,
+ readability: MetadataReadability.SYSTEM,
+ labelIdentifierFieldMetadataName: 'id',
+ },
+ workspaceId,
+ standardObjectMetadataRelatedEntityIds,
+ twentyStandardApplicationId,
+ now,
+ }),
task: ({
now,
workspaceId,
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/object-metadata/create-standard-object-flat-metadata.util.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/object-metadata/create-standard-object-flat-metadata.util.ts
index b45cfe414ec..401ac543871 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/object-metadata/create-standard-object-flat-metadata.util.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/object-metadata/create-standard-object-flat-metadata.util.ts
@@ -25,6 +25,7 @@ export type CreateStandardObjectContext<O extends AllStandardObjectName> = {
isUIEditable?: boolean;
isUICreatable?: boolean;
writability?: MetadataWritability;
+ readability?: MetadataReadability;
openRecordIn?: ObjectOpenRecordIn;
shortcut?: string | null;
duplicateCriteria?: string[][] | null;
@@ -56,6 +57,7 @@ export const createStandardObjectFlatMetadata = <
isUIEditable = true,
isUICreatable = true,
writability = MetadataWritability.OPEN,
+ readability = MetadataReadability.OPEN,
openRecordIn = ObjectOpenRecordIn.USER_CHOICE,
shortcut = null,
duplicateCriteria = null,
@@ -100,7 +102,7 @@ export const createStandardObjectFlatMetadata = <
isUIEditable,
isUICreatable,
writability,
- readability: MetadataReadability.OPEN,
+ readability,
openRecordIn,
isLabelSyncedWithName: false,
overrides: null,
diff --git a/packages/twenty-server/test/integration/graphql/suites/object-records-permissions/record-share-object.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-records-permissions/record-share-object.integration-spec.ts
new file mode 100644
index 00000000000..87be14eda10
--- /dev/null
+++ b/packages/twenty-server/test/integration/graphql/suites/object-records-permissions/record-share-object.integration-spec.ts
@@ -0,0 +1,119 @@
+import { randomUUID } from 'node:crypto';
+
+import { createOneOperationFactory } from 'test/integration/graphql/utils/create-one-operation-factory.util';
+import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
+import { getAppProviderByClassName } from 'test/integration/utils/get-app-provider-by-class-name.util';
+import { getCoreRepository } from 'test/integration/utils/get-core-repository.util';
+import {
+ RecordShareAccessLevel,
+ RecordSharePrincipalType,
+ RecordShareRowCause,
+} from 'twenty-shared/types';
+
+import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
+import { type RecordShareService } from 'src/engine/record-share/services/record-share.service';
+import { type RecordShareInput } from 'src/engine/record-share/types/record-share-input.type';
+import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
+import { PERSON_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/data/constants/person-data-seeds.constant';
+
+describe('recordShare object', () => {
+ let recordShareService: RecordShareService;
+ let personObjectMetadataId: string;
+ let recordShareInput: RecordShareInput;
+
+ const sourceId = randomUUID();
+
+ beforeAll(async () => {
+ recordShareService =
+ getAppProviderByClassName<RecordShareService>('RecordShareService');
+
+ const personObjectMetadata = await getCoreRepository<ObjectMetadataEntity>(
+ ObjectMetadataEntity,
+ ).findOneOrFail({
+ where: {
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ nameSingular: 'person',
+ },
+ });
+
+ personObjectMetadataId = personObjectMetadata.id;
+
+ recordShareInput = {
+ recordId: PERSON_DATA_SEED_IDS.ID_1,
+ objectMetadataId: personObjectMetadataId,
+ principalId: randomUUID(),
+ principalType: RecordSharePrincipalType.WORKSPACE_MEMBER,
+ accessLevel: RecordShareAccessLevel.READ,
+ rowCause: RecordShareRowCause.MANUAL,
+ sourceId,
+ };
+ });
+
+ afterAll(async () => {
+ await recordShareService.deleteBySourceId({
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ sourceId,
+ });
+ });
+
+ it('refuses creation through the GraphQL API even for an admin', async () => {
+ const response = await makeGraphqlAPIRequest(
+ createOneOperationFactory({
+ objectMetadataSingularName: 'recordShare',
+ gqlFields: 'id',
+ data: recordShareInput,
+ }),
+ );
+
+ expect(response.body.errors).toBeDefined();
+ expect(response.body.errors[0].message).toContain('not writable');
+ });
+
+ it('inserts, reads back, deduplicates and removes shares through the service', async () => {
+ await recordShareService.insertMany({
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ recordShares: [recordShareInput],
+ });
+
+ const insertedRecordShares = await recordShareService.findByRecord({
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ objectMetadataId: personObjectMetadataId,
+ recordId: PERSON_DATA_SEED_IDS.ID_1,
+ });
+
+ expect(insertedRecordShares).toHaveLength(1);
+ expect(insertedRecordShares[0]).toMatchObject(recordShareInput);
+
+ await recordShareService.insertMany({
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ recordShares: [
+ { ...recordShareInput, accessLevel: RecordShareAccessLevel.FULL },
+ ],
+ });
+
+ const recordSharesAfterDuplicateInsert =
+ await recordShareService.findByRecord({
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ objectMetadataId: personObjectMetadataId,
+ recordId: PERSON_DATA_SEED_IDS.ID_1,
+ });
+
+ expect(recordSharesAfterDuplicateInsert).toHaveLength(1);
+ expect(recordSharesAfterDuplicateInsert[0].accessLevel).toBe(
+ RecordShareAccessLevel.READ,
+ );
+
+ await recordShareService.deleteBySourceId({
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ sourceId,
+ });
+
+ const recordSharesAfterDelete = await recordShareService.findByRecord({
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ objectMetadataId: personObjectMetadataId,
+ recordId: PERSON_DATA_SEED_IDS.ID_1,
+ });
+
+ expect(recordSharesAfterDelete).toHaveLength(0);
+ });
+});
diff --git a/packages/twenty-shared/src/constants/EveryonePrincipalId.ts b/packages/twenty-shared/src/constants/EveryonePrincipalId.ts
new file mode 100644
index 00000000000..b776d4ccef1
--- /dev/null
+++ b/packages/twenty-shared/src/constants/EveryonePrincipalId.ts
@@ -0,0 +1 @@
+export const EVERYONE_PRINCIPAL_ID = '5047ca8f-514a-4609-8ef4-1bb63f3084c5';
diff --git a/packages/twenty-shared/src/constants/index.ts b/packages/twenty-shared/src/constants/index.ts
index ce7d0ef28da..bbc4ce19cce 100644
--- a/packages/twenty-shared/src/constants/index.ts
+++ b/packages/twenty-shared/src/constants/index.ts
@@ -33,6 +33,7 @@ export { DOCUMENTATION_SUPPORTED_LANGUAGES } from './DocumentationSupportedLangu
export { EMAIL_IMAGE_MIME_TYPES } from './EmailImageMimeTypes';
export type { EnterpriseInstanceType } from './EnterpriseInstanceType';
export { ENTERPRISE_INSTANCE_TYPE } from './EnterpriseInstanceType';
+export { EVERYONE_PRINCIPAL_ID } from './EveryonePrincipalId';
export { EXCLUDED_FIELD_NAMES_FROM_AGENT_TOOL_SCHEMA } from './ExcludedFieldNamesFromAgentToolSchema';
export { FIELD_FOR_TOTAL_COUNT_AGGREGATE_OPERATION } from './FieldForTotalCountAggregateOperation';
export { MAX_OPTIONS_TO_DISPLAY } from './FieldMetadataMaxOptionsToDisplay';
diff --git a/packages/twenty-shared/src/metadata/__tests__/__snapshots__/standardObjectUniversalIdentifiers.test.ts.snap b/packages/twenty-shared/src/metadata/__tests__/__snapshots__/standardObjectUniversalIdentifiers.test.ts.snap
index f654c8d9b09..ca980e17769 100644
--- a/packages/twenty-shared/src/metadata/__tests__/__snapshots__/standardObjectUniversalIdentifiers.test.ts.snap
+++ b/packages/twenty-shared/src/metadata/__tests__/__snapshots__/standardObjectUniversalIdentifiers.test.ts.snap
@@ -2515,6 +2515,68 @@ exports[`STANDARD_OBJECTS universal identifiers should never change without an e
},
},
},
+ "recordShare": {
+ "fields": {
+ "accessLevel": {
+ "universalIdentifier": "943b9926-9620-43de-8a46-8ebfee74dea3",
+ },
+ "createdAt": {
+ "universalIdentifier": "5a199f71-d282-50bf-9456-dd9d05579dc3",
+ },
+ "createdBy": {
+ "universalIdentifier": "558a8d87-de8e-540f-8fa9-9c413656e588",
+ },
+ "deletedAt": {
+ "universalIdentifier": "a25180d7-c4ea-516d-9406-24831210a118",
+ },
+ "id": {
+ "universalIdentifier": "e5a5509c-f262-558d-a698-d148516b4dea",
+ },
+ "objectMetadataId": {
+ "universalIdentifier": "504cec47-6aae-4e5b-85fd-1581b62602e3",
+ },
+ "position": {
+ "universalIdentifier": "db40ca46-5ea0-535d-b3bc-a3000fc61584",
+ },
+ "principalId": {
+ "universalIdentifier": "c1849ee2-1d2a-409e-800d-16fc16621257",
+ },
+ "principalType": {
+ "universalIdentifier": "556161f6-1a01-478e-8f01-acc413102e44",
+ },
+ "recordId": {
+ "universalIdentifier": "01edb657-6339-475c-b581-784a0c3e0509",
+ },
+ "rowCause": {
+ "universalIdentifier": "be27640e-f739-4d07-8979-dba4526e406a",
+ },
+ "searchVector": {
+ "universalIdentifier": "80a32ec3-1583-5383-acb6-c9373a57761f",
+ },
+ "sourceId": {
+ "universalIdentifier": "534a2244-9feb-4d21-afd9-c9a20052b300",
+ },
+ "updatedAt": {
+ "universalIdentifier": "413637e8-c0e3-5315-9238-6fd36c91ba58",
+ },
+ "updatedBy": {
+ "universalIdentifier": "52dd5a05-1197-5a77-a7fb-90b15e61cda9",
+ },
+ },
+ "indexes": {
+ "principalIdIndex": {
+ "universalIdentifier": "66fbc3d2-6126-4e29-a306-dbe9995bf062",
+ },
+ "recordPrincipalCauseSourceUniqueIndex": {
+ "universalIdentifier": "4580f104-47a7-4110-87a8-26cb6f63ce7b",
+ },
+ "sourceIdIndex": {
+ "universalIdentifier": "21b84593-c647-40ce-bdf4-a8b4ac658f57",
+ },
+ },
+ "universalIdentifier": "fecdb92c-d150-4544-81f8-f1158d18a7a2",
+ "views": {},
+ },
"task": {
"fields": {
"assignee": {
diff --git a/packages/twenty-shared/src/metadata/constants/standard-object-fields.constant.ts b/packages/twenty-shared/src/metadata/constants/standard-object-fields.constant.ts
index 476be5ceeb4..db3b1e27760 100644
--- a/packages/twenty-shared/src/metadata/constants/standard-object-fields.constant.ts
+++ b/packages/twenty-shared/src/metadata/constants/standard-object-fields.constant.ts
@@ -1006,6 +1006,32 @@ export const STANDARD_OBJECT_FIELDS = {
universalIdentifier: '8b8d1be0-4c94-4413-a2c9-c7ede205a81d',
},
},
+ recordShare: {
+ ...buildStandardObjectSystemFields(
+ STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.recordShare,
+ ),
+ recordId: {
+ universalIdentifier: '01edb657-6339-475c-b581-784a0c3e0509',
+ },
+ objectMetadataId: {
+ universalIdentifier: '504cec47-6aae-4e5b-85fd-1581b62602e3',
+ },
+ principalId: {
+ universalIdentifier: 'c1849ee2-1d2a-409e-800d-16fc16621257',
+ },
+ principalType: {
+ universalIdentifier: '556161f6-1a01-478e-8f01-acc413102e44',
+ },
+ accessLevel: {
+ universalIdentifier: '943b9926-9620-43de-8a46-8ebfee74dea3',
+ },
+ rowCause: {
+ universalIdentifier: 'be27640e-f739-4d07-8979-dba4526e406a',
+ },
+ sourceId: {
+ universalIdentifier: '534a2244-9feb-4d21-afd9-c9a20052b300',
+ },
+ },
task: {
...buildStandardObjectSystemFields(
STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.task,
diff --git a/packages/twenty-shared/src/metadata/constants/standard-object-universal-identifiers.constant.ts b/packages/twenty-shared/src/metadata/constants/standard-object-universal-identifiers.constant.ts
index c3f0e1e43a7..5c10ea6f30f 100644
--- a/packages/twenty-shared/src/metadata/constants/standard-object-universal-identifiers.constant.ts
+++ b/packages/twenty-shared/src/metadata/constants/standard-object-universal-identifiers.constant.ts
@@ -16,6 +16,7 @@ export const STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS = {
noteTarget: '20202020-fff0-4b44-be82-bda313884400',
taskTarget: '20202020-5a9a-44e8-95df-771cd06d0fb1',
person: '20202020-e674-48e5-a542-72570eee7213',
+ recordShare: 'fecdb92c-d150-4544-81f8-f1158d18a7a2',
company: '20202020-b374-4779-a561-80086cb2e17f',
opportunity: '20202020-9549-49dd-b2b2-883999db8938',
note: '20202020-0b00-45cd-b6f6-6cd806fc6804',
diff --git a/packages/twenty-shared/src/metadata/constants/standard-object.constant.ts b/packages/twenty-shared/src/metadata/constants/standard-object.constant.ts
index ea7c776d35c..5b93b3deaf7 100644
--- a/packages/twenty-shared/src/metadata/constants/standard-object.constant.ts
+++ b/packages/twenty-shared/src/metadata/constants/standard-object.constant.ts
@@ -968,6 +968,22 @@ export const STANDARD_OBJECTS = {
},
},
},
+ recordShare: {
+ universalIdentifier: STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.recordShare,
+ fields: STANDARD_OBJECT_FIELDS.recordShare,
+ indexes: {
+ recordPrincipalCauseSourceUniqueIndex: {
+ universalIdentifier: '4580f104-47a7-4110-87a8-26cb6f63ce7b',
+ },
+ principalIdIndex: {
+ universalIdentifier: '66fbc3d2-6126-4e29-a306-dbe9995bf062',
+ },
+ sourceIdIndex: {
+ universalIdentifier: '21b84593-c647-40ce-bdf4-a8b4ac658f57',
+ },
+ },
+ views: {},
+ },
task: {
universalIdentifier: STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.task,
fields: STANDARD_OBJECT_FIELDS.task,
diff --git a/packages/twenty-shared/src/types/RecordShareAccessLevel.ts b/packages/twenty-shared/src/types/RecordShareAccessLevel.ts
new file mode 100644
index 00000000000..ea78e7aa0a8
--- /dev/null
+++ b/packages/twenty-shared/src/types/RecordShareAccessLevel.ts
@@ -0,0 +1,5 @@
+export enum RecordShareAccessLevel {
+ READ = 'READ',
+ READ_WRITE = 'READ_WRITE',
+ FULL = 'FULL',
+}
diff --git a/packages/twenty-shared/src/types/RecordSharePrincipalType.ts b/packages/twenty-shared/src/types/RecordSharePrincipalType.ts
new file mode 100644
index 00000000000..150b9c814cc
--- /dev/null
+++ b/packages/twenty-shared/src/types/RecordSharePrincipalType.ts
@@ -0,0 +1,5 @@
+export enum RecordSharePrincipalType {
+ EVERYONE = 'EVERYONE',
+ WORKSPACE_MEMBER = 'WORKSPACE_MEMBER',
+ ROLE = 'ROLE',
+}
diff --git a/packages/twenty-shared/src/types/RecordShareRowCause.ts b/packages/twenty-shared/src/types/RecordShareRowCause.ts
new file mode 100644
index 00000000000..00c98e95574
--- /dev/null
+++ b/packages/twenty-shared/src/types/RecordShareRowCause.ts
@@ -0,0 +1,6 @@
+export enum RecordShareRowCause {
+ OWNER = 'OWNER',
+ MANUAL = 'MANUAL',
+ RULE = 'RULE',
+ APPLICATION = 'APPLICATION',
+}
diff --git a/packages/twenty-shared/src/types/index.ts b/packages/twenty-shared/src/types/index.ts
index e87b3c27a9b..6655a33745c 100644
--- a/packages/twenty-shared/src/types/index.ts
+++ b/packages/twenty-shared/src/types/index.ts
@@ -292,6 +292,9 @@ export type { RecordGqlOperationGqlRecordFields } from './RecordGqlOperationGqlR
export type { RecordGqlOperationOrderBy } from './RecordGqlOperationOrderBy';
export type { RecordGqlOperationSignature } from './RecordGqlOperationSignature';
export type { RecordGqlOperationVariables } from './RecordGqlOperationVariables';
+export { RecordShareAccessLevel } from './RecordShareAccessLevel';
+export { RecordSharePrincipalType } from './RecordSharePrincipalType';
+export { RecordShareRowCause } from './RecordShareRowCause';
export type { RelationAndMorphRelationFieldMetadataType } from './RelationAndMorphRelationFieldMetadataType';
export type { RelationCreationPayload } from './RelationCreationPayload';
export { RelationOnDeleteAction } from './RelationOnDeleteAction.type';