From 0d5617d446ce6100285f6ebc2bbbcdcf73277b2c Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Thu, 14 May 2026 12:04:09 +0200 Subject: [PATCH] chore(server): drop unused postgresCredentials feature (#20573) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Drops the `postgresCredentials` legacy feature: a never-finished "postgres proxy" that would have let users query their workspace data over a standard Postgres connection. Nothing — frontend, e2e, Zapier, docs, other server code — calls these mutations/query. ## History - **Introduced** June 2024 (#5767, Thomas Trompette) as "first step for creating credentials for database proxy", alongside the Postgres FDW / remote-server work and the custom `twenty-postgres-spilo` image. Planned follow-ups (provisioning a DB on the proxy, mapping users, exposing it as a remote server) never landed. - **Abandoned** January 2026 (#17001, Weiko) when the sibling "remote integration" feature was removed as a BREAKING CHANGE — "not maintained for more than a year and never officially launched". The spilo image was then replaced with vanilla `postgres:16` (#19182, March 2026), retiring the FDW infrastructure entirely. - This PR finishes the cleanup: removes the orphaned module, the `allPostgresCredentials` relation, `JwtTokenTypeEnum.POSTGRES_PROXY` + payload, the reserved metadata keywords, and adds a 2.5.0 fast instance command that drops `core.postgresCredentials` (reversible `down`). Regenerated frontend GraphQL types + SDK metadata client. ## Test plan - [x] `tsgo --noEmit` clean on twenty-server + twenty-front; lint + prettier clean on touched files. - [x] `database:migrate:generate` reports no pending schema diff; server boots and serves the new schema. --- .../src/metadata/generated/schema.graphql | 10 - .../src/metadata/generated/schema.ts | 31 - .../src/metadata/generated/types.ts | 558 +++++++++--------- .../src/generated-metadata/graphql.ts | 11 - ...ete-orphaned-workspace-entities.command.ts | 2 - ...0000000-drop-postgres-credentials-table.ts | 36 ++ .../instance-commands.constant.ts | 2 + .../auth/types/auth-context.type.ts | 6 - .../engine/core-modules/core-engine.module.ts | 2 - .../dtos/postgres-credentials.dto.ts | 20 - .../postgres-credentials.entity.ts | 33 -- .../postgres-credentials.module.ts | 22 - .../postgres-credentials.resolver.ts | 44 -- .../postgres-credentials.service.ts | 127 ---- ...e-entity-non-cached-properties.constant.ts | 1 - .../workspace/workspace.entity.ts | 7 - ...eserved-metadata-name-keywords.constant.ts | 2 - 17 files changed, 304 insertions(+), 610 deletions(-) create mode 100644 packages/twenty-server/src/database/commands/upgrade-version-command/2-5/2-5-instance-command-fast-1798500000000-drop-postgres-credentials-table.ts delete mode 100644 packages/twenty-server/src/engine/core-modules/postgres-credentials/dtos/postgres-credentials.dto.ts delete mode 100644 packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.entity.ts delete mode 100644 packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.module.ts delete mode 100644 packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.resolver.ts delete mode 100644 packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.service.ts diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql index 9976c91dcb2..db4312854bd 100644 --- a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql +++ b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql @@ -2443,13 +2443,6 @@ type ImapSmtpCaldavConnectionSuccess { connectedAccountId: String! } -type PostgresCredentials { - id: UUID! - user: String! - password: String! - workspaceId: UUID! -} - type ToolIndexEntry { name: String! description: String! @@ -3062,7 +3055,6 @@ type Query { getAutoCompleteAddress(address: String!, token: String!, country: String, isFieldCity: Boolean): [AutocompleteResult!]! getAddressDetails(placeId: String!, token: String!): PlaceDetailsResult! getUsageAnalytics(input: UsageAnalyticsInput): UsageAnalytics! - getPostgresCredentials: PostgresCredentials findManyPublicDomains: [PublicDomain!]! getEmailingDomains: [EmailingDomain!]! findManyMarketplaceApps: [MarketplaceApp!]! @@ -3334,8 +3326,6 @@ type Mutation { startChannelSync(connectedAccountId: UUID!): ChannelSyncSuccess! saveImapSmtpCaldavAccount(accountOwnerId: UUID!, handle: String!, connectionParameters: EmailAccountConnectionParameters!, id: UUID): ImapSmtpCaldavConnectionSuccess! updateLabPublicFeatureFlag(input: UpdateLabPublicFeatureFlagInput!): FeatureFlag! - enablePostgresProxy: PostgresCredentials! - disablePostgresProxy: PostgresCredentials! createPublicDomain(domain: String!, applicationId: String): PublicDomain! updatePublicDomain(domain: String!, applicationId: String): PublicDomain! deletePublicDomain(domain: String!): Boolean! diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.ts b/packages/twenty-client-sdk/src/metadata/generated/schema.ts index 8b50d21c0e7..aadc24de44b 100644 --- a/packages/twenty-client-sdk/src/metadata/generated/schema.ts +++ b/packages/twenty-client-sdk/src/metadata/generated/schema.ts @@ -2124,14 +2124,6 @@ export interface ImapSmtpCaldavConnectionSuccess { __typename: 'ImapSmtpCaldavConnectionSuccess' } -export interface PostgresCredentials { - id: Scalars['UUID'] - user: Scalars['String'] - password: Scalars['String'] - workspaceId: Scalars['UUID'] - __typename: 'PostgresCredentials' -} - export interface ToolIndexEntry { name: Scalars['String'] description: Scalars['String'] @@ -2665,7 +2657,6 @@ export interface Query { getAutoCompleteAddress: AutocompleteResult[] getAddressDetails: PlaceDetailsResult getUsageAnalytics: UsageAnalytics - getPostgresCredentials?: PostgresCredentials findManyPublicDomains: PublicDomain[] getEmailingDomains: EmailingDomain[] findManyMarketplaceApps: MarketplaceApp[] @@ -2870,8 +2861,6 @@ export interface Mutation { startChannelSync: ChannelSyncSuccess saveImapSmtpCaldavAccount: ImapSmtpCaldavConnectionSuccess updateLabPublicFeatureFlag: FeatureFlag - enablePostgresProxy: PostgresCredentials - disablePostgresProxy: PostgresCredentials createPublicDomain: PublicDomain updatePublicDomain: PublicDomain deletePublicDomain: Scalars['Boolean'] @@ -5158,15 +5147,6 @@ export interface ImapSmtpCaldavConnectionSuccessGenqlSelection{ __scalar?: boolean | number } -export interface PostgresCredentialsGenqlSelection{ - id?: boolean | number - user?: boolean | number - password?: boolean | number - workspaceId?: boolean | number - __typename?: boolean | number - __scalar?: boolean | number -} - export interface ToolIndexEntryGenqlSelection{ name?: boolean | number description?: boolean | number @@ -5730,7 +5710,6 @@ export interface QueryGenqlSelection{ getAutoCompleteAddress?: (AutocompleteResultGenqlSelection & { __args: {address: Scalars['String'], token: Scalars['String'], country?: (Scalars['String'] | null), isFieldCity?: (Scalars['Boolean'] | null)} }) getAddressDetails?: (PlaceDetailsResultGenqlSelection & { __args: {placeId: Scalars['String'], token: Scalars['String']} }) getUsageAnalytics?: (UsageAnalyticsGenqlSelection & { __args?: {input?: (UsageAnalyticsInput | null)} }) - getPostgresCredentials?: PostgresCredentialsGenqlSelection findManyPublicDomains?: PublicDomainGenqlSelection getEmailingDomains?: EmailingDomainGenqlSelection findManyMarketplaceApps?: MarketplaceAppGenqlSelection @@ -5956,8 +5935,6 @@ export interface MutationGenqlSelection{ startChannelSync?: (ChannelSyncSuccessGenqlSelection & { __args: {connectedAccountId: Scalars['UUID']} }) saveImapSmtpCaldavAccount?: (ImapSmtpCaldavConnectionSuccessGenqlSelection & { __args: {accountOwnerId: Scalars['UUID'], handle: Scalars['String'], connectionParameters: EmailAccountConnectionParameters, id?: (Scalars['UUID'] | null)} }) updateLabPublicFeatureFlag?: (FeatureFlagGenqlSelection & { __args: {input: UpdateLabPublicFeatureFlagInput} }) - enablePostgresProxy?: PostgresCredentialsGenqlSelection - disablePostgresProxy?: PostgresCredentialsGenqlSelection createPublicDomain?: (PublicDomainGenqlSelection & { __args: {domain: Scalars['String'], applicationId?: (Scalars['String'] | null)} }) updatePublicDomain?: (PublicDomainGenqlSelection & { __args: {domain: Scalars['String'], applicationId?: (Scalars['String'] | null)} }) deletePublicDomain?: { __args: {domain: Scalars['String']} } @@ -7975,14 +7952,6 @@ export interface LogicFunctionLogsInput {applicationId?: (Scalars['UUID'] | null - const PostgresCredentials_possibleTypes: string[] = ['PostgresCredentials'] - export const isPostgresCredentials = (obj?: { __typename?: any } | null): obj is PostgresCredentials => { - if (!obj?.__typename) throw new Error('__typename is missing in "isPostgresCredentials"') - return PostgresCredentials_possibleTypes.includes(obj.__typename) - } - - - const ToolIndexEntry_possibleTypes: string[] = ['ToolIndexEntry'] export const isToolIndexEntry = (obj?: { __typename?: any } | null): obj is ToolIndexEntry => { if (!obj?.__typename) throw new Error('__typename is missing in "isToolIndexEntry"') diff --git a/packages/twenty-client-sdk/src/metadata/generated/types.ts b/packages/twenty-client-sdk/src/metadata/generated/types.ts index 72f09ba5fba..8cefdf38277 100644 --- a/packages/twenty-client-sdk/src/metadata/generated/types.ts +++ b/packages/twenty-client-sdk/src/metadata/generated/types.ts @@ -60,26 +60,26 @@ export default { 226, 262, 263, - 294, + 293, + 302, 303, 304, 305, - 306, + 307, 308, 309, 310, 311, 312, 313, - 314, - 317, - 319, - 329, - 336, - 343, - 379, - 455, - 467 + 316, + 318, + 328, + 335, + 342, + 378, + 454, + 466 ], "types": { "BillingProductDTO": { @@ -4825,23 +4825,6 @@ export default { 1 ] }, - "PostgresCredentials": { - "id": [ - 3 - ], - "user": [ - 1 - ], - "password": [ - 1 - ], - "workspaceId": [ - 3 - ], - "__typename": [ - 1 - ] - }, "ToolIndexEntry": { "name": [ 1 @@ -4981,7 +4964,7 @@ export default { 1 ], "series": [ - 275 + 274 ], "xAxisLabel": [ 1 @@ -5030,7 +5013,7 @@ export default { 1 ], "data": [ - 277 + 276 ], "__typename": [ 1 @@ -5038,7 +5021,7 @@ export default { }, "LineChartData": { "series": [ - 278 + 277 ], "xAxisLabel": [ 1 @@ -5075,7 +5058,7 @@ export default { }, "PieChartData": { "data": [ - 280 + 279 ], "showLegend": [ 6 @@ -5191,13 +5174,13 @@ export default { }, "PublicImapSmtpCaldavConnectionParameters": { "IMAP": [ - 284 + 283 ], "SMTP": [ - 284 + 283 ], "CALDAV": [ - 284 + 283 ], "__typename": [ 1 @@ -5250,7 +5233,7 @@ export default { 4 ], "connectionParameters": [ - 285 + 284 ], "__typename": [ 1 @@ -5306,13 +5289,13 @@ export default { }, "EventLogQueryResult": { "records": [ - 288 + 287 ], "totalCount": [ 21 ], "pageInfo": [ - 289 + 288 ], "__typename": [ 1 @@ -5376,7 +5359,7 @@ export default { 1 ], "parts": [ - 273 + 272 ], "processedAt": [ 4 @@ -5390,7 +5373,7 @@ export default { }, "AgentChatThread": { "id": [ - 294 + 293 ], "title": [ 1 @@ -5446,7 +5429,7 @@ export default { }, "AiSystemPromptPreview": { "sections": [ - 295 + 294 ], "estimatedTokenCount": [ 21 @@ -5522,10 +5505,10 @@ export default { 3 ], "evaluations": [ - 300 + 299 ], "messages": [ - 292 + 291 ], "createdAt": [ 4 @@ -5542,19 +5525,19 @@ export default { 1 ], "syncStatus": [ - 303 + 302 ], "syncStage": [ - 304 + 303 ], "visibility": [ - 305 + 304 ], "isContactAutoCreationEnabled": [ 6 ], "contactAutoCreationPolicy": [ - 306 + 305 ], "isSyncEnabled": [ 6 @@ -5590,22 +5573,22 @@ export default { 3 ], "visibility": [ - 308 + 307 ], "handle": [ 1 ], "type": [ - 309 + 308 ], "isContactAutoCreationEnabled": [ 6 ], "contactAutoCreationPolicy": [ - 310 + 309 ], "messageFolderImportPolicy": [ - 311 + 310 ], "excludeNonProfessionalEmails": [ 6 @@ -5614,7 +5597,7 @@ export default { 6 ], "pendingGroupEmailsAction": [ - 312 + 311 ], "isSyncEnabled": [ 6 @@ -5623,10 +5606,10 @@ export default { 4 ], "syncStatus": [ - 313 + 312 ], "syncStage": [ - 314 + 313 ], "syncStageStartedAt": [ 4 @@ -5647,7 +5630,7 @@ export default { 4 ], "connectedAccount": [ - 286 + 285 ], "__typename": [ 1 @@ -5662,7 +5645,7 @@ export default { "MessageChannelSyncStage": {}, "CreateEmailGroupChannelOutput": { "messageChannel": [ - 307 + 306 ], "forwardingAddress": [ 1 @@ -5691,7 +5674,7 @@ export default { 1 ], "pendingSyncAction": [ - 317 + 316 ], "messageChannelId": [ 3 @@ -5709,7 +5692,7 @@ export default { "MessageFolderPendingSyncAction": {}, "CollectionHash": { "collectionName": [ - 319 + 318 ], "hash": [ 1 @@ -5776,13 +5759,13 @@ export default { }, "MinimalMetadata": { "objectMetadataItems": [ - 320 + 319 ], "views": [ - 321 + 320 ], "collectionHashes": [ - 318 + 317 ], "__typename": [ 1 @@ -5948,7 +5931,7 @@ export default { 2, { "input": [ - 325, + 324, "GetApiKeyInput!" ] } @@ -6061,7 +6044,7 @@ export default { 41, { "input": [ - 326, + 325, "LogicFunctionIdInput!" ] } @@ -6073,7 +6056,7 @@ export default { 15, { "input": [ - 326, + 325, "LogicFunctionIdInput!" ] } @@ -6082,7 +6065,7 @@ export default { 1, { "input": [ - 326, + 325, "LogicFunctionIdInput!" ] } @@ -6165,7 +6148,7 @@ export default { 25, { "input": [ - 327, + 326, "AgentIdInput!" ] } @@ -6174,7 +6157,7 @@ export default { 29 ], "getToolIndex": [ - 272 + 271 ], "getToolInputSchema": [ 15, @@ -6225,7 +6208,7 @@ export default { } ], "myMessageFolders": [ - 316, + 315, { "messageChannelId": [ 3 @@ -6233,7 +6216,7 @@ export default { } ], "myMessageChannels": [ - 307, + 306, { "connectedAccountId": [ 3 @@ -6241,10 +6224,10 @@ export default { } ], "myConnectedAccounts": [ - 283 + 282 ], "connectedAccountById": [ - 286, + 285, { "id": [ 3, @@ -6253,10 +6236,10 @@ export default { } ], "connectedAccounts": [ - 283 + 282 ], "myCalendarChannels": [ - 302, + 301, { "connectedAccountId": [ 3 @@ -6264,10 +6247,10 @@ export default { } ], "webhooks": [ - 323 + 322 ], "webhook": [ - 323, + 322, { "id": [ 3, @@ -6276,13 +6259,13 @@ export default { } ], "minimalMetadata": [ - 322 + 321 ], "chatThreads": [ - 293 + 292 ], "chatThread": [ - 293, + 292, { "id": [ 3, @@ -6291,7 +6274,7 @@ export default { } ], "chatMessages": [ - 292, + 291, { "threadId": [ 3, @@ -6300,7 +6283,7 @@ export default { } ], "chatStreamCatchupChunks": [ - 297, + 296, { "threadId": [ 3, @@ -6309,13 +6292,13 @@ export default { } ], "getAiSystemPromptPreview": [ - 296 + 295 ], "skills": [ - 291 + 290 ], "skill": [ - 291, + 290, { "id": [ 3, @@ -6324,7 +6307,7 @@ export default { } ], "agentTurns": [ - 301, + 300, { "agentId": [ 3, @@ -6469,37 +6452,37 @@ export default { 219 ], "eventLogs": [ - 290, + 289, { "input": [ - 328, + 327, "EventLogQueryInput!" ] } ], "pieChartData": [ - 281, + 280, { "input": [ - 332, + 331, "PieChartDataInput!" ] } ], "lineChartData": [ - 279, + 278, { "input": [ - 333, + 332, "LineChartDataInput!" ] } ], "barChartData": [ - 276, + 275, { "input": [ - 334, + 333, "BarChartDataInput!" ] } @@ -6549,13 +6532,10 @@ export default { 253, { "input": [ - 335 + 334 ] } ], - "getPostgresCredentials": [ - 271 - ], "findManyPublicDomains": [ 259 ], @@ -6588,7 +6568,7 @@ export default { }, "LogicFunctionIdInput": { "id": [ - 294 + 293 ], "__typename": [ 1 @@ -6604,10 +6584,10 @@ export default { }, "EventLogQueryInput": { "table": [ - 329 + 328 ], "filters": [ - 330 + 329 ], "first": [ 21 @@ -6628,7 +6608,7 @@ export default { 1 ], "dateRange": [ - 331 + 330 ], "recordId": [ 1 @@ -6695,7 +6675,7 @@ export default { 1 ], "operationTypes": [ - 336 + 335 ], "__typename": [ 1 @@ -6707,7 +6687,7 @@ export default { 6, { "input": [ - 338, + 337, "AddQuerySubscriptionInput!" ] } @@ -6716,7 +6696,7 @@ export default { 6, { "input": [ - 339, + 338, "RemoveQueryFromEventStreamInput!" ] } @@ -6725,7 +6705,7 @@ export default { 157, { "inputs": [ - 340, + 339, "[CreateNavigationMenuItemInput!]!" ] } @@ -6734,7 +6714,7 @@ export default { 157, { "input": [ - 340, + 339, "CreateNavigationMenuItemInput!" ] } @@ -6743,7 +6723,7 @@ export default { 157, { "inputs": [ - 341, + 340, "[UpdateOneNavigationMenuItemInput!]!" ] } @@ -6752,7 +6732,7 @@ export default { 157, { "input": [ - 341, + 340, "UpdateOneNavigationMenuItemInput!" ] } @@ -6779,7 +6759,7 @@ export default { 129, { "file": [ - 343, + 342, "Upload!" ] } @@ -6788,7 +6768,7 @@ export default { 129, { "file": [ - 343, + 342, "Upload!" ] } @@ -6797,7 +6777,7 @@ export default { 129, { "file": [ - 343, + 342, "Upload!" ] } @@ -6806,7 +6786,7 @@ export default { 129, { "file": [ - 343, + 342, "Upload!" ] } @@ -6815,7 +6795,7 @@ export default { 129, { "file": [ - 343, + 342, "Upload!" ] } @@ -6824,7 +6804,7 @@ export default { 129, { "file": [ - 343, + 342, "Upload!" ], "fieldMetadataId": [ @@ -6837,7 +6817,7 @@ export default { 129, { "file": [ - 343, + 342, "Upload!" ], "fieldMetadataUniversalIdentifier": [ @@ -6850,7 +6830,7 @@ export default { 61, { "input": [ - 344, + 343, "CreateViewFilterGroupInput!" ] } @@ -6863,7 +6843,7 @@ export default { "String!" ], "input": [ - 345, + 344, "UpdateViewFilterGroupInput!" ] } @@ -6890,7 +6870,7 @@ export default { 63, { "input": [ - 346, + 345, "CreateViewFilterInput!" ] } @@ -6899,7 +6879,7 @@ export default { 63, { "input": [ - 347, + 346, "UpdateViewFilterInput!" ] } @@ -6908,7 +6888,7 @@ export default { 63, { "input": [ - 349, + 348, "DeleteViewFilterInput!" ] } @@ -6917,7 +6897,7 @@ export default { 63, { "input": [ - 350, + 349, "DestroyViewFilterInput!" ] } @@ -6926,7 +6906,7 @@ export default { 69, { "input": [ - 351, + 350, "CreateViewInput!" ] } @@ -6939,7 +6919,7 @@ export default { "String!" ], "input": [ - 352, + 351, "UpdateViewInput!" ] } @@ -6966,7 +6946,7 @@ export default { 69, { "input": [ - 353, + 352, "UpsertViewWidgetInput!" ] } @@ -6975,7 +6955,7 @@ export default { 66, { "input": [ - 358, + 357, "CreateViewSortInput!" ] } @@ -6984,7 +6964,7 @@ export default { 66, { "input": [ - 359, + 358, "UpdateViewSortInput!" ] } @@ -6993,7 +6973,7 @@ export default { 6, { "input": [ - 361, + 360, "DeleteViewSortInput!" ] } @@ -7002,7 +6982,7 @@ export default { 6, { "input": [ - 362, + 361, "DestroyViewSortInput!" ] } @@ -7011,7 +6991,7 @@ export default { 59, { "input": [ - 363, + 362, "UpdateViewFieldInput!" ] } @@ -7020,7 +7000,7 @@ export default { 59, { "input": [ - 365, + 364, "CreateViewFieldInput!" ] } @@ -7029,7 +7009,7 @@ export default { 59, { "inputs": [ - 365, + 364, "[CreateViewFieldInput!]!" ] } @@ -7038,7 +7018,7 @@ export default { 59, { "input": [ - 366, + 365, "DeleteViewFieldInput!" ] } @@ -7047,7 +7027,7 @@ export default { 59, { "input": [ - 367, + 366, "DestroyViewFieldInput!" ] } @@ -7056,7 +7036,7 @@ export default { 68, { "input": [ - 368, + 367, "UpdateViewFieldGroupInput!" ] } @@ -7065,7 +7045,7 @@ export default { 68, { "input": [ - 370, + 369, "CreateViewFieldGroupInput!" ] } @@ -7074,7 +7054,7 @@ export default { 68, { "inputs": [ - 370, + 369, "[CreateViewFieldGroupInput!]!" ] } @@ -7083,7 +7063,7 @@ export default { 68, { "input": [ - 371, + 370, "DeleteViewFieldGroupInput!" ] } @@ -7092,7 +7072,7 @@ export default { 68, { "input": [ - 372, + 371, "DestroyViewFieldGroupInput!" ] } @@ -7101,7 +7081,7 @@ export default { 69, { "input": [ - 373, + 372, "UpsertFieldsWidgetInput!" ] } @@ -7110,7 +7090,7 @@ export default { 2, { "input": [ - 376, + 375, "CreateApiKeyInput!" ] } @@ -7119,7 +7099,7 @@ export default { 2, { "input": [ - 377, + 376, "UpdateApiKeyInput!" ] } @@ -7128,7 +7108,7 @@ export default { 2, { "input": [ - 378, + 377, "RevokeApiKeyInput!" ] } @@ -7170,7 +7150,7 @@ export default { 127, { "type": [ - 379, + 378, "AnalyticsType!" ], "name": [ @@ -7283,7 +7263,7 @@ export default { 128, { "input": [ - 380, + 379, "CreateApprovedAccessDomainInput!" ] } @@ -7292,7 +7272,7 @@ export default { 6, { "input": [ - 381, + 380, "DeleteApprovedAccessDomainInput!" ] } @@ -7301,7 +7281,7 @@ export default { 128, { "input": [ - 382, + 381, "ValidateApprovedAccessDomainInput!" ] } @@ -7310,7 +7290,7 @@ export default { 122, { "input": [ - 383, + 382, "CreatePageLayoutTabInput!" ] } @@ -7323,7 +7303,7 @@ export default { "String!" ], "input": [ - 384, + 383, "UpdatePageLayoutTabInput!" ] } @@ -7341,7 +7321,7 @@ export default { 123, { "input": [ - 385, + 384, "CreatePageLayoutInput!" ] } @@ -7354,7 +7334,7 @@ export default { "String!" ], "input": [ - 386, + 385, "UpdatePageLayoutInput!" ] } @@ -7376,7 +7356,7 @@ export default { "String!" ], "input": [ - 387, + 386, "UpdatePageLayoutWithTabsInput!" ] } @@ -7429,7 +7409,7 @@ export default { 84, { "input": [ - 391, + 390, "CreatePageLayoutWidgetInput!" ] } @@ -7442,7 +7422,7 @@ export default { "String!" ], "input": [ - 392, + 391, "UpdatePageLayoutWidgetInput!" ] } @@ -7460,7 +7440,7 @@ export default { 41, { "input": [ - 326, + 325, "LogicFunctionIdInput!" ] } @@ -7469,7 +7449,7 @@ export default { 41, { "input": [ - 393, + 392, "CreateLogicFunctionFromSourceInput!" ] } @@ -7478,7 +7458,7 @@ export default { 166, { "input": [ - 394, + 393, "ExecuteOneLogicFunctionInput!" ] } @@ -7487,7 +7467,7 @@ export default { 6, { "input": [ - 395, + 394, "UpdateLogicFunctionFromSourceInput!" ] } @@ -7496,7 +7476,7 @@ export default { 35, { "input": [ - 397, + 396, "CreateCommandMenuItemInput!" ] } @@ -7505,7 +7485,7 @@ export default { 35, { "input": [ - 398, + 397, "UpdateCommandMenuItemInput!" ] } @@ -7523,7 +7503,7 @@ export default { 34, { "input": [ - 399, + 398, "CreateFrontComponentInput!" ] } @@ -7532,7 +7512,7 @@ export default { 34, { "input": [ - 400, + 399, "UpdateFrontComponentInput!" ] } @@ -7550,7 +7530,7 @@ export default { 55, { "input": [ - 402, + 401, "CreateOneObjectInput!" ] } @@ -7559,7 +7539,7 @@ export default { 55, { "input": [ - 404, + 403, "DeleteOneObjectInput!" ] } @@ -7568,7 +7548,7 @@ export default { 55, { "input": [ - 405, + 404, "UpdateOneObjectInput!" ] } @@ -7577,7 +7557,7 @@ export default { 25, { "input": [ - 407, + 406, "CreateAgentInput!" ] } @@ -7586,7 +7566,7 @@ export default { 25, { "input": [ - 408, + 407, "UpdateAgentInput!" ] } @@ -7595,7 +7575,7 @@ export default { 25, { "input": [ - 327, + 326, "AgentIdInput!" ] } @@ -7617,7 +7597,7 @@ export default { 29, { "createRoleInput": [ - 409, + 408, "CreateRoleInput!" ] } @@ -7626,7 +7606,7 @@ export default { 29, { "updateRoleInput": [ - 410, + 409, "UpdateRoleInput!" ] } @@ -7644,7 +7624,7 @@ export default { 16, { "upsertObjectPermissionsInput": [ - 412, + 411, "UpsertObjectPermissionsInput!" ] } @@ -7653,7 +7633,7 @@ export default { 27, { "upsertPermissionFlagsInput": [ - 414, + 413, "UpsertPermissionFlagsInput!" ] } @@ -7662,7 +7642,7 @@ export default { 26, { "upsertFieldPermissionsInput": [ - 415, + 414, "UpsertFieldPermissionsInput!" ] } @@ -7671,7 +7651,7 @@ export default { 229, { "input": [ - 417, + 416, "UpsertRowLevelPermissionPredicatesInput!" ] } @@ -7702,7 +7682,7 @@ export default { 43, { "input": [ - 420, + 419, "CreateOneFieldMetadataInput!" ] } @@ -7711,7 +7691,7 @@ export default { 43, { "input": [ - 422, + 421, "UpdateOneFieldMetadataInput!" ] } @@ -7720,7 +7700,7 @@ export default { 43, { "input": [ - 424, + 423, "DeleteOneFieldInput!" ] } @@ -7729,7 +7709,7 @@ export default { 65, { "input": [ - 425, + 424, "CreateViewGroupInput!" ] } @@ -7738,7 +7718,7 @@ export default { 65, { "inputs": [ - 425, + 424, "[CreateViewGroupInput!]!" ] } @@ -7747,7 +7727,7 @@ export default { 65, { "input": [ - 426, + 425, "UpdateViewGroupInput!" ] } @@ -7756,7 +7736,7 @@ export default { 65, { "inputs": [ - 426, + 425, "[UpdateViewGroupInput!]!" ] } @@ -7765,7 +7745,7 @@ export default { 65, { "input": [ - 428, + 427, "DeleteViewGroupInput!" ] } @@ -7774,49 +7754,49 @@ export default { 65, { "input": [ - 429, + 428, "DestroyViewGroupInput!" ] } ], "updateMessageFolder": [ - 316, + 315, { "input": [ - 430, + 429, "UpdateMessageFolderInput!" ] } ], "updateMessageFolders": [ - 316, + 315, { "input": [ - 432, + 431, "UpdateMessageFoldersInput!" ] } ], "updateMessageChannel": [ - 307, + 306, { "input": [ - 433, + 432, "UpdateMessageChannelInput!" ] } ], "createEmailGroupChannel": [ - 315, + 314, { "input": [ - 435, + 434, "CreateEmailGroupChannelInput!" ] } ], "deleteEmailGroupChannel": [ - 307, + 306, { "id": [ 3, @@ -7825,7 +7805,7 @@ export default { } ], "deleteConnectedAccount": [ - 283, + 282, { "id": [ 3, @@ -7834,34 +7814,34 @@ export default { } ], "updateCalendarChannel": [ - 302, + 301, { "input": [ - 436, + 435, "UpdateCalendarChannelInput!" ] } ], "createWebhook": [ - 323, + 322, { "input": [ - 438, + 437, "CreateWebhookInput!" ] } ], "updateWebhook": [ - 323, + 322, { "input": [ - 439, + 438, "UpdateWebhookInput!" ] } ], "deleteWebhook": [ - 323, + 322, { "id": [ 3, @@ -7870,10 +7850,10 @@ export default { } ], "createChatThread": [ - 293 + 292 ], "sendChatMessage": [ - 298, + 297, { "threadId": [ 3, @@ -7909,7 +7889,7 @@ export default { } ], "renameChatThread": [ - 293, + 292, { "id": [ 3, @@ -7922,7 +7902,7 @@ export default { } ], "archiveChatThread": [ - 293, + 292, { "id": [ 3, @@ -7931,7 +7911,7 @@ export default { } ], "unarchiveChatThread": [ - 293, + 292, { "id": [ 3, @@ -7958,25 +7938,25 @@ export default { } ], "createSkill": [ - 291, + 290, { "input": [ - 441, + 440, "CreateSkillInput!" ] } ], "updateSkill": [ - 291, + 290, { "input": [ - 442, + 441, "UpdateSkillInput!" ] } ], "deleteSkill": [ - 291, + 290, { "id": [ 3, @@ -7985,7 +7965,7 @@ export default { } ], "activateSkill": [ - 291, + 290, { "id": [ 3, @@ -7994,7 +7974,7 @@ export default { } ], "deactivateSkill": [ - 291, + 290, { "id": [ 3, @@ -8003,7 +7983,7 @@ export default { } ], "evaluateAgentTurn": [ - 300, + 299, { "turnId": [ 3, @@ -8012,7 +7992,7 @@ export default { } ], "runEvaluationInput": [ - 301, + 300, { "agentId": [ 3, @@ -8028,7 +8008,7 @@ export default { 238, { "input": [ - 443, + 442, "GetAuthorizationUrlForSSOInput!" ] } @@ -8282,7 +8262,7 @@ export default { 196, { "input": [ - 444, + 443, "CreateApplicationRegistrationInput!" ] } @@ -8291,7 +8271,7 @@ export default { 7, { "input": [ - 445, + 444, "UpdateApplicationRegistrationInput!" ] } @@ -8318,7 +8298,7 @@ export default { 5, { "input": [ - 447, + 446, "CreateApplicationRegistrationVariableInput!" ] } @@ -8327,7 +8307,7 @@ export default { 5, { "input": [ - 448, + 447, "UpdateApplicationRegistrationVariableInput!" ] } @@ -8345,7 +8325,7 @@ export default { 7, { "file": [ - 343, + 342, "Upload!" ], "universalIdentifier": [ @@ -8416,7 +8396,7 @@ export default { 6, { "input": [ - 450, + 449, "UpdateWorkspaceMemberSettingsInput!" ] } @@ -8450,7 +8430,7 @@ export default { 75, { "data": [ - 451, + 450, "ActivateWorkspaceInput!" ] } @@ -8459,7 +8439,7 @@ export default { 75, { "data": [ - 452, + 451, "UpdateWorkspaceInput!" ] } @@ -8486,7 +8466,7 @@ export default { 6, { "workspaceMigration": [ - 453, + 452, "WorkspaceMigrationInput!" ] } @@ -8504,7 +8484,7 @@ export default { 220, { "input": [ - 456, + 455, "SetupOIDCSsoInput!" ] } @@ -8513,7 +8493,7 @@ export default { 220, { "input": [ - 457, + 456, "SetupSAMLSsoInput!" ] } @@ -8522,7 +8502,7 @@ export default { 216, { "input": [ - 458, + 457, "DeleteSsoInput!" ] } @@ -8531,13 +8511,13 @@ export default { 217, { "input": [ - 459, + 458, "EditSsoInput!" ] } ], "duplicateDashboard": [ - 282, + 281, { "id": [ 3, @@ -8559,16 +8539,16 @@ export default { } ], "sendEmail": [ - 287, + 286, { "input": [ - 460, + 459, "SendEmailInput!" ] } ], "startChannelSync": [ - 274, + 273, { "connectedAccountId": [ 3, @@ -8588,7 +8568,7 @@ export default { "String!" ], "connectionParameters": [ - 462, + 461, "EmailAccountConnectionParameters!" ], "id": [ @@ -8600,17 +8580,11 @@ export default { 168, { "input": [ - 464, + 463, "UpdateLabPublicFeatureFlagInput!" ] } ], - "enablePostgresProxy": [ - 271 - ], - "disablePostgresProxy": [ - 271 - ], "createPublicDomain": [ 259, { @@ -8688,7 +8662,7 @@ export default { 77, { "input": [ - 465, + 464, "CreateOneAppTokenInput!" ] } @@ -8743,7 +8717,7 @@ export default { 256, { "file": [ - 343, + 342, "Upload!" ], "applicationUniversalIdentifier": [ @@ -8751,7 +8725,7 @@ export default { "String!" ], "fileFolder": [ - 467, + 466, "FileFolder!" ], "filePath": [ @@ -8860,7 +8834,7 @@ export default { 3 ], "update": [ - 342 + 341 ], "__typename": [ 1 @@ -8967,7 +8941,7 @@ export default { 3 ], "update": [ - 348 + 347 ], "__typename": [ 1 @@ -9123,16 +9097,16 @@ export default { 3 ], "viewFields": [ - 354 + 353 ], "viewFilters": [ - 355 + 354 ], "viewFilterGroups": [ - 356 + 355 ], "viewSorts": [ - 357 + 356 ], "__typename": [ 1 @@ -9240,7 +9214,7 @@ export default { 3 ], "update": [ - 360 + 359 ], "__typename": [ 1 @@ -9278,7 +9252,7 @@ export default { 3 ], "update": [ - 364 + 363 ], "__typename": [ 1 @@ -9354,7 +9328,7 @@ export default { 3 ], "update": [ - 369 + 368 ], "__typename": [ 1 @@ -9418,10 +9392,10 @@ export default { 3 ], "groups": [ - 374 + 373 ], "fields": [ - 375 + 374 ], "__typename": [ 1 @@ -9441,7 +9415,7 @@ export default { 6 ], "fields": [ - 375 + 374 ], "__typename": [ 1 @@ -9610,7 +9584,7 @@ export default { 3 ], "tabs": [ - 388 + 387 ], "__typename": [ 1 @@ -9633,7 +9607,7 @@ export default { 88 ], "widgets": [ - 389 + 388 ], "__typename": [ 1 @@ -9656,7 +9630,7 @@ export default { 3 ], "gridPosition": [ - 390 + 389 ], "position": [ 15 @@ -9705,7 +9679,7 @@ export default { 3 ], "gridPosition": [ - 390 + 389 ], "position": [ 15 @@ -9731,7 +9705,7 @@ export default { 3 ], "gridPosition": [ - 390 + 389 ], "position": [ 15 @@ -9803,7 +9777,7 @@ export default { 3 ], "update": [ - 396 + 395 ], "__typename": [ 1 @@ -9963,7 +9937,7 @@ export default { 3 ], "update": [ - 401 + 400 ], "__typename": [ 1 @@ -9982,7 +9956,7 @@ export default { }, "CreateOneObjectInput": { "object": [ - 403 + 402 ], "__typename": [ 1 @@ -10042,7 +10016,7 @@ export default { }, "UpdateOneObjectInput": { "update": [ - 406 + 405 ], "id": [ 3 @@ -10214,7 +10188,7 @@ export default { }, "UpdateRoleInput": { "update": [ - 411 + 410 ], "id": [ 3 @@ -10269,7 +10243,7 @@ export default { 3 ], "objectPermissions": [ - 413 + 412 ], "__typename": [ 1 @@ -10311,7 +10285,7 @@ export default { 3 ], "fieldPermissions": [ - 416 + 415 ], "__typename": [ 1 @@ -10342,10 +10316,10 @@ export default { 3 ], "predicates": [ - 418 + 417 ], "predicateGroups": [ - 419 + 418 ], "__typename": [ 1 @@ -10405,7 +10379,7 @@ export default { }, "CreateOneFieldMetadataInput": { "field": [ - 421 + 420 ], "__typename": [ 1 @@ -10478,7 +10452,7 @@ export default { 3 ], "update": [ - 423 + 422 ], "__typename": [ 1 @@ -10570,7 +10544,7 @@ export default { 3 ], "update": [ - 427 + 426 ], "__typename": [ 1 @@ -10614,7 +10588,7 @@ export default { 3 ], "update": [ - 431 + 430 ], "__typename": [ 1 @@ -10633,7 +10607,7 @@ export default { 3 ], "update": [ - 431 + 430 ], "__typename": [ 1 @@ -10644,7 +10618,7 @@ export default { 3 ], "update": [ - 434 + 433 ], "__typename": [ 1 @@ -10652,16 +10626,16 @@ export default { }, "UpdateMessageChannelInputUpdates": { "visibility": [ - 308 + 307 ], "isContactAutoCreationEnabled": [ 6 ], "contactAutoCreationPolicy": [ - 310 + 309 ], "messageFolderImportPolicy": [ - 311 + 310 ], "isSyncEnabled": [ 6 @@ -10689,7 +10663,7 @@ export default { 3 ], "update": [ - 437 + 436 ], "__typename": [ 1 @@ -10697,13 +10671,13 @@ export default { }, "UpdateCalendarChannelInputUpdates": { "visibility": [ - 305 + 304 ], "isContactAutoCreationEnabled": [ 6 ], "contactAutoCreationPolicy": [ - 306 + 305 ], "isSyncEnabled": [ 6 @@ -10737,7 +10711,7 @@ export default { 3 ], "update": [ - 440 + 439 ], "__typename": [ 1 @@ -10842,7 +10816,7 @@ export default { 1 ], "update": [ - 446 + 445 ], "__typename": [ 1 @@ -10890,7 +10864,7 @@ export default { 1 ], "update": [ - 449 + 448 ], "__typename": [ 1 @@ -11008,7 +10982,7 @@ export default { }, "WorkspaceMigrationInput": { "actions": [ - 454 + 453 ], "__typename": [ 1 @@ -11016,10 +10990,10 @@ export default { }, "WorkspaceMigrationDeleteActionInput": { "type": [ - 455 + 454 ], "metadataName": [ - 319 + 318 ], "universalIdentifier": [ 1 @@ -11111,7 +11085,7 @@ export default { 1 ], "files": [ - 461 + 460 ], "__typename": [ 1 @@ -11130,13 +11104,13 @@ export default { }, "EmailAccountConnectionParameters": { "IMAP": [ - 463 + 462 ], "SMTP": [ - 463 + 462 ], "CALDAV": [ - 463 + 462 ], "__typename": [ 1 @@ -11175,7 +11149,7 @@ export default { }, "CreateOneAppTokenInput": { "appToken": [ - 466 + 465 ], "__typename": [ 1 @@ -11204,13 +11178,13 @@ export default { 230, { "input": [ - 469, + 468, "LogicFunctionLogsInput!" ] } ], "onAgentChatEvent": [ - 299, + 298, { "threadId": [ 3, diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts index 9c18146be81..8ead62eaaa5 100644 --- a/packages/twenty-front/src/generated-metadata/graphql.ts +++ b/packages/twenty-front/src/generated-metadata/graphql.ts @@ -2455,11 +2455,9 @@ export type Mutation = { destroyViewFilterGroup: Scalars['Boolean']; destroyViewGroup: ViewGroup; destroyViewSort: Scalars['Boolean']; - disablePostgresProxy: PostgresCredentials; duplicateDashboard: DuplicatedDashboard; editSSOIdentityProvider: EditSso; emailPasswordResetLink: EmailPasswordResetLink; - enablePostgresProxy: PostgresCredentials; endSubscriptionTrialPeriod: BillingEndTrialPeriod; evaluateAgentTurn: AgentTurnEvaluation; executeOneLogicFunction: LogicFunctionExecutionResult; @@ -4030,14 +4028,6 @@ export type PlaceDetailsResult = { street?: Maybe; }; -export type PostgresCredentials = { - __typename?: 'PostgresCredentials'; - id: Scalars['UUID']; - password: Scalars['String']; - user: Scalars['String']; - workspaceId: Scalars['UUID']; -}; - export type PublicApplicationRegistration = { __typename?: 'PublicApplicationRegistration'; id: Scalars['UUID']; @@ -4161,7 +4151,6 @@ export type Query = { getPageLayoutWidget: PageLayoutWidget; getPageLayoutWidgets: Array; getPageLayouts: Array; - getPostgresCredentials?: Maybe; getPublicWorkspaceDataByDomain: PublicWorkspaceData; getPublicWorkspaceDataById: PublicWorkspaceDataSummary; getResourceCreditUsage: Array; diff --git a/packages/twenty-server/src/database/commands/list-and-delete-orphaned-workspace-entities.command.ts b/packages/twenty-server/src/database/commands/list-and-delete-orphaned-workspace-entities.command.ts index 7b49d93cd98..71260b481e4 100644 --- a/packages/twenty-server/src/database/commands/list-and-delete-orphaned-workspace-entities.command.ts +++ b/packages/twenty-server/src/database/commands/list-and-delete-orphaned-workspace-entities.command.ts @@ -17,7 +17,6 @@ import { BillingSubscriptionEntity } from 'src/engine/core-modules/billing/entit import { EmailingDomainEntity } from 'src/engine/core-modules/emailing-domain/emailing-domain.entity'; import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity'; import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity'; -import { PostgresCredentialsEntity } from 'src/engine/core-modules/postgres-credentials/postgres-credentials.entity'; import { PublicDomainEntity } from 'src/engine/core-modules/public-domain/public-domain.entity'; import { WorkspaceSSOIdentityProviderEntity } from 'src/engine/core-modules/sso/workspace-sso-identity-provider.entity'; import { UserWorkspaceEntity } from 'src/engine/core-modules/user-workspace/user-workspace.entity'; @@ -103,7 +102,6 @@ const WORKSPACE_RELATED_ENTITIES: EntityTarget[] = [ EmailingDomainEntity, FeatureFlagEntity, FileEntity, - PostgresCredentialsEntity, PublicDomainEntity, WebhookEntity, WorkspaceSSOIdentityProviderEntity, diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-5/2-5-instance-command-fast-1798500000000-drop-postgres-credentials-table.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-5/2-5-instance-command-fast-1798500000000-drop-postgres-credentials-table.ts new file mode 100644 index 00000000000..b7f7ee20d17 --- /dev/null +++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-5/2-5-instance-command-fast-1798500000000-drop-postgres-credentials-table.ts @@ -0,0 +1,36 @@ +import { type QueryRunner } from 'typeorm'; + +import { RegisteredInstanceCommand } from 'src/engine/core-modules/upgrade/decorators/registered-instance-command.decorator'; +import { type FastInstanceCommand } from 'src/engine/core-modules/upgrade/interfaces/fast-instance-command.interface'; + +@RegisteredInstanceCommand('2.5.0', 1798500000000) +export class DropPostgresCredentialsTableFastInstanceCommand + implements FastInstanceCommand +{ + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE IF EXISTS "core"."postgresCredentials" DROP CONSTRAINT IF EXISTS "FK_9494639abc06f9c8c3691bf5d22"`, + ); + await queryRunner.query( + `DROP TABLE IF EXISTS "core"."postgresCredentials"`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE IF NOT EXISTS "core"."postgresCredentials" ( + "id" uuid NOT NULL DEFAULT uuid_generate_v4(), + "user" character varying NOT NULL, + "passwordHash" character varying NOT NULL, + "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + "deletedAt" TIMESTAMP WITH TIME ZONE, + "workspaceId" uuid NOT NULL, + CONSTRAINT "PK_3f9c4cdf895bfea0a6ea15bdd81" PRIMARY KEY ("id") + )`, + ); + await queryRunner.query( + `ALTER TABLE "core"."postgresCredentials" ADD CONSTRAINT "FK_9494639abc06f9c8c3691bf5d22" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } +} diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/instance-commands.constant.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/instance-commands.constant.ts index e128e0cb911..c762fd4d406 100644 --- a/packages/twenty-server/src/database/commands/upgrade-version-command/instance-commands.constant.ts +++ b/packages/twenty-server/src/database/commands/upgrade-version-command/instance-commands.constant.ts @@ -39,6 +39,7 @@ import { EncryptApplicationRegistrationVariableSlowInstanceCommand } from 'src/d import { EncryptSigningKeyPrivateKeysSlowInstanceCommand } from 'src/database/commands/upgrade-version-command/2-5/2-5-instance-command-slow-1798000007000-encrypt-signing-key-private-keys'; import { EncryptSensitiveConfigStorageSlowInstanceCommand } from 'src/database/commands/upgrade-version-command/2-5/2-5-instance-command-slow-1798000008000-encrypt-sensitive-config-storage'; import { AddSubFieldNameToViewSortFastInstanceCommand } from 'src/database/commands/upgrade-version-command/2-5/2-5-instance-command-fast-1778502963794-add-sub-field-name-to-view-sort'; +import { DropPostgresCredentialsTableFastInstanceCommand } from 'src/database/commands/upgrade-version-command/2-5/2-5-instance-command-fast-1798500000000-drop-postgres-credentials-table'; export const INSTANCE_COMMANDS = [ AddViewFieldGroupIdIndexOnViewFieldFastInstanceCommand, @@ -80,4 +81,5 @@ export const INSTANCE_COMMANDS = [ EncryptSigningKeyPrivateKeysSlowInstanceCommand, EncryptSensitiveConfigStorageSlowInstanceCommand, AddSubFieldNameToViewSortFastInstanceCommand, + DropPostgresCredentialsTableFastInstanceCommand, ]; diff --git a/packages/twenty-server/src/engine/core-modules/auth/types/auth-context.type.ts b/packages/twenty-server/src/engine/core-modules/auth/types/auth-context.type.ts index cd761a34748..ad6f766f49f 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/types/auth-context.type.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/types/auth-context.type.ts @@ -43,7 +43,6 @@ export enum JwtTokenTypeEnum { LOGIN = 'LOGIN', FILE = 'FILE', API_KEY = 'API_KEY', - POSTGRES_PROXY = 'POSTGRES_PROXY', REMOTE_SERVER = 'REMOTE_SERVER', KEY_ENCRYPTION_KEY = 'KEY_ENCRYPTION_KEY', APPLICATION_ACCESS = 'APPLICATION_ACCESS', @@ -138,10 +137,6 @@ export type AccessTokenJwtPayload = CommonPropertiesJwtPayload & { impersonatedUserWorkspaceId?: string; }; -export type PostgresProxyTokenJwtPayload = CommonPropertiesJwtPayload & { - type: JwtTokenTypeEnum.POSTGRES_PROXY; -}; - export type AppOAuthStateJwtPayload = CommonPropertiesJwtPayload & { type: JwtTokenTypeEnum.APP_OAUTH_STATE; workspaceId: string; @@ -170,5 +165,4 @@ export type JwtPayload = | RefreshTokenJwtPayload | FileTokenJwtPayload | FileTokenJwtPayloadLegacy - | PostgresProxyTokenJwtPayload | AppOAuthStateJwtPayload; 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 7eff83c0d6f..4a6e33c1186 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 @@ -51,7 +51,6 @@ import { MessagingWebhooksModule } from 'src/engine/core-modules/messaging-webho import { MetricsModule } from 'src/engine/core-modules/metrics/metrics.module'; import { MetricsService } from 'src/engine/core-modules/metrics/metrics.service'; import { OpenApiModule } from 'src/engine/core-modules/open-api/open-api.module'; -import { PostgresCredentialsModule } from 'src/engine/core-modules/postgres-credentials/postgres-credentials.module'; import { PublicDomainModule } from 'src/engine/core-modules/public-domain/public-domain.module'; import { RedisClientModule } from 'src/engine/core-modules/redis-client/redis-client.module'; import { RedisClientService } from 'src/engine/core-modules/redis-client/redis-client.service'; @@ -116,7 +115,6 @@ import { FileModule } from './file/file.module'; PublicDomainModule, CloudflareModule, DnsManagerModule, - PostgresCredentialsModule, WorkflowApiModule, WorkspaceEventEmitterModule, ActorModule, diff --git a/packages/twenty-server/src/engine/core-modules/postgres-credentials/dtos/postgres-credentials.dto.ts b/packages/twenty-server/src/engine/core-modules/postgres-credentials/dtos/postgres-credentials.dto.ts deleted file mode 100644 index 45129cfc4ee..00000000000 --- a/packages/twenty-server/src/engine/core-modules/postgres-credentials/dtos/postgres-credentials.dto.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Field, ObjectType } from '@nestjs/graphql'; - -import { IDField } from '@ptc-org/nestjs-query-graphql'; - -import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars'; - -@ObjectType('PostgresCredentials') -export class PostgresCredentialsDTO { - @IDField(() => UUIDScalarType) - id: string; - - @Field() - user: string; - - @Field() - password: string; - - @Field(() => UUIDScalarType) - workspaceId: string; -} diff --git a/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.entity.ts b/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.entity.ts deleted file mode 100644 index 99129b19cf1..00000000000 --- a/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.entity.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { ObjectType } from '@nestjs/graphql'; - -import { - Column, - CreateDateColumn, - Entity, - PrimaryGeneratedColumn, - UpdateDateColumn, -} from 'typeorm'; - -import { WorkspaceRelatedEntity } from 'src/engine/workspace-manager/types/workspace-related-entity'; - -@Entity({ name: 'postgresCredentials', schema: 'core' }) -@ObjectType('PostgresCredentials') -export class PostgresCredentialsEntity extends WorkspaceRelatedEntity { - @PrimaryGeneratedColumn('uuid') - id: string; - - @Column({ nullable: false }) - user: string; - - @Column({ nullable: false }) - passwordHash: string; - - @CreateDateColumn({ type: 'timestamptz' }) - createdAt: Date; - - @UpdateDateColumn({ type: 'timestamptz' }) - updatedAt: Date; - - @Column({ nullable: true, type: 'timestamptz' }) - deletedAt: Date; -} diff --git a/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.module.ts b/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.module.ts deleted file mode 100644 index 208d865d19a..00000000000 --- a/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.module.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Module } from '@nestjs/common'; -import { TypeOrmModule } from '@nestjs/typeorm'; - -import { JwtModule } from 'src/engine/core-modules/jwt/jwt.module'; -import { PostgresCredentialsEntity } from 'src/engine/core-modules/postgres-credentials/postgres-credentials.entity'; -import { PostgresCredentialsResolver } from 'src/engine/core-modules/postgres-credentials/postgres-credentials.resolver'; -import { PostgresCredentialsService } from 'src/engine/core-modules/postgres-credentials/postgres-credentials.service'; -import { PermissionsModule } from 'src/engine/metadata-modules/permissions/permissions.module'; - -@Module({ - imports: [ - JwtModule, - TypeOrmModule.forFeature([PostgresCredentialsEntity]), - PermissionsModule, - ], - providers: [ - PostgresCredentialsResolver, - PostgresCredentialsService, - PostgresCredentialsEntity, - ], -}) -export class PostgresCredentialsModule {} diff --git a/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.resolver.ts b/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.resolver.ts deleted file mode 100644 index ff3d4e9bee1..00000000000 --- a/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.resolver.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { UseGuards } from '@nestjs/common'; -import { Mutation, Query } from '@nestjs/graphql'; - -import { PermissionFlagType } from 'twenty-shared/constants'; - -import { MetadataResolver } from 'src/engine/api/graphql/graphql-config/decorators/metadata-resolver.decorator'; -import { PostgresCredentialsDTO } from 'src/engine/core-modules/postgres-credentials/dtos/postgres-credentials.dto'; -import { PostgresCredentialsService } from 'src/engine/core-modules/postgres-credentials/postgres-credentials.service'; -import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity'; -import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator'; -import { SettingsPermissionGuard } from 'src/engine/guards/settings-permission.guard'; -import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard'; - -@UseGuards( - WorkspaceAuthGuard, - SettingsPermissionGuard(PermissionFlagType.DATA_MODEL), -) -@MetadataResolver(() => PostgresCredentialsDTO) -export class PostgresCredentialsResolver { - constructor( - private readonly postgresCredentialsService: PostgresCredentialsService, - ) {} - - @Mutation(() => PostgresCredentialsDTO) - async enablePostgresProxy( - @AuthWorkspace() { id: workspaceId }: WorkspaceEntity, - ) { - return this.postgresCredentialsService.enablePostgresProxy(workspaceId); - } - - @Mutation(() => PostgresCredentialsDTO) - async disablePostgresProxy( - @AuthWorkspace() { id: workspaceId }: WorkspaceEntity, - ) { - return this.postgresCredentialsService.disablePostgresProxy(workspaceId); - } - - @Query(() => PostgresCredentialsDTO, { nullable: true }) - async getPostgresCredentials( - @AuthWorkspace() { id: workspaceId }: WorkspaceEntity, - ) { - return this.postgresCredentialsService.getPostgresCredentials(workspaceId); - } -} diff --git a/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.service.ts b/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.service.ts deleted file mode 100644 index a2c5f2794ff..00000000000 --- a/packages/twenty-server/src/engine/core-modules/postgres-credentials/postgres-credentials.service.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { BadRequestException } from '@nestjs/common'; -import { InjectRepository } from '@nestjs/typeorm'; - -import { randomBytes } from 'crypto'; - -import { Repository } from 'typeorm'; - -import { - decryptText, - encryptText, -} from 'src/engine/core-modules/auth/auth.util'; -import { NotFoundError } from 'src/engine/core-modules/graphql/utils/graphql-errors.util'; -import { JwtWrapperService } from 'src/engine/core-modules/jwt/services/jwt-wrapper.service'; -import { type PostgresCredentialsDTO } from 'src/engine/core-modules/postgres-credentials/dtos/postgres-credentials.dto'; -import { PostgresCredentialsEntity } from 'src/engine/core-modules/postgres-credentials/postgres-credentials.entity'; -import { JwtTokenTypeEnum } from 'src/engine/core-modules/auth/types/auth-context.type'; - -export class PostgresCredentialsService { - constructor( - @InjectRepository(PostgresCredentialsEntity) - private readonly postgresCredentialsRepository: Repository, - private readonly jwtWrapperService: JwtWrapperService, - ) {} - - async enablePostgresProxy( - workspaceId: string, - ): Promise { - const user = `user_${randomBytes(4).toString('hex')}`; - const password = randomBytes(16).toString('hex'); - - const key = this.jwtWrapperService.generateAppSecret( - JwtTokenTypeEnum.POSTGRES_PROXY, - workspaceId, - ); - const passwordHash = encryptText(password, key); - - const existingCredentials = - await this.postgresCredentialsRepository.findOne({ - where: { - workspaceId, - }, - }); - - if (existingCredentials) { - throw new BadRequestException( - 'Postgres credentials already exist for this workspace', - ); - } - - const postgresCredentials = await this.postgresCredentialsRepository.create( - { - user, - passwordHash, - workspaceId, - }, - ); - - await this.postgresCredentialsRepository.save(postgresCredentials); - - return { - id: postgresCredentials.id, - user, - password, - workspaceId, - }; - } - - async disablePostgresProxy( - workspaceId: string, - ): Promise { - const postgresCredentials = - await this.postgresCredentialsRepository.findOne({ - where: { - workspaceId, - }, - }); - - if (!postgresCredentials?.id) { - throw new NotFoundError( - 'No valid Postgres credentials not found for this workspace', - ); - } - - await this.postgresCredentialsRepository.delete({ - id: postgresCredentials.id, - }); - - const key = this.jwtWrapperService.generateAppSecret( - JwtTokenTypeEnum.POSTGRES_PROXY, - workspaceId, - ); - - return { - id: postgresCredentials.id, - user: postgresCredentials.user, - password: decryptText(postgresCredentials.passwordHash, key), - workspaceId: postgresCredentials.workspaceId, - }; - } - - async getPostgresCredentials( - workspaceId: string, - ): Promise { - const postgresCredentials = - await this.postgresCredentialsRepository.findOne({ - where: { - workspaceId, - }, - }); - - if (!postgresCredentials) { - return null; - } - - const key = this.jwtWrapperService.generateAppSecret( - JwtTokenTypeEnum.POSTGRES_PROXY, - workspaceId, - ); - - return { - id: postgresCredentials.id, - user: postgresCredentials.user, - password: decryptText(postgresCredentials.passwordHash, key), - workspaceId: postgresCredentials.workspaceId, - }; - } -} diff --git a/packages/twenty-server/src/engine/core-modules/workspace/constants/workspace-entity-non-cached-properties.constant.ts b/packages/twenty-server/src/engine/core-modules/workspace/constants/workspace-entity-non-cached-properties.constant.ts index 5600565240d..213c0ff4cf4 100644 --- a/packages/twenty-server/src/engine/core-modules/workspace/constants/workspace-entity-non-cached-properties.constant.ts +++ b/packages/twenty-server/src/engine/core-modules/workspace/constants/workspace-entity-non-cached-properties.constant.ts @@ -10,7 +10,6 @@ export const WORKSPACE_ENTITY_NON_CACHED_PROPERTIES = [ 'emailingDomains', 'publicDomains', 'workspaceMembersCount', - 'allPostgresCredentials', 'workspaceSSOIdentityProviders', 'agents', 'webhooks', diff --git a/packages/twenty-server/src/engine/core-modules/workspace/workspace.entity.ts b/packages/twenty-server/src/engine/core-modules/workspace/workspace.entity.ts index a7d70231743..9b1d86b028d 100644 --- a/packages/twenty-server/src/engine/core-modules/workspace/workspace.entity.ts +++ b/packages/twenty-server/src/engine/core-modules/workspace/workspace.entity.ts @@ -29,7 +29,6 @@ import { EmailingDomainEntity } from 'src/engine/core-modules/emailing-domain/em import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity'; import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity'; import { KeyValuePairEntity } from 'src/engine/core-modules/key-value-pair/key-value-pair.entity'; -import { PostgresCredentialsEntity } from 'src/engine/core-modules/postgres-credentials/postgres-credentials.entity'; import { PublicDomainEntity } from 'src/engine/core-modules/public-domain/public-domain.entity'; import { WorkspaceSSOIdentityProviderEntity } from 'src/engine/core-modules/sso/workspace-sso-identity-provider.entity'; import { UserWorkspaceEntity } from 'src/engine/core-modules/user-workspace/user-workspace.entity'; @@ -180,12 +179,6 @@ export class WorkspaceEntity { @Column({ type: 'timestamptz', nullable: true }) suspendedAt: Date | null; - @OneToMany( - () => PostgresCredentialsEntity, - (postgresCredentials) => postgresCredentials.workspace, - ) - allPostgresCredentials: Relation; - @OneToMany( () => WorkspaceSSOIdentityProviderEntity, (workspaceSSOIdentityProviders) => workspaceSSOIdentityProviders.workspace, diff --git a/packages/twenty-shared/src/metadata/constants/reserved-metadata-name-keywords.constant.ts b/packages/twenty-shared/src/metadata/constants/reserved-metadata-name-keywords.constant.ts index 8a271e73d82..f4f0265837d 100644 --- a/packages/twenty-shared/src/metadata/constants/reserved-metadata-name-keywords.constant.ts +++ b/packages/twenty-shared/src/metadata/constants/reserved-metadata-name-keywords.constant.ts @@ -27,8 +27,6 @@ export const RESERVED_METADATA_NAME_KEYWORDS = [ 'pageLayoutTabs', 'pageLayoutWidget', 'pageLayoutWidgets', - 'postgresCredential', - 'postgresCredentials', 'twoFactorMethod', 'twoFactorMethods', 'user',