Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
Seanaye/feat/add more soup events (#5252)
Sean Aye1c431ce85c01
diff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.jsonindex 34814fbe0c..1f4805949d 100644--- a/.github/workspace-dep-closures.json+++ b/.github/workspace-dep-closures.json@@ -951,6 +951,7 @@"crates/call","crates/channel_sender","crates/channels",+ "crates/chat","crates/complete_graph","crates/connection","crates/connection_gateway_client",@@ -960,6 +961,7 @@"crates/crm","crates/document_sub_type","crates/documents",+ "crates/dynamodb_client","crates/email","crates/email_db_client","crates/email_utils",@@ -994,6 +996,7 @@"crates/macro_event_broker","crates/macro_event_topics","crates/macro_service_urls",+ "crates/macro_sha_count_client","crates/macro_sync_service_jwt","crates/macro_user_id","crates/macro_uuid",@@ -1020,11 +1023,13 @@"crates/notification","crates/opensearch_client","crates/opensearch_query_builder",+ "crates/projects","crates/prompt","crates/properties","crates/rate_limit","crates/readonly_pool","crates/remote_env_var",+ "crates/roles_and_permissions","crates/s3_key","crates/secretsmanager_client","crates/share_permission_db_utils",@@ -2975,6 +2980,7 @@"crates/call","crates/channel_sender","crates/channels",+ "crates/chat","crates/connection","crates/connection_gateway_client","crates/connection_gateway_models",@@ -2983,6 +2989,7 @@"crates/crm","crates/document_sub_type","crates/documents",+ "crates/dynamodb_client","crates/email","crates/email_db_client","crates/email_utils",@@ -3011,6 +3018,7 @@"crates/macro_event_broker","crates/macro_event_topics","crates/macro_service_urls",+ "crates/macro_sha_count_client","crates/macro_sync_service_jwt","crates/macro_user_id","crates/macro_uuid",@@ -3037,11 +3045,13 @@"crates/notification","crates/opensearch_client","crates/opensearch_query_builder",+ "crates/projects","crates/prompt","crates/properties","crates/rate_limit","crates/readonly_pool","crates/remote_env_var",+ "crates/roles_and_permissions","crates/s3_key","crates/secretsmanager_client","crates/share_permission_db_utils",@@ -5390,6 +5400,7 @@"crates/call","crates/channel_sender","crates/channels",+ "crates/chat","crates/connection","crates/connection_gateway_client","crates/connection_gateway_models",@@ -5398,6 +5409,7 @@"crates/crm","crates/document_sub_type","crates/documents",+ "crates/dynamodb_client","crates/email","crates/email_db_client","crates/email_utils",@@ -5423,6 +5435,7 @@"crates/macro_event_broker","crates/macro_event_topics","crates/macro_service_urls",+ "crates/macro_sha_count_client","crates/macro_sync_service_jwt","crates/macro_user_id","crates/macro_uuid",@@ -5437,7 +5450,6 @@"crates/models_bulk_upload","crates/models_email","crates/models_entity_access_management",- "crates/models_grouping","crates/models_opensearch","crates/models_pagination","crates/models_permissions",@@ -5449,15 +5461,15 @@"crates/notification","crates/opensearch_client","crates/opensearch_query_builder",+ "crates/projects","crates/prompt","crates/properties","crates/rate_limit",- "crates/readonly_pool","crates/remote_env_var",+ "crates/roles_and_permissions","crates/s3_key","crates/secretsmanager_client","crates/share_permission_db_utils",- "crates/soup","crates/soup_realtime","crates/sqs_client","crates/sqs_worker",diff --git a/Cargo.lock b/Cargo.lockindex 52d086c7cc..72429e8e5c 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4279,6 +4279,7 @@ dependencies = ["frecency","futures","github",+ "graphql_soup","hex","http-body-util","jsonwebtoken 10.3.0",@@ -6161,6 +6162,7 @@ dependencies = ["axum-extra","chrono","document_sub_type",+ "either","email","entity_access","filter_ast",@@ -6174,11 +6176,14 @@ dependencies = ["model_file_type","models_grouping","models_pagination",+ "models_properties","models_soup",+ "rootcause","serde","serde_json","soup","soup_realtime",+ "tokio","uuid","workspace-hack",]@@ -13597,8 +13602,10 @@ name = "soup_realtime"version = "0.1.0"dependencies = ["broadcast",- "chrono",+ "channels",+ "chat","documents",+ "email","entity_access","futures","kafka_util",@@ -13606,13 +13613,11 @@ dependencies = ["macro_event_topics","macro_user_id","model-entity",- "models_properties",- "models_soup",+ "projects","rdkafka","rootcause","serde","serde_json",- "soup","tokio","tokio-retry","tracing",diff --git a/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.test.ts b/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.test.tsindex a26e0a6855..eb1e8b6009 100644--- a/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.test.ts+++ b/apps/web/src/lib/graphql-cache/exchange/normalized-cache-exchange.test.ts@@ -28,7 +28,6 @@ const QUERY = gql`query Soup($input: SoupInput!) {soup(input: $input) {nextCursor- hasMore}}`;diff --git a/apps/web/src/lib/service-clients/service-storage/graphql/generated/graphql.ts b/apps/web/src/lib/service-clients/service-storage/graphql/generated/graphql.tsindex ae4f316f14..2d1a0148d3 100644--- a/apps/web/src/lib/service-clients/service-storage/graphql/generated/graphql.ts+++ b/apps/web/src/lib/service-clients/service-storage/graphql/generated/graphql.ts@@ -1131,7 +1131,7 @@ export type SoupQueryVariables = Exact<{}>;-export type SoupQuery = { user: { id: string, soup: { nextCursor: string | null, hasMore: boolean, items: Array<+export type SoupQuery = { user: { id: string, soup: { nextCursor: string | null, items: Array<| { __typename: 'GraphqlSoupCall', channelId: string, channelName: string | null, createdBy: string, customName: string | null, summary: string | null, startedAt: string, endedAt: string | null, durationMs: number | null, isActive: boolean, status: string, attended: boolean, frecencyScore: number | null, id: string, entityType: GraphqlSoupEntityType, displayName: string | null, isFavorited: boolean, participants: Array<{ userId: string, joinedAt: string, leftAt: string | null }>, properties: Array<{ id: string, propertyDefinitionId: string, displayName: string, dataType: GraphqlPropertyDataType, isMultiSelect: boolean, specificEntityType: GraphqlPropertyEntityType | null, isSystem: boolean, isMetadata: boolean, value:| { __typename: 'GraphqlBooleanPropertyValue', boolValue: boolean }| { __typename: 'GraphqlDatePropertyValue', dateValue: string }@@ -1339,4 +1339,4 @@ export const SetEntityFavoriteDocument = {"kind":"Document","definitions":[{"kinexport const GroupSoupMembershipDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GroupSoupMembership"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"GroupedSoupInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"groupSoup"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bins"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}},{"kind":"Field","name":{"kind":"Name","value":"nextCursor"}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<GroupSoupMembershipQuery, GroupSoupMembershipQueryVariables>;export const GroupSoupDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GroupSoup"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"GroupedSoupInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"groupSoup"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"bins"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}},{"kind":"Field","name":{"kind":"Name","value":"nextCursor"}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupItemFields"}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupNotificationFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupNotification"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"eventType"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"sent"}},{"kind":"Field","name":{"kind":"Name","value":"done"}},{"kind":"Field","name":{"kind":"Name","value":"seen"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupEntityCoreFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"isFavorited"}},{"kind":"Field","name":{"kind":"Name","value":"notifications"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupNotificationFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupPropertyFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlProperty"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"propertyDefinitionId"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"dataType"}},{"kind":"Field","name":{"kind":"Name","value":"isMultiSelect"}},{"kind":"Field","name":{"kind":"Name","value":"specificEntityType"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"value"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlBooleanPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"boolValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlNumberPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"numberValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlStringPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"stringValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlDatePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dateValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSelectOptionPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"optionIds"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlEntityReferencePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"references"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"specificMessageId"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlLinkPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"urls"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupChannelMessageFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessagePreview"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"mentions"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupItemFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupEntityCoreFields"}},{"kind":"Field","name":{"kind":"Name","value":"frecencyScore"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupDocument"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"documentName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"fileType"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"subType"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlTaskSubType"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"isCompleted"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChat"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"chatName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"isPersistent"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupProject"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"projectName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"parentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEmailThread"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerId"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"inboxVisible"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","alias":{"kind":"Name","value":"emailName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"senderEmail"}},{"kind":"Field","name":{"kind":"Name","value":"senderName"}},{"kind":"Field","name":{"kind":"Name","value":"senderPhotoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isDraft"}},{"kind":"Field","name":{"kind":"Name","value":"isImportant"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"sortTs"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"sfsPhotoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"attachments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"providerAttachmentId"}},{"kind":"Field","name":{"kind":"Name","value":"filename"}},{"kind":"Field","name":{"kind":"Name","value":"mimeType"}},{"kind":"Field","name":{"kind":"Name","value":"sizeBytes"}},{"kind":"Field","name":{"kind":"Name","value":"contentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"messageListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"labelListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"type"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestContentMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"subject"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"internalDateTs"}},{"kind":"Field","name":{"kind":"Name","value":"sentAt"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isStarred"}},{"kind":"Field","name":{"kind":"Name","value":"isSent"}},{"kind":"Field","name":{"kind":"Name","value":"hasAttachments"}},{"kind":"Field","name":{"kind":"Name","value":"from"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"to"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bcc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bodyParsed"}},{"kind":"Field","name":{"kind":"Name","value":"bodyText"}},{"kind":"Field","name":{"kind":"Name","value":"bodyHtmlSanitized"}},{"kind":"Field","name":{"kind":"Name","value":"bodyMacro"}},{"kind":"Field","name":{"kind":"Name","value":"bodyReplyless"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannel"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"channelName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"channelType"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"organizationId"}},{"kind":"Field","alias":{"kind":"Name","value":"channelTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"interactedAt"}},{"kind":"Field","name":{"kind":"Name","value":"isParticipant"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestNonThreadMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessage"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"effectiveUpdatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"replyCount"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCall"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"channelName"}},{"kind":"Field","name":{"kind":"Name","value":"createdBy"}},{"kind":"Field","name":{"kind":"Name","value":"customName"}},{"kind":"Field","name":{"kind":"Name","value":"summary"}},{"kind":"Field","name":{"kind":"Name","value":"startedAt"}},{"kind":"Field","name":{"kind":"Name","value":"endedAt"}},{"kind":"Field","name":{"kind":"Name","value":"durationMs"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"attended"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCrmCompany"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"crmTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","alias":{"kind":"Name","value":"crmCompanyName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"emailSync"}},{"kind":"Field","name":{"kind":"Name","value":"hidden"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"domains"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupForeignEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"foreignEntityId"}},{"kind":"Field","name":{"kind":"Name","value":"foreignEntitySource"}},{"kind":"Field","name":{"kind":"Name","value":"storedForId"}},{"kind":"Field","name":{"kind":"Name","value":"storedForAuthEntity"}},{"kind":"Field","name":{"kind":"Name","value":"sourceMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<GroupSoupQuery, GroupSoupQueryVariables>;export const SetEntityPropertyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"SetEntityProperty"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"SetEntityPropertyInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"setEntityProperty"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupPropertyFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlProperty"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"propertyDefinitionId"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"dataType"}},{"kind":"Field","name":{"kind":"Name","value":"isMultiSelect"}},{"kind":"Field","name":{"kind":"Name","value":"specificEntityType"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"value"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlBooleanPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"boolValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlNumberPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"numberValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlStringPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"stringValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlDatePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dateValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSelectOptionPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"optionIds"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlEntityReferencePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"references"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"specificMessageId"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlLinkPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"urls"}}]}}]}}]}}]} as unknown as DocumentNode<SetEntityPropertyMutation, SetEntityPropertyMutationVariables>;-export const SoupDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Soup"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"SoupInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"soup"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupItemFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"nextCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasMore"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupNotificationFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupNotification"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"eventType"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"sent"}},{"kind":"Field","name":{"kind":"Name","value":"done"}},{"kind":"Field","name":{"kind":"Name","value":"seen"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupEntityCoreFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"isFavorited"}},{"kind":"Field","name":{"kind":"Name","value":"notifications"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupNotificationFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupPropertyFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlProperty"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"propertyDefinitionId"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"dataType"}},{"kind":"Field","name":{"kind":"Name","value":"isMultiSelect"}},{"kind":"Field","name":{"kind":"Name","value":"specificEntityType"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"value"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlBooleanPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"boolValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlNumberPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"numberValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlStringPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"stringValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlDatePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dateValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSelectOptionPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"optionIds"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlEntityReferencePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"references"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"specificMessageId"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlLinkPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"urls"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupChannelMessageFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessagePreview"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"mentions"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupItemFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupEntityCoreFields"}},{"kind":"Field","name":{"kind":"Name","value":"frecencyScore"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupDocument"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"documentName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"fileType"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"subType"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlTaskSubType"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"isCompleted"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChat"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"chatName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"isPersistent"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupProject"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"projectName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"parentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEmailThread"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerId"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"inboxVisible"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","alias":{"kind":"Name","value":"emailName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"senderEmail"}},{"kind":"Field","name":{"kind":"Name","value":"senderName"}},{"kind":"Field","name":{"kind":"Name","value":"senderPhotoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isDraft"}},{"kind":"Field","name":{"kind":"Name","value":"isImportant"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"sortTs"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"sfsPhotoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"attachments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"providerAttachmentId"}},{"kind":"Field","name":{"kind":"Name","value":"filename"}},{"kind":"Field","name":{"kind":"Name","value":"mimeType"}},{"kind":"Field","name":{"kind":"Name","value":"sizeBytes"}},{"kind":"Field","name":{"kind":"Name","value":"contentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"messageListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"labelListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"type"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestContentMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"subject"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"internalDateTs"}},{"kind":"Field","name":{"kind":"Name","value":"sentAt"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isStarred"}},{"kind":"Field","name":{"kind":"Name","value":"isSent"}},{"kind":"Field","name":{"kind":"Name","value":"hasAttachments"}},{"kind":"Field","name":{"kind":"Name","value":"from"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"to"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bcc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bodyParsed"}},{"kind":"Field","name":{"kind":"Name","value":"bodyText"}},{"kind":"Field","name":{"kind":"Name","value":"bodyHtmlSanitized"}},{"kind":"Field","name":{"kind":"Name","value":"bodyMacro"}},{"kind":"Field","name":{"kind":"Name","value":"bodyReplyless"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannel"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"channelName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"channelType"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"organizationId"}},{"kind":"Field","alias":{"kind":"Name","value":"channelTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"interactedAt"}},{"kind":"Field","name":{"kind":"Name","value":"isParticipant"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestNonThreadMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessage"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"effectiveUpdatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"replyCount"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCall"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"channelName"}},{"kind":"Field","name":{"kind":"Name","value":"createdBy"}},{"kind":"Field","name":{"kind":"Name","value":"customName"}},{"kind":"Field","name":{"kind":"Name","value":"summary"}},{"kind":"Field","name":{"kind":"Name","value":"startedAt"}},{"kind":"Field","name":{"kind":"Name","value":"endedAt"}},{"kind":"Field","name":{"kind":"Name","value":"durationMs"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"attended"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCrmCompany"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"crmTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","alias":{"kind":"Name","value":"crmCompanyName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"emailSync"}},{"kind":"Field","name":{"kind":"Name","value":"hidden"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"domains"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupForeignEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"foreignEntityId"}},{"kind":"Field","name":{"kind":"Name","value":"foreignEntitySource"}},{"kind":"Field","name":{"kind":"Name","value":"storedForId"}},{"kind":"Field","name":{"kind":"Name","value":"storedForAuthEntity"}},{"kind":"Field","name":{"kind":"Name","value":"sourceMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<SoupQuery, SoupQueryVariables>;\ No newline at end of file+export const SoupDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Soup"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"SoupInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"soup"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupItemFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"nextCursor"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupNotificationFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupNotification"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"eventType"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"sent"}},{"kind":"Field","name":{"kind":"Name","value":"done"}},{"kind":"Field","name":{"kind":"Name","value":"seen"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupEntityCoreFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"isFavorited"}},{"kind":"Field","name":{"kind":"Name","value":"notifications"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupNotificationFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupPropertyFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlProperty"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"propertyDefinitionId"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"dataType"}},{"kind":"Field","name":{"kind":"Name","value":"isMultiSelect"}},{"kind":"Field","name":{"kind":"Name","value":"specificEntityType"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"value"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlBooleanPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"boolValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlNumberPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"numberValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlStringPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"stringValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlDatePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"dateValue"},"name":{"kind":"Name","value":"value"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSelectOptionPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"optionIds"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlEntityReferencePropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"references"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entityId"}},{"kind":"Field","name":{"kind":"Name","value":"entityType"}},{"kind":"Field","name":{"kind":"Name","value":"specificMessageId"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlLinkPropertyValue"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"urls"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupChannelMessageFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessagePreview"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"mentions"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"SoupItemFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupEntityCoreFields"}},{"kind":"Field","name":{"kind":"Name","value":"frecencyScore"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupDocument"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"documentName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"fileType"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"subType"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlTaskSubType"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"isCompleted"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChat"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"chatName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"isPersistent"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupProject"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"projectName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"parentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupEmailThread"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerId"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"inboxVisible"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","alias":{"kind":"Name","value":"emailName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"senderEmail"}},{"kind":"Field","name":{"kind":"Name","value":"senderName"}},{"kind":"Field","name":{"kind":"Name","value":"senderPhotoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isDraft"}},{"kind":"Field","name":{"kind":"Name","value":"isImportant"}},{"kind":"Field","name":{"kind":"Name","value":"projectId"}},{"kind":"Field","name":{"kind":"Name","value":"sortTs"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"sfsPhotoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"attachments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"messageId"}},{"kind":"Field","name":{"kind":"Name","value":"providerAttachmentId"}},{"kind":"Field","name":{"kind":"Name","value":"filename"}},{"kind":"Field","name":{"kind":"Name","value":"mimeType"}},{"kind":"Field","name":{"kind":"Name","value":"sizeBytes"}},{"kind":"Field","name":{"kind":"Name","value":"contentId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"messageListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"labelListVisibility"}},{"kind":"Field","name":{"kind":"Name","value":"type"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestContentMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"threadId"}},{"kind":"Field","name":{"kind":"Name","value":"linkId"}},{"kind":"Field","name":{"kind":"Name","value":"subject"}},{"kind":"Field","name":{"kind":"Name","value":"snippet"}},{"kind":"Field","name":{"kind":"Name","value":"internalDateTs"}},{"kind":"Field","name":{"kind":"Name","value":"sentAt"}},{"kind":"Field","name":{"kind":"Name","value":"isRead"}},{"kind":"Field","name":{"kind":"Name","value":"isStarred"}},{"kind":"Field","name":{"kind":"Name","value":"isSent"}},{"kind":"Field","name":{"kind":"Name","value":"hasAttachments"}},{"kind":"Field","name":{"kind":"Name","value":"from"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"to"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bcc"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"photoUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"labels"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"providerLabelId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"bodyParsed"}},{"kind":"Field","name":{"kind":"Name","value":"bodyText"}},{"kind":"Field","name":{"kind":"Name","value":"bodyHtmlSanitized"}},{"kind":"Field","name":{"kind":"Name","value":"bodyMacro"}},{"kind":"Field","name":{"kind":"Name","value":"bodyReplyless"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannel"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"channelName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"channelType"}},{"kind":"Field","name":{"kind":"Name","value":"ownerId"}},{"kind":"Field","name":{"kind":"Name","value":"organizationId"}},{"kind":"Field","alias":{"kind":"Name","value":"channelTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"interactedAt"}},{"kind":"Field","name":{"kind":"Name","value":"isParticipant"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}},{"kind":"Field","name":{"kind":"Name","value":"latestNonThreadMessage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupChannelMessageFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupChannelMessage"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"senderId"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"effectiveUpdatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"replyCount"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCall"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"channelId"}},{"kind":"Field","name":{"kind":"Name","value":"channelName"}},{"kind":"Field","name":{"kind":"Name","value":"createdBy"}},{"kind":"Field","name":{"kind":"Name","value":"customName"}},{"kind":"Field","name":{"kind":"Name","value":"summary"}},{"kind":"Field","name":{"kind":"Name","value":"startedAt"}},{"kind":"Field","name":{"kind":"Name","value":"endedAt"}},{"kind":"Field","name":{"kind":"Name","value":"durationMs"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"attended"}},{"kind":"Field","name":{"kind":"Name","value":"participants"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"joinedAt"}},{"kind":"Field","name":{"kind":"Name","value":"leftAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupCrmCompany"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"crmTeamId"},"name":{"kind":"Name","value":"teamId"}},{"kind":"Field","alias":{"kind":"Name","value":"crmCompanyName"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"emailSync"}},{"kind":"Field","name":{"kind":"Name","value":"hidden"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"viewedAt"}},{"kind":"Field","name":{"kind":"Name","value":"domains"}},{"kind":"Field","name":{"kind":"Name","value":"properties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"SoupPropertyFields"}}]}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GraphqlSoupForeignEntity"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"foreignEntityId"}},{"kind":"Field","name":{"kind":"Name","value":"foreignEntitySource"}},{"kind":"Field","name":{"kind":"Name","value":"storedForId"}},{"kind":"Field","name":{"kind":"Name","value":"storedForAuthEntity"}},{"kind":"Field","name":{"kind":"Name","value":"sourceMetadata"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<SoupQuery, SoupQueryVariables>;\ No newline at end of filediff --git a/apps/web/src/lib/service-clients/service-storage/graphql/soup.graphql b/apps/web/src/lib/service-clients/service-storage/graphql/soup.graphqlindex 34c4f5f17a..dabbd82beb 100644--- a/apps/web/src/lib/service-clients/service-storage/graphql/soup.graphql+++ b/apps/web/src/lib/service-clients/service-storage/graphql/soup.graphql@@ -6,7 +6,6 @@ query Soup($input: SoupInput!) {...SoupItemFields}nextCursor- hasMore}}}diff --git a/apps/web/tauri/graphql_cache_plugin/src/engine/test.rs b/apps/web/tauri/graphql_cache_plugin/src/engine/test.rsindex 6a5c253941..c61feebceb 100644--- a/apps/web/tauri/graphql_cache_plugin/src/engine/test.rs+++ b/apps/web/tauri/graphql_cache_plugin/src/engine/test.rs@@ -2,7 +2,7 @@ use super::*;use pollster::block_on;const QUERY: &str = r#"query Soup($input: SoupInput!) {- user { id soup(input: $input) { nextCursor hasMore items { __typename id } } }+ user { id soup(input: $input) { nextCursor items { __typename id } } }}"#;fn variables() -> Variables {@@ -12,13 +12,12 @@ fn variables() -> Variables {vars}-fn soup_data(has_more: bool) -> serde_json::Value {+fn soup_data(has_next_page: bool) -> serde_json::Value {serde_json::json!({"user": {"id": "user-1","soup": {- "nextCursor": null,- "hasMore": has_more,+ "nextCursor": has_next_page.then_some("cursor-1"),"items": [{"__typename": "GraphqlSoupDocument", "id": "doc-1"}]}}@@ -94,7 +93,6 @@ fn record_selection_returns_native_cache_entities() {}}nextCursor- hasMore}}}"#;@@ -113,8 +111,7 @@ fn record_selection_returns_native_cache_entities() {"deletedAt": null,"subType": null}],- "nextCursor": null,- "hasMore": false+ "nextCursor": null}}});@@ -135,7 +132,10 @@ fn record_selection_returns_native_cache_entities() {10,)).unwrap();- assert_eq!(page.records, vec![serde_json::json!({"id": "doc-1", "name": "A note"})]);+ assert_eq!(+ page.records,+ vec![serde_json::json!({"id": "doc-1", "name": "A note"})]+ );assert!(page.next_cursor.is_none());}@@ -153,8 +153,8 @@ fn query_inspection_serializes_generated_variables_and_value() {assert_eq!(instances.len(), 1);assert_eq!(instances[0].variables, variables());assert_eq!(- instances[0].value.as_ref().unwrap()["hasMore"],- serde_json::json!(false)+ instances[0].value.as_ref().unwrap()["nextCursor"],+ serde_json::Value::Null);assert_eq!(serde_json::to_value(&instances).unwrap(),@@ -162,7 +162,6 @@ fn query_inspection_serializes_generated_variables_and_value() {"variables": {"input": {"limit": 1}},"value": {"nextCursor": null,- "hasMore": false,"items": [{"__typename": "GraphqlSoupDocument", "id": "doc-1"}]}}])diff --git a/crates/client/cache-core/tests/engine.rs b/crates/client/cache-core/tests/engine.rsindex 93cd4b74d5..216b2c03e8 100644--- a/crates/client/cache-core/tests/engine.rs+++ b/crates/client/cache-core/tests/engine.rs@@ -17,7 +17,6 @@ query Soup($input: SoupInput!) {... on GraphqlSoupDocument { documentName: name ownerId }}nextCursor- hasMore}}}@@ -45,8 +44,7 @@ fn page_for_user(user: &str, names: &[(&str, &str)]) -> Json {"documentName": name,"ownerId": user})).collect::<Vec<_>>(),- "nextCursor": null,- "hasMore": false+ "nextCursor": null}}})@@ -326,7 +324,6 @@ fn capacity_constrained_rewrite_preserves_fields() {... on GraphqlSoupDocument { documentName: name }}nextCursor- hasMore}}}@@ -340,8 +337,7 @@ fn capacity_constrained_rewrite_preserves_fields() {{ "__typename": "GraphqlSoupDocument", "id": "doc-2", "documentName": "B2" },{ "__typename": "GraphqlSoupDocument", "id": "doc-3", "documentName": "C2" }],- "nextCursor": null,- "hasMore": false+ "nextCursor": null}}});diff --git a/crates/client/cache-core/tests/optimistic.rs b/crates/client/cache-core/tests/optimistic.rsindex 980ec11d1d..ed8546caf8 100644--- a/crates/client/cache-core/tests/optimistic.rs+++ b/crates/client/cache-core/tests/optimistic.rs@@ -27,7 +27,7 @@ query Soup($input: SoupInput!) {}}}- hasMore+ nextCursor}}}@@ -86,7 +86,7 @@ fn soup_page(display_name: &str, value: &str) -> Json {}}]}],- "hasMore": false+ "nextCursor": null}}})@@ -453,7 +453,7 @@ fn clear_and_identity_reset_drop_durable_queue() {&json!({"user": {"id": "user-2",- "soup": { "items": [], "hasMore": false }+ "soup": { "items": [], "nextCursor": null }}}),Some("user-2"),diff --git a/crates/client/cache-core/tests/query_inspection.rs b/crates/client/cache-core/tests/query_inspection.rsindex a4b9b2dbdc..c3d4e57520 100644--- a/crates/client/cache-core/tests/query_inspection.rs+++ b/crates/client/cache-core/tests/query_inspection.rs@@ -107,14 +107,14 @@ fn enumerates_variants_aliases_and_misses_in_canonical_order() {// A different schema field on the same normalized user is ignored.let soup_query =- "query Soup($input: SoupInput!) { user { id soup(input: $input) { hasMore } } }";+ "query Soup($input: SoupInput!) { user { id soup(input: $input) { nextCursor } } }";engine.write_query(None,soup_query,Some("Soup"),&object(json!({"input": {"initial": {"limit": 20}}})),- &json!({"user": {"id": "user-1", "soup": {"hasMore": false}}}),+ &json!({"user": {"id": "user-1", "soup": {"nextCursor": null}}}),None,).awaitdiff --git a/crates/client/cache-core/tests/roundtrip.rs b/crates/client/cache-core/tests/roundtrip.rsindex 5a72a5b8a5..17d4453594 100644--- a/crates/client/cache-core/tests/roundtrip.rs+++ b/crates/client/cache-core/tests/roundtrip.rs@@ -41,7 +41,6 @@ query Soup($input: SoupInput!) {}}nextCursor- hasMore}}}@@ -129,8 +128,7 @@ fn response_data() -> Json {]}],- "nextCursor": "cursor-2",- "hasMore": true+ "nextCursor": "cursor-2"}}})@@ -240,7 +238,6 @@ fn entity_update_visible_through_other_query() {soup(input: $input) {items { __typename id ... on GraphqlSoupDocument { documentName: name } }nextCursor- hasMore}}}"#,@@ -255,8 +252,7 @@ fn entity_update_visible_through_other_query() {"id": "doc-1","documentName": "Renamed"}],- "nextCursor": null,- "hasMore": false+ "nextCursor": null}}});diff --git a/crates/client/cache-idb/tests/web.rs b/crates/client/cache-idb/tests/web.rsindex a437d3511e..f3f2d013e0 100644--- a/crates/client/cache-idb/tests/web.rs+++ b/crates/client/cache-idb/tests/web.rs@@ -175,13 +175,13 @@ async fn engine_over_idb() {let mut engine = Engine::new(storage);let query = r#"query Soup($input: SoupInput!) {- user { id soup(input: $input) { nextCursor hasMore items { __typename id } } }+ user { id soup(input: $input) { nextCursor items { __typename id } } }}"#;let serde_json::Value::Object(vars) = serde_json::json!({"input": {"limit": 1}}) else {unreachable!()};let data = serde_json::json!({- "user": { "id": "user-1", "soup": { "nextCursor": null, "hasMore": false, "items": [{"__typename": "GraphqlSoupDocument", "id": "doc-1"}] } }+ "user": { "id": "user-1", "soup": { "nextCursor": null, "items": [{"__typename": "GraphqlSoupDocument", "id": "doc-1"}] } }});enginediff --git a/crates/client/cache-sqlite/src/lib.rs b/crates/client/cache-sqlite/src/lib.rsindex a6cb734a5e..1e8f8cb9a1 100644--- a/crates/client/cache-sqlite/src/lib.rs+++ b/crates/client/cache-sqlite/src/lib.rs@@ -672,13 +672,13 @@ mod tests {let storage = SqliteStorage::open_in_memory("user-1").unwrap();let mut engine = Engine::new(storage);let query = r#"query Soup($input: SoupInput!) {- user { id soup(input: $input) { nextCursor hasMore items { __typename id } } }+ user { id soup(input: $input) { nextCursor items { __typename id } } }}"#;let serde_json::Value::Object(vars) = serde_json::json!({"input": {"limit": 1}}) else {unreachable!()};let data = serde_json::json!({- "user": { "id": "user-1", "soup": { "nextCursor": null, "hasMore": false, "items": [{"__typename": "GraphqlSoupDocument", "id": "doc-1"}] } }+ "user": { "id": "user-1", "soup": { "nextCursor": null, "items": [{"__typename": "GraphqlSoupDocument", "id": "doc-1"}] } }});engine.write_query(None, query, Some("Soup"), &vars, &data, None)diff --git a/crates/client/cache-sqlite/tests/mutation_queue.rs b/crates/client/cache-sqlite/tests/mutation_queue.rsindex 90ec692f84..668fdb214b 100644--- a/crates/client/cache-sqlite/tests/mutation_queue.rs+++ b/crates/client/cache-sqlite/tests/mutation_queue.rs@@ -19,7 +19,7 @@ query Soup($input: SoupInput!) {properties { id displayName }}}- hasMore+ nextCursor}}}@@ -138,7 +138,7 @@ fn restart_hydration_preserves_legacy_json_with_envelope_keys() {"id": "doc-1","properties": [{"id": "prop-1", "displayName": "Status"}]}],- "hasMore": false+ "nextCursor": null}}});let optimistic = json!({"version": 2,diff --git a/crates/client/cache-wasm/tests/web.rs b/crates/client/cache-wasm/tests/web.rsindex 851e3ecb10..38b7495529 100644--- a/crates/client/cache-wasm/tests/web.rs+++ b/crates/client/cache-wasm/tests/web.rs@@ -15,7 +15,6 @@ const QUERY: &str = r#"query Soup($input: SoupInput!) {idsoup(input: $input) {nextCursor- hasMoreitems {__typenameid@@ -41,7 +40,6 @@ async fn write_then_read_through_js_boundary() {"id": "user-1","soup": {"nextCursor": null,- "hasMore": false,"items": [{ "__typename": "GraphqlSoupDocument", "id": "doc-1" }]}}@@ -148,7 +146,7 @@ async fn write_then_read_through_js_boundary() {}const PROPERTY_QUERY: &str = r#"query Soup($input: SoupInput!) {- user { id soup(input: $input) { hasMore items {+ user { id soup(input: $input) { nextCursor items {__typenameid... on GraphqlSoupDocument { properties { id displayName } }@@ -168,7 +166,7 @@ async fn optimistic_write_round_trip() {let vars = serde_json::json!({"input": {"limit": 1}});let base = serde_json::json!({- "user": { "id": "user-1", "soup": { "hasMore": false, "items": [{+ "user": { "id": "user-1", "soup": { "nextCursor": null, "items": [{"__typename": "GraphqlSoupDocument","id": "doc-1","properties": [{ "id": "prop-1", "displayName": "Status" }]diff --git a/crates/complete_graph/src/schema.rs b/crates/complete_graph/src/schema.rsindex a7c42cbcd1..36fb9f91c6 100644--- a/crates/complete_graph/src/schema.rs+++ b/crates/complete_graph/src/schema.rs@@ -22,7 +22,7 @@ use graphql_properties::{PropertiesMutationRoot,};use graphql_soup::{- GraphqlSoupEntity, GroupedSoup, GroupedSoupInput, SoupInput, SoupPage, resolve_grouped_soup,+ GroupedSoup, GroupedSoupInput, SoupInput, SoupPage, SoupPatch, resolve_grouped_soup,resolve_soup, resolve_soup_updates,};use macro_authorization::{@@ -360,9 +360,7 @@ where&self,ctx: &Context<'_>,) -> async_graphql::Result<- impl async_graphql::futures_util::Stream<- Item = GraphqlSoupEntity<SoupEdges<NR, PR, ER, FR, AR>>,- >,+ impl async_graphql::futures_util::Stream<Item = SoupPatch<SoupEdges<NR, PR, ER, FR, AR>>>,> {resolve_soup_updates::<R, Auth, St, SoupEdges<NR, PR, ER, FR, AR>>(&self.service, ctx).await}diff --git a/crates/complete_graph/src/schema/test.rs b/crates/complete_graph/src/schema/test.rsindex 571c91b1a7..d7af256f14 100644--- a/crates/complete_graph/src/schema/test.rs+++ b/crates/complete_graph/src/schema/test.rs@@ -21,10 +21,12 @@ use macro_user_id::{lowercased::Lowercase,user_id::{MacroUserId, MacroUserIdStr},};+use model_entity::EntityType as ModelEntityType;use model_user::UserContext;use models_pagination::{PaginatedCursor, SimpleSortMethod};use models_soup::{document::SoupDocument, item::SoupItem};use rootcause::Report;+use soup_realtime::domain::models::Patch;use uuid::Uuid;use super::*;@@ -35,8 +37,7 @@ const VALID_INTERNAL_KEY: &str = "valid-internal-key";#[derive(Clone)]struct TestRealtimeSubscriptionService {- #[allow(clippy::type_complexity)]- receiver: Arc<Mutex<Option<tokio::sync::mpsc::Receiver<Arc<SoupItem<()>>>>>>,+ receiver: Arc<Mutex<Option<tokio::sync::mpsc::Receiver<Patch<model_entity::Entity<'static>>>>>>,subscribed_user: Arc<Mutex<Option<MacroUserIdStr<'static>>>>,}@@ -44,7 +45,7 @@ impl SoupRealtimeSubscriptionService for TestRealtimeSubscriptionService {fn subscribe(&self,user_id: MacroUserIdStr<'static>,- ) -> tokio::sync::mpsc::Receiver<Arc<SoupItem<()>>> {+ ) -> tokio::sync::mpsc::Receiver<Patch<model_entity::Entity<'static>>> {*self.subscribed_user.lock().expect("subscribed user lock") = Some(user_id);self.receiver.lock()@@ -616,7 +617,7 @@ async fn soup_updates_subscribes_as_the_authenticated_user() {NoOpEntityPermissionEdgeReader,> = build_schema_with_services(NoOpSoupService, realtime);let request = async_graphql::Request::new(- "subscription { soupUpdates { id entityType ... on GraphqlSoupDocument { name } } }",+ "subscription { soupUpdates { operation entity { id entityType } } }",).data(user_id.clone());let responses = schema.execute_stream(request);@@ -624,19 +625,18 @@ async fn soup_updates_subscribes_as_the_authenticated_user() {let document_id = Uuid::from_u128(42);sender- .send(Arc::new(grouped_document(document_id).map_extra(|_| ())))+ .send(Patch::Updated(+ ModelEntityType::Document.with_entity_string(document_id.to_string()),+ )).await.expect("subscription remains open");let response = responses.next().await.expect("one subscription response");assert!(response.errors.is_empty(), "{:?}", response.errors);let data = response.data.into_json().expect("response data is JSON");- assert_eq!(data["soupUpdates"]["id"], document_id.to_string());- assert_eq!(data["soupUpdates"]["entityType"], "DOCUMENT");- assert_eq!(- data["soupUpdates"]["name"],- format!("Document {document_id}")- );+ assert_eq!(data["soupUpdates"]["operation"], "UPDATED");+ assert_eq!(data["soupUpdates"]["entity"]["id"], document_id.to_string());+ assert_eq!(data["soupUpdates"]["entity"]["entityType"], "DOCUMENT");assert_eq!(subscribed_user.lock()@@ -688,7 +688,7 @@ async fn soup_passes_team_receipt_to_raw_path() {let harness = harness();let _response = harness- .execute("{ user { soup(input: {initial: {}}) { hasMore } } }")+ .execute("{ user { soup(input: {initial: {}}) { nextCursor } } }").await;assert_eq!(harness.inbox_calls.load(Ordering::SeqCst), 1);@@ -708,7 +708,7 @@ async fn soup_input_rejects_initial_and_continuation_together() {let response = harness.execute(- r#"{ user { soup(input: {initial: {}, continuation: {cursor: "invalid"}}) { hasMore } } }"#,+ r#"{ user { soup(input: {initial: {}, continuation: {cursor: "invalid"}}) { nextCursor } } }"#,).await;@@ -778,7 +778,7 @@ async fn crm_scoped_soup_resolves_team_membership_lazily() {// input still receives the always-resolved team receipt.let response = harness.execute(- r#"{ user { soup(input: {initial: {filters: {emailFilter: {crmScope: {domains: ["example.com"]}}}}}) { hasMore } } }"#,+ r#"{ user { soup(input: {initial: {filters: {emailFilter: {crmScope: {domains: ["example.com"]}}}}}) { nextCursor } } }"#,).await;diff --git a/crates/complete_graph/src/sdl_test.rs b/crates/complete_graph/src/sdl_test.rsindex 21e4fe3ca1..820deadb0a 100644--- a/crates/complete_graph/src/sdl_test.rs+++ b/crates/complete_graph/src/sdl_test.rs@@ -35,8 +35,12 @@ fn soup_response_schema_exposes_frontend_fields() {"deletedAt: String","type GraphqlSoupProject implements GraphqlSoupEntity {","parent: GraphqlEntity",+ "type SoupPatch {",+ "operation: GraphqlPatchOperation!",+ "entity: GraphqlEntity!",+ "item: GraphqlSoupEntity","type SoupSubscriptionRoot {",- "soupUpdates: GraphqlSoupEntity!",+ "soupUpdates: SoupPatch!",] {assert_sdl_line(&sdl, expected);}diff --git a/crates/graphql_common/src/entity_type.rs b/crates/graphql_common/src/entity_type.rsindex 26b5fdd30f..5ecba77721 100644--- a/crates/graphql_common/src/entity_type.rs+++ b/crates/graphql_common/src/entity_type.rs@@ -149,3 +149,12 @@ impl<'a> GraphqlEntity<'a> {GraphqlEntityType::new(self.0.entity_type)}}++/// Operation carried by a realtime entity patch.+#[derive(Enum, Clone, Copy, PartialEq, Eq)]+pub enum GraphqlPatchOperation {+ /// The entity was created or updated.+ Updated,+ /// The entity was deleted.+ Deleted,+}diff --git a/crates/graphql_common/src/lib.rs b/crates/graphql_common/src/lib.rsindex 3c1fe44c30..c8d44f3547 100644--- a/crates/graphql_common/src/lib.rs+++ b/crates/graphql_common/src/lib.rs@@ -21,7 +21,9 @@ mod property_filter;mod request_context;pub use authorization::require_authorized_user;-pub use entity_type::{GraphqlEntity, GraphqlEntityType, GraphqlSoupEntityType};+pub use entity_type::{+ GraphqlEntity, GraphqlEntityType, GraphqlPatchOperation, GraphqlSoupEntityType,+};pub use extract::extract_part;pub use filter_input::{IntoFilterExpr, optional_tree, parse_id, parse_macro_user_id, parse_uuid};pub use property_filter::{diff --git a/crates/graphql_soup/Cargo.toml b/crates/graphql_soup/Cargo.tomlindex 3faeb79be0..8bc0f58ad0 100644--- a/crates/graphql_soup/Cargo.toml+++ b/crates/graphql_soup/Cargo.toml@@ -31,9 +31,15 @@ model_file_type = { path = "../model_file_type" }models_grouping = { path = "../models_grouping" }models_pagination = { path = "../models_pagination" }models_soup = { path = "../models_soup" }+rootcause = { workspace = true }serde = { workspace = true }serde_json = { workspace = true }soup = { path = "../soup", default-features = false, features = ["ports"] }soup_realtime = { path = "../soup_realtime", default-features = false, features = ["ports"] }+tokio = { workspace = true }uuid = { workspace = true }workspace-hack = { version = "0.1", path = "../workspace-hack" }++[dev-dependencies]+either = { workspace = true }+models_properties = { path = "../models_properties" }diff --git a/crates/graphql_soup/src/lib.rs b/crates/graphql_soup/src/lib.rsindex d9c4cd748e..750629f91d 100644--- a/crates/graphql_soup/src/lib.rs+++ b/crates/graphql_soup/src/lib.rs@@ -8,6 +8,8 @@/// GraphQL inputs and conversion into Soup domain requests.mod inputs;+/// DataLoader-backed hydration for realtime Soup patches.+mod loaders;/// GraphQL objects representing Soup pages and entities.mod objects;/// Top-level Soup query resolver.@@ -15,10 +17,15 @@ mod resolvers;pub use graphql_common::{GraphqlRequestParts, GraphqlSoupEntityType};pub use inputs::{GraphqlSimpleSortMethod, GroupedSoupInput, SoupInput};+pub use loaders::{+ EmailServiceInboxReader, SoupInboxReader, SoupItemDataLoader, SoupItemLoader,+ SoupItemLoaderError, SoupItemLoaderKey, soup_item_loader,+};pub use objects::{GraphqlSoupBin, GraphqlSoupCall, GraphqlSoupChannel, GraphqlSoupChannelMessage,GraphqlSoupChannelMessagePreview, GraphqlSoupChat, GraphqlSoupCrmCompany, GraphqlSoupDocument,GraphqlSoupDocumentSubType, GraphqlSoupEmailThread, GraphqlSoupEntity,GraphqlSoupForeignEntity, GraphqlSoupProject, GroupedSoup, SoupEntityEdges, SoupPage,+ SoupPatch,};pub use resolvers::{resolve_grouped_soup, resolve_soup, resolve_soup_updates};diff --git a/crates/graphql_soup/src/loaders.rs b/crates/graphql_soup/src/loaders.rsnew file mode 100644index 0000000000..4b9cafd736--- /dev/null+++ b/crates/graphql_soup/src/loaders.rs@@ -0,0 +1,395 @@+//! DataLoader-backed hydration of lightweight realtime Soup patches.++#[cfg(test)]+mod test;++use std::{+ collections::{HashMap, HashSet},+ future::Future,+ sync::Arc,+};++use async_graphql::dataloader::{DataLoader, Loader};+use email::domain::{+ models::{PreviewView, PreviewViewStandardLabel},+ ports::EmailService,+};+use filter_ast::Expr;+use futures::{future::BoxFuture, future::try_join_all};+use item_filters::ast::{+ EmailFilterAst, EntityFilterAst,+ call::CallLiteral,+ channel::{ChannelLiteral, ChannelThreadLiteral},+ chat::ChatLiteral,+ crm_company::CrmCompanyLiteral,+ document::DocumentLiteral,+ email::EmailLiteral,+ foreign_entity::ForeignEntityLiteral,+ project::ProjectLiteral,+};+use macro_user_id::user_id::MacroUserIdStr;+use model_entity::{Entity, EntityType};+use models_pagination::SimpleSortMethod;+use models_soup::item::SoupItem;+use rootcause::{+ Report,+ markers::{Cloneable, Dynamic},+};+use soup::domain::{+ models::{SoupQuery, SoupRequest, SoupType},+ ports::SoupService,+};+use uuid::Uuid;++/// Maximum number of entity keys folded into one user-scoped Soup request.+const MAX_BATCH_SIZE: usize = 500;++/// Key used to hydrate one Soup item for one viewer.+pub type SoupItemLoaderKey = (MacroUserIdStr<'static>, Entity<'static>);++/// Cloneable error returned by the realtime Soup item loader.+pub type SoupItemLoaderError = Report<Dynamic, Cloneable>;++/// Resolves the inboxes visible to a user for email-thread Soup hydration.+pub trait SoupInboxReader: Send + Sync + 'static {+ /// Return the IDs of every inbox visible to `user_id`.+ fn get_inbox_ids(+ &self,+ user_id: MacroUserIdStr<'static>,+ ) -> impl Future<Output = Result<Vec<Uuid>, SoupItemLoaderError>> + Send;+}++/// Inbox reader backed by the email domain service.+pub struct EmailServiceInboxReader<E> {+ /// Shared email service used to resolve visible inboxes.+ service: Arc<E>,+}++impl<E> EmailServiceInboxReader<E> {+ /// Construct an inbox reader from the shared email service.+ pub fn new(service: Arc<E>) -> Self {+ Self { service }+ }+}++impl<E> SoupInboxReader for EmailServiceInboxReader<E>+where+ E: EmailService,+{+ async fn get_inbox_ids(+ &self,+ user_id: MacroUserIdStr<'static>,+ ) -> Result<Vec<Uuid>, SoupItemLoaderError> {+ self.service+ .get_inboxes_for_macro_id(user_id)+ .await+ .map(|links| links.into_iter().map(|link| link.id).collect())+ .map_err(|error| rootcause::report!(error).into_dynamic().into_cloneable())+ }+}++/// Batches lightweight entity patches into one filtered Soup request per user.+pub struct SoupItemLoader<S, I> {+ /// Existing Soup query service.+ soup_service: S,+ /// Reader used only when a batch requests email threads.+ inbox_reader: I,+}++impl<S, I> SoupItemLoader<S, I> {+ /// Construct a Soup item loader from its existing domain services.+ pub fn new(soup_service: S, inbox_reader: I) -> Self {+ Self {+ soup_service,+ inbox_reader,+ }+ }+}++impl<S, I> SoupItemLoader<S, I>+where+ S: SoupService,+ I: SoupInboxReader,+{+ /// Execute one filtered Soup request for one user's portion of a batch.+ async fn load_user(+ &self,+ user_id: MacroUserIdStr<'static>,+ entities: Vec<Entity<'static>>,+ ) -> Result<HashMap<SoupItemLoaderKey, SoupItem<()>>, SoupItemLoaderError> {+ let requested = entities.iter().cloned().collect::<HashSet<_>>();+ let needs_inboxes = entities+ .iter()+ .any(|entity| entity.entity_type == EntityType::EmailThread);+ let link_ids = if needs_inboxes {+ self.inbox_reader.get_inbox_ids(user_id.clone()).await?+ } else {+ Vec::new()+ };+ let filter = entity_filter_ast(&entities)?;+ let limit = u16::try_from(entities.len())+ .unwrap_or(MAX_BATCH_SIZE as u16)+ .clamp(1, MAX_BATCH_SIZE as u16);+ let request = SoupRequest {+ soup_type: SoupType::Expanded,+ limit,+ cursor: SoupQuery::new_sort_simple(SimpleSortMethod::UpdatedAt, filter),+ user: user_id.clone(),+ email_preview_view: PreviewView::StandardLabel(PreviewViewStandardLabel::All),+ link_ids,+ };++ let items = self+ .soup_service+ .get_user_soup(request, None)+ .await+ .map_err(|error| rootcause::report!(error).into_dynamic().into_cloneable())?+ .either(|page| page.items, |page| page.items);++ let mut loaded = HashMap::with_capacity(items.len());+ for item in items {+ let entity = item.entity();+ if !requested.contains(&entity) {+ return Err(rootcause::report!(+ "filtered Soup request returned unrequested entity {} {}",+ entity.entity_type,+ entity.entity_id+ )+ .into_cloneable());+ }+ if loaded+ .insert((user_id.clone(), entity.clone()), item)+ .is_some()+ {+ return Err(rootcause::report!(+ "filtered Soup request returned duplicate entity {} {}",+ entity.entity_type,+ entity.entity_id+ )+ .into_cloneable());+ }+ }++ Ok(loaded)+ }+}++impl<S, I> SoupItemLoader<S, I>+where+ S: SoupService,+ I: SoupInboxReader,+{+ /// Partition keys by user and execute one Soup request for each user.+ async fn load_keys(+ &self,+ keys: Vec<SoupItemLoaderKey>,+ ) -> Result<HashMap<SoupItemLoaderKey, SoupItem<()>>, SoupItemLoaderError> {+ let mut entities_by_user = HashMap::<MacroUserIdStr<'static>, Vec<Entity<'static>>>::new();+ for (user_id, entity) in keys {+ entities_by_user.entry(user_id).or_default().push(entity);+ }++ let batches = entities_by_user+ .into_iter()+ .map(|(user_id, entities)| self.load_user(user_id, entities));+ let loaded = try_join_all(batches).await?;+ Ok(loaded.into_iter().flatten().collect())+ }+}++impl<S, I> Loader<SoupItemLoaderKey> for SoupItemLoader<S, I>+where+ S: SoupService,+ I: SoupInboxReader,+{+ type Value = SoupItem<()>;+ type Error = SoupItemLoaderError;++ async fn load(+ &self,+ keys: &[SoupItemLoaderKey],+ ) -> Result<HashMap<SoupItemLoaderKey, Self::Value>, Self::Error> {+ self.load_keys(keys.to_vec()).await+ }+}++/// Owned key used only across the type-erased GraphQL context boundary.+#[derive(Clone, Hash, PartialEq, Eq)]+struct OwnedSoupItemLoaderKey {+ /// User whose Soup visibility applies.+ user_id: MacroUserIdStr<'static>,+ /// Entity to hydrate.+ entity: Entity<'static>,+}++impl<S, I> Loader<OwnedSoupItemLoaderKey> for SoupItemLoader<S, I>+where+ S: SoupService,+ I: SoupInboxReader,+{+ type Value = SoupItem<()>;+ type Error = SoupItemLoaderError;++ async fn load(+ &self,+ keys: &[OwnedSoupItemLoaderKey],+ ) -> Result<HashMap<OwnedSoupItemLoaderKey, Self::Value>, Self::Error> {+ let tuple_keys = keys+ .iter()+ .map(|key| (key.user_id.clone(), key.entity.clone()))+ .collect();+ let loaded = self.load_keys(tuple_keys).await?;+ Ok(loaded+ .into_iter()+ .map(|((user_id, entity), item)| (OwnedSoupItemLoaderKey { user_id, entity }, item))+ .collect())+ }+}++/// Type-erased function that loads one Soup item through a concrete DataLoader.+type LoadOne = dyn Fn(+ OwnedSoupItemLoaderKey,+ ) -> BoxFuture<'static, Result<Option<SoupItem<()>>, SoupItemLoaderError>>+ + Send+ + Sync;++/// Load one statically owned key through a concrete DataLoader.+async fn load_one_owned<S, I>(+ loader: Arc<DataLoader<SoupItemLoader<S, I>>>,+ key: OwnedSoupItemLoaderKey,+) -> Result<Option<SoupItem<()>>, SoupItemLoaderError>+where+ S: SoupService,+ I: SoupInboxReader,+{+ loader.load_one::<OwnedSoupItemLoaderKey>(key).await+}++/// Type-erased Soup DataLoader stored in GraphQL request or connection data.+#[derive(Clone)]+pub struct SoupItemDataLoader {+ /// Function backed by the concrete async-graphql DataLoader.+ load_one: Arc<LoadOne>,+}++impl SoupItemDataLoader {+ /// Construct a type-erased DataLoader from a concrete loader implementation.+ fn new<S, I>(loader: SoupItemLoader<S, I>) -> Self+ where+ S: SoupService,+ I: SoupInboxReader,+ {+ let loader = Arc::new(DataLoader::new(loader, tokio::spawn).max_batch_size(MAX_BATCH_SIZE));+ // A WebSocket may receive repeated updates for the same entity. Only+ // coalesce concurrent loads; never retain an item across updates.+ loader.enable_all_cache(false);+ Self {+ load_one: Arc::new(move |key| {+ let loader = Arc::clone(&loader);+ Box::pin(load_one_owned(loader, key))+ }),+ }+ }++ /// Load one Soup item for one viewer.+ pub async fn load_one(+ &self,+ key: SoupItemLoaderKey,+ ) -> Result<Option<SoupItem<()>>, SoupItemLoaderError> {+ let (user_id, entity) = key;+ (self.load_one)(OwnedSoupItemLoaderKey { user_id, entity }).await+ }+}++/// Build the realtime Soup DataLoader from the existing Soup and email services.+pub fn soup_item_loader<S, E>(soup_service: S, email_service: Arc<E>) -> SoupItemDataLoader+where+ S: SoupService,+ E: EmailService,+{+ SoupItemDataLoader::new(SoupItemLoader::new(+ soup_service,+ EmailServiceInboxReader::new(email_service),+ ))+}++/// Build an OR tree from literals, falling back to an impossible literal when empty.+fn literal_tree<T>(literals: Vec<T>, impossible: T) -> Arc<Expr<T>> {+ Arc::new(+ literals+ .into_iter()+ .map(Expr::val)+ .reduce(Expr::or)+ .unwrap_or_else(|| Expr::val(impossible)),+ )+}++/// Encode an exact entity set into all branches of the Soup filter AST.+fn entity_filter_ast(entities: &[Entity<'static>]) -> Result<EntityFilterAst, SoupItemLoaderError> {+ let mut documents = Vec::new();+ let mut chats = Vec::new();+ let mut projects = Vec::new();+ let mut email_threads = Vec::new();+ let mut channels = Vec::new();+ let mut channel_threads = Vec::new();+ let mut calls = Vec::new();+ let mut crm_companies = Vec::new();+ let mut foreign_entities = Vec::new();++ for entity in entities {+ let id = Uuid::parse_str(entity.entity_id.as_ref()).map_err(|error| {+ rootcause::report!(+ "invalid {} entity id {}: {error}",+ entity.entity_type,+ entity.entity_id+ )+ .into_cloneable()+ })?;+ match entity.entity_type {+ EntityType::Document => documents.push(DocumentLiteral::Id(id)),+ EntityType::Chat => chats.push(ChatLiteral::ChatId(id)),+ EntityType::Project => projects.push(ProjectLiteral::ProjectIdSelf(id)),+ EntityType::EmailThread => email_threads.push(EmailLiteral::ThreadId(id)),+ EntityType::Channel => channels.push(ChannelLiteral::ChannelId(id)),+ EntityType::ChannelMessage => {+ channel_threads.push(ChannelThreadLiteral::ThreadId(id));+ }+ EntityType::Call => calls.push(CallLiteral::CallId(id)),+ EntityType::CrmCompany => crm_companies.push(CrmCompanyLiteral::Id(id)),+ EntityType::ForeignEntity => foreign_entities.push(ForeignEntityLiteral::Id(id)),+ EntityType::User+ | EntityType::Team+ | EntityType::StaticFile+ | EntityType::CrmContact => {+ return Err(rootcause::report!(+ "entity type {} is not represented in Soup",+ entity.entity_type+ )+ .into_cloneable());+ }+ }+ }++ let nil = Uuid::nil();+ Ok(EntityFilterAst {+ document_filter: Some(literal_tree(documents, DocumentLiteral::Id(nil))),+ project_filter: Some(literal_tree(projects, ProjectLiteral::ProjectIdSelf(nil))),+ chat_filter: Some(literal_tree(chats, ChatLiteral::ChatId(nil))),+ email_filter: EmailFilterAst {+ tree: Some(literal_tree(email_threads, EmailLiteral::ThreadId(nil))),+ crm_scope: None,+ },+ channel_filter: Some(literal_tree(channels, ChannelLiteral::ChannelId(nil))),+ channel_thread_filter: Some(literal_tree(+ channel_threads,+ ChannelThreadLiteral::ThreadId(nil),+ )),+ call_filter: Some(literal_tree(calls, CallLiteral::CallId(nil))),+ crm_company_filter: Some(literal_tree(crm_companies, CrmCompanyLiteral::Id(nil))),+ foreign_entity_filter: Some(literal_tree(+ foreign_entities,+ ForeignEntityLiteral::Id(nil),+ )),+ properties_filter: None,+ })+}diff --git a/crates/graphql_soup/src/loaders/test.rs b/crates/graphql_soup/src/loaders/test.rsnew file mode 100644index 0000000000..f39ef31c3e--- /dev/null+++ b/crates/graphql_soup/src/loaders/test.rs@@ -0,0 +1,467 @@+use std::{+ collections::{HashMap, HashSet},+ sync::{Arc, Mutex},+};++use chrono::{DateTime, Utc};+use either::Either;+use entity_access::domain::models::{EntityAccessReceipt, MemberTeamRole};+use item_filters::ast::{+ call::CallLiteral,+ channel::{ChannelLiteral, ChannelThreadLiteral},+ chat::ChatLiteral,+ crm_company::CrmCompanyLiteral,+ document::DocumentLiteral,+ email::EmailLiteral,+ foreign_entity::ForeignEntityLiteral,+ project::ProjectLiteral,+};+use models_pagination::{Paginated, PaginatedCursor};+use models_properties::service::property_definition_with_options::PropertyDefinitionWithOptions;+use models_soup::document::SoupDocument;+use soup::domain::{+ models::{+ EnrichedSoupItem, GroupedSortRequest, IntoSoupReqAst, SoupErr, SoupPropertiesField,+ SoupRequest, grouping::ItemGroupingInfo,+ },+ ports::{SoupOutput, SoupService},+};++use super::*;++/// One Soup request observed by the recording service.+#[derive(Debug)]+struct RecordedRequest {+ /// User attached to the request.+ user_id: MacroUserIdStr<'static>,+ /// Requested page size.+ limit: u16,+ /// Inbox IDs attached to the request.+ link_ids: Vec<Uuid>,+}++/// Soup service that records raw requests and returns configured items by user.+#[derive(Clone, Default)]+struct RecordingSoupService {+ /// Requests received by the service.+ calls: Arc<Mutex<Vec<RecordedRequest>>>,+ /// Items returned for each user.+ responses: Arc<Mutex<HashMap<MacroUserIdStr<'static>, Vec<SoupItem<()>>>>>,+}++impl RecordingSoupService {+ /// Configure the items returned for a user.+ fn with_response(self, user_id: MacroUserIdStr<'static>, items: Vec<SoupItem<()>>) -> Self {+ self.responses+ .lock()+ .expect("responses lock")+ .insert(user_id, items);+ self+ }+}++impl SoupService for RecordingSoupService {+ async fn get_user_soup<T>(+ &self,+ req: SoupRequest<T>,+ team_receipt: Option<EntityAccessReceipt<MemberTeamRole>>,+ ) -> Result<SoupOutput<T>, SoupErr>+ where+ SoupRequest<T>: IntoSoupReqAst,+ T: Clone + serde::Serialize + Send,+ {+ assert!(team_receipt.is_none());+ let items = self+ .responses+ .lock()+ .expect("responses lock")+ .get(&req.user)+ .cloned()+ .unwrap_or_default();+ self.calls+ .lock()+ .expect("calls lock")+ .push(RecordedRequest {+ user_id: req.user,+ limit: req.limit,+ link_ids: req.link_ids,+ });+ let page: PaginatedCursor<SoupItem<()>, String, SimpleSortMethod, T> =+ Paginated::from_parts(items, None);+ Ok(Either::Left(page))+ }++ async fn get_user_soup_with_properties<T>(+ &self,+ _req: SoupRequest<T>,+ _team_receipt: Option<EntityAccessReceipt<MemberTeamRole>>,+ ) -> Result<SoupOutput<T, EnrichedSoupItem>, SoupErr>+ where+ SoupRequest<T>: IntoSoupReqAst,+ T: Clone + serde::Serialize + Send,+ {+ unreachable!("loader only performs raw Soup queries")+ }++ async fn get_user_soup_with_frecency<T>(+ &self,+ _req: SoupRequest<T>,+ _team_receipt: Option<EntityAccessReceipt<MemberTeamRole>>,+ ) -> Result<SoupOutput<T, EnrichedSoupItem>, SoupErr>+ where+ SoupRequest<T>: IntoSoupReqAst,+ T: Clone + serde::Serialize + Send,+ {+ unreachable!("loader only performs raw Soup queries")+ }++ async fn get_user_soup_with_properties_and_frecency<T>(+ &self,+ _req: SoupRequest<T>,+ _team_receipt: Option<EntityAccessReceipt<MemberTeamRole>>,+ ) -> Result<SoupOutput<T, EnrichedSoupItem>, SoupErr>+ where+ SoupRequest<T>: IntoSoupReqAst,+ T: Clone + serde::Serialize + Send,+ {+ unreachable!("loader only performs raw Soup queries")+ }++ async fn get_user_soup_grouped(+ &self,+ _req: GroupedSortRequest<'_>,+ ) -> Result<impl Iterator<Item = ItemGroupingInfo<SoupPropertiesField>> + Send, SoupErr> {+ unreachable!("loader does not perform grouped Soup queries");+ #[allow(unreachable_code)]+ Ok(Vec::<ItemGroupingInfo<SoupPropertiesField>>::new().into_iter())+ }++ async fn caller_tag_sets<'a>(+ &self,+ _user_id: MacroUserIdStr<'a>,+ ) -> Result<Vec<PropertyDefinitionWithOptions>, SoupErr> {+ unreachable!("loader does not load tag definitions")+ }+}++/// Inbox reader that records users and returns configured inbox IDs.+#[derive(Clone, Default)]+struct RecordingInboxReader {+ /// Users whose inboxes were requested.+ calls: Arc<Mutex<Vec<MacroUserIdStr<'static>>>>,+ /// Inbox IDs returned for each user.+ responses: Arc<HashMap<MacroUserIdStr<'static>, Vec<Uuid>>>,+}++impl SoupInboxReader for RecordingInboxReader {+ async fn get_inbox_ids(+ &self,+ user_id: MacroUserIdStr<'static>,+ ) -> Result<Vec<Uuid>, SoupItemLoaderError> {+ self.calls+ .lock()+ .expect("inbox calls lock")+ .push(user_id.clone());+ Ok(self.responses.get(&user_id).cloned().unwrap_or_default())+ }+}++/// Build a stable test user ID.+fn user(value: &str) -> MacroUserIdStr<'static> {+ MacroUserIdStr::try_from(value.to_string()).expect("valid user id")+}++/// Build a document Soup item for loader result mapping.+fn document(id: Uuid) -> SoupItem<()> {+ document_named(id, format!("Document {id}"))+}++/// Build a document Soup item with an explicit name.+fn document_named(id: Uuid, name: impl Into<String>) -> SoupItem<()> {+ SoupItem::Document(SoupDocument {+ id,+ document_version_id: 1,+ owner_id: user("macro|[email protected]"),+ name: name.into(),+ file_type: None,+ sha: None,+ project_id: None,+ branched_from_id: None,+ branched_from_version_id: None,+ document_family_id: None,+ created_at: DateTime::<Utc>::default(),+ updated_at: DateTime::<Utc>::default(),+ viewed_at: None,+ sub_type: None,+ deleted_at: None,+ extra: (),+ })+}++/// Collect literal UUIDs from a binary expression tree.+fn collect_ids<T>(expr: &Expr<T>, literal_id: impl Copy + Fn(&T) -> Option<Uuid>) -> HashSet<Uuid> {+ match expr {+ Expr::And(left, right) | Expr::Or(left, right) => {+ let mut ids = collect_ids(left, literal_id);+ ids.extend(collect_ids(right, literal_id));+ ids+ }+ Expr::Not(inner) => collect_ids(inner, literal_id),+ Expr::Literal(literal) => literal_id(literal).into_iter().collect(),+ }+}++#[tokio::test]+async fn batches_all_keys_for_one_user_into_one_soup_request() {+ let user_id = user("macro|[email protected]");+ let first_id = Uuid::from_u128(1);+ let second_id = Uuid::from_u128(2);+ let service = RecordingSoupService::default().with_response(+ user_id.clone(),+ vec![document(first_id), document(second_id)],+ );+ let calls = Arc::clone(&service.calls);+ let loader = SoupItemLoader::new(service, RecordingInboxReader::default());+ let keys = vec![+ (+ user_id.clone(),+ EntityType::Document.with_entity_string(first_id.to_string()),+ ),+ (+ user_id.clone(),+ EntityType::Document.with_entity_string(second_id.to_string()),+ ),+ ];++ let loaded = Loader::<SoupItemLoaderKey>::load(&loader, &keys)+ .await+ .expect("batch loads");++ assert_eq!(loaded.len(), 2);+ let calls = calls.lock().expect("calls lock");+ assert_eq!(calls.len(), 1);+ assert_eq!(calls[0].user_id, user_id);+ assert_eq!(calls[0].limit, 2);+}++#[tokio::test]+async fn separates_one_soup_request_per_unique_user() {+ let first_user = user("macro|[email protected]");+ let second_user = user("macro|[email protected]");+ let first_id = Uuid::from_u128(1);+ let second_id = Uuid::from_u128(2);+ let service = RecordingSoupService::default()+ .with_response(first_user.clone(), vec![document(first_id)])+ .with_response(second_user.clone(), vec![document(second_id)]);+ let calls = Arc::clone(&service.calls);+ let loader = SoupItemLoader::new(service, RecordingInboxReader::default());+ let keys = vec![+ (+ first_user.clone(),+ EntityType::Document.with_entity_string(first_id.to_string()),+ ),+ (+ second_user.clone(),+ EntityType::Document.with_entity_string(second_id.to_string()),+ ),+ ];++ let loaded = Loader::<SoupItemLoaderKey>::load(&loader, &keys)+ .await+ .expect("batch loads");++ assert_eq!(loaded.len(), 2);+ let users = calls+ .lock()+ .expect("calls lock")+ .iter()+ .map(|call| call.user_id.clone())+ .collect::<HashSet<_>>();+ assert_eq!(users, HashSet::from([first_user, second_user]));+}++#[tokio::test]+async fn resolves_inboxes_once_for_a_users_email_entities() {+ let user_id = user("macro|[email protected]");+ let first_id = Uuid::from_u128(11);+ let second_id = Uuid::from_u128(12);+ let inbox_id = Uuid::from_u128(13);+ let service = RecordingSoupService::default();+ let soup_calls = Arc::clone(&service.calls);+ let inbox_calls = Arc::new(Mutex::new(Vec::new()));+ let inbox_reader = RecordingInboxReader {+ calls: Arc::clone(&inbox_calls),+ responses: Arc::new(HashMap::from([(user_id.clone(), vec![inbox_id])])),+ };+ let loader = SoupItemLoader::new(service, inbox_reader);+ let keys = vec![+ (+ user_id.clone(),+ EntityType::EmailThread.with_entity_string(first_id.to_string()),+ ),+ (+ user_id.clone(),+ EntityType::EmailThread.with_entity_string(second_id.to_string()),+ ),+ ];++ Loader::<SoupItemLoaderKey>::load(&loader, &keys)+ .await+ .expect("batch loads");++ assert_eq!(inbox_calls.lock().expect("inbox calls lock").len(), 1);+ assert_eq!(+ soup_calls.lock().expect("Soup calls lock")[0].link_ids,+ vec![inbox_id]+ );+}++#[tokio::test]+async fn context_loader_does_not_cache_across_realtime_updates() {+ let user_id = user("macro|[email protected]");+ let document_id = Uuid::from_u128(20);+ let entity = EntityType::Document.with_entity_string(document_id.to_string());+ let service = RecordingSoupService::default()+ .with_response(user_id.clone(), vec![document_named(document_id, "First")]);+ let calls = Arc::clone(&service.calls);+ let responses = Arc::clone(&service.responses);+ let loader = SoupItemDataLoader::new(SoupItemLoader::new(+ service,+ RecordingInboxReader::default(),+ ));++ let first = loader+ .load_one((user_id.clone(), entity.clone()))+ .await+ .expect("first load succeeds")+ .expect("first item exists");+ responses+ .lock()+ .expect("responses lock")+ .insert(user_id.clone(), vec![document_named(document_id, "Second")]);+ let second = loader+ .load_one((user_id, entity))+ .await+ .expect("second load succeeds")+ .expect("second item exists");++ assert!(matches!(first, SoupItem::Document(document) if document.name == "First"));+ assert!(matches!(second, SoupItem::Document(document) if document.name == "Second"));+ assert_eq!(calls.lock().expect("calls lock").len(), 2);+}++#[test]+fn encodes_requested_ids_and_disables_unrequested_entity_branches() {+ let first_document = Uuid::from_u128(21);+ let second_document = Uuid::from_u128(22);+ let channel = Uuid::from_u128(23);+ let entities = vec![+ EntityType::Document.with_entity_string(first_document.to_string()),+ EntityType::Document.with_entity_string(second_document.to_string()),+ EntityType::Channel.with_entity_string(channel.to_string()),+ ];++ let ast = entity_filter_ast(&entities).expect("valid AST");++ let document_ids = collect_ids(+ ast.document_filter.as_deref().expect("document filter"),+ |literal| match literal {+ DocumentLiteral::Id(id) => Some(*id),+ _ => None,+ },+ );+ let channel_ids = collect_ids(+ ast.channel_filter.as_deref().expect("channel filter"),+ |literal| match literal {+ ChannelLiteral::ChannelId(id) => Some(*id),+ _ => None,+ },+ );+ assert_eq!(+ document_ids,+ HashSet::from([first_document, second_document])+ );+ assert_eq!(channel_ids, HashSet::from([channel]));++ let nil = Uuid::nil();+ assert_eq!(+ collect_ids(+ ast.project_filter.as_deref().expect("project filter"),+ |literal| {+ match literal {+ ProjectLiteral::ProjectIdSelf(id) => Some(*id),+ _ => None,+ }+ }+ ),+ HashSet::from([nil])+ );+ assert_eq!(+ collect_ids(+ ast.chat_filter.as_deref().expect("chat filter"),+ |literal| {+ match literal {+ ChatLiteral::ChatId(id) => Some(*id),+ _ => None,+ }+ }+ ),+ HashSet::from([nil])+ );+ assert_eq!(+ collect_ids(+ ast.email_filter.tree.as_deref().expect("email filter"),+ |literal| match literal {+ EmailLiteral::ThreadId(id) => Some(*id),+ _ => None,+ }+ ),+ HashSet::from([nil])+ );+ assert_eq!(+ collect_ids(+ ast.channel_thread_filter+ .as_deref()+ .expect("channel-thread filter"),+ |literal| match literal {+ ChannelThreadLiteral::ThreadId(id) => Some(*id),+ _ => None,+ }+ ),+ HashSet::from([nil])+ );+ assert_eq!(+ collect_ids(+ ast.call_filter.as_deref().expect("call filter"),+ |literal| {+ match literal {+ CallLiteral::CallId(id) => Some(*id),+ _ => None,+ }+ }+ ),+ HashSet::from([nil])+ );+ assert_eq!(+ collect_ids(+ ast.crm_company_filter.as_deref().expect("CRM filter"),+ |literal| match literal {+ CrmCompanyLiteral::Id(id) => Some(*id),+ _ => None,+ }+ ),+ HashSet::from([nil])+ );+ assert_eq!(+ collect_ids(+ ast.foreign_entity_filter+ .as_deref()+ .expect("foreign-entity filter"),+ |literal| match literal {+ ForeignEntityLiteral::Id(id) => Some(*id),+ _ => None,+ }+ ),+ HashSet::from([nil])+ );+}diff --git a/crates/graphql_soup/src/objects.rs b/crates/graphql_soup/src/objects.rsindex a3d534275b..2933844c3a 100644--- a/crates/graphql_soup/src/objects.rs+++ b/crates/graphql_soup/src/objects.rs@@ -1,8 +1,12 @@+use std::marker::PhantomData;+use async_graphql::{- Context, ID, Interface, Json, Object, ObjectType, OutputType, SimpleObject, Union,+ ComplexObject, Context, ID, Interface, Json, Object, ObjectType, OutputType, SimpleObject,+ Union,};-use graphql_common::{GraphqlEntity, GraphqlSoupEntityType};+use graphql_common::{GraphqlEntity, GraphqlPatchOperation, GraphqlSoupEntityType};use graphql_permission::GraphqlEntityPermission;+use macro_user_id::user_id::MacroUserIdStr;use models_pagination::PaginatedOpaqueCursor;use models_soup::{call_record::{SoupCallRecord, SoupCallRecordParticipant},@@ -20,8 +24,11 @@ use models_soup::{};use serde_json::Value;use soup::domain::models::{EnrichedSoupItem, SoupPropertiesField, grouping::NestedSoupGroups};+use soup_realtime::domain::models::Patch;use uuid::Uuid;+use crate::loaders::SoupItemDataLoader;+/// Extension fields attached to every top-level Soup entity.////// The concrete edge object is supplied by the schema composition crate and@@ -84,24 +91,19 @@ pub struct SoupPage<E: SoupEntityEdges> {items: Vec<GraphqlSoupEntity<E>>,/// Opaque cursor for the next page, if one exists.next_cursor: Option<String>,- /// Whether more items are available after this page.- has_more: bool,}impl<E: SoupEntityEdges> SoupPage<E> {/// Construct a GraphQL page from plain Soup items.pub fn new(page: PaginatedOpaqueCursor<SoupItem<()>>) -> Self {- let has_more = page.next_cursor.is_some();Self {items: page.items.into_iter().map(GraphqlSoupEntity::new).collect(),next_cursor: page.next_cursor,- has_more,}}/// Construct a GraphQL page from frecency-enriched Soup items.pub fn new_from_enriched(page: PaginatedOpaqueCursor<EnrichedSoupItem>) -> Self {- let has_more = page.next_cursor.is_some();Self {items: page.items@@ -109,7 +111,6 @@ impl<E: SoupEntityEdges> SoupPage<E> {.map(GraphqlSoupEntity::new_from_enriched).collect(),next_cursor: page.next_cursor,- has_more,}}}@@ -1722,3 +1723,52 @@ impl_common_interface_edges!(GraphqlSoupCrmCompany,GraphqlSoupForeignEntity,);++/// Lightweight realtime Soup patch with optional lazy item hydration.+#[derive(SimpleObject)]+#[graphql(complex)]+pub struct SoupPatch<E: SoupEntityEdges> {+ /// Operation represented by this patch.+ operation: GraphqlPatchOperation,+ /// Canonical identity of the affected entity.+ entity: GraphqlEntity<'static>,+ /// User whose visibility scope must be used to hydrate the item.+ #[graphql(skip)]+ user_id: MacroUserIdStr<'static>,+ /// Associates the patch with its composed Soup edge object.+ #[graphql(skip)]+ phantom: PhantomData<E>,+}++impl<E: SoupEntityEdges> SoupPatch<E> {+ /// Construct a GraphQL patch for one recipient-targeted domain patch.+ pub fn new(+ user_id: MacroUserIdStr<'static>,+ patch: Patch<model_entity::Entity<'static>>,+ ) -> Self {+ let (operation, entity) = match patch {+ Patch::Updated(entity) => (GraphqlPatchOperation::Updated, entity),+ Patch::Deleted(entity) => (GraphqlPatchOperation::Deleted, entity),+ };+ Self {+ operation,+ entity: GraphqlEntity(entity),+ user_id,+ phantom: PhantomData,+ }+ }+}++#[ComplexObject]+impl<E: SoupEntityEdges> SoupPatch<E> {+ /// Hydrate the current Soup item only when selected by the client.+ async fn item(&self, ctx: &Context<'_>) -> async_graphql::Result<Option<GraphqlSoupEntity<E>>> {+ if self.operation == GraphqlPatchOperation::Deleted {+ return Ok(None);+ }++ let loader = ctx.data::<SoupItemDataLoader>()?;+ let key = (self.user_id.clone(), self.entity.0.clone());+ Ok(loader.load_one(key).await?.map(GraphqlSoupEntity::new))+ }+}diff --git a/crates/graphql_soup/src/resolvers.rs b/crates/graphql_soup/src/resolvers.rsindex d50dd029f5..20c43e020a 100644--- a/crates/graphql_soup/src/resolvers.rs+++ b/crates/graphql_soup/src/resolvers.rs@@ -20,14 +20,14 @@ use soup_realtime::domain::ports::SoupRealtimeSubscriptionService;use crate::{inputs::{GroupedSoupInput, SoupInput},- objects::{GraphqlSoupEntity, GroupedSoup, SoupEntityEdges, SoupPage},+ objects::{GroupedSoup, SoupEntityEdges, SoupPage, SoupPatch},};/// Subscribe to realtime Soup updates for the authenticated user.pub async fn resolve_soup_updates<R, Auth, St, Edges>(service: &R,ctx: &Context<'_>,-) -> async_graphql::Result<impl Stream<Item = GraphqlSoupEntity<Edges>> + Send + 'static>+) -> async_graphql::Result<impl Stream<Item = SoupPatch<Edges>> + Send + 'static>whereR: SoupRealtimeSubscriptionService,Auth: MacroAuthorizationService,@@ -36,11 +36,11 @@ whereEdges: SoupEntityEdges,{let macro_user_id = require_authorized_user::<Auth, St>(ctx).await?;- let mut receiver = service.subscribe(macro_user_id);+ let mut receiver = service.subscribe(macro_user_id.clone());Ok(async_stream::stream! {- while let Some(item) = receiver.recv().await {- yield GraphqlSoupEntity::new(item.as_ref().clone());+ while let Some(patch) = receiver.recv().await {+ yield SoupPatch::new(macro_user_id.clone(), patch);}})}diff --git a/crates/soup_realtime/Cargo.toml b/crates/soup_realtime/Cargo.tomlindex 692f4f1686..e4e9af7225 100644--- a/crates/soup_realtime/Cargo.toml+++ b/crates/soup_realtime/Cargo.toml@@ -6,8 +6,12 @@ version = "0.1.0"[features]consumer = [+ "dep:channels",+ "dep:chat","dep:documents",+ "dep:email","dep:kafka_util",+ "dep:projects","dep:rdkafka","dep:tokio","macro_event_broker/outbound",@@ -16,7 +20,6 @@ consumer = [default = ["consumer", "outbound", "ports"]outbound = ["dep:entity_access",- "dep:soup","ports",]ports = [@@ -30,7 +33,10 @@ ports = [[dependencies]broadcast = { path = "../broadcast", optional = true }-documents = { path = "../documents", default-features = false, optional = true }+channels = { path = "../channels", default-features = false, optional = true }+chat = { path = "../chat", default-features = false, optional = true }+documents = { path = "../documents", default-features = false, features = ["service"], optional = true }+email = { path = "../email", default-features = false, optional = true }entity_access = { path = "../entity_access", default-features = false, features = ["ports"], optional = true }futures = { workspace = true, optional = true }kafka_util = { path = "../kafka_util", optional = true }@@ -38,19 +44,16 @@ macro_event_broker = { path = "../macro_event_broker", default-features = falsemacro_event_topics = { path = "../macro_event_topics" }macro_user_id = { path = "../macro_user_id" }model-entity = { path = "../model-entity" }-models_soup = { path = "../models_soup" }+projects = { path = "../projects", default-features = false, features = ["service"], optional = true }rdkafka = { workspace = true, optional = true }rootcause = { workspace = true, optional = true }serde = { workspace = true }-soup = { path = "../soup", default-features = false, features = ["ports"], optional = true }tokio = { workspace = true, features = ["sync", "time"], optional = true }tokio-retry = { workspace = true, optional = true }tracing = { workspace = true, optional = true }workspace-hack = { version = "0.1", path = "../workspace-hack" }[dev-dependencies]-chrono = { workspace = true }-models_properties = { path = "../models_properties" }serde_json = { workspace = true }tokio = { workspace = true, features = ["macros", "rt-multi-thread", "test-util", "time"] }uuid = { workspace = true }diff --git a/crates/soup_realtime/README.md b/crates/soup_realtime/README.mdindex d5c3e589b6..9cffc0daf4 100644--- a/crates/soup_realtime/README.md+++ b/crates/soup_realtime/README.md@@ -1,9 +1,9 @@# soup_realtime-Hexagonal components for expanding `document.updated` Kafka events into one full `SoupItem<()>` message per current accessor. The item is loaded once through the first accessor and its user-specific `viewed_at` field is set to `None` before fan-out.+Hexagonal components for turning existing document, project, chat, email, and channel Kafka events into recipient-targeted Soup patches.-This crate intentionally does not start a consumer or wire itself into a service binary. A later composition root can combine the domain service with the entity-access, Soup repository, Kafka publisher, and Kafka consumer adapters exposed here.+The inbound consumer maps each source event to `Patch::Updated(Entity)` or `Patch::Deleted(Entity)`. The domain service expands current access and publishes one patch per recipient to `macro.soup`; it does not hydrate or serialize `SoupItem` values. Channel threads use their containing channel as the access source.-Delivery is at least once. If publication partially succeeds and processing is retried, downstream consumers may receive duplicate messages.+The Soup topic carries `Patch<(MacroUserIdStr<'static>, Entity<'static>)>` and is also keyed by recipient user ID. Delivery is at least once: offsets are committed only after successful fan-out, and exhausted retries stop the consumer so its supervisor can restart it for redelivery. Downstream consumers must tolerate duplicate patches.-`SoupRealtimeConsumerService` can run a realtime consumer adapter and distribute received items through instance-local, user-keyed subscriptions. Subscription values are shared as `Arc<SoupItem<()>>` so multiple subscribers do not require cloning the underlying item.+`SoupRealtimeConsumerService` consumes recipient-targeted patches and distributes `Patch<Entity<'static>>` values through instance-local, user-keyed subscriptions.diff --git a/crates/soup_realtime/src/domain/models.rs b/crates/soup_realtime/src/domain/models.rsindex 3441ff8306..8094a21e0f 100644--- a/crates/soup_realtime/src/domain/models.rs+++ b/crates/soup_realtime/src/domain/models.rs@@ -1,40 +1,91 @@-//! Realtime Soup message and broker event models.+//! Realtime Soup patch and broker event models.use macro_event_broker::{Event, MacroEvent, TopicEvent};use macro_event_topics::MacroSoupRealtimeTopic;use macro_user_id::user_id::MacroUserIdStr;-use models_soup::item::SoupItem;+use model_entity::Entity;use serde::{Deserialize, Serialize};-/// One full Soup item addressed to a recipient for realtime delivery.-#[derive(Debug, Serialize, Deserialize)]+/// A change to one value.+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]+#[serde(tag = "event_type", content = "metadata")]+pub enum Patch<T> {+ /// The value was created or updated.+ #[serde(rename = "soup.updated")]+ Updated(T),+ /// The value was deleted.+ #[serde(rename = "soup.deleted")]+ Deleted(T),+}++impl<T> Patch<T> {+ /// Maps the value carried by this patch while preserving its operation.+ pub fn map<U>(self, map: impl FnOnce(T) -> U) -> Patch<U> {+ match self {+ Self::Updated(value) => Patch::Updated(map(value)),+ Self::Deleted(value) => Patch::Deleted(map(value)),+ }+ }++ /// Returns the value carried by this patch.+ pub fn value(&self) -> &T {+ match self {+ Self::Updated(value) | Self::Deleted(value) => value,+ }+ }+}++/// A patch paired with the entity used to resolve its recipients.+#[derive(Debug, Clone, PartialEq, Eq)]+pub struct SoupRealtimePatch {+ /// Patch delivered to each recipient.+ pub patch: Patch<Entity<'static>>,+ /// Entity whose current accessors should receive the patch.+ pub access_source: Entity<'static>,+}++impl SoupRealtimePatch {+ /// Creates a patch with an explicit recipient access source.+ pub fn new(patch: Patch<Entity<'static>>, access_source: Entity<'static>) -> Self {+ Self {+ patch,+ access_source,+ }+ }++ /// Creates a patch whose entity also determines its recipients.+ pub fn for_entity(patch: Patch<Entity<'static>>) -> Self {+ let access_source = patch.value().clone();+ Self::new(patch, access_source)+ }+}++/// One recipient-targeted patch after decoding the Soup topic event.+#[derive(Debug, Clone, PartialEq, Eq)]pub struct SoupRealtimeMessage {- /// User to whom the Soup item is addressed.+ /// User to whom the patch is addressed.pub user_id: MacroUserIdStr<'static>,- /// Complete Soup item with transient user-specific fields normalized.- pub item: SoupItem<()>,+ /// Entity patch addressed to the user.+ pub patch: Patch<Entity<'static>>,}impl SoupRealtimeMessage {- /// Creates a message addressed to a recipient.- pub fn new(user_id: MacroUserIdStr<'static>, item: SoupItem<()>) -> Self {- Self { user_id, item }+ /// Creates a patch addressed to a recipient.+ pub fn new(user_id: MacroUserIdStr<'static>, patch: Patch<Entity<'static>>) -> Self {+ Self { user_id, patch }}}-/// Events published to [`MacroSoupRealtimeTopic`].-#[derive(Debug, Serialize, Deserialize)]-#[serde(tag = "event_type", content = "metadata")]-pub enum SoupTopicEvent {- /// A complete Soup item changed and should be delivered to its recipient.- #[serde(rename = "soup.item.updated")]- ItemUpdated(SoupRealtimeMessage),-}+/// Wire payload for [`MacroSoupRealtimeTopic`].+///+/// The recipient is included in the patch payload and repeated as the Kafka+/// key so consumers can route without hydrating a Soup item.+pub type SoupTopicEvent = Patch<(MacroUserIdStr<'static>, Entity<'static>)>;impl TopicEvent for SoupTopicEvent {type Topic = MacroSoupRealtimeTopic;- const SCHEMA_VERSION: u8 = 1;+ const SCHEMA_VERSION: u8 = 2;}/// Publishable realtime Soup event keyed by recipient user ID.@@ -44,10 +95,12 @@ pub struct SoupMacroEvent {}impl SoupMacroEvent {- /// Creates a recipient-keyed item update event.- pub fn item_updated(message: SoupRealtimeMessage) -> Self {- let key = message.user_id.as_ref().to_string();- Self::with_event(key, Event::new(SoupTopicEvent::ItemUpdated(message)))+ /// Creates a recipient-keyed patch event.+ pub fn from_message(message: SoupRealtimeMessage) -> Self {+ let SoupRealtimeMessage { user_id, patch } = message;+ let key = user_id.as_ref().to_string();+ let event = patch.map(|entity| (user_id, entity));+ Self::with_event(key, Event::new(event))}/// Builds an event from its Kafka key and pre-built envelope.@@ -58,10 +111,15 @@ impl SoupMacroEvent {}}- /// Returns the recipient-targeted message carried by this event.+ /// Returns the recipient and entity patch carried by this event.pub fn into_message(self) -> SoupRealtimeMessage {match self.event.event {- SoupTopicEvent::ItemUpdated(message) => message,+ Patch::Updated((user_id, entity)) => {+ SoupRealtimeMessage::new(user_id, Patch::Updated(entity))+ }+ Patch::Deleted((user_id, entity)) => {+ SoupRealtimeMessage::new(user_id, Patch::Deleted(entity))+ }}}}diff --git a/crates/soup_realtime/src/domain/ports.rs b/crates/soup_realtime/src/domain/ports.rsindex 5a43e5d60a..452c03e777 100644--- a/crates/soup_realtime/src/domain/ports.rs+++ b/crates/soup_realtime/src/domain/ports.rs@@ -1,46 +1,45 @@//! Ports used by realtime Soup services.-use std::{future::Future, sync::Arc};+use std::future::Future;use macro_user_id::user_id::MacroUserIdStr;use model_entity::Entity;-use models_soup::item::SoupItem;use rootcause::Report;-use super::models::SoupRealtimeMessage;+use super::models::{Patch, SoupRealtimeMessage, SoupRealtimePatch};/// Inbound use-case port driven by entity update transports.pub trait SoupRealtimeService: Send + Sync + 'static {- /// Hydrates one normalized Soup item and publishes it to every current accessor.+ /// Publishes one entity patch to every current accessor of its access source.fn notify_users(&self,- entity: Entity<'static>,+ patch: SoupRealtimePatch,) -> impl Future<Output = Result<(), Report>> + Send;}-/// Receives complete recipient-targeted Soup messages.+/// Receives recipient-targeted Soup patches.pub trait SoupRealtimeConsumer: Send + Sync + 'static {- /// Waits for and returns the next realtime Soup message.+ /// Waits for and returns the next realtime Soup patch.fn recv(&self) -> impl Future<Output = Result<SoupRealtimeMessage, Report>> + Send;}-/// Provides user-scoped subscriptions to received realtime Soup items.+/// Provides user-scoped subscriptions to received realtime Soup patches.pub trait SoupRealtimeSubscriptionService: Send + Sync + 'static {- /// Subscribes to realtime Soup items addressed to `user_id`.+ /// Subscribes to entity patches addressed to `user_id`.fn subscribe(&self,user_id: MacroUserIdStr<'static>,- ) -> tokio::sync::mpsc::Receiver<Arc<SoupItem<()>>>;+ ) -> tokio::sync::mpsc::Receiver<Patch<Entity<'static>>>;}-impl<S> SoupRealtimeSubscriptionService for Arc<S>+impl<S> SoupRealtimeSubscriptionService for std::sync::Arc<S>whereS: SoupRealtimeSubscriptionService,{fn subscribe(&self,user_id: MacroUserIdStr<'static>,- ) -> tokio::sync::mpsc::Receiver<Arc<SoupItem<()>>> {+ ) -> tokio::sync::mpsc::Receiver<Patch<Entity<'static>>> {self.as_ref().subscribe(user_id)}}@@ -53,7 +52,7 @@ impl SoupRealtimeSubscriptionService for NoOpSoupRealtimeSubscriptionService {fn subscribe(&self,_user_id: MacroUserIdStr<'static>,- ) -> tokio::sync::mpsc::Receiver<Arc<SoupItem<()>>> {+ ) -> tokio::sync::mpsc::Receiver<Patch<Entity<'static>>> {let (_sender, receiver) = tokio::sync::mpsc::channel(1);receiver}@@ -64,26 +63,16 @@ pub trait UserAccessExpander: Send + Sync + 'static {/// Returns all current user accessors for `entity`.////// Implementations may return duplicates; the domain service deduplicates- /// recipients before hydration.+ /// recipients before publication.fn expand_user_access(&self,entity: &Entity<'static>,) -> impl Future<Output = Result<Vec<MacroUserIdStr<'static>>, Report>> + Send;}-/// Reads a complete Soup item under an individual user's visibility scope.-pub trait SoupItemReader: Send + Sync + 'static {- /// Reads `entity` through the visibility scope of `user_id`.- fn read_for_user(- &self,- user_id: MacroUserIdStr<'static>,- entity: &Entity<'static>,- ) -> impl Future<Output = Result<Option<SoupItem<()>>, Report>> + Send;-}--/// Publishes complete recipient-targeted Soup messages.+/// Publishes recipient-targeted Soup patches.pub trait SoupRealtimePublisher: Send + Sync + 'static {- /// Publishes one realtime Soup message and awaits delivery.+ /// Publishes one realtime Soup patch and awaits delivery.fn publish(&self,message: SoupRealtimeMessage,diff --git a/crates/soup_realtime/src/domain/service.rs b/crates/soup_realtime/src/domain/service.rsindex dcc446ec28..0a96c8b49c 100644--- a/crates/soup_realtime/src/domain/service.rs+++ b/crates/soup_realtime/src/domain/service.rs@@ -1,22 +1,21 @@-//! Realtime Soup orchestration.+//! Realtime Soup patch orchestration.#[cfg(test)]mod test;-use std::{collections::HashSet, num::NonZeroUsize, sync::Arc, time::Duration};+use std::{collections::HashSet, num::NonZeroUsize, time::Duration};use broadcast::{BroadcastManager, GlobalSpawner};use futures::{StreamExt as _, stream};use macro_user_id::user_id::MacroUserIdStr;use model_entity::Entity;-use models_soup::item::SoupItem;use rootcause::prelude::{Report, ResultExt as _};use tokio_retry::{Retry, strategy::ExponentialBackoff};use super::{- models::SoupRealtimeMessage,+ models::{Patch, SoupRealtimeMessage, SoupRealtimePatch},ports::{- SoupItemReader, SoupRealtimeConsumer, SoupRealtimePublisher, SoupRealtimeService,+ SoupRealtimeConsumer, SoupRealtimePublisher, SoupRealtimeService,SoupRealtimeSubscriptionService, UserAccessExpander,},};@@ -35,13 +34,13 @@ fn receive_retry_strategy() -> impl Iterator<Item = Duration> {.take(MAX_RECEIVE_ATTEMPTS - 1)}-/// Service for distributing recipient-targeted realtime Soup messages.+/// Service for distributing recipient-targeted realtime Soup patches.pub struct SoupRealtimeConsumerService<C>whereC: SoupRealtimeConsumer,{consumer: C,- broadcasts: BroadcastManager<GlobalSpawner, MacroUserIdStr<'static>, Arc<SoupItem<()>>>,+ broadcasts: BroadcastManager<GlobalSpawner, MacroUserIdStr<'static>, Patch<Entity<'static>>>,}impl<C> SoupRealtimeConsumerService<C>@@ -56,7 +55,7 @@ where}}- /// Subscribes to realtime Soup items addressed to `user_id`.+ /// Subscribes to realtime Soup patches addressed to `user_id`.////// The returned receiver is closed if its buffer fills, ensuring a slow/// subscriber cannot delay the shared consumer or other subscribers.@@ -64,32 +63,32 @@ wherepub fn subscribe(&self,user_id: MacroUserIdStr<'static>,- ) -> tokio::sync::mpsc::Receiver<Arc<SoupItem<()>>> {+ ) -> tokio::sync::mpsc::Receiver<Patch<Entity<'static>>> {self.broadcasts.subscribe(user_id, SUBSCRIBER_BUFFER_CAPACITY)}- /// Receives messages and distributes them to subscribers until reception fails.+ /// Receives patches and distributes them to subscribers until reception fails.///- /// Callers should run this future in a supervised task. A message for a user+ /// Callers should run this future in a supervised task. A patch for a user/// without active subscribers is intentionally dropped.#[tracing::instrument(skip(self), err)]pub async fn run(&self) -> Result<(), Report> {loop {- let SoupRealtimeMessage { user_id, item } = Retry::start(+ let SoupRealtimeMessage { user_id, patch } = Retry::start(receive_retry_strategy(),|| self.consumer.recv(),).await.context(format!(- "failed to receive realtime Soup message after {MAX_RECEIVE_ATTEMPTS} attempts"+ "failed to receive realtime Soup patch after {MAX_RECEIVE_ATTEMPTS} attempts"))?;- match self.broadcasts.publish(&user_id, Arc::new(item)) {+ match self.broadcasts.publish(&user_id, patch) {Ok(subscriber_count) => {- tracing::trace!(subscriber_count, "distributed realtime Soup message")+ tracing::trace!(subscriber_count, "distributed realtime Soup patch")}- Err(_) => tracing::trace!("dropping realtime Soup message without subscribers"),+ Err(_) => tracing::trace!("dropping realtime Soup patch without subscribers"),}}}@@ -102,7 +101,7 @@ wherefn subscribe(&self,user_id: MacroUserIdStr<'static>,- ) -> tokio::sync::mpsc::Receiver<Arc<SoupItem<()>>> {+ ) -> tokio::sync::mpsc::Receiver<Patch<Entity<'static>>> {SoupRealtimeConsumerService::subscribe(self, user_id)}}@@ -110,43 +109,42 @@ where/// Maximum number of Kafka publications polled concurrently.const PUBLISH_CONCURRENCY: usize = 16;-/// Domain service that expands access, hydrates one normalized item, and fans out.-pub struct SoupRealtimeServiceImpl<A, R, P> {+/// Domain service that expands entity access and fans out lightweight patches.+pub struct SoupRealtimeServiceImpl<A, P> {access_expander: A,- item_reader: R,publisher: P,}-impl<A, R, P> SoupRealtimeServiceImpl<A, R, P> {- /// Creates a realtime Soup service from its three outbound capabilities.- pub fn new(access_expander: A, item_reader: R, publisher: P) -> Self {+impl<A, P> SoupRealtimeServiceImpl<A, P> {+ /// Creates a realtime Soup service from its outbound capabilities.+ pub fn new(access_expander: A, publisher: P) -> Self {Self {access_expander,- item_reader,publisher,}}}-impl<A, R, P> SoupRealtimeService for SoupRealtimeServiceImpl<A, R, P>+impl<A, P> SoupRealtimeService for SoupRealtimeServiceImpl<A, P>whereA: UserAccessExpander,- R: SoupItemReader,P: SoupRealtimePublisher,{#[tracing::instrument(skip(self),fields(- entity_type = %entity.entity_type,- entity_id = %entity.entity_id,+ entity_type = %patch.patch.value().entity_type,+ entity_id = %patch.patch.value().entity_id,+ access_source_type = %patch.access_source.entity_type,+ access_source_id = %patch.access_source.entity_id,recipient_count = tracing::field::Empty,),err)]- async fn notify_users(&self, entity: Entity<'static>) -> Result<(), Report> {+ async fn notify_users(&self, patch: SoupRealtimePatch) -> Result<(), Report> {let mut users = self.access_expander- .expand_user_access(&entity)+ .expand_user_access(&patch.access_source).await.context("failed to expand current user access")?;@@ -154,51 +152,10 @@ whereusers.retain(|user_id| seen.insert(user_id.clone()));tracing::Span::current().record("recipient_count", users.len());- if users.is_empty() {- return Ok(());- }-- let hydration_user_id = users[0].clone();- let item = self- .item_reader- .read_for_user(hydration_user_id.clone(), &entity)- .await- .context_with(|| {- format!("failed to hydrate Soup item through accessor {hydration_user_id}")- })?- .ok_or_else(|| {- rootcause::report!(- "Soup item for {} {} was missing for accessor {}",- entity.entity_type,- entity.entity_id,- hydration_user_id- )- })?;-- let hydrated_entity = item.entity();- if hydrated_entity != entity {- return Err(rootcause::report!(- "Soup reader returned {} {} while hydrating {} {} through accessor {}",- hydrated_entity.entity_type,- hydrated_entity.entity_id,- entity.entity_type,- entity.entity_id,- hydration_user_id- ));- }-- let SoupItem::Document(mut document) = item else {- return Err(rootcause::report!(- "realtime Soup fan-out currently supports document items only"- ));- };- document.viewed_at = None;-let messages = users.into_iter()- .map(|user_id| SoupRealtimeMessage::new(user_id, SoupItem::Document(document.clone())))+ .map(|user_id| SoupRealtimeMessage::new(user_id, patch.patch.clone())).collect::<Vec<_>>();-let results = stream::iter(messages.into_iter()diff --git a/crates/soup_realtime/src/domain/service/test.rs b/crates/soup_realtime/src/domain/service/test.rsindex e71cc0e645..ed9bfa759b 100644--- a/crates/soup_realtime/src/domain/service/test.rs+++ b/crates/soup_realtime/src/domain/service/test.rs@@ -1,18 +1,13 @@-use std::collections::{HashMap, HashSet, VecDeque};+use std::collections::{HashSet, VecDeque};use std::sync::atomic::{AtomicUsize, Ordering};use std::sync::{Arc, Mutex};use std::time::Duration;-use chrono::{DateTime, Utc};use macro_user_id::user_id::MacroUserIdStr;use model_entity::{Entity, EntityType};-use models_soup::{document::SoupDocument, item::SoupItem};-use uuid::Uuid;use super::*;-use crate::domain::ports::{- SoupItemReader, SoupRealtimeConsumer, SoupRealtimePublisher, UserAccessExpander,-};+use crate::domain::ports::{SoupRealtimeConsumer, SoupRealtimePublisher, UserAccessExpander};const DOCUMENT_ID: &str = "00000000-0000-0000-0000-000000000001";const OTHER_DOCUMENT_ID: &str = "00000000-0000-0000-0000-000000000002";@@ -21,14 +16,19 @@ struct FakeAccessExpander {users: Vec<MacroUserIdStr<'static>>,fail: bool,calls: Arc<AtomicUsize>,+ entities: Arc<Mutex<Vec<Entity<'static>>>>,}impl UserAccessExpander for FakeAccessExpander {async fn expand_user_access(&self,- _entity: &Entity<'static>,+ entity: &Entity<'static>,) -> Result<Vec<MacroUserIdStr<'static>>, Report> {self.calls.fetch_add(1, Ordering::SeqCst);+ self.entities+ .lock()+ .expect("access entities lock")+ .push(entity.clone());if self.fail {Err(rootcause::report!("access unavailable"))} else {@@ -37,38 +37,6 @@ impl UserAccessExpander for FakeAccessExpander {}}-enum ReadResponse {- Item(Box<SoupItem<()>>),- Missing,- Failure,-}--struct FakeReader {- responses: Mutex<HashMap<String, ReadResponse>>,- calls: Arc<AtomicUsize>,-}--impl SoupItemReader for FakeReader {- async fn read_for_user(- &self,- user_id: MacroUserIdStr<'static>,- _entity: &Entity<'static>,- ) -> Result<Option<SoupItem<()>>, Report> {- self.calls.fetch_add(1, Ordering::SeqCst);- match self- .responses- .lock()- .expect("responses lock")- .remove(user_id.as_ref())- .unwrap_or(ReadResponse::Missing)- {- ReadResponse::Item(item) => Ok(Some(*item)),- ReadResponse::Missing => Ok(None),- ReadResponse::Failure => Err(rootcause::report!("reader unavailable")),- }- }-}-struct FakeRealtimeConsumer {messages: Mutex<VecDeque<Result<SoupRealtimeMessage, Report>>>,calls: Arc<AtomicUsize>,@@ -103,9 +71,9 @@ impl SoupRealtimePublisher for FakePublisher {}struct Harness {- service: SoupRealtimeServiceImpl<FakeAccessExpander, FakeReader, FakePublisher>,+ service: SoupRealtimeServiceImpl<FakeAccessExpander, FakePublisher>,access_calls: Arc<AtomicUsize>,- read_calls: Arc<AtomicUsize>,+ access_entities: Arc<Mutex<Vec<Entity<'static>>>>,messages: Arc<Mutex<Vec<SoupRealtimeMessage>>>,}@@ -113,60 +81,28 @@ fn user(local: &str) -> MacroUserIdStr<'static> {MacroUserIdStr::try_from(format!("macro|{local}@example.com")).expect("valid user id")}-fn timestamp(seconds: i64) -> DateTime<Utc> {- DateTime::from_timestamp(seconds, 0).expect("valid timestamp")-}--fn document_item(id: &str, name: &str, viewed_at: Option<DateTime<Utc>>) -> SoupItem<()> {- SoupItem::Document(SoupDocument {- id: Uuid::parse_str(id).expect("valid document id"),- document_version_id: 42,- owner_id: user("owner"),- name: name.to_string(),- file_type: Some("md".to_string()),- sha: Some("document-sha".to_string()),- project_id: None,- branched_from_id: None,- branched_from_version_id: None,- document_family_id: None,- created_at: timestamp(1),- updated_at: timestamp(2),- viewed_at,- sub_type: None,- deleted_at: None,- extra: (),- })+fn document(id: &str) -> Entity<'static> {+ EntityType::Document.with_entity_string(id.to_string())}-fn document_entity() -> Entity<'static> {- EntityType::Document.with_entity_string(DOCUMENT_ID.to_string())-}--fn document_name(item: &SoupItem<()>) -> &str {- let SoupItem::Document(document) = item else {- panic!("expected document item")- };- &document.name+fn updated_document() -> Patch<Entity<'static>> {+ Patch::Updated(document(DOCUMENT_ID))}fn harness(users: Vec<MacroUserIdStr<'static>>,- responses: HashMap<String, ReadResponse>,access_fails: bool,fail_users: HashSet<String>,) -> Harness {let access_calls = Arc::new(AtomicUsize::new(0));- let read_calls = Arc::new(AtomicUsize::new(0));+ let access_entities = Arc::new(Mutex::new(Vec::new()));let messages = Arc::new(Mutex::new(Vec::new()));let service = SoupRealtimeServiceImpl::new(FakeAccessExpander {users,fail: access_fails,calls: access_calls.clone(),- },- FakeReader {- responses: Mutex::new(responses),- calls: read_calls.clone(),+ entities: access_entities.clone(),},FakePublisher {messages: messages.clone(),@@ -176,37 +112,23 @@ fn harness(Harness {service,access_calls,- read_calls,+ access_entities,messages,}}-fn item_response(- recipient: &MacroUserIdStr<'static>,- item: SoupItem<()>,-) -> (String, ReadResponse) {- (- recipient.as_ref().to_string(),- ReadResponse::Item(Box::new(item)),- )-}-#[tokio::test(start_paused = true)]-async fn consumer_service_distributes_items_only_to_their_users() {+async fn consumer_service_distributes_patches_only_to_their_users() {let one = user("one");let two = user("two");+ let one_patch = Patch::Updated(document(DOCUMENT_ID));+ let two_patch = Patch::Deleted(document(OTHER_DOCUMENT_ID));let receive_calls = Arc::new(AtomicUsize::new(0));let consumer = FakeRealtimeConsumer {messages: Mutex::new(VecDeque::from([Err(rootcause::report!("transient receive failure")),- Ok(SoupRealtimeMessage::new(- one.clone(),- document_item(DOCUMENT_ID, "For one", None),- )),- Ok(SoupRealtimeMessage::new(- two.clone(),- document_item(OTHER_DOCUMENT_ID, "For two", None),- )),+ Ok(SoupRealtimeMessage::new(one.clone(), one_patch.clone())),+ Ok(SoupRealtimeMessage::new(two.clone(), two_patch.clone())),])),calls: Arc::clone(&receive_calls),};@@ -226,261 +148,131 @@ async fn consumer_service_distributes_items_only_to_their_users() {assert_eq!(receive_calls.load(Ordering::SeqCst),3 + MAX_RECEIVE_ATTEMPTS,- "a successful message resets the receive retry strategy"+ "a successful patch resets the receive retry strategy");- let one_first_item = tokio::time::timeout(Duration::from_secs(1), one_first.recv())- .await- .expect("first user subscription receives before timeout")- .expect("first user subscription remains open");- let one_second_item = tokio::time::timeout(Duration::from_secs(1), one_second.recv())- .await- .expect("second user subscription receives before timeout")- .expect("second user subscription remains open");- let two_item = tokio::time::timeout(Duration::from_secs(1), two_receiver.recv())- .await- .expect("other user subscription receives before timeout")- .expect("other user subscription remains open");-- assert_eq!(document_name(&one_first_item), "For one");- assert!(Arc::ptr_eq(&one_first_item, &one_second_item));- assert_eq!(document_name(&two_item), "For two");- assert!(matches!(- one_first.try_recv(),- Err(tokio::sync::mpsc::error::TryRecvError::Empty)- ));- assert!(matches!(- two_receiver.try_recv(),- Err(tokio::sync::mpsc::error::TryRecvError::Empty)- ));+ assert_eq!(+ tokio::time::timeout(Duration::from_secs(1), one_first.recv())+ .await+ .expect("first subscription receives")+ .expect("subscription remains open"),+ one_patch+ );+ assert_eq!(+ tokio::time::timeout(Duration::from_secs(1), one_second.recv())+ .await+ .expect("second subscription receives")+ .expect("subscription remains open"),+ one_patch+ );+ assert_eq!(+ tokio::time::timeout(Duration::from_secs(1), two_receiver.recv())+ .await+ .expect("other user subscription receives")+ .expect("subscription remains open"),+ two_patch+ );}#[tokio::test]-async fn zero_users_skips_reads_and_publications() {- let harness = harness(Vec::new(), HashMap::new(), false, HashSet::new());+async fn zero_users_skips_publication() {+ let harness = harness(Vec::new(), false, HashSet::new());harness.service- .notify_users(document_entity())+ .notify_users(SoupRealtimePatch::for_entity(updated_document())).await.expect("zero recipients is successful");assert_eq!(harness.access_calls.load(Ordering::SeqCst), 1);- assert_eq!(harness.read_calls.load(Ordering::SeqCst), 0);assert!(harness.messages.lock().expect("messages lock").is_empty());}#[tokio::test]-async fn one_user_receives_one_full_message() {+async fn recipient_expansion_can_use_a_different_entity_from_the_patch() {let recipient = user("one");- let viewed_at = Some(timestamp(3));- let responses = HashMap::from([item_response(- &recipient,- document_item(DOCUMENT_ID, "Full document", viewed_at),- )]);- let harness = harness(vec![recipient.clone()], responses, false, HashSet::new());+ let harness = harness(vec![recipient], false, HashSet::new());+ let channel = EntityType::Channel.with_entity_string(OTHER_DOCUMENT_ID.to_string());harness.service- .notify_users(document_entity())+ .notify_users(SoupRealtimePatch::new(updated_document(), channel.clone())).await.expect("fan-out succeeds");- let mut messages = harness.messages.lock().expect("messages lock");- let message = messages.pop().expect("one message");- assert!(messages.is_empty());- assert_eq!(message.user_id, recipient);- match message.item {- SoupItem::Document(document) => {- assert_eq!(document.name, "Full document");- assert_eq!(document.document_version_id, 42);- assert_eq!(document.sha.as_deref(), Some("document-sha"));- assert_eq!(document.viewed_at, None);- }- _ => panic!("expected document item"),- }+ assert_eq!(+ harness+ .access_entities+ .lock()+ .expect("access entities lock")+ .as_slice(),+ &[channel]+ );}#[tokio::test]-async fn three_unique_users_receive_exactly_three_messages() {- let users = [user("one"), user("two"), user("three")];- let responses = users- .iter()- .map(|recipient| {- item_response(- recipient,- document_item(DOCUMENT_ID, recipient.as_ref(), None),- )- })- .collect();- let harness = harness(users.to_vec(), responses, false, HashSet::new());-- harness- .service- .notify_users(document_entity())- .await- .expect("fan-out succeeds");-- assert_eq!(harness.read_calls.load(Ordering::SeqCst), 1);- let messages = harness.messages.lock().expect("messages lock");- assert_eq!(messages.len(), 3);- let recipients: HashSet<_> = messages- .iter()- .map(|message| message.user_id.as_ref().to_string())- .collect();- assert_eq!(recipients.len(), 3);- assert!(- users- .iter()- .all(|recipient| recipients.contains(recipient.as_ref()))- );+async fn updated_and_deleted_patches_are_published_unchanged() {+ for patch in [+ Patch::Updated(document(DOCUMENT_ID)),+ Patch::Deleted(document(DOCUMENT_ID)),+ ] {+ let recipient = user("one");+ let harness = harness(vec![recipient.clone()], false, HashSet::new());++ harness+ .service+ .notify_users(SoupRealtimePatch::for_entity(patch.clone()))+ .await+ .expect("fan-out succeeds");++ let messages = harness.messages.lock().expect("messages lock");+ assert_eq!(+ messages.as_slice(),+ &[SoupRealtimeMessage::new(recipient, patch)]+ );+ }}#[tokio::test]async fn duplicate_accessors_are_deduplicated() {let one = user("one");let two = user("two");- let responses = HashMap::from([- item_response(&one, document_item(DOCUMENT_ID, "One", None)),- item_response(&two, document_item(DOCUMENT_ID, "Two", None)),- ]);- let harness = harness(- vec![one.clone(), two, one],- responses,- false,- HashSet::new(),- );+ let harness = harness(vec![one.clone(), two, one], false, HashSet::new());harness.service- .notify_users(document_entity())+ .notify_users(SoupRealtimePatch::for_entity(updated_document())).await.expect("fan-out succeeds");- assert_eq!(harness.read_calls.load(Ordering::SeqCst), 1);assert_eq!(harness.messages.lock().expect("messages lock").len(), 2);}#[tokio::test]-async fn all_recipients_get_the_first_item_with_no_viewed_at() {- let one = user("one");- let two = user("two");- let responses = HashMap::from([- item_response(- &one,- document_item(DOCUMENT_ID, "Representative", Some(timestamp(10))),- ),- item_response(- &two,- document_item(DOCUMENT_ID, "Should not be read", Some(timestamp(20))),- ),- ]);- let harness = harness(vec![one, two], responses, false, HashSet::new());+async fn access_failure_prevents_publication() {+ let harness = harness(vec![user("one")], true, HashSet::new());harness.service- .notify_users(document_entity())- .await- .expect("fan-out succeeds");-- assert_eq!(harness.read_calls.load(Ordering::SeqCst), 1);- let messages = harness.messages.lock().expect("messages lock");- assert_eq!(messages.len(), 2);- for message in messages.iter() {- let SoupItem::Document(document) = &message.item else {- panic!("expected document item")- };- assert_eq!(document.name, "Representative");- assert_eq!(document.viewed_at, None);- }-}--#[tokio::test]-async fn access_failure_prevents_reads_and_publications() {- let harness = harness(vec![user("one")], HashMap::new(), true, HashSet::new());-- harness- .service- .notify_users(document_entity())+ .notify_users(SoupRealtimePatch::for_entity(updated_document())).await.expect_err("access failure propagates");- assert_eq!(harness.read_calls.load(Ordering::SeqCst), 0);- assert!(harness.messages.lock().expect("messages lock").is_empty());-}--#[tokio::test]-async fn missing_item_prevents_all_publication() {- let recipient = user("one");- let responses = HashMap::from([(recipient.as_ref().to_string(), ReadResponse::Missing)]);- let harness = harness(vec![recipient], responses, false, HashSet::new());-- harness- .service- .notify_users(document_entity())- .await- .expect_err("missing item is an error");-- assert!(harness.messages.lock().expect("messages lock").is_empty());-}--#[tokio::test]-async fn mismatched_item_prevents_all_publication() {- let recipient = user("one");- let responses = HashMap::from([item_response(- &recipient,- document_item(OTHER_DOCUMENT_ID, "Wrong", None),- )]);- let harness = harness(vec![recipient], responses, false, HashSet::new());-- harness- .service- .notify_users(document_entity())- .await- .expect_err("mismatched item is an error");-- assert!(harness.messages.lock().expect("messages lock").is_empty());-}--#[tokio::test]-async fn representative_reader_failure_prevents_all_publication() {- let one = user("one");- let two = user("two");- let responses = HashMap::from([(one.as_ref().to_string(), ReadResponse::Failure)]);- let harness = harness(vec![one, two], responses, false, HashSet::new());-- harness- .service- .notify_users(document_entity())- .await- .expect_err("reader failure propagates");-- assert_eq!(harness.read_calls.load(Ordering::SeqCst), 1);assert!(harness.messages.lock().expect("messages lock").is_empty());}#[tokio::test]async fn publisher_failure_is_returned_after_all_messages_are_attempted() {let users = [user("one"), user("two"), user("three")];- let responses = users- .iter()- .map(|recipient| {- item_response(- recipient,- document_item(DOCUMENT_ID, recipient.as_ref(), None),- )- })- .collect();let harness = harness(users.to_vec(),- responses,false,HashSet::from([users[1].as_ref().to_string()]),);harness.service- .notify_users(document_entity())+ .notify_users(SoupRealtimePatch::for_entity(updated_document())).await.expect_err("publication failure propagates");diff --git a/crates/soup_realtime/src/inbound/kafka_consumer.rs b/crates/soup_realtime/src/inbound/kafka_consumer.rsindex c604c2d2ac..5946a26a3c 100644--- a/crates/soup_realtime/src/inbound/kafka_consumer.rs+++ b/crates/soup_realtime/src/inbound/kafka_consumer.rs@@ -1,7 +1,7 @@-//! Kafka consumer for `document.updated` realtime Soup fan-out.+//! Kafka consumer for entity events that change realtime Soup items.//!//! Delivery is at least once: offsets are committed only after successful-//! domain processing. Malformed and currently unsupported document events are+//! domain processing. Malformed and recognized-but-irrelevant events are//! poison/ignored records and are committed so they cannot wedge a partition.#[cfg(test)]@@ -9,23 +9,28 @@ mod test;use std::{future::Future, time::Duration};-use documents::domain::events::{DocumentMacroEvent, DocumentTopicEvent};+use channels::domain::broker_events::{ChannelMacroEvent, ChannelTopicEvent};+use chat::domain::events::{ChatMacroEvent, ChatTopicEvent};+use documents::domain::events::{DocumentMacroEvent, DocumentTopicEvent, InteractionReason};+use email::domain::events::{EmailMacroEvent, EmailTopicEvent};use kafka_util::{GroupName, KafkaEventConsumer};use macro_event_broker::{KafkaConsumerAdapter, MacroEvent as _, MacroEventCollection as _, MacroEventConsumerService,};use model_entity::{Entity, EntityType};+use projects::domain::events::{ProjectMacroEvent, ProjectTopicEvent};use rdkafka::consumer::CommitMode;use rdkafka::message::{BorrowedMessage, Message as _};use rootcause::prelude::{Report, ResultExt as _};use tokio_retry::{Retry, strategy::ExponentialBackoff};use crate::domain::{- ports::{SoupItemReader, SoupRealtimePublisher, SoupRealtimeService, UserAccessExpander},+ models::{Patch, SoupRealtimePatch},+ ports::{SoupRealtimePublisher, SoupRealtimeService, UserAccessExpander},service::SoupRealtimeServiceImpl,};-/// Consumer group used for document update fan-out offsets.+/// Consumer group used for Soup-affecting entity event offsets.struct SoupRealtimeConsumerGroup;impl GroupName for SoupRealtimeConsumerGroup {@@ -36,7 +41,14 @@ type SoupRealtimeKafkaAdapter = KafkaConsumerAdapter<SoupRealtimeConsumerGroup,type SoupRealtimeKafkaConsumer =MacroEventConsumerService<DeclaredMacroEvent, SoupRealtimeKafkaAdapter>;-macro_event_broker::declare_topics!(DeclaredMacroEvent: DocumentMacroEvent);+macro_event_broker::declare_topics!(+ DeclaredMacroEvent:+ DocumentMacroEvent,+ ProjectMacroEvent,+ ChatMacroEvent,+ EmailMacroEvent,+ ChannelMacroEvent,+);/// Total service attempts before returning for supervisor-driven redelivery.const MAX_SERVICE_ATTEMPTS: u32 = 5;@@ -49,62 +61,323 @@ fn service_retry_strategy() -> impl Iterator<Item = Duration> {.take((MAX_SERVICE_ATTEMPTS - 1) as usize)}-fn entity_from_document_event(event: &DocumentMacroEvent) -> Option<Entity<'static>> {- match &event.event().event {+fn entity(entity_type: EntityType, entity_id: impl ToString) -> Entity<'static> {+ entity_type.with_entity_string(entity_id.to_string())+}++fn update(entity_type: EntityType, entity_id: impl ToString) -> SoupRealtimePatch {+ SoupRealtimePatch::for_entity(Patch::Updated(entity(entity_type, entity_id)))+}++fn delete(entity_type: EntityType, entity_id: impl ToString) -> SoupRealtimePatch {+ SoupRealtimePatch::for_entity(Patch::Deleted(entity(entity_type, entity_id)))+}++fn push_unique_patch(patches: &mut Vec<SoupRealtimePatch>, patch: Patch<Entity<'static>>) {+ if patch.value().entity_id.is_empty()+ || patches.iter().any(|candidate| candidate.patch == patch)+ {+ return;+ }+ patches.push(SoupRealtimePatch::for_entity(patch));+}++fn push_unique_update(+ patches: &mut Vec<SoupRealtimePatch>,+ entity_type: EntityType,+ entity_id: &str,+) {+ push_unique_patch(patches, Patch::Updated(entity(entity_type, entity_id)));+}++fn push_unique_delete(+ patches: &mut Vec<SoupRealtimePatch>,+ entity_type: EntityType,+ entity_id: &str,+) {+ push_unique_patch(patches, Patch::Deleted(entity(entity_type, entity_id)));+}++fn patches_from_document_event(event: &DocumentTopicEvent) -> Vec<SoupRealtimePatch> {+ let mut updates = Vec::new();+ match event {+ DocumentTopicEvent::Created(metadata) => {+ push_unique_update(&mut updates, EntityType::Document, &metadata.document_id);+ if let Some(project_id) = metadata.project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ }DocumentTopicEvent::Updated(metadata) => {- Some(EntityType::Document.with_entity_string(metadata.document_id.clone()))+ push_unique_update(&mut updates, EntityType::Document, &metadata.document_id);+ if let Some(project_id) = metadata.project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ if metadata.previous_project_id.as_deref() != metadata.project_id.as_deref()+ && let Some(previous_project_id) = metadata.previous_project_id.as_deref()+ {+ push_unique_update(&mut updates, EntityType::Project, previous_project_id);+ }+ }+ DocumentTopicEvent::Deleted(metadata) => {+ push_unique_delete(&mut updates, EntityType::Document, &metadata.document_id);+ if let Some(project_id) = metadata.project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ }+ DocumentTopicEvent::Copied(metadata) => {+ push_unique_update(&mut updates, EntityType::Document, &metadata.document_id);+ }+ DocumentTopicEvent::Interaction(metadata)+ if metadata.reason == InteractionReason::Edited =>+ {+ push_unique_update(&mut updates, EntityType::Document, &metadata.document_id);+ }+ DocumentTopicEvent::Interaction(_) => {}+ }+ updates+}++fn patches_from_project_event(event: &ProjectTopicEvent) -> Vec<SoupRealtimePatch> {+ let mut updates = Vec::new();+ match event {+ ProjectTopicEvent::Created(metadata) => {+ push_unique_update(&mut updates, EntityType::Project, &metadata.project_id);+ if let Some(parent_id) = metadata.parent_project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, parent_id);+ }+ }+ ProjectTopicEvent::Updated(metadata) => {+ push_unique_update(&mut updates, EntityType::Project, &metadata.project_id);+ if let Some(previous_parent_id) = metadata.previous_parent_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, previous_parent_id);+ }+ if let Some(parent_id) = metadata.parent_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, parent_id);+ }+ }+ ProjectTopicEvent::Deleted(metadata) => {+ push_unique_delete(&mut updates, EntityType::Project, &metadata.project_id);+ for project_id in &metadata.deleted_project_ids {+ push_unique_delete(&mut updates, EntityType::Project, project_id);+ }+ for document_id in &metadata.deleted_document_ids {+ push_unique_delete(&mut updates, EntityType::Document, document_id);+ }+ for chat_id in &metadata.deleted_chat_ids {+ push_unique_delete(&mut updates, EntityType::Chat, chat_id);+ }+ if let Some(parent_id) = metadata.parent_project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, parent_id);+ }+ }+ ProjectTopicEvent::Restored(metadata) => {+ push_unique_update(&mut updates, EntityType::Project, &metadata.project_id);+ for project_id in &metadata.restored_project_ids {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ }+ ProjectTopicEvent::PermanentlyDeleted(_) => {}+ ProjectTopicEvent::Uploaded(metadata) => {+ for project_id in &metadata.project_ids {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ }+ }+ updates+}++fn patches_from_chat_event(event: &ChatTopicEvent) -> Vec<SoupRealtimePatch> {+ let mut updates = Vec::new();+ match event {+ ChatTopicEvent::Created(metadata) => {+ push_unique_update(&mut updates, EntityType::Chat, &metadata.chat_id);+ if let Some(project_id) = metadata.project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ }+ ChatTopicEvent::Updated(metadata) => {+ push_unique_update(&mut updates, EntityType::Chat, &metadata.chat_id);+ if let Some(project_id) = metadata.project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ if metadata.previous_project_id.as_deref() != metadata.project_id.as_deref()+ && let Some(previous_project_id) = metadata.previous_project_id.as_deref()+ {+ push_unique_update(&mut updates, EntityType::Project, previous_project_id);+ }+ }+ ChatTopicEvent::Deleted(metadata) => {+ push_unique_delete(&mut updates, EntityType::Chat, &metadata.chat_id);+ if let Some(project_id) = metadata.project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ }+ ChatTopicEvent::PermanentlyDeleted(metadata) => {+ if let Some(project_id) = metadata.project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ }+ ChatTopicEvent::Restored(metadata) => {+ push_unique_update(&mut updates, EntityType::Chat, &metadata.chat_id);+ if let Some(project_id) = metadata.project_id.as_deref() {+ push_unique_update(&mut updates, EntityType::Project, project_id);+ }+ }+ ChatTopicEvent::Copied(metadata) => {+ push_unique_update(&mut updates, EntityType::Chat, &metadata.chat_id);+ }+ ChatTopicEvent::MessageSent(_) | ChatTopicEvent::MessageDeleted(_) => {}+ }+ updates+}++fn patches_from_email_event(event: &EmailTopicEvent) -> Vec<SoupRealtimePatch> {+ if let EmailTopicEvent::ThreadTrashed(metadata) = event+ && metadata.trashed+ {+ return vec![delete(EntityType::EmailThread, metadata.thread_id)];+ }++ let thread_id = match event {+ EmailTopicEvent::MessageReceived(metadata) if !metadata.is_spam_or_trash => {+ metadata.thread_id+ }+ EmailTopicEvent::MessageSent(metadata) => metadata.thread_id,+ EmailTopicEvent::MessageDeleted(metadata) => metadata.thread_id,+ EmailTopicEvent::MessageSendQueued(metadata) => metadata.thread_id,+ EmailTopicEvent::MessageSendCancelled(metadata) => metadata.thread_id,+ EmailTopicEvent::ThreadArchived(metadata) => metadata.thread_id,+ EmailTopicEvent::ThreadTrashed(metadata) if !metadata.trashed => metadata.thread_id,+ EmailTopicEvent::ThreadRead(metadata) => metadata.thread_id,+ EmailTopicEvent::ThreadStarred(metadata) => metadata.thread_id,+ EmailTopicEvent::ThreadProjectChanged(metadata) => metadata.thread_id,+ EmailTopicEvent::ThreadLabelsUpdated(metadata) => metadata.thread_id,+ EmailTopicEvent::LinkConnected(_)+ | EmailTopicEvent::LinkDisconnected(_)+ | EmailTopicEvent::LinkReauthRequired(_)+ | EmailTopicEvent::MessageReceived(_)+ | EmailTopicEvent::ThreadTrashed(_) => return Vec::new(),+ };+ vec![update(EntityType::EmailThread, thread_id)]+}++fn channel_and_thread_entities(+ channel_id: impl ToString,+ message_id: impl ToString,+ thread_id: Option<impl ToString>,+) -> Vec<SoupRealtimePatch> {+ let channel = entity(EntityType::Channel, channel_id);+ let thread = entity(+ EntityType::ChannelMessage,+ thread_id+ .map(|id| id.to_string())+ .unwrap_or_else(|| message_id.to_string()),+ );+ vec![+ SoupRealtimePatch::for_entity(Patch::Updated(channel.clone())),+ SoupRealtimePatch::new(Patch::Updated(thread), channel),+ ]+}++fn patches_from_channel_event(event: &ChannelTopicEvent) -> Vec<SoupRealtimePatch> {+ match event {+ ChannelTopicEvent::Updated(metadata) => {+ vec![update(EntityType::Channel, metadata.channel_id)]+ }+ ChannelTopicEvent::MessagePosted(metadata) => channel_and_thread_entities(+ metadata.channel_id,+ metadata.message_id,+ metadata.thread_id,+ ),+ ChannelTopicEvent::MessagePatched(metadata) => channel_and_thread_entities(+ metadata.channel_id,+ metadata.message_id,+ metadata.thread_id,+ ),+ ChannelTopicEvent::MessageDeleted(metadata) => {+ let channel = entity(EntityType::Channel, metadata.channel_id);+ let thread_patch = match metadata.thread_id {+ Some(thread_id) => Patch::Updated(entity(EntityType::ChannelMessage, thread_id)),+ None => Patch::Deleted(entity(EntityType::ChannelMessage, metadata.message_id)),+ };+ vec![+ SoupRealtimePatch::for_entity(Patch::Updated(channel.clone())),+ SoupRealtimePatch::new(thread_patch, channel),+ ]+ }+ ChannelTopicEvent::MessageAttachmentCreated(metadata) => {+ vec![update(EntityType::Channel, metadata.channel_id)]+ }+ ChannelTopicEvent::MessageAttachmentRemoved(metadata) => {+ vec![update(EntityType::Channel, metadata.channel_id)]+ }+ ChannelTopicEvent::ParticipantAdded(metadata) => {+ vec![update(EntityType::Channel, metadata.channel_id)]}- DocumentTopicEvent::Created(_) => {- tracing::trace!(event_type = "document.created", "ignoring document event");- None+ ChannelTopicEvent::ParticipantRemoved(metadata) => {+ vec![update(EntityType::Channel, metadata.channel_id)]}- DocumentTopicEvent::Deleted(_) => {- tracing::trace!(event_type = "document.deleted", "ignoring document event");- None+ ChannelTopicEvent::Created(metadata) => {+ vec![update(EntityType::Channel, metadata.channel_id)]}- DocumentTopicEvent::Copied(_) => {- tracing::trace!(event_type = "document.copied", "ignoring document event");- None+ ChannelTopicEvent::Deleted(metadata) => {+ vec![delete(EntityType::Channel, metadata.channel_id)]}- DocumentTopicEvent::Interaction(_) => {- tracing::trace!(- event_type = "document.interaction",- "ignoring document event"- );- None+ }+}++fn patches_from_event(event: &DeclaredMacroEvent) -> Vec<SoupRealtimePatch> {+ match event {+ DeclaredMacroEvent::DocumentMacroEvent(event) => {+ patches_from_document_event(&event.event().event)+ }+ DeclaredMacroEvent::ProjectMacroEvent(event) => {+ patches_from_project_event(&event.event().event)+ }+ DeclaredMacroEvent::ChatMacroEvent(event) => patches_from_chat_event(&event.event().event),+ DeclaredMacroEvent::EmailMacroEvent(event) => {+ patches_from_email_event(&event.event().event)+ }+ DeclaredMacroEvent::ChannelMacroEvent(event) => {+ patches_from_channel_event(&event.event().event)}}}-/// Commit-safe outcome after processing one document event.-enum DocumentEventOutcome {- /// An update was successfully sent through the domain service.+/// Commit-safe outcome after processing one entity event.+enum EventOutcome {+ /// Every affected item was successfully sent through the domain service.Notified,- /// A recognized document event is outside the current scope.+ /// A recognized event does not change a Soup-visible entity.Ignored,}#[tracing::instrument(skip(service, event), fields(partition, offset), err)]-async fn process_document_event<S: SoupRealtimeService>(+async fn process_event<S: SoupRealtimeService>(service: &S,- event: &DocumentMacroEvent,+ event: &DeclaredMacroEvent,partition: i32,offset: i64,-) -> Result<DocumentEventOutcome, Report> {- match entity_from_document_event(event) {- Some(entity) => {- notify_with_retry(service, entity, partition, offset).await?;- Ok(DocumentEventOutcome::Notified)- }- None => Ok(DocumentEventOutcome::Ignored),+) -> Result<EventOutcome, Report> {+ let patches = patches_from_event(event);+ if patches.is_empty() {+ tracing::trace!("ignoring event without a Soup patch");+ return Ok(EventOutcome::Ignored);}++ for patch in patches {+ notify_with_retry(service, patch, partition, offset).await?;+ }+ Ok(EventOutcome::Notified)}#[tracing::instrument(- skip(service),+ skip(service, patch),fields(- entity_type = %entity.entity_type,- entity_id = %entity.entity_id,+ entity_type = %patch.patch.value().entity_type,+ entity_id = %patch.patch.value().entity_id,+ access_source_type = %patch.access_source.entity_type,+ access_source_id = %patch.access_source.entity_id,partition,offset,),@@ -112,17 +385,17 @@ async fn process_document_event<S: SoupRealtimeService>()]async fn notify_with_retry<S: SoupRealtimeService>(service: &S,- entity: Entity<'static>,+ patch: SoupRealtimePatch,partition: i32,offset: i64,) -> Result<(), Report> {let mut attempt = 0u32;Retry::start(service_retry_strategy(), || {attempt += 1;- let entity = entity.clone();+ let patch = patch.clone();async move {tracing::trace!(attempt, "notifying realtime Soup recipients");- let result = service.notify_users(entity).await;+ let result = service.notify_users(patch).await;match &result {Ok(()) => tracing::trace!(attempt, "realtime Soup recipients notified"),Err(error) if attempt < MAX_SERVICE_ATTEMPTS => {@@ -166,21 +439,20 @@ fn commit_logged(consumer: &SoupRealtimeKafkaConsumer, message: &BorrowedMessage}}-impl<A, R, P> SoupRealtimeServiceImpl<A, R, P>+impl<A, P> SoupRealtimeServiceImpl<A, P>whereA: UserAccessExpander,- R: SoupItemReader,P: SoupRealtimePublisher,{- /// Runs the document update consumer until `shutdown` resolves.+ /// Runs the Soup-affecting entity event consumer until `shutdown` resolves.///- /// The consumer subscribes only to `macro.documents` under the- /// `soup-realtime` group. It commits malformed and recognized-but-ignored- /// events, and commits `document.updated` only after [`SoupRealtimeService`]- /// succeeds. Exhausted service retries return without committing so a future- /// supervisor restart can redeliver the record.+ /// The consumer subscribes to every existing entity topic with events that+ /// can change a Soup item under the `soup-realtime` group. It commits malformed+ /// and recognized-but-ignored events, and commits affecting events only after+ /// [`SoupRealtimeService`] succeeds. Exhausted service retries return without+ /// committing so a future supervisor restart can redeliver the record.#[tracing::instrument(skip(self, shutdown), fields(brokers), err)]- pub async fn run_document_update_consumer(+ pub async fn run_entity_update_consumer(&self,brokers: &str,shutdown: impl Future<Output = ()> + Send,@@ -188,19 +460,19 @@ wherelet consumer = KafkaEventConsumer::<SoupRealtimeConsumerGroup>::from_env(brokers)?;let consumer = KafkaConsumerAdapter::<SoupRealtimeConsumerGroup, ()>::new(consumer).subscribe::<DeclaredMacroEvent>()- .context("failed to subscribe to document update topic")?;+ .context("failed to subscribe to Soup-affecting entity topics")?;let consumer = SoupRealtimeKafkaConsumer::new(consumer);tracing::info!(topics = ?DeclaredMacroEvent::topics(),group = SoupRealtimeConsumerGroup::GROUP_NAME,- "realtime Soup document consumer listening"+ "realtime Soup entity consumer listening");let mut shutdown = std::pin::pin!(shutdown);loop {tokio::select! {_ = &mut shutdown => {- tracing::info!("realtime Soup document consumer shutting down");+ tracing::info!("realtime Soup entity consumer shutting down");break;}result = consumer.recv() => {@@ -213,21 +485,21 @@ where};let kafka_message = message.inner();let event = match message.decode_payload() {- Ok(DeclaredMacroEvent::DocumentMacroEvent(event)) => event,+ Ok(event) => event,Err(error) => {tracing::error!(error = ?error,topic = kafka_message.topic(),partition = kafka_message.partition(),offset = kafka_message.offset(),- "dropping malformed document event"+ "dropping malformed Soup source event");commit_logged(&consumer, kafka_message);continue;}};- match process_document_event(+ match process_event(self,&event,kafka_message.partition(),@@ -235,23 +507,18 @@ where).await{- Ok(DocumentEventOutcome::Notified | DocumentEventOutcome::Ignored) => {}+ Ok(EventOutcome::Notified | EventOutcome::Ignored) => {}Err(error) => {tracing::error!(error = ?error,topic = kafka_message.topic(),partition = kafka_message.partition(),offset = kafka_message.offset(),- "realtime Soup fan-out retries exhausted; pausing partition for redelivery"+ "realtime Soup fan-out retries exhausted; restarting consumer for redelivery");- // Kafka commits are cumulative within a partition, so- // pause it before any later record can advance the- // committed offset past this failure.- consumer- .inner()- .pause_message_partition(kafka_message)- .context("failed to pause Kafka partition after fan-out failure")?;- continue;+ return Err(error+ .context("realtime Soup entity consumer requires restart for redelivery")+ .into_dynamic());}}diff --git a/crates/soup_realtime/src/inbound/kafka_consumer/test.rs b/crates/soup_realtime/src/inbound/kafka_consumer/test.rsindex 85c2d787c0..00c28d745c 100644--- a/crates/soup_realtime/src/inbound/kafka_consumer/test.rs+++ b/crates/soup_realtime/src/inbound/kafka_consumer/test.rs@@ -1,12 +1,24 @@use std::sync::atomic::{AtomicU32, Ordering};use std::sync::{Arc, Mutex};+use channels::domain::{+ broker_events::{+ ChannelMessageAttachmentCreatedMetadata, ChannelMessageDeletedMetadata, ChannelTopicEvent,+ },+ models::ChannelSender,+};+use chat::domain::events::{ChatMessageDeletedMetadata, ChatTopicEvent, ChatUpdatedMetadata};use documents::domain::events::{- DocumentCopiedMetadata, DocumentCreatedMetadata, DocumentDeletedMetadata,- DocumentInteractionMetadata, DocumentUpdatedMetadata, InteractionReason,+ DocumentCreatedMetadata, DocumentDeletedMetadata, DocumentInteractionMetadata,+ DocumentUpdatedMetadata, InteractionReason,+};+use email::domain::events::{+ EmailEventOrigin, EmailTopicEvent, ThreadReadMetadata, ThreadTrashedMetadata,};use macro_event_broker::{Event, EventBrokerError, MacroEventCollection as _, MessageParts};use macro_user_id::user_id::MacroUserIdStr;+use projects::domain::events::{ProjectDeletedMetadata, ProjectTopicEvent};+use uuid::Uuid;use super::*;@@ -51,49 +63,20 @@ fn updated_event() -> Event<DocumentTopicEvent> {}))}-fn ignored_events() -> Vec<DocumentTopicEvent> {- vec![- DocumentTopicEvent::Created(DocumentCreatedMetadata {- document_id: DOCUMENT_ID.to_string(),- owner: user(),- document_name: "Created".to_string(),- file_type: None,- project_id: None,- sub_type: None,- created_at: None,- }),- DocumentTopicEvent::Deleted(DocumentDeletedMetadata {- document_id: DOCUMENT_ID.to_string(),- actor_user_id: None,- project_id: None,- }),- DocumentTopicEvent::Copied(DocumentCopiedMetadata {- document_id: DOCUMENT_ID.to_string(),- source_document_id: "00000000-0000-0000-0000-000000000002".to_string(),- source_version_id: None,- owner: user(),- document_name: "Copied".to_string(),- file_type: None,- project_id: None,- sub_type: None,- }),- DocumentTopicEvent::Interaction(DocumentInteractionMetadata {- document_id: DOCUMENT_ID.to_string(),- reason: InteractionReason::Edited,- }),- ]+fn patch_entity(patch: &SoupRealtimePatch) -> &Entity<'static> {+ patch.patch.value()}#[derive(Clone)]struct FlakyService {attempts: Arc<AtomicU32>,failures: u32,- entities: Arc<Mutex<Vec<Entity<'static>>>>,+ patches: Arc<Mutex<Vec<SoupRealtimePatch>>>,}impl SoupRealtimeService for FlakyService {- async fn notify_users(&self, entity: Entity<'static>) -> Result<(), Report> {- self.entities.lock().expect("entities lock").push(entity);+ async fn notify_users(&self, patch: SoupRealtimePatch) -> Result<(), Report> {+ self.patches.lock().expect("patches lock").push(patch);let attempt = self.attempts.fetch_add(1, Ordering::SeqCst) + 1;if attempt <= self.failures {Err(rootcause::report!("temporary fan-out failure"))@@ -107,46 +90,255 @@ fn flaky_service(failures: u32) -> FlakyService {FlakyService {attempts: Arc::new(AtomicU32::new(0)),failures,- entities: Arc::new(Mutex::new(Vec::new())),+ patches: Arc::new(Mutex::new(Vec::new())),}}#[test]-fn subscribes_only_to_documents() {- assert_eq!(DeclaredMacroEvent::topics(), ["macro.documents"]);+fn subscribes_to_all_existing_soup_source_topics() {+ assert_eq!(+ DeclaredMacroEvent::topics(),+ [+ "macro.documents",+ "macro.projects",+ "macro.chats",+ "macro.email",+ "macro.channels",+ ]+ );}-#[tokio::test]-async fn updated_payload_maps_to_document_entity() {- let event = DocumentMacroEvent::with_event(DOCUMENT_ID, updated_event());- let service = flaky_service(0);+#[test]+fn document_lifecycle_events_map_to_updated_and_deleted_patches() {+ let created = DocumentTopicEvent::Created(DocumentCreatedMetadata {+ document_id: DOCUMENT_ID.to_string(),+ owner: user(),+ document_name: "Created".to_string(),+ file_type: None,+ project_id: None,+ sub_type: None,+ created_at: None,+ });+ let deleted = DocumentTopicEvent::Deleted(DocumentDeletedMetadata {+ document_id: DOCUMENT_ID.to_string(),+ actor_user_id: None,+ project_id: None,+ });++ let created = patches_from_document_event(&created);+ assert!(matches!(created[0].patch, Patch::Updated(_)));+ assert_eq!(patch_entity(&created[0]).entity_type, EntityType::Document);++ let deleted = patches_from_document_event(&deleted);+ assert!(matches!(deleted[0].patch, Patch::Deleted(_)));+ assert_eq!(patch_entity(&deleted[0]).entity_id, DOCUMENT_ID);+}++#[test]+fn moving_a_document_out_of_a_project_updates_the_previous_project() {+ let previous_project_id = Uuid::now_v7().to_string();+ let event = DocumentTopicEvent::Updated(DocumentUpdatedMetadata {+ document_id: DOCUMENT_ID.to_string(),+ owner: user(),+ actor_user_id: None,+ document_name: None,+ previous_project_id: Some(previous_project_id.clone()),+ project_id: None,+ file_type: None,+ share_permission_updated: false,+ });++ let patches = patches_from_document_event(&event);+ assert_eq!(patches.len(), 2);+ assert!(matches!(patches[1].patch, Patch::Updated(_)));+ assert_eq!(patch_entity(&patches[1]).entity_type, EntityType::Project);+ assert_eq!(patch_entity(&patches[1]).entity_id, previous_project_id);+}++#[test]+fn document_edit_interactions_map_to_updated_patches() {+ let edited = DocumentTopicEvent::Interaction(DocumentInteractionMetadata {+ document_id: DOCUMENT_ID.to_string(),+ reason: InteractionReason::Edited,+ });+ let first_join = DocumentTopicEvent::Interaction(DocumentInteractionMetadata {+ document_id: DOCUMENT_ID.to_string(),+ reason: InteractionReason::FirstJoin,+ });assert!(matches!(- process_document_event(&service, &event, 0, 0)- .await- .expect("processing succeeds"),- DocumentEventOutcome::Notified+ patches_from_document_event(&edited)[0].patch,+ Patch::Updated(_)+ ));+ assert!(patches_from_document_event(&first_join).is_empty());+}++#[test]+fn project_deletion_maps_cascade_entities_to_deleted_patches() {+ let project_id = Uuid::now_v7().to_string();+ let child_id = Uuid::now_v7().to_string();+ let document_id = Uuid::now_v7().to_string();+ let chat_id = Uuid::now_v7().to_string();+ let event = ProjectTopicEvent::Deleted(ProjectDeletedMetadata {+ project_id: project_id.clone(),+ owner: user(),+ actor_user_id: None,+ parent_project_id: None,+ deleted_project_ids: vec![project_id.clone(), child_id.clone()],+ deleted_document_ids: vec![document_id.clone()],+ deleted_chat_ids: vec![chat_id.clone()],+ });++ let patches = patches_from_project_event(&event);+ assert_eq!(patches.len(), 4);+ assert!(+ patches+ .iter()+ .all(|patch| matches!(patch.patch, Patch::Deleted(_)))+ );+ let entities = patches+ .iter()+ .map(patch_entity)+ .map(|entity| (entity.entity_type, entity.entity_id.as_ref()))+ .collect::<Vec<_>>();+ assert!(entities.contains(&(EntityType::Project, project_id.as_str())));+ assert!(entities.contains(&(EntityType::Project, child_id.as_str())));+ assert!(entities.contains(&(EntityType::Document, document_id.as_str())));+ assert!(entities.contains(&(EntityType::Chat, chat_id.as_str())));+}++#[test]+fn chat_metadata_events_map_to_updated_patches() {+ let event = ChatTopicEvent::Updated(ChatUpdatedMetadata {+ chat_id: DOCUMENT_ID.to_string(),+ actor_user_id: user(),+ name: Some("Renamed".to_string()),+ previous_project_id: None,+ project_id: None,+ share_permission_updated: false,+ });++ let patches = patches_from_chat_event(&event);+ assert_eq!(patches.len(), 1);+ assert!(matches!(patches[0].patch, Patch::Updated(_)));+ assert_eq!(patch_entity(&patches[0]).entity_type, EntityType::Chat);+}++#[test]+fn moving_a_chat_out_of_a_project_updates_the_previous_project() {+ let previous_project_id = Uuid::now_v7().to_string();+ let event = ChatTopicEvent::Updated(ChatUpdatedMetadata {+ chat_id: DOCUMENT_ID.to_string(),+ actor_user_id: user(),+ name: None,+ previous_project_id: Some(previous_project_id.clone()),+ project_id: None,+ share_permission_updated: false,+ });++ let patches = patches_from_chat_event(&event);+ assert_eq!(patches.len(), 2);+ assert!(matches!(patches[1].patch, Patch::Updated(_)));+ assert_eq!(patch_entity(&patches[1]).entity_type, EntityType::Project);+ assert_eq!(patch_entity(&patches[1]).entity_id, previous_project_id);+}++#[test]+fn deleted_chat_messages_do_not_change_soup() {+ let event = ChatTopicEvent::MessageDeleted(ChatMessageDeletedMetadata {+ chat_id: DOCUMENT_ID.to_string(),+ message_id: Uuid::now_v7().to_string(),+ });++ assert!(patches_from_chat_event(&event).is_empty());+}++#[test]+fn email_state_events_map_to_updated_or_deleted_patches() {+ let thread_id = Uuid::now_v7();+ let read = EmailTopicEvent::ThreadRead(ThreadReadMetadata {+ link_id: Uuid::now_v7(),+ owner: user(),+ actor: Some(user()),+ thread_id,+ is_read: true,+ origin: EmailEventOrigin::UserAction,+ });+ let trashed = EmailTopicEvent::ThreadTrashed(ThreadTrashedMetadata {+ link_id: Uuid::now_v7(),+ owner: user(),+ actor: Some(user()),+ thread_id,+ trashed: true,+ origin: EmailEventOrigin::UserAction,+ });++ assert!(matches!(+ patches_from_email_event(&read)[0].patch,+ Patch::Updated(_)+ ));+ assert!(matches!(+ patches_from_email_event(&trashed)[0].patch,+ Patch::Deleted(_)));+}++#[test]+fn attachment_events_use_only_metadata_available_on_the_existing_event() {+ let channel_id = Uuid::now_v7();+ let event =+ ChannelTopicEvent::MessageAttachmentCreated(ChannelMessageAttachmentCreatedMetadata {+ channel_id,+ message_id: Uuid::now_v7(),+ actor: ChannelSender::new_from_user(user()),+ attachments: Vec::new(),+ });++ let patches = patches_from_channel_event(&event);+ assert_eq!(patches.len(), 1);+ assert_eq!(patch_entity(&patches[0]).entity_type, EntityType::Channel);+ assert_eq!(patch_entity(&patches[0]).entity_id, channel_id.to_string());+}++#[test]+fn deleting_a_root_channel_message_deletes_its_thread_patch() {+ let channel_id = Uuid::now_v7();+ let message_id = Uuid::now_v7();+ let event = ChannelTopicEvent::MessageDeleted(ChannelMessageDeletedMetadata {+ channel_id,+ message_id,+ thread_id: None,+ actor: ChannelSender::new_from_user(user()),+ deleted_at: None,+ });- let entities = service.entities.lock().expect("entities lock");- assert_eq!(entities.len(), 1);- assert_eq!(entities[0].entity_type, EntityType::Document);- assert_eq!(entities[0].entity_id, DOCUMENT_ID);+ let patches = patches_from_channel_event(&event);+ assert_eq!(patches.len(), 2);+ assert!(matches!(patches[0].patch, Patch::Updated(_)));+ assert!(matches!(patches[1].patch, Patch::Deleted(_)));+ assert_eq!(patch_entity(&patches[1]).entity_id, message_id.to_string());+ assert_eq!(patches[1].access_source.entity_type, EntityType::Channel);}#[tokio::test]-async fn non_update_events_are_ignored() {+async fn updated_payload_maps_to_document_patch() {+ let event = DeclaredMacroEvent::DocumentMacroEvent(DocumentMacroEvent::with_event(+ DOCUMENT_ID,+ updated_event(),+ ));let service = flaky_service(0);- for event in ignored_events() {- let event = DocumentMacroEvent::with_event(DOCUMENT_ID, Event::new(event));- assert!(matches!(- process_document_event(&service, &event, 0, 0)- .await- .expect("processing succeeds"),- DocumentEventOutcome::Ignored- ));- }- assert_eq!(service.attempts.load(Ordering::SeqCst), 0);++ assert!(matches!(+ process_event(&service, &event, 0, 0)+ .await+ .expect("processing succeeds"),+ EventOutcome::Notified+ ));++ let patches = service.patches.lock().expect("patches lock");+ assert_eq!(patches.len(), 1);+ assert!(matches!(patches[0].patch, Patch::Updated(_)));+ assert_eq!(patch_entity(&patches[0]).entity_id, DOCUMENT_ID);}#[test]@@ -166,22 +358,26 @@ fn malformed_and_unknown_events_are_rejected_by_the_declared_collection() {#[tokio::test(start_paused = true)]async fn transient_service_failures_retry_then_succeed() {let service = flaky_service(2);- let entity = EntityType::Document.with_entity_string(DOCUMENT_ID.to_string());+ let patch = SoupRealtimePatch::for_entity(Patch::Updated(+ EntityType::Document.with_entity_string(DOCUMENT_ID.to_string()),+ ));- notify_with_retry(&service, entity, 2, 17)+ notify_with_retry(&service, patch, 2, 17).await.expect("eventual success");assert_eq!(service.attempts.load(Ordering::SeqCst), 3);- assert_eq!(service.entities.lock().expect("entities lock").len(), 3);+ assert_eq!(service.patches.lock().expect("patches lock").len(), 3);}#[tokio::test(start_paused = true)]async fn exhausted_retries_return_for_redelivery() {let service = flaky_service(u32::MAX);- let entity = EntityType::Document.with_entity_string(DOCUMENT_ID.to_string());+ let patch = SoupRealtimePatch::for_entity(Patch::Updated(+ EntityType::Document.with_entity_string(DOCUMENT_ID.to_string()),+ ));- notify_with_retry(&service, entity, 2, 17)+ notify_with_retry(&service, patch, 2, 17).await.expect_err("persistent failure returns without a commit");diff --git a/crates/soup_realtime/src/inbound/mod.rs b/crates/soup_realtime/src/inbound/mod.rsindex 1d73c01b15..12d1a5f0d6 100644--- a/crates/soup_realtime/src/inbound/mod.rs+++ b/crates/soup_realtime/src/inbound/mod.rs@@ -1,4 +1,4 @@//! Inbound adapters that drive realtime Soup fan-out.-/// Kafka consumer for document update events.+/// Kafka consumer for events that change Soup items.pub mod kafka_consumer;diff --git a/crates/soup_realtime/src/outbound/kafka_publisher.rs b/crates/soup_realtime/src/outbound/kafka_publisher.rsindex 2f59c1904b..bc7ef0d8f5 100644--- a/crates/soup_realtime/src/outbound/kafka_publisher.rs+++ b/crates/soup_realtime/src/outbound/kafka_publisher.rs@@ -1,4 +1,4 @@-//! Macro event broker publisher for realtime Soup events.+//! Macro event broker publisher for realtime Soup patches.#[cfg(test)]mod test;@@ -11,7 +11,7 @@ use crate::domain::{ports::SoupRealtimePublisher,};-/// Realtime Soup publisher backed by the typed macro event broker service.+/// Realtime Soup patch publisher backed by the typed macro event broker service.pub struct KafkaSoupRealtimePublisher<B> {broker: B,}@@ -33,7 +33,7 @@ whereerr)]async fn publish(&self, message: SoupRealtimeMessage) -> Result<(), Report> {- let event = SoupMacroEvent::item_updated(message);+ let event = SoupMacroEvent::from_message(message);let publish = self.broker.send_event(&event)diff --git a/crates/soup_realtime/src/outbound/kafka_publisher/test.rs b/crates/soup_realtime/src/outbound/kafka_publisher/test.rsindex 36854ec445..e90bd7e389 100644--- a/crates/soup_realtime/src/outbound/kafka_publisher/test.rs+++ b/crates/soup_realtime/src/outbound/kafka_publisher/test.rs@@ -1,14 +1,15 @@use std::sync::{Arc, Mutex};-use chrono::{DateTime, Utc};use macro_event_broker::{EventBrokerError, EventPublisher, GlobalSpawner, MacroEvent, MacroEventBrokerService, Topic,};use macro_user_id::user_id::MacroUserIdStr;-use models_soup::{document::SoupDocument, item::SoupItem};-use uuid::Uuid;+use model_entity::{Entity, EntityType};use super::*;+use crate::domain::models::Patch;++const DOCUMENT_ID: &str = "00000000-0000-0000-0000-000000000001";#[derive(Debug)]struct PublishedRecord {@@ -44,36 +45,16 @@ fn user() -> MacroUserIdStr<'static> {MacroUserIdStr::try_from("macro|[email protected]".to_string()).expect("valid user id")}-fn timestamp(seconds: i64) -> DateTime<Utc> {- DateTime::from_timestamp(seconds, 0).expect("valid timestamp")+fn document() -> Entity<'static> {+ EntityType::Document.with_entity_string(DOCUMENT_ID.to_string())}fn message() -> SoupRealtimeMessage {- SoupRealtimeMessage::new(- user(),- SoupItem::Document(SoupDocument {- id: Uuid::parse_str("00000000-0000-0000-0000-000000000001").expect("valid document id"),- document_version_id: 9,- owner_id: user(),- name: "Published document".to_string(),- file_type: Some("md".to_string()),- sha: Some("sha".to_string()),- project_id: None,- branched_from_id: None,- branched_from_version_id: None,- document_family_id: None,- created_at: timestamp(1),- updated_at: timestamp(2),- viewed_at: Some(timestamp(3)),- sub_type: None,- deleted_at: None,- extra: (),- }),- )+ SoupRealtimeMessage::new(user(), Patch::Updated(document()))}#[tokio::test]-async fn publishes_typed_recipient_keyed_event_to_soup_topic() {+async fn publishes_recipient_and_entity_patch_in_the_soup_topic_payload() {let records = Arc::new(Mutex::new(Vec::new()));let broker = MacroEventBrokerService::new(RecordingPublisher {@@ -94,22 +75,42 @@ async fn publishes_typed_recipient_keyed_event_to_soup_topic() {let json: serde_json::Value = serde_json::from_slice(&record.payload).expect("payload is JSON");assert!(json["event_id"].is_string());- assert_eq!(json["schema_version"], 1);- assert_eq!(json["event_type"], "soup.item.updated");- assert_eq!(json["metadata"]["user_id"], "macro|[email protected]");+ assert_eq!(json["schema_version"], 2);+ assert_eq!(json["event_type"], "soup.updated");+ assert_eq!(json["metadata"][0], "macro|[email protected]");+ assert_eq!(json["metadata"][1]["entity_type"], "document");+ assert_eq!(json["metadata"][1]["entity_id"], DOCUMENT_ID);+ assert!(json.to_string().find("document_version_id").is_none());let decoded = SoupMacroEvent::decode(record.key, &record.payload).expect("event round-trips");- assert_eq!(decoded.event().schema_version, 1);- let decoded = decoded.into_message();- assert_eq!(decoded.user_id.as_ref(), "macro|[email protected]");- match decoded.item {- SoupItem::Document(document) => {- assert_eq!(document.name, "Published document");- assert_eq!(document.document_version_id, 9);- assert_eq!(document.viewed_at, Some(timestamp(3)));- }- _ => panic!("expected document item"),- }+ assert_eq!(decoded.event().schema_version, 2);+ assert_eq!(+ decoded.into_message(),+ SoupRealtimeMessage::new(user(), Patch::Updated(document()))+ );+}++#[tokio::test]+async fn publishes_deleted_patches() {+ let records = Arc::new(Mutex::new(Vec::new()));+ let broker = MacroEventBrokerService::new(+ RecordingPublisher {+ records: records.clone(),+ fail: false,+ },+ GlobalSpawner,+ );+ let adapter = KafkaSoupRealtimePublisher::new(broker);++ adapter+ .publish(SoupRealtimeMessage::new(user(), Patch::Deleted(document())))+ .await+ .expect("publish succeeds");++ let records = records.lock().expect("records lock");+ let json: serde_json::Value =+ serde_json::from_slice(&records[0].payload).expect("payload is JSON");+ assert_eq!(json["event_type"], "soup.deleted");}#[tokio::test]diff --git a/crates/soup_realtime/src/outbound/mod.rs b/crates/soup_realtime/src/outbound/mod.rsindex 39fe268ff5..be94d4b9b2 100644--- a/crates/soup_realtime/src/outbound/mod.rs+++ b/crates/soup_realtime/src/outbound/mod.rs@@ -9,6 +9,3 @@ pub mod kafka_publisher;/// Independent Kafka consumer for recipient-targeted Soup messages.#[cfg(feature = "consumer")]pub mod soup_consumer;-/// User-scoped Soup item reader adapter.-#[cfg(feature = "outbound")]-pub mod soup_item_reader;diff --git a/crates/soup_realtime/src/outbound/soup_consumer.rs b/crates/soup_realtime/src/outbound/soup_consumer.rsindex db6848c3f8..4275130545 100644--- a/crates/soup_realtime/src/outbound/soup_consumer.rs+++ b/crates/soup_realtime/src/outbound/soup_consumer.rs@@ -10,11 +10,16 @@ mod test;use std::time::Duration;use kafka_util::{InitialOffset, KafkaEventConsumer, Ungrouped};-use macro_event_broker::{KafkaConsumerAdapter, MacroEventCollection, MacroEventConsumerService};+use macro_event_broker::{+ Event, EventBrokerError, KafkaConsumerAdapter, MacroEventCollection, MacroEventConsumerService,+ MessageParts, Topic, TopicEvent,+};+use rdkafka::message::Message as _;use rootcause::prelude::{Report, ResultExt as _};+use serde::{Deserialize, Serialize};use crate::domain::{- models::{SoupMacroEvent, SoupRealtimeMessage},+ models::{SoupMacroEvent, SoupRealtimeMessage, SoupTopicEvent},ports::SoupRealtimeConsumer,};@@ -26,6 +31,31 @@ type SoupEventConsumer = MacroEventConsumerService<DeclaredMacroEvent, Independemacro_event_broker::declare_topics!(DeclaredMacroEvent: SoupMacroEvent);+#[derive(Deserialize, Serialize)]+struct SchemaVersionPayload {}++impl TopicEvent for SchemaVersionPayload {+ type Topic = <SoupTopicEvent as TopicEvent>::Topic;++ const SCHEMA_VERSION: u8 = SoupTopicEvent::SCHEMA_VERSION;+}++fn validate_soup_schema(message: &impl MessageParts) -> Result<(), EventBrokerError> {+ let payload = message+ .payload()+ .ok_or(EventBrokerError::MissingMessagePayload)?;+ let actual = Event::<SchemaVersionPayload>::decode(payload)?.schema_version;+ let expected = SoupTopicEvent::SCHEMA_VERSION;+ if actual != expected {+ return Err(EventBrokerError::UnsupportedSchemaVersion {+ topic: <<SoupTopicEvent as TopicEvent>::Topic as Topic>::TOPIC_STR,+ expected,+ actual,+ });+ }+ Ok(())+}+/// Independent consumer of recipient-targeted Soup messages.////// This consumer starts at the end of every current `macro.soup` partition, so@@ -58,21 +88,47 @@ impl SoupTopicConsumer {/// Receives and decodes the next typed realtime Soup event.///- /// This operation is cancel-safe. Missing keys and malformed or unsupported- /// payloads are returned as errors; because the consumer is ungrouped, a- /// subsequent call proceeds to the next locally assigned record.+ /// This operation is cancel-safe. Unsupported schema versions are poison+ /// records and are skipped. Other missing or malformed payload data is+ /// returned as an error.pub async fn recv(&self) -> Result<SoupRealtimeMessage, Report> {- let message = self- .consumer- .recv()- .await- .context("failed to receive realtime Soup event")?;- let event = message- .decode_payload()- .context("failed to decode realtime Soup event")?;-- match event {- DeclaredMacroEvent::SoupMacroEvent(event) => Ok(event.into_message()),+ loop {+ let message = self+ .consumer+ .recv()+ .await+ .context("failed to receive realtime Soup event")?;+ let kafka_message = message.inner();+ match validate_soup_schema(kafka_message) {+ Ok(()) => {}+ Err(EventBrokerError::UnsupportedSchemaVersion {+ topic,+ expected,+ actual,+ }) => {+ tracing::warn!(+ topic,+ expected,+ actual,+ partition = kafka_message.partition(),+ offset = kafka_message.offset(),+ "dropping realtime Soup event with unsupported schema version"+ );+ continue;+ }+ Err(error) => {+ return Err(Report::new(error)+ .context("failed to decode realtime Soup event envelope")+ .into_dynamic());+ }+ }++ let event = message+ .decode_payload()+ .context("failed to decode realtime Soup event")?;+ return match event {+ DeclaredMacroEvent::SoupMacroEvent(event) => Ok(event.into_message()),+ };}}}diff --git a/crates/soup_realtime/src/outbound/soup_consumer/test.rs b/crates/soup_realtime/src/outbound/soup_consumer/test.rsindex 2d5e577f53..3c154722a3 100644--- a/crates/soup_realtime/src/outbound/soup_consumer/test.rs+++ b/crates/soup_realtime/src/outbound/soup_consumer/test.rs@@ -1,8 +1,48 @@-use macro_event_broker::MacroEventCollection as _;+use macro_event_broker::{EventBrokerError, MacroEventCollection as _, MessageParts};-use super::DeclaredMacroEvent;+use super::{DeclaredMacroEvent, validate_soup_schema};++struct TestMessage {+ payload: Vec<u8>,+}++impl MessageParts for TestMessage {+ fn key(&self) -> Option<&str> {+ Some("macro|[email protected]")+ }++ fn payload(&self) -> Option<&[u8]> {+ Some(&self.payload)+ }++ fn topic(&self) -> &str {+ "macro.soup"+ }+}#[test]fn assigns_only_the_typed_soup_topic() {assert_eq!(DeclaredMacroEvent::topics(), ["macro.soup"]);}++#[test]+fn classifies_v1_soup_events_as_unsupported_before_decoding_the_old_payload() {+ let message = TestMessage {+ payload: serde_json::to_vec(&serde_json::json!({+ "event_id": "00000000-0000-0000-0000-000000000001",+ "schema_version": 1,+ "event_type": "soup.item.updated",+ "metadata": {}+ }))+ .expect("serializable event"),+ };++ assert!(matches!(+ validate_soup_schema(&message),+ Err(EventBrokerError::UnsupportedSchemaVersion {+ expected: 2,+ actual: 1,+ ..+ })+ ));+}diff --git a/crates/soup_realtime/src/outbound/soup_item_reader.rs b/crates/soup_realtime/src/outbound/soup_item_reader.rsdeleted file mode 100644index f72c37c6b4..0000000000--- a/crates/soup_realtime/src/outbound/soup_item_reader.rs+++ /dev/null@@ -1,76 +0,0 @@-//! Adapter for loading complete, user-scoped Soup items.--#[cfg(test)]-mod test;--use model_entity::{Entity, EntityType};-use models_soup::item::SoupItem;-use rootcause::prelude::{Report, ResultExt as _};-use soup::domain::{models::AdvancedSortParams, ports::SoupRepo};--use crate::domain::ports::SoupItemReader;--/// Soup item reader backed by an existing [`SoupRepo`].-pub struct SoupRepoItemReader<R> {- repo: R,-}--impl<R> SoupRepoItemReader<R> {- /// Creates a user-scoped item reader around a Soup repository.- pub fn new(repo: R) -> Self {- Self { repo }- }-}--impl<R> SoupItemReader for SoupRepoItemReader<R>-where- R: SoupRepo,- R::Err: std::error::Error + Send + Sync + 'static,-{- #[tracing::instrument(- skip(self),- fields(- user_id = %user_id,- entity_type = %entity.entity_type,- entity_id = %entity.entity_id,- ),- err- )]- async fn read_for_user(- &self,- user_id: macro_user_id::user_id::MacroUserIdStr<'static>,- entity: &Entity<'static>,- ) -> Result<Option<SoupItem<()>>, Report> {- if entity.entity_type != EntityType::Document {- return Err(rootcause::report!(- "realtime Soup reader does not support entity type {}",- entity.entity_type- ));- }-- let requested_entities = [entity.clone()];- let items = self- .repo- .expanded_soup_by_ids(AdvancedSortParams {- entities: &requested_entities,- user_id,- })- .await- .context("failed to read expanded user-scoped Soup item")?;-- let mut matches = items.into_iter().filter(|item| item.entity() == *entity);- let Some(item) = matches.next() else {- return Ok(None);- };-- if matches.next().is_some() {- return Err(rootcause::report!(- "expanded Soup query returned duplicate items for {} {}",- entity.entity_type,- entity.entity_id- ));- }-- Ok(Some(item))- }-}diff --git a/crates/soup_realtime/src/outbound/soup_item_reader/test.rs b/crates/soup_realtime/src/outbound/soup_item_reader/test.rsdeleted file mode 100644index c58cc7e8fb..0000000000--- a/crates/soup_realtime/src/outbound/soup_item_reader/test.rs+++ /dev/null@@ -1,213 +0,0 @@-use std::io;-use std::sync::{Arc, Mutex};--use chrono::{DateTime, Utc};-use macro_user_id::user_id::MacroUserIdStr;-use models_properties::service::property_definition_with_options::PropertyDefinitionWithOptions;-use models_soup::{document::SoupDocument, item::SoupItem};-use soup::domain::{- models::{- AdvancedSortParams, GroupedSortRequest, SimpleSortRequest, SoupPropertiesField,- grouping::ItemGroupingInfo,- },- ports::SoupRepo,-};-use uuid::Uuid;--use super::*;--const DOCUMENT_ID: &str = "00000000-0000-0000-0000-000000000001";--type RecordedQuery = (String, Vec<(String, EntityType)>);-type RecordedQueries = Arc<Mutex<Vec<RecordedQuery>>>;--struct RecordingSoupRepo {- calls: RecordedQueries,- items: Mutex<Option<Result<Vec<SoupItem<()>>, io::Error>>>,-}--impl SoupRepo for RecordingSoupRepo {- type Err = io::Error;- type GroupedItems = std::vec::IntoIter<ItemGroupingInfo>;-- async fn expanded_generic_cursor_soup<'a>(- &self,- _req: SimpleSortRequest<'a>,- ) -> Result<Vec<SoupItem<()>>, Self::Err> {- unreachable!("unexpected generic cursor query")- }-- async fn unexpanded_generic_cursor_soup<'a>(- &self,- _req: SimpleSortRequest<'a>,- ) -> Result<Vec<SoupItem<()>>, Self::Err> {- unreachable!("unexpected generic cursor query")- }-- async fn expanded_soup_by_ids<'a>(- &self,- req: AdvancedSortParams<'a>,- ) -> Result<Vec<SoupItem<()>>, Self::Err> {- self.calls.lock().expect("calls lock").push((- req.user_id.as_ref().to_string(),- req.entities- .iter()- .map(|entity| (entity.entity_id.to_string(), entity.entity_type))- .collect(),- ));- self.items- .lock()- .expect("items lock")- .take()- .expect("one expanded query expected")- }-- async fn unexpanded_soup_by_ids<'a>(- &self,- _req: AdvancedSortParams<'a>,- ) -> Result<Vec<SoupItem<()>>, Self::Err> {- unreachable!("unexpected unexpanded query")- }-- async fn populate_properties<'a>(- &self,- _user_id: MacroUserIdStr<'a>,- _items: Vec<SoupItem<()>>,- ) -> Result<Vec<SoupItem<SoupPropertiesField>>, Self::Err> {- unreachable!("unexpected properties query")- }-- async fn caller_tag_sets<'a>(- &self,- _user_id: MacroUserIdStr<'a>,- ) -> Result<Vec<PropertyDefinitionWithOptions>, Self::Err> {- unreachable!("unexpected tag query")- }-- async fn expanded_grouped_cursor_soup<'a>(- &self,- _req: GroupedSortRequest<'a>,- ) -> Result<Self::GroupedItems, Self::Err> {- unreachable!("unexpected grouped query")- }-}--fn user() -> MacroUserIdStr<'static> {- MacroUserIdStr::try_from("macro|[email protected]".to_string()).expect("valid user id")-}--fn timestamp(seconds: i64) -> DateTime<Utc> {- DateTime::from_timestamp(seconds, 0).expect("valid timestamp")-}--fn document_item(id: &str, viewed_at: Option<DateTime<Utc>>) -> SoupItem<()> {- SoupItem::Document(SoupDocument {- id: Uuid::parse_str(id).expect("valid document id"),- document_version_id: 7,- owner_id: user(),- name: "Realtime document".to_string(),- file_type: Some("md".to_string()),- sha: None,- project_id: None,- branched_from_id: None,- branched_from_version_id: None,- document_family_id: None,- created_at: timestamp(1),- updated_at: timestamp(2),- viewed_at,- sub_type: None,- deleted_at: None,- extra: (),- })-}--fn reader_with(- items: Result<Vec<SoupItem<()>>, io::Error>,-) -> (SoupRepoItemReader<RecordingSoupRepo>, RecordedQueries) {- let calls = Arc::new(Mutex::new(Vec::new()));- let repo = RecordingSoupRepo {- calls: calls.clone(),- items: Mutex::new(Some(items)),- };- (SoupRepoItemReader::new(repo), calls)-}--#[tokio::test]-async fn uses_expanded_query_for_requested_user_and_entity() {- let viewed_at = Some(timestamp(3));- let (reader, calls) = reader_with(Ok(vec![document_item(DOCUMENT_ID, viewed_at)]));- let entity = EntityType::Document.with_entity_string(DOCUMENT_ID.to_string());-- let item = reader- .read_for_user(user(), &entity)- .await- .expect("read succeeds")- .expect("item exists");-- match item {- SoupItem::Document(document) => {- assert_eq!(document.name, "Realtime document");- assert_eq!(document.viewed_at, viewed_at);- }- _ => panic!("expected document item"),- }- assert_eq!(- calls.lock().expect("calls lock").as_slice(),- &[(- "macro|[email protected]".to_string(),- vec![(DOCUMENT_ID.to_string(), EntityType::Document)]- )]- );-}--#[tokio::test]-async fn returns_none_when_requested_item_is_absent() {- let other_id = "00000000-0000-0000-0000-000000000002";- let (reader, _) = reader_with(Ok(vec![document_item(other_id, None)]));- let entity = EntityType::Document.with_entity_string(DOCUMENT_ID.to_string());-- assert!(- reader- .read_for_user(user(), &entity)- .await- .expect("read succeeds")- .is_none()- );-}--#[tokio::test]-async fn rejects_duplicate_matching_items() {- let (reader, _) = reader_with(Ok(vec![- document_item(DOCUMENT_ID, None),- document_item(DOCUMENT_ID, Some(timestamp(4))),- ]));- let entity = EntityType::Document.with_entity_string(DOCUMENT_ID.to_string());-- reader- .read_for_user(user(), &entity)- .await- .expect_err("duplicate items violate the repository contract");-}--#[tokio::test]-async fn rejects_non_document_entities_without_querying() {- let (reader, calls) = reader_with(Ok(Vec::new()));- let entity = EntityType::Project.with_entity_string(DOCUMENT_ID.to_string());-- reader- .read_for_user(user(), &entity)- .await- .expect_err("projects are unsupported");- assert!(calls.lock().expect("calls lock").is_empty());-}--#[tokio::test]-async fn propagates_repository_failures() {- let (reader, _) = reader_with(Err(io::Error::other("query unavailable")));- let entity = EntityType::Document.with_entity_string(DOCUMENT_ID.to_string());-- reader- .read_for_user(user(), &entity)- .await- .expect_err("repository failure propagates");-}diff --git a/services/document_storage_service/Cargo.toml b/services/document_storage_service/Cargo.tomlindex 8e8b8e3d92..6198953c71 100644--- a/services/document_storage_service/Cargo.toml+++ b/services/document_storage_service/Cargo.toml@@ -102,6 +102,7 @@ github = { path = "../../crates/github", default-features = false, features = ["outbound","sync",] }+graphql_soup = { path = "../../crates/graphql_soup" }hex = { workspace = true }http-body-util = { workspace = true }jsonwebtoken = { workspace = true }diff --git a/services/document_storage_service/src/api/graphql_soup.rs b/services/document_storage_service/src/api/graphql_soup.rsindex 85be80e3aa..5a16b9258e 100644--- a/services/document_storage_service/src/api/graphql_soup.rs+++ b/services/document_storage_service/src/api/graphql_soup.rs@@ -13,6 +13,7 @@ use axum::{};use axum_extra::extract::Cached;use complete_graph::GraphqlRequestParts;+use graphql_soup::soup_item_loader;use macro_authorization::{OptionalMacroAuthorizationExtractor, UserOrInternalService, UserOrInternalServiceAuthorization,};@@ -99,7 +100,12 @@ async fn subscription_handler(}fn graphql_subscription_context_data(state: ApiContext, user: MacroUserIdStr<'static>) -> Data {+ let soup_item_loader = soup_item_loader(+ state.soup_router_state.service(),+ state.soup_router_state.email_service(),+ );let mut data = Data::default();+ data.insert(soup_item_loader);data.insert(state);data.insert(user);datadiff --git a/services/document_storage_service/src/main.rs b/services/document_storage_service/src/main.rsindex 0175ac1bc5..58de9a9b6b 100644--- a/services/document_storage_service/src/main.rs+++ b/services/document_storage_service/src/main.rs@@ -114,7 +114,7 @@ use soup_realtime::{domain::service::{SoupRealtimeConsumerService, SoupRealtimeServiceImpl},outbound::{entity_access::EntityAccessExpander, kafka_publisher::KafkaSoupRealtimePublisher,- soup_consumer::SoupTopicConsumer, soup_item_reader::SoupRepoItemReader,+ soup_consumer::SoupTopicConsumer,},};use sqlx::postgres::PgPoolOptions;@@ -138,6 +138,14 @@ mod model;mod outbound;mod service;+const SOUP_CONSUMER_RESTART_MAX_DELAY_SECS: u64 = 60;+const SOUP_CONSUMER_RESTART_ALERT_THRESHOLD: u32 = 5;++fn soup_consumer_restart_delay(consecutive_failures: u32) -> Duration {+ let exponent = consecutive_failures.saturating_sub(1).min(6);+ Duration::from_secs((1_u64 << exponent).min(SOUP_CONSUMER_RESTART_MAX_DELAY_SECS))+}+maybe_env_vars! {struct AppleBundleId;struct SnsApnsVoipPlatformArn;@@ -931,10 +939,10 @@ async fn main() -> anyhow::Result<()> {consumer_tracker.spawn({let brokers = config.kafka_brokers.as_ref().to_string();let entity_access_service = entity_access_service.as_ref().clone();- let soup_pool = readonly_pool::ReadOnlyPool(readonly_db.clone());let macro_event_broker = macro_event_broker.clone();let cancellation_token = consumer_cancellation_token.clone();async move {+ let mut consecutive_failures = 0_u32;loop {if cancellation_token.is_cancelled() {break;@@ -942,32 +950,49 @@ async fn main() -> anyhow::Result<()> {let fanout_service = SoupRealtimeServiceImpl::new(EntityAccessExpander::new(entity_access_service.clone()),- SoupRepoItemReader::new(PgSoupRepo::new(soup_pool.clone())),KafkaSoupRealtimePublisher::new(macro_event_broker.clone()),);- tracing::info!("starting realtime Soup document consumer");+ tracing::info!("starting realtime Soup entity consumer");let result = fanout_service- .run_document_update_consumer(&brokers, cancellation_token.cancelled())+ .run_entity_update_consumer(&brokers, cancellation_token.cancelled()).await;if cancellation_token.is_cancelled() {break;}- match result {+ let restart_delay = match result {Ok(()) => {- tracing::error!("realtime Soup document consumer exited unexpectedly")+ consecutive_failures = 0;+ tracing::error!("realtime Soup entity consumer exited unexpectedly");+ soup_consumer_restart_delay(1)}- Err(error) => tracing::error!(- error = ?error,- "realtime Soup document consumer exited unexpectedly"- ),- }+ Err(error) => {+ consecutive_failures = consecutive_failures.saturating_add(1);+ let restart_delay = soup_consumer_restart_delay(consecutive_failures);+ if consecutive_failures >= SOUP_CONSUMER_RESTART_ALERT_THRESHOLD {+ tracing::error!(+ error = ?error,+ consecutive_failures,+ restart_delay_secs = restart_delay.as_secs(),+ "realtime Soup entity consumer repeatedly failed"+ );+ } else {+ tracing::warn!(+ error = ?error,+ consecutive_failures,+ restart_delay_secs = restart_delay.as_secs(),+ "realtime Soup entity consumer failed; scheduling restart"+ );+ }+ restart_delay+ }+ };tokio::select! {biased;_ = cancellation_token.cancelled() => break,- _ = tokio::time::sleep(Duration::from_secs(5)) => {}+ _ = tokio::time::sleep(restart_delay) => {}}}}diff --git a/static_assets/schema.graphql b/static_assets/schema.graphqlindex 26e86f70ee..7e70fcf433 100644--- a/static_assets/schema.graphql+++ b/static_assets/schema.graphql@@ -1284,6 +1284,20 @@ type GraphqlNumberPropertyValue {value: Float!}+"""+Operation carried by a realtime entity patch.+"""+enum GraphqlPatchOperation {+ """+ The entity was created or updated.+ """+ UPDATED+ """+ The entity was deleted.+ """+ DELETED+}+"""The two operands of a recursive `ProjectFilterExpr` binary expression."""@@ -3254,10 +3268,24 @@ type SoupPage {Opaque cursor for the next page, if one exists."""nextCursor: String+}++"""+Lightweight realtime Soup patch with optional lazy item hydration.+"""+type SoupPatch {+ """+ Operation represented by this patch.+ """+ operation: GraphqlPatchOperation!+ """+ Canonical identity of the affected entity.+ """+ entity: GraphqlEntity!"""- Whether more items are available after this page.+ Hydrate the current Soup item only when selected by the client."""- hasMore: Boolean!+ item: GraphqlSoupEntity}"""@@ -3277,7 +3305,7 @@ type SoupSubscriptionRoot {"""Subscribe to realtime Soup updates for the authenticated user."""- soupUpdates: GraphqlSoupEntity!+ soupUpdates: SoupPatch!}"""