Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(soup): email types (#302)

Sean Aye7a472611f1f4
diff --git a/js/app/packages/macro-entity/src/queries/dss.ts b/js/app/packages/macro-entity/src/queries/dss.ts
index 9dd50fcb71..6122bfdf6b 100644
--- a/js/app/packages/macro-entity/src/queries/dss.ts
+++ b/js/app/packages/macro-entity/src/queries/dss.ts
@@ -23,6 +23,7 @@ import type { Accessor } from 'solid-js';
import type {
ChatEntity,
DocumentEntity,
+ EmailEntity,
EntityData,
ProjectEntity,
} from '../types/entity';
@@ -50,8 +51,8 @@ const fetchPaginatedDocumentsGet = async ({
const result: SoupPage = await response.json();
result.items.forEach((item) => {
- if (item.type === 'document' && item.fileType === 'md') {
- syncServiceClient.wakeup({ documentId: item.id });
+ if (item.tag === 'document' && item.data.fileType === 'md') {
+ syncServiceClient.wakeup({ documentId: item.data.id });
}
});
return result;
@@ -86,8 +87,8 @@ const fetchPaginatedDocumentsPost = async ({
const result: SoupPage = await response.json();
result.items.forEach((item) => {
- if (item.type === 'document' && item.fileType === 'md') {
- syncServiceClient.wakeup({ documentId: item.id });
+ if (item.tag === 'document' && item.data.fileType === 'md') {
+ syncServiceClient.wakeup({ documentId: item.data.id });
}
});
return result;
@@ -211,49 +212,70 @@ const selectData: (
options: {
instructionsIdQuery: UseQueryResult<string | null | undefined, Error>;
}
-) => (DocumentEntity | ChatEntity | ProjectEntity)[] = (data, options) => {
+) => (DocumentEntity | ChatEntity | ProjectEntity | EmailEntity)[] = (
+ data,
+ options
+) => {
return data.pages.flatMap(({ items }) =>
items
.filter(
(item) =>
- item.type !== 'document' ||
+ item.tag !== 'document' ||
!options.instructionsIdQuery.isSuccess ||
- item.id !== options.instructionsIdQuery.data
+ item.data.id !== options.instructionsIdQuery.data
)
- .map((item): DocumentEntity | ChatEntity | ProjectEntity => {
- if (item.type === 'chat') {
- return {
- ...item,
- name: item.name || 'New Chat',
- frecencyScore: item.frecency_score,
- viewedAt: item.viewedAt ?? undefined,
- projectId: item.projectId ?? undefined,
- };
- }
+ .map(
+ (item): DocumentEntity | ChatEntity | ProjectEntity | EmailEntity => {
+ if (item.tag === 'chat') {
+ return {
+ ...item.data,
+ type: item.tag,
+ name: item.data.name || 'New Chat',
+ frecencyScore: item.frecency_score,
+ viewedAt: item.data.viewedAt ?? undefined,
+ projectId: item.data.projectId ?? undefined,
+ };
+ }
+
+ if (item.tag === 'project') {
+ return {
+ createdAt: item.data.createdAt,
+ updatedAt: item.data.updatedAt,
+ id: item.data.id,
+ ownerId: item.data.ownerId,
+ frecencyScore: item.frecency_score,
+ viewedAt: item.data.viewedAt ?? undefined,
+ parentId: item.data.parentId ?? undefined,
+ type: item.tag,
+ name: item.data.name || 'New Project',
+ };
+ }
+
+ if (item.tag === 'emailThread') {
+ return {
+ ...item.data,
+ senderEmail: item.data.senderEmail ?? undefined,
+ senderName: item.data.senderName ?? undefined,
+ snippet: item.data.snippet ?? undefined,
+ done: !item.data.inboxVisible,
+ type: 'email',
+ name: item.data.name || 'Email Thread',
+ frecencyScore: item.frecency_score,
+ viewedAt: item.data.viewedAt ?? undefined,
+ };
+ }
- if (item.type === 'project') {
return {
- createdAt: item.createdAt,
- updatedAt: item.updatedAt,
- id: item.id,
- ownerId: item.ownerId,
+ ...item.data,
+ name: item.data.name || 'New Note',
+ type: item.tag,
frecencyScore: item.frecency_score,
- viewedAt: item.viewedAt ?? undefined,
- parentId: item.parentId ?? undefined,
- type: item.type,
- name: item.name || 'New Project',
+ viewedAt: item.data.viewedAt ?? undefined,
+ fileType: item.data.fileType ?? undefined,
+ projectId: item.data.projectId ?? undefined,
};
}
-
- return {
- ...item,
- name: item.name || 'New Note',
- frecencyScore: item.frecency_score,
- viewedAt: item.viewedAt ?? undefined,
- fileType: item.fileType ?? undefined,
- projectId: item.projectId ?? undefined,
- };
- })
+ )
);
};
@@ -294,16 +316,17 @@ export function createDocumentsInfiniteQuery(
select: (data) =>
data.pages.flatMap(({ items }) =>
items
- .filter((item) => item.type === 'document')
- .filter((item) => item.id !== instructionsIdQuery.data)
+ .filter((item) => item.tag === 'document')
+ .filter((item) => item.data.id !== instructionsIdQuery.data)
.map(
(item): DocumentEntity => ({
- ...item,
- name: item.name || 'New Note',
+ ...item.data,
+ type: item.tag,
+ name: item.data.name || 'New Note',
frecencyScore: item.frecency_score,
- viewedAt: item.viewedAt ?? undefined,
- fileType: item.fileType ?? undefined,
- projectId: item.projectId ?? undefined,
+ viewedAt: item.data.viewedAt ?? undefined,
+ fileType: item.data.fileType ?? undefined,
+ projectId: item.data.projectId ?? undefined,
})
)
),
@@ -340,14 +363,15 @@ export function createChatsInfiniteQuery(
select: (data) =>
data.pages.flatMap(({ items }) =>
items
- .filter((item) => item.type === 'chat')
- .filter((item) => !item.isPersistent)
+ .filter((item) => item.tag === 'chat')
+ .filter((item) => !item.data.isPersistent)
.map(
(item): ChatEntity => ({
- ...item,
+ ...item.data,
+ type: item.tag,
frecencyScore: item.frecency_score,
- viewedAt: item.viewedAt ?? undefined,
- projectId: item.projectId ?? undefined,
+ viewedAt: item.data.viewedAt ?? undefined,
+ projectId: item.data.projectId ?? undefined,
})
)
),
diff --git a/js/app/packages/service-storage/generated/schemas/index.ts b/js/app/packages/service-storage/generated/schemas/index.ts
index 991b244545..d036c02b72 100644
--- a/js/app/packages/service-storage/generated/schemas/index.ts
+++ b/js/app/packages/service-storage/generated/schemas/index.ts
@@ -357,10 +357,19 @@ export * from './sharePermissionV2PublicAccessLevel';
export * from './soupApiItem';
export * from './soupApiItemAllOf';
export * from './soupApiSort';
+export * from './soupAttachment';
+export * from './soupAttachmentContentId';
+export * from './soupAttachmentFilename';
+export * from './soupAttachmentMimeType';
+export * from './soupAttachmentProviderAttachmentId';
+export * from './soupAttachmentSizeBytes';
export * from './soupChat';
export * from './soupChatProjectId';
-export * from './soupChatType';
export * from './soupChatViewedAt';
+export * from './soupContact';
+export * from './soupContactEmailAddress';
+export * from './soupContactName';
+export * from './soupContactSfsPhotoUrl';
export * from './soupDocument';
export * from './soupDocumentBranchedFromId';
export * from './soupDocumentBranchedFromVersionId';
@@ -368,15 +377,32 @@ export * from './soupDocumentDocumentFamilyId';
export * from './soupDocumentFileType';
export * from './soupDocumentProjectId';
export * from './soupDocumentSha';
-export * from './soupDocumentType';
export * from './soupDocumentViewedAt';
+export * from './soupEmailThreadPreview';
+export * from './soupEmailThreadPreviewName';
+export * from './soupEmailThreadPreviewProviderId';
+export * from './soupEmailThreadPreviewSenderEmail';
+export * from './soupEmailThreadPreviewSenderName';
+export * from './soupEmailThreadPreviewSenderPhotoUrl';
+export * from './soupEmailThreadPreviewSnippet';
+export * from './soupEmailThreadPreviewViewedAt';
+export * from './soupEnrichedEmailThreadPreview';
+export * from './soupEnrichedEmailThreadPreviewAllOf';
export * from './soupItem';
+export * from './soupItemOneOf';
+export * from './soupItemOneOfFive';
+export * from './soupItemOneOfFiveTag';
+export * from './soupItemOneOfSeven';
+export * from './soupItemOneOfSevenTag';
+export * from './soupItemOneOfTag';
+export * from './soupItemOneOfThree';
+export * from './soupItemOneOfThreeTag';
export * from './soupItemType';
+export * from './soupMacroAttachment';
export * from './soupPage';
export * from './soupPageNextCursor';
export * from './soupProject';
export * from './soupProjectParentId';
-export * from './soupProjectType';
export * from './soupProjectViewedAt';
export * from './successResponse';
export * from './syncServiceVersionID';
diff --git a/js/app/packages/service-storage/generated/schemas/soupAttachment.ts b/js/app/packages/service-storage/generated/schemas/soupAttachment.ts
new file mode 100644
index 0000000000..3af07d5a7d
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupAttachment.ts
@@ -0,0 +1,22 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupAttachmentContentId } from './soupAttachmentContentId';
+import type { SoupAttachmentFilename } from './soupAttachmentFilename';
+import type { SoupAttachmentMimeType } from './soupAttachmentMimeType';
+import type { SoupAttachmentProviderAttachmentId } from './soupAttachmentProviderAttachmentId';
+import type { SoupAttachmentSizeBytes } from './soupAttachmentSizeBytes';
+
+export interface SoupAttachment {
+ contentId?: SoupAttachmentContentId;
+ createdAt: number;
+ filename?: SoupAttachmentFilename;
+ id: string;
+ messageId: string;
+ mimeType?: SoupAttachmentMimeType;
+ providerAttachmentId?: SoupAttachmentProviderAttachmentId;
+ sizeBytes?: SoupAttachmentSizeBytes;
+}
diff --git a/js/app/packages/service-storage/generated/schemas/soupAttachmentContentId.ts b/js/app/packages/service-storage/generated/schemas/soupAttachmentContentId.ts
new file mode 100644
index 0000000000..b5af203f7c
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupAttachmentContentId.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupAttachmentContentId = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupAttachmentFilename.ts b/js/app/packages/service-storage/generated/schemas/soupAttachmentFilename.ts
new file mode 100644
index 0000000000..41414c5cf7
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupAttachmentFilename.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupAttachmentFilename = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupAttachmentMimeType.ts b/js/app/packages/service-storage/generated/schemas/soupAttachmentMimeType.ts
new file mode 100644
index 0000000000..befc578a5a
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupAttachmentMimeType.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupAttachmentMimeType = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupAttachmentProviderAttachmentId.ts b/js/app/packages/service-storage/generated/schemas/soupAttachmentProviderAttachmentId.ts
new file mode 100644
index 0000000000..653816af71
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupAttachmentProviderAttachmentId.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupAttachmentProviderAttachmentId = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupAttachmentSizeBytes.ts b/js/app/packages/service-storage/generated/schemas/soupAttachmentSizeBytes.ts
new file mode 100644
index 0000000000..07e967a691
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupAttachmentSizeBytes.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupAttachmentSizeBytes = number | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupChat.ts b/js/app/packages/service-storage/generated/schemas/soupChat.ts
index be3646427b..2a5734689c 100644
--- a/js/app/packages/service-storage/generated/schemas/soupChat.ts
+++ b/js/app/packages/service-storage/generated/schemas/soupChat.ts
@@ -6,7 +6,6 @@
*/
import type { SoupChatProjectId } from './soupChatProjectId';
import type { SoupChatViewedAt } from './soupChatViewedAt';
-import type { SoupChatType } from './soupChatType';
export interface SoupChat {
/** The time the chat was created */
@@ -25,5 +24,4 @@ export interface SoupChat {
updatedAt: number;
/** The time the chat was last viewed */
viewedAt: SoupChatViewedAt;
- type: SoupChatType;
}
diff --git a/js/app/packages/service-storage/generated/schemas/soupContact.ts b/js/app/packages/service-storage/generated/schemas/soupContact.ts
new file mode 100644
index 0000000000..e54559543b
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupContact.ts
@@ -0,0 +1,17 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupContactEmailAddress } from './soupContactEmailAddress';
+import type { SoupContactName } from './soupContactName';
+import type { SoupContactSfsPhotoUrl } from './soupContactSfsPhotoUrl';
+
+export interface SoupContact {
+ emailAddress?: SoupContactEmailAddress;
+ id: string;
+ linkId: string;
+ name?: SoupContactName;
+ sfsPhotoUrl?: SoupContactSfsPhotoUrl;
+}
diff --git a/js/app/packages/service-storage/generated/schemas/soupContactEmailAddress.ts b/js/app/packages/service-storage/generated/schemas/soupContactEmailAddress.ts
new file mode 100644
index 0000000000..5a2fc7c732
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupContactEmailAddress.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupContactEmailAddress = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupContactName.ts b/js/app/packages/service-storage/generated/schemas/soupContactName.ts
new file mode 100644
index 0000000000..bc4a224a61
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupContactName.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupContactName = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupContactSfsPhotoUrl.ts b/js/app/packages/service-storage/generated/schemas/soupContactSfsPhotoUrl.ts
new file mode 100644
index 0000000000..21a8f746a0
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupContactSfsPhotoUrl.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupContactSfsPhotoUrl = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupDocument.ts b/js/app/packages/service-storage/generated/schemas/soupDocument.ts
index 888e63aab8..61d6837ecf 100644
--- a/js/app/packages/service-storage/generated/schemas/soupDocument.ts
+++ b/js/app/packages/service-storage/generated/schemas/soupDocument.ts
@@ -11,7 +11,6 @@ import type { SoupDocumentFileType } from './soupDocumentFileType';
import type { SoupDocumentProjectId } from './soupDocumentProjectId';
import type { SoupDocumentSha } from './soupDocumentSha';
import type { SoupDocumentViewedAt } from './soupDocumentViewedAt';
-import type { SoupDocumentType } from './soupDocumentType';
export interface SoupDocument {
/** The id of the document this document branched from */
@@ -43,5 +42,4 @@ If the document is a DOCX, this will not be present */
updatedAt: number;
/** The time the document was last viewed */
viewedAt: SoupDocumentViewedAt;
- type: SoupDocumentType;
}
diff --git a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreview.ts b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreview.ts
new file mode 100644
index 0000000000..f30e834b43
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreview.ts
@@ -0,0 +1,32 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupEmailThreadPreviewName } from './soupEmailThreadPreviewName';
+import type { SoupEmailThreadPreviewProviderId } from './soupEmailThreadPreviewProviderId';
+import type { SoupEmailThreadPreviewSenderEmail } from './soupEmailThreadPreviewSenderEmail';
+import type { SoupEmailThreadPreviewSenderName } from './soupEmailThreadPreviewSenderName';
+import type { SoupEmailThreadPreviewSenderPhotoUrl } from './soupEmailThreadPreviewSenderPhotoUrl';
+import type { SoupEmailThreadPreviewSnippet } from './soupEmailThreadPreviewSnippet';
+import type { SoupEmailThreadPreviewViewedAt } from './soupEmailThreadPreviewViewedAt';
+
+export interface SoupEmailThreadPreview {
+ createdAt: number;
+ id: string;
+ inboxVisible: boolean;
+ isDraft: boolean;
+ isImportant: boolean;
+ isRead: boolean;
+ name?: SoupEmailThreadPreviewName;
+ ownerId: string;
+ providerId?: SoupEmailThreadPreviewProviderId;
+ senderEmail?: SoupEmailThreadPreviewSenderEmail;
+ senderName?: SoupEmailThreadPreviewSenderName;
+ senderPhotoUrl?: SoupEmailThreadPreviewSenderPhotoUrl;
+ snippet?: SoupEmailThreadPreviewSnippet;
+ sortTs: number;
+ updatedAt: number;
+ viewedAt: SoupEmailThreadPreviewViewedAt;
+}
diff --git a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewName.ts b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewName.ts
new file mode 100644
index 0000000000..8fa88a4355
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewName.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupEmailThreadPreviewName = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewProviderId.ts b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewProviderId.ts
new file mode 100644
index 0000000000..cdb49b99f5
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewProviderId.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupEmailThreadPreviewProviderId = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSenderEmail.ts b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSenderEmail.ts
new file mode 100644
index 0000000000..7c1a00ae2c
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSenderEmail.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupEmailThreadPreviewSenderEmail = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSenderName.ts b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSenderName.ts
new file mode 100644
index 0000000000..6cf65e12d7
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSenderName.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupEmailThreadPreviewSenderName = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSenderPhotoUrl.ts b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSenderPhotoUrl.ts
new file mode 100644
index 0000000000..8b2cc4920c
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSenderPhotoUrl.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupEmailThreadPreviewSenderPhotoUrl = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSnippet.ts b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSnippet.ts
new file mode 100644
index 0000000000..d910a0d79f
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewSnippet.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupEmailThreadPreviewSnippet = string | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewViewedAt.ts b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewViewedAt.ts
new file mode 100644
index 0000000000..4f61f9e5ea
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewViewedAt.ts
@@ -0,0 +1,8 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupEmailThreadPreviewViewedAt = number | null;
diff --git a/js/app/packages/service-storage/generated/schemas/soupEnrichedEmailThreadPreview.ts b/js/app/packages/service-storage/generated/schemas/soupEnrichedEmailThreadPreview.ts
new file mode 100644
index 0000000000..114d7cd9a7
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEnrichedEmailThreadPreview.ts
@@ -0,0 +1,10 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupEmailThreadPreview } from './soupEmailThreadPreview';
+import type { SoupEnrichedEmailThreadPreviewAllOf } from './soupEnrichedEmailThreadPreviewAllOf';
+
+export type SoupEnrichedEmailThreadPreview = SoupEmailThreadPreview & SoupEnrichedEmailThreadPreviewAllOf;
diff --git a/js/app/packages/service-storage/generated/schemas/soupEnrichedEmailThreadPreviewAllOf.ts b/js/app/packages/service-storage/generated/schemas/soupEnrichedEmailThreadPreviewAllOf.ts
new file mode 100644
index 0000000000..e20b31b8d2
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupEnrichedEmailThreadPreviewAllOf.ts
@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupAttachment } from './soupAttachment';
+import type { SoupMacroAttachment } from './soupMacroAttachment';
+import type { SoupContact } from './soupContact';
+
+export type SoupEnrichedEmailThreadPreviewAllOf = {
+ attachments: SoupAttachment[];
+ attachmentsMacro: SoupMacroAttachment[];
+ participants: SoupContact[];
+};
diff --git a/js/app/packages/service-storage/generated/schemas/soupItem.ts b/js/app/packages/service-storage/generated/schemas/soupItem.ts
index 32c1042c92..014b734ac3 100644
--- a/js/app/packages/service-storage/generated/schemas/soupItem.ts
+++ b/js/app/packages/service-storage/generated/schemas/soupItem.ts
@@ -4,8 +4,9 @@
* document_storage_service
* OpenAPI spec version: 0.1.0
*/
-import type { SoupDocument } from './soupDocument';
-import type { SoupChat } from './soupChat';
-import type { SoupProject } from './soupProject';
+import type { SoupItemOneOf } from './soupItemOneOf';
+import type { SoupItemOneOfThree } from './soupItemOneOfThree';
+import type { SoupItemOneOfFive } from './soupItemOneOfFive';
+import type { SoupItemOneOfSeven } from './soupItemOneOfSeven';
-export type SoupItem = SoupDocument | SoupChat | SoupProject;
+export type SoupItem = SoupItemOneOf | SoupItemOneOfThree | SoupItemOneOfFive | SoupItemOneOfSeven;
diff --git a/js/app/packages/service-storage/generated/schemas/soupItemOneOf.ts b/js/app/packages/service-storage/generated/schemas/soupItemOneOf.ts
new file mode 100644
index 0000000000..df4d0e4785
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupItemOneOf.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupDocument } from './soupDocument';
+import type { SoupItemOneOfTag } from './soupItemOneOfTag';
+
+export type SoupItemOneOf = {
+ data: SoupDocument;
+ tag: SoupItemOneOfTag;
+};
diff --git a/js/app/packages/service-storage/generated/schemas/soupItemOneOfFive.ts b/js/app/packages/service-storage/generated/schemas/soupItemOneOfFive.ts
new file mode 100644
index 0000000000..557c2540a7
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupItemOneOfFive.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupProject } from './soupProject';
+import type { SoupItemOneOfFiveTag } from './soupItemOneOfFiveTag';
+
+export type SoupItemOneOfFive = {
+ data: SoupProject;
+ tag: SoupItemOneOfFiveTag;
+};
diff --git a/js/app/packages/service-storage/generated/schemas/soupProjectType.ts b/js/app/packages/service-storage/generated/schemas/soupItemOneOfFiveTag.ts
similarity index 62%
rename from js/app/packages/service-storage/generated/schemas/soupProjectType.ts
rename to js/app/packages/service-storage/generated/schemas/soupItemOneOfFiveTag.ts
index 6e2fa62519..bea4d62b71 100644
--- a/js/app/packages/service-storage/generated/schemas/soupProjectType.ts
+++ b/js/app/packages/service-storage/generated/schemas/soupItemOneOfFiveTag.ts
@@ -5,10 +5,10 @@
* OpenAPI spec version: 0.1.0
*/
-export type SoupProjectType = typeof SoupProjectType[keyof typeof SoupProjectType];
+export type SoupItemOneOfFiveTag = typeof SoupItemOneOfFiveTag[keyof typeof SoupItemOneOfFiveTag];
// eslint-disable-next-line @typescript-eslint/no-redeclare
-export const SoupProjectType = {
+export const SoupItemOneOfFiveTag = {
project: 'project',
} as const;
diff --git a/js/app/packages/service-storage/generated/schemas/soupItemOneOfSeven.ts b/js/app/packages/service-storage/generated/schemas/soupItemOneOfSeven.ts
new file mode 100644
index 0000000000..1bc7e8ebf8
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupItemOneOfSeven.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupEnrichedEmailThreadPreview } from './soupEnrichedEmailThreadPreview';
+import type { SoupItemOneOfSevenTag } from './soupItemOneOfSevenTag';
+
+export type SoupItemOneOfSeven = {
+ data: SoupEnrichedEmailThreadPreview;
+ tag: SoupItemOneOfSevenTag;
+};
diff --git a/js/app/packages/service-storage/generated/schemas/soupItemOneOfSevenTag.ts b/js/app/packages/service-storage/generated/schemas/soupItemOneOfSevenTag.ts
new file mode 100644
index 0000000000..26b08f93f7
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupItemOneOfSevenTag.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupItemOneOfSevenTag = typeof SoupItemOneOfSevenTag[keyof typeof SoupItemOneOfSevenTag];
+
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const SoupItemOneOfSevenTag = {
+ emailThread: 'emailThread',
+} as const;
diff --git a/js/app/packages/service-storage/generated/schemas/soupDocumentType.ts b/js/app/packages/service-storage/generated/schemas/soupItemOneOfTag.ts
similarity index 65%
rename from js/app/packages/service-storage/generated/schemas/soupDocumentType.ts
rename to js/app/packages/service-storage/generated/schemas/soupItemOneOfTag.ts
index f66c062787..7aad341598 100644
--- a/js/app/packages/service-storage/generated/schemas/soupDocumentType.ts
+++ b/js/app/packages/service-storage/generated/schemas/soupItemOneOfTag.ts
@@ -5,10 +5,10 @@
* OpenAPI spec version: 0.1.0
*/
-export type SoupDocumentType = typeof SoupDocumentType[keyof typeof SoupDocumentType];
+export type SoupItemOneOfTag = typeof SoupItemOneOfTag[keyof typeof SoupItemOneOfTag];
// eslint-disable-next-line @typescript-eslint/no-redeclare
-export const SoupDocumentType = {
+export const SoupItemOneOfTag = {
document: 'document',
} as const;
diff --git a/js/app/packages/service-storage/generated/schemas/soupItemOneOfThree.ts b/js/app/packages/service-storage/generated/schemas/soupItemOneOfThree.ts
new file mode 100644
index 0000000000..7798718d57
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupItemOneOfThree.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupChat } from './soupChat';
+import type { SoupItemOneOfThreeTag } from './soupItemOneOfThreeTag';
+
+export type SoupItemOneOfThree = {
+ data: SoupChat;
+ tag: SoupItemOneOfThreeTag;
+};
diff --git a/js/app/packages/service-storage/generated/schemas/soupChatType.ts b/js/app/packages/service-storage/generated/schemas/soupItemOneOfThreeTag.ts
similarity index 60%
rename from js/app/packages/service-storage/generated/schemas/soupChatType.ts
rename to js/app/packages/service-storage/generated/schemas/soupItemOneOfThreeTag.ts
index 8ba42faee2..ef81ed5ffe 100644
--- a/js/app/packages/service-storage/generated/schemas/soupChatType.ts
+++ b/js/app/packages/service-storage/generated/schemas/soupItemOneOfThreeTag.ts
@@ -5,10 +5,10 @@
* OpenAPI spec version: 0.1.0
*/
-export type SoupChatType = typeof SoupChatType[keyof typeof SoupChatType];
+export type SoupItemOneOfThreeTag = typeof SoupItemOneOfThreeTag[keyof typeof SoupItemOneOfThreeTag];
// eslint-disable-next-line @typescript-eslint/no-redeclare
-export const SoupChatType = {
+export const SoupItemOneOfThreeTag = {
chat: 'chat',
} as const;
diff --git a/js/app/packages/service-storage/generated/schemas/soupItemType.ts b/js/app/packages/service-storage/generated/schemas/soupItemType.ts
index 480d7ec91a..c9032b01eb 100644
--- a/js/app/packages/service-storage/generated/schemas/soupItemType.ts
+++ b/js/app/packages/service-storage/generated/schemas/soupItemType.ts
@@ -13,4 +13,5 @@ export const SoupItemType = {
document: 'document',
chat: 'chat',
project: 'project',
+ email_thread: 'email_thread',
} as const;
diff --git a/js/app/packages/service-storage/generated/schemas/soupMacroAttachment.ts b/js/app/packages/service-storage/generated/schemas/soupMacroAttachment.ts
new file mode 100644
index 0000000000..1d8131b76d
--- /dev/null
+++ b/js/app/packages/service-storage/generated/schemas/soupMacroAttachment.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export interface SoupMacroAttachment {
+ dbId: string;
+ itemId: string;
+ itemType: string;
+ messageId: string;
+ threadId: string;
+}
diff --git a/js/app/packages/service-storage/generated/schemas/soupProject.ts b/js/app/packages/service-storage/generated/schemas/soupProject.ts
index 77ca9bbdd0..2d21ab4a29 100644
--- a/js/app/packages/service-storage/generated/schemas/soupProject.ts
+++ b/js/app/packages/service-storage/generated/schemas/soupProject.ts
@@ -6,7 +6,6 @@
*/
import type { SoupProjectParentId } from './soupProjectParentId';
import type { SoupProjectViewedAt } from './soupProjectViewedAt';
-import type { SoupProjectType } from './soupProjectType';
export interface SoupProject {
/** The time the project was created */
@@ -23,5 +22,4 @@ export interface SoupProject {
updatedAt: number;
/** The time the document was last viewed */
viewedAt: SoupProjectViewedAt;
- type: SoupProjectType;
}
diff --git a/js/app/packages/service-storage/generated/zod.ts b/js/app/packages/service-storage/generated/zod.ts
index d663514e12..3421f137ab 100644
--- a/js/app/packages/service-storage/generated/zod.ts
+++ b/js/app/packages/service-storage/generated/zod.ts
@@ -1161,6 +1161,7 @@ export const getItemsSoupQueryParams = zod.object({
export const getItemsSoupResponse = zod.object({
"items": zod.array(zod.union([zod.object({
+ "data": zod.object({
"branchedFromId": zod.string().uuid().nullish().describe('The id of the document this document branched from'),
"branchedFromVersionId": zod.number().nullish().describe('The id of the version this document branched from\nThis could be either DocumentInstance or DocumentBom id depending on the file type'),
"createdAt": zod.number().describe('The time the document was created'),
@@ -1173,9 +1174,11 @@ export const getItemsSoupResponse = zod.object({
"projectId": zod.string().uuid().nullish().describe('The id of the project that this document belongs to'),
"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),
"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),
- "viewedAt": zod.number().nullable().describe('The time the document was last viewed'),
- "type": zod.enum(['document'])
+ "viewedAt": zod.number().nullable().describe('The time the document was last viewed')
+}),
+ "tag": zod.enum(['document'])
}),zod.object({
+ "data": zod.object({
"createdAt": zod.number().describe('The time the chat was created'),
"id": zod.string().uuid().describe('The chat uuid'),
"isPersistent": zod.boolean().describe('Whether the chat is persistent or not'),
@@ -1183,17 +1186,65 @@ export const getItemsSoupResponse = zod.object({
"ownerId": zod.string().describe('Who the chat belongs to'),
"projectId": zod.string().uuid().nullish().describe('The project id of the chat'),
"updatedAt": zod.number().describe('The time the chat was last updated'),
- "viewedAt": zod.number().nullable().describe('The time the chat was last viewed'),
- "type": zod.enum(['chat'])
+ "viewedAt": zod.number().nullable().describe('The time the chat was last viewed')
+}),
+ "tag": zod.enum(['chat'])
}),zod.object({
+ "data": zod.object({
"createdAt": zod.number().describe('The time the project was created'),
"id": zod.string().uuid().describe('The id of the project'),
"name": zod.string().describe('The name of the project'),
"ownerId": zod.string().describe('The user id of who created the project'),
"parentId": zod.string().uuid().nullish().describe('The parent project id'),
"updatedAt": zod.number().describe('The time the project was updated'),
- "viewedAt": zod.number().nullable().describe('The time the document was last viewed'),
- "type": zod.enum(['project'])
+ "viewedAt": zod.number().nullable().describe('The time the document was last viewed')
+}),
+ "tag": zod.enum(['project'])
+}),zod.object({
+ "data": zod.object({
+ "createdAt": zod.number(),
+ "id": zod.string().uuid(),
+ "inboxVisible": zod.boolean(),
+ "isDraft": zod.boolean(),
+ "isImportant": zod.boolean(),
+ "isRead": zod.boolean(),
+ "name": zod.string().nullish(),
+ "ownerId": zod.string(),
+ "providerId": zod.string().nullish(),
+ "senderEmail": zod.string().nullish(),
+ "senderName": zod.string().nullish(),
+ "senderPhotoUrl": zod.string().nullish(),
+ "snippet": zod.string().nullish(),
+ "sortTs": zod.number(),
+ "updatedAt": zod.number(),
+ "viewedAt": zod.number().nullable()
+}).and(zod.object({
+ "attachments": zod.array(zod.object({
+ "contentId": zod.string().nullish(),
+ "createdAt": zod.number(),
+ "filename": zod.string().nullish(),
+ "id": zod.string().uuid(),
+ "messageId": zod.string().uuid(),
+ "mimeType": zod.string().nullish(),
+ "providerAttachmentId": zod.string().nullish(),
+ "sizeBytes": zod.number().nullish()
+})),
+ "attachmentsMacro": zod.array(zod.object({
+ "dbId": zod.string().uuid(),
+ "itemId": zod.string().uuid(),
+ "itemType": zod.string(),
+ "messageId": zod.string().uuid(),
+ "threadId": zod.string().uuid()
+})),
+ "participants": zod.array(zod.object({
+ "emailAddress": zod.string().nullish(),
+ "id": zod.string().uuid(),
+ "linkId": zod.string().uuid(),
+ "name": zod.string().nullish(),
+ "sfsPhotoUrl": zod.string().nullish()
+}))
+})),
+ "tag": zod.enum(['emailThread'])
})]).and(zod.object({
"frecency_score": zod.number()
}))),
@@ -1249,6 +1300,7 @@ export const postItemsSoupBody = zod.object({
export const postItemsSoupResponse = zod.object({
"items": zod.array(zod.union([zod.object({
+ "data": zod.object({
"branchedFromId": zod.string().uuid().nullish().describe('The id of the document this document branched from'),
"branchedFromVersionId": zod.number().nullish().describe('The id of the version this document branched from\nThis could be either DocumentInstance or DocumentBom id depending on the file type'),
"createdAt": zod.number().describe('The time the document was created'),
@@ -1261,9 +1313,11 @@ export const postItemsSoupResponse = zod.object({
"projectId": zod.string().uuid().nullish().describe('The id of the project that this document belongs to'),
"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),
"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),
- "viewedAt": zod.number().nullable().describe('The time the document was last viewed'),
- "type": zod.enum(['document'])
+ "viewedAt": zod.number().nullable().describe('The time the document was last viewed')
+}),
+ "tag": zod.enum(['document'])
}),zod.object({
+ "data": zod.object({
"createdAt": zod.number().describe('The time the chat was created'),
"id": zod.string().uuid().describe('The chat uuid'),
"isPersistent": zod.boolean().describe('Whether the chat is persistent or not'),
@@ -1271,17 +1325,65 @@ export const postItemsSoupResponse = zod.object({
"ownerId": zod.string().describe('Who the chat belongs to'),
"projectId": zod.string().uuid().nullish().describe('The project id of the chat'),
"updatedAt": zod.number().describe('The time the chat was last updated'),
- "viewedAt": zod.number().nullable().describe('The time the chat was last viewed'),
- "type": zod.enum(['chat'])
+ "viewedAt": zod.number().nullable().describe('The time the chat was last viewed')
+}),
+ "tag": zod.enum(['chat'])
}),zod.object({
+ "data": zod.object({
"createdAt": zod.number().describe('The time the project was created'),
"id": zod.string().uuid().describe('The id of the project'),
"name": zod.string().describe('The name of the project'),
"ownerId": zod.string().describe('The user id of who created the project'),
"parentId": zod.string().uuid().nullish().describe('The parent project id'),
"updatedAt": zod.number().describe('The time the project was updated'),
- "viewedAt": zod.number().nullable().describe('The time the document was last viewed'),
- "type": zod.enum(['project'])
+ "viewedAt": zod.number().nullable().describe('The time the document was last viewed')
+}),
+ "tag": zod.enum(['project'])
+}),zod.object({
+ "data": zod.object({
+ "createdAt": zod.number(),
+ "id": zod.string().uuid(),
+ "inboxVisible": zod.boolean(),
+ "isDraft": zod.boolean(),
+ "isImportant": zod.boolean(),
+ "isRead": zod.boolean(),
+ "name": zod.string().nullish(),
+ "ownerId": zod.string(),
+ "providerId": zod.string().nullish(),
+ "senderEmail": zod.string().nullish(),
+ "senderName": zod.string().nullish(),
+ "senderPhotoUrl": zod.string().nullish(),
+ "snippet": zod.string().nullish(),
+ "sortTs": zod.number(),
+ "updatedAt": zod.number(),
+ "viewedAt": zod.number().nullable()
+}).and(zod.object({
+ "attachments": zod.array(zod.object({
+ "contentId": zod.string().nullish(),
+ "createdAt": zod.number(),
+ "filename": zod.string().nullish(),
+ "id": zod.string().uuid(),
+ "messageId": zod.string().uuid(),
+ "mimeType": zod.string().nullish(),
+ "providerAttachmentId": zod.string().nullish(),
+ "sizeBytes": zod.number().nullish()
+})),
+ "attachmentsMacro": zod.array(zod.object({
+ "dbId": zod.string().uuid(),
+ "itemId": zod.string().uuid(),
+ "itemType": zod.string(),
+ "messageId": zod.string().uuid(),
+ "threadId": zod.string().uuid()
+})),
+ "participants": zod.array(zod.object({
+ "emailAddress": zod.string().nullish(),
+ "id": zod.string().uuid(),
+ "linkId": zod.string().uuid(),
+ "name": zod.string().nullish(),
+ "sfsPhotoUrl": zod.string().nullish()
+}))
+})),
+ "tag": zod.enum(['emailThread'])
})]).and(zod.object({
"frecency_score": zod.number()
}))),
diff --git a/js/app/packages/service-storage/openapi.json b/js/app/packages/service-storage/openapi.json
index ecde279a7d..0f94f8e992 100644
--- a/js/app/packages/service-storage/openapi.json
+++ b/js/app/packages/service-storage/openapi.json
@@ -6730,6 +6730,20 @@
"frecency"
]
},
+ "SoupAttachment": {
+ "type": "object",
+ "required": ["id", "messageId", "createdAt"],
+ "properties": {
+ "contentId": { "type": ["string", "null"] },
+ "createdAt": { "type": "integer", "format": "int64" },
+ "filename": { "type": ["string", "null"] },
+ "id": { "type": "string", "format": "uuid" },
+ "messageId": { "type": "string", "format": "uuid" },
+ "mimeType": { "type": ["string", "null"] },
+ "providerAttachmentId": { "type": ["string", "null"] },
+ "sizeBytes": { "type": ["integer", "null"], "format": "int64" }
+ }
+ },
"SoupChat": {
"type": "object",
"required": [
@@ -6778,6 +6792,17 @@
}
}
},
+ "SoupContact": {
+ "type": "object",
+ "required": ["id", "linkId"],
+ "properties": {
+ "emailAddress": { "type": ["string", "null"] },
+ "id": { "type": "string", "format": "uuid" },
+ "linkId": { "type": "string", "format": "uuid" },
+ "name": { "type": ["string", "null"] },
+ "sfsPhotoUrl": { "type": ["string", "null"] }
+ }
+ },
"SoupDocument": {
"type": "object",
"required": [
@@ -6853,24 +6878,114 @@
}
}
},
+ "SoupEmailThreadPreview": {
+ "type": "object",
+ "required": [
+ "id",
+ "ownerId",
+ "inboxVisible",
+ "isRead",
+ "isDraft",
+ "isImportant",
+ "sortTs",
+ "createdAt",
+ "updatedAt",
+ "viewedAt"
+ ],
+ "properties": {
+ "createdAt": { "type": "integer", "format": "int64" },
+ "id": { "type": "string", "format": "uuid" },
+ "inboxVisible": { "type": "boolean" },
+ "isDraft": { "type": "boolean" },
+ "isImportant": { "type": "boolean" },
+ "isRead": { "type": "boolean" },
+ "name": { "type": ["string", "null"] },
+ "ownerId": { "type": "string" },
+ "providerId": { "type": ["string", "null"] },
+ "senderEmail": { "type": ["string", "null"] },
+ "senderName": { "type": ["string", "null"] },
+ "senderPhotoUrl": { "type": ["string", "null"] },
+ "snippet": { "type": ["string", "null"] },
+ "sortTs": { "type": "integer", "format": "int64" },
+ "updatedAt": { "type": "integer", "format": "int64" },
+ "viewedAt": { "type": ["integer", "null"], "format": "int64" }
+ }
+ },
+ "SoupEnrichedEmailThreadPreview": {
+ "allOf": [
+ { "$ref": "#/components/schemas/SoupEmailThreadPreview" },
+ {
+ "type": "object",
+ "required": ["attachments", "attachmentsMacro", "participants"],
+ "properties": {
+ "attachments": {
+ "type": "array",
+ "items": { "$ref": "#/components/schemas/SoupAttachment" }
+ },
+ "attachmentsMacro": {
+ "type": "array",
+ "items": { "$ref": "#/components/schemas/SoupMacroAttachment" }
+ },
+ "participants": {
+ "type": "array",
+ "items": { "$ref": "#/components/schemas/SoupContact" }
+ }
+ }
+ }
+ ]
+ },
"SoupItem": {
"oneOf": [
- { "$ref": "#/components/schemas/SoupDocument" },
- { "$ref": "#/components/schemas/SoupChat" },
- { "$ref": "#/components/schemas/SoupProject" }
- ],
- "discriminator": {
- "propertyName": "type",
- "mapping": {
- "chat": "#/components/schemas/SoupChat",
- "document": "#/components/schemas/SoupDocument",
- "project": "#/components/schemas/SoupProject"
+ {
+ "type": "object",
+ "required": ["data", "tag"],
+ "properties": {
+ "data": { "$ref": "#/components/schemas/SoupDocument" },
+ "tag": { "type": "string", "enum": ["document"] }
+ }
+ },
+ {
+ "type": "object",
+ "required": ["data", "tag"],
+ "properties": {
+ "data": { "$ref": "#/components/schemas/SoupChat" },
+ "tag": { "type": "string", "enum": ["chat"] }
+ }
+ },
+ {
+ "type": "object",
+ "required": ["data", "tag"],
+ "properties": {
+ "data": { "$ref": "#/components/schemas/SoupProject" },
+ "tag": { "type": "string", "enum": ["project"] }
+ }
+ },
+ {
+ "type": "object",
+ "required": ["data", "tag"],
+ "properties": {
+ "data": {
+ "$ref": "#/components/schemas/SoupEnrichedEmailThreadPreview"
+ },
+ "tag": { "type": "string", "enum": ["emailThread"] }
+ }
}
- }
+ ]
},
"SoupItemType": {
"type": "string",
- "enum": ["document", "chat", "project"]
+ "enum": ["document", "chat", "project", "email_thread"]
+ },
+ "SoupMacroAttachment": {
+ "type": "object",
+ "required": ["threadId", "dbId", "messageId", "itemId", "itemType"],
+ "properties": {
+ "dbId": { "type": "string", "format": "uuid" },
+ "itemId": { "type": "string", "format": "uuid" },
+ "itemType": { "type": "string" },
+ "messageId": { "type": "string", "format": "uuid" },
+ "threadId": { "type": "string", "format": "uuid" }
+ }
},
"SoupPage": {
"type": "object",
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index d01330affb..fee279780c 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -152,12 +152,6 @@ dependencies = [
"url",
]
-[[package]]
-name = "android-tzdata"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
-
[[package]]
name = "android_system_properties"
version = "0.1.5"
@@ -1578,17 +1572,16 @@ dependencies = [
[[package]]
name = "chrono"
-version = "0.4.41"
+version = "0.4.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d"
+checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
dependencies = [
- "android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"serde",
"wasm-bindgen",
- "windows-link 0.1.1",
+ "windows-link 0.2.1",
]
[[package]]
@@ -2687,6 +2680,49 @@ dependencies = [
"zip",
]
+[[package]]
+name = "doppleganger"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4f6e63a190778be95e1805cdb16becc932fbe6caa42150edfdad948242ba75aa"
+dependencies = [
+ "doppleganger-core",
+ "doppleganger-macros",
+]
+
+[[package]]
+name = "doppleganger-core"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "314f5bc3b014813956a5f373d5d310b1cdfa7b2295fbb875e7f4512dd382dd34"
+dependencies = [
+ "chrono",
+ "uuid",
+]
+
+[[package]]
+name = "doppleganger-macros"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "abdff597f92f7f4f55ab8dfa59385189b870bb8df39dae33513092986feff984"
+dependencies = [
+ "doppleganger-macros-parse",
+ "proc-macro2",
+ "quote",
+ "unsynn",
+]
+
+[[package]]
+name = "doppleganger-macros-parse"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "847fd9f860890bb89d4c67838a1be9c0af044fd42ed211d87ac290cf9d53bafd"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unsynn",
+]
+
[[package]]
name = "dotenv"
version = "0.15.0"
@@ -3276,15 +3312,12 @@ dependencies = [
"chrono",
"cool_asserts",
"filter_ast",
- "futures",
"item_filters",
"macro_db_migrator",
- "macro_env",
"macro_env_var",
"macro_user_id",
"mockall",
"model-entity",
- "models_pagination",
"num-traits",
"ordered-float",
"rand 0.9.0",
@@ -4750,7 +4783,6 @@ dependencies = [
"models_pagination",
"models_permissions",
"models_search",
- "models_soup",
"models_team",
"rand 0.9.0",
"serde",
@@ -4913,6 +4945,7 @@ dependencies = [
name = "macro_user_id"
version = "0.1.0"
dependencies = [
+ "doppleganger",
"nom 8.0.0",
"serde",
"thiserror 2.0.17",
@@ -5476,6 +5509,8 @@ version = "0.1.0"
dependencies = [
"anyhow",
"chrono",
+ "doppleganger",
+ "email",
"macro_user_id",
"model-entity",
"models_pagination",
@@ -5525,6 +5560,12 @@ dependencies = [
"version_check",
]
+[[package]]
+name = "mutants"
+version = "0.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc0287524726960e07b119cebd01678f852f147742ae0d925e6a520dca956126"
+
[[package]]
name = "native-tls"
version = "0.2.13"
@@ -7933,6 +7974,7 @@ dependencies = [
"axum",
"chrono",
"cool_asserts",
+ "doppleganger",
"either",
"filter_ast",
"frecency",
@@ -9028,6 +9070,17 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
+[[package]]
+name = "unsynn"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "501a7adf1a4bd9951501e5c66621e972ef8874d787628b7f90e64f936ef7ec0a"
+dependencies = [
+ "mutants",
+ "proc-macro2",
+ "rustc-hash 2.1.1",
+]
+
[[package]]
name = "untrusted"
version = "0.9.0"
@@ -9215,13 +9268,15 @@ dependencies = [
[[package]]
name = "uuid"
-version = "1.15.1"
+version = "1.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587"
+checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
dependencies = [
"getrandom 0.3.1",
+ "js-sys",
"rand 0.9.0",
"serde",
+ "wasm-bindgen",
]
[[package]]
diff --git a/rust/cloud-storage/Cargo.toml b/rust/cloud-storage/Cargo.toml
index 173e2e3a17..283e3e9e52 100644
--- a/rust/cloud-storage/Cargo.toml
+++ b/rust/cloud-storage/Cargo.toml
@@ -210,6 +210,7 @@ bzip2 = { version = "0.5.1", default-features = false, features = [
"libbz2-rs-sys",
] }
derive_builder = "0.20.2"
+doppleganger = "0.1"
once_cell = "1.21.3"
scraper = "0.18"
strum_macros = "0.27.1"
diff --git a/rust/cloud-storage/connection_gateway/Cargo.toml b/rust/cloud-storage/connection_gateway/Cargo.toml
index 944a3e8a57..501192142b 100644
--- a/rust/cloud-storage/connection_gateway/Cargo.toml
+++ b/rust/cloud-storage/connection_gateway/Cargo.toml
@@ -28,7 +28,11 @@ axum = { workspace = true, features = ["macros", "tower-log", "ws"] }
chrono = { workspace = true }
dashmap = { workspace = true }
ensure_exists = { path = "../ensure_exists", features = ["dynamodb"] }
-frecency = { path = "../frecency", features = ["postgres"] }
+frecency = { path = "../frecency", features = [
+ "inbound",
+ "outbound",
+ "postgres",
+] }
futures = { workspace = true }
http-body-util = { workspace = true }
itertools = "0.14.0"
diff --git a/rust/cloud-storage/connection_gateway/src/main.rs b/rust/cloud-storage/connection_gateway/src/main.rs
index bdf34bbadf..2be352968d 100644
--- a/rust/cloud-storage/connection_gateway/src/main.rs
+++ b/rust/cloud-storage/connection_gateway/src/main.rs
@@ -17,7 +17,10 @@ use constants::ORIGINS;
use frecency::{
domain::services::{EventIngestorImpl, PullAggregatorImpl},
inbound::polling_aggregator::FrecencyAggregatorWorkerHandle,
- outbound::postgres::{FrecencyPgProcessor, FrecencyPgStorage},
+ outbound::{
+ postgres::{FrecencyPgProcessor, FrecencyPgStorage},
+ time::DefaultTime,
+ },
};
use macro_auth::middleware::decode_jwt::JwtValidationArgs;
use macro_entrypoint::MacroEntrypoint;
@@ -112,7 +115,7 @@ async fn main() -> Result<()> {
jwt_args,
internal_auth_key: LocalOrRemoteSecret::Local(InternalApiSecretKey::new()?),
frecency_worker: Arc::new(FrecencyAggregatorWorkerHandle::new_worker(
- PullAggregatorImpl::new_with_default_time(FrecencyPgProcessor::new(pgpool)),
+ PullAggregatorImpl::new(FrecencyPgProcessor::new(pgpool), DefaultTime),
Duration::from_secs(60),
)),
})
diff --git a/rust/cloud-storage/document_storage_service/Cargo.toml b/rust/cloud-storage/document_storage_service/Cargo.toml
index e805997b13..3e64467262 100644
--- a/rust/cloud-storage/document_storage_service/Cargo.toml
+++ b/rust/cloud-storage/document_storage_service/Cargo.toml
@@ -88,7 +88,7 @@ schemars = { workspace = true }
secretsmanager_client = { path = "../secretsmanager_client" }
serde = { workspace = true }
serde_json = { workspace = true }
-soup = { path = "../soup", features = ["axum"] }
+soup = { path = "../soup", features = ["axum", "inbound", "outbound"] }
sqlx = { workspace = true }
sqs_client = { path = "../sqs_client", default-features = false, features = [
"document",
diff --git a/rust/cloud-storage/email/Cargo.toml b/rust/cloud-storage/email/Cargo.toml
index ffc0bbb9dd..e05536449b 100644
--- a/rust/cloud-storage/email/Cargo.toml
+++ b/rust/cloud-storage/email/Cargo.toml
@@ -14,6 +14,9 @@ axum = [
"model_user/axum",
"models_pagination/axum",
]
+inbound = ["ports"]
+outbound = ["dep:sqlx", "ports"]
+ports = ["dep:tokio", "frecency/ports"]
[dependencies]
anyhow = { workspace = true }
@@ -28,10 +31,10 @@ models_pagination = { path = "../models_pagination" }
schemars = { workspace = true, optional = true, features = ["uuid1"] }
serde = { workspace = true }
serde_with = { workspace = true }
-sqlx = { workspace = true }
+sqlx = { workspace = true, optional = true }
strum = { workspace = true }
thiserror = { workspace = true }
-tokio = { workspace = true, features = ["macros"] }
+tokio = { workspace = true, features = ["macros"], optional = true }
tracing = { workspace = true }
utoipa = { workspace = true, optional = true }
uuid = { workspace = true }
diff --git a/rust/cloud-storage/email/src/domain.rs b/rust/cloud-storage/email/src/domain.rs
index 901e625fda..2b79af4ee0 100644
--- a/rust/cloud-storage/email/src/domain.rs
+++ b/rust/cloud-storage/email/src/domain.rs
@@ -1,3 +1,6 @@
pub mod models;
+
+#[cfg(feature = "ports")]
pub mod ports;
+#[cfg(feature = "ports")]
pub mod service;
diff --git a/rust/cloud-storage/email/src/domain/models.rs b/rust/cloud-storage/email/src/domain/models.rs
index c19639b905..5a3e41d3f2 100644
--- a/rust/cloud-storage/email/src/domain/models.rs
+++ b/rust/cloud-storage/email/src/domain/models.rs
@@ -1,8 +1,8 @@
-use frecency::domain::ports::FrecencyQueryErr;
+use chrono::{DateTime, Utc};
+use frecency::domain::models::FrecencyQueryErr;
use macro_user_id::user_id::MacroUserIdStr;
use models_pagination::{Identify, Query, SimpleSortMethod, SortOn};
use serde_with::{DeserializeFromStr, SerializeDisplay};
-use sqlx::types::chrono::{DateTime, Utc};
use std::str::FromStr;
use strum::{Display, EnumString};
use thiserror::Error;
@@ -62,7 +62,7 @@ impl FromStr for PreviewView {
#[derive(Debug, Clone)]
#[non_exhaustive]
-pub struct ThreadPreviewCursor {
+pub struct EmailThreadPreview {
pub id: Uuid,
pub provider_id: Option<String>,
pub owner_id: MacroUserIdStr<'static>,
@@ -82,15 +82,15 @@ pub struct ThreadPreviewCursor {
}
#[non_exhaustive]
-pub struct EnrichedThreadPreviewCursor {
- pub thread: ThreadPreviewCursor,
+pub struct EnrichedEmailThreadPreview {
+ pub thread: EmailThreadPreview,
pub attachments: Vec<Attachment>,
pub attachments_macro: Vec<AttachmentMacro>,
pub frecency_score: Option<f64>,
pub participants: Vec<Contact>,
}
-impl Identify for EnrichedThreadPreviewCursor {
+impl Identify for EnrichedEmailThreadPreview {
type Id = Uuid;
fn id(&self) -> Self::Id {
@@ -98,7 +98,7 @@ impl Identify for EnrichedThreadPreviewCursor {
}
}
-impl SortOn<SimpleSortMethod> for EnrichedThreadPreviewCursor {
+impl SortOn<SimpleSortMethod> for EnrichedEmailThreadPreview {
fn sort_on(
sort: SimpleSortMethod,
) -> impl FnOnce(&Self) -> models_pagination::CursorVal<SimpleSortMethod> {
diff --git a/rust/cloud-storage/email/src/domain/ports.rs b/rust/cloud-storage/email/src/domain/ports.rs
index f32c506fd4..1e3e372f87 100644
--- a/rust/cloud-storage/email/src/domain/ports.rs
+++ b/rust/cloud-storage/email/src/domain/ports.rs
@@ -1,6 +1,6 @@
use crate::domain::models::{
- Attachment, AttachmentMacro, Contact, EmailErr, EnrichedThreadPreviewCursor, GetEmailsRequest,
- PreviewCursorQuery, ThreadPreviewCursor,
+ Attachment, AttachmentMacro, Contact, EmailErr, EmailThreadPreview, EnrichedEmailThreadPreview,
+ GetEmailsRequest, PreviewCursorQuery,
};
use macro_user_id::user_id::MacroUserIdStr;
use models_pagination::{PaginatedCursor, SimpleSortMethod};
@@ -12,7 +12,7 @@ pub trait EmailRepo: Send + Sync + 'static {
&self,
query: PreviewCursorQuery,
user_id: MacroUserIdStr<'static>,
- ) -> impl Future<Output = Result<Vec<ThreadPreviewCursor>, Self::Err>> + Send;
+ ) -> impl Future<Output = Result<Vec<EmailThreadPreview>, Self::Err>> + Send;
fn attachments_by_thread_ids(
&self,
@@ -36,7 +36,7 @@ pub trait EmailService: Send + Sync + 'static {
req: GetEmailsRequest,
) -> impl Future<
Output = Result<
- PaginatedCursor<EnrichedThreadPreviewCursor, Uuid, SimpleSortMethod, ()>,
+ PaginatedCursor<EnrichedEmailThreadPreview, Uuid, SimpleSortMethod, ()>,
EmailErr,
>,
> + Send;
diff --git a/rust/cloud-storage/email/src/domain/service.rs b/rust/cloud-storage/email/src/domain/service.rs
index ae0cbae1e4..ec0bdcb700 100644
--- a/rust/cloud-storage/email/src/domain/service.rs
+++ b/rust/cloud-storage/email/src/domain/service.rs
@@ -1,5 +1,5 @@
use crate::domain::{
- models::{EmailErr, EnrichedThreadPreviewCursor, GetEmailsRequest, PreviewCursorQuery},
+ models::{EmailErr, EnrichedEmailThreadPreview, GetEmailsRequest, PreviewCursorQuery},
ports::{EmailRepo, EmailService},
};
use frecency::domain::{models::FrecencyByIdsRequest, ports::FrecencyQueryService};
@@ -36,7 +36,7 @@ where
async fn get_email_thread_previews(
&self,
req: GetEmailsRequest,
- ) -> Result<PaginatedCursor<EnrichedThreadPreviewCursor, Uuid, SimpleSortMethod, ()>, EmailErr>
+ ) -> Result<PaginatedCursor<EnrichedEmailThreadPreview, Uuid, SimpleSortMethod, ()>, EmailErr>
{
let GetEmailsRequest {
view,
@@ -69,7 +69,7 @@ where
let ids: Vec<_> = thread_ids
.iter()
- .map(|id| EntityType::Email.with_entity_string(id.to_string()))
+ .map(|id| EntityType::EmailThread.with_entity_string(id.to_string()))
.collect();
let frecency_request = FrecencyByIdsRequest {
@@ -116,7 +116,7 @@ where
Ok(previews
.into_iter()
- .map(|thread| EnrichedThreadPreviewCursor {
+ .map(|thread| EnrichedEmailThreadPreview {
attachments: attachment_map.remove(&thread.id).unwrap_or_default(),
attachments_macro: macro_attachment_map.remove(&thread.id).unwrap_or_default(),
participants: participant_map.remove(&thread.id).unwrap_or_default(),
diff --git a/rust/cloud-storage/email/src/inbound/axum/api_types.rs b/rust/cloud-storage/email/src/inbound/axum/api_types.rs
index 96ad7dfa5d..933eecd349 100644
--- a/rust/cloud-storage/email/src/inbound/axum/api_types.rs
+++ b/rust/cloud-storage/email/src/inbound/axum/api_types.rs
@@ -5,7 +5,7 @@ use utoipa::ToSchema;
use uuid::Uuid;
use crate::domain::models::{
- Attachment, AttachmentMacro, Contact, EnrichedThreadPreviewCursor, ThreadPreviewCursor,
+ Attachment, AttachmentMacro, Contact, EmailThreadPreview, EnrichedEmailThreadPreview,
};
/// common types of sorts based on timestamps
@@ -47,8 +47,8 @@ struct ApiThreadPreviewCursor {
impl ApiThreadPreviewCursor {
#[inline]
- fn new(model: EnrichedThreadPreviewCursor) -> Self {
- let EnrichedThreadPreviewCursor {
+ fn new(model: EnrichedEmailThreadPreview) -> Self {
+ let EnrichedEmailThreadPreview {
thread,
attachments,
attachments_macro,
@@ -106,8 +106,8 @@ pub struct ApiThreadPreviewCursorInner {
impl ApiThreadPreviewCursorInner {
#[inline]
- fn new(thread: ThreadPreviewCursor) -> Self {
- let ThreadPreviewCursor {
+ fn new(thread: EmailThreadPreview) -> Self {
+ let EmailThreadPreview {
id,
provider_id,
owner_id,
@@ -266,7 +266,7 @@ pub struct ApiPaginatedThreadCursor {
impl ApiPaginatedThreadCursor {
#[inline]
- pub(crate) fn new(model: PaginatedOpaqueCursor<EnrichedThreadPreviewCursor>) -> Self {
+ pub(crate) fn new(model: PaginatedOpaqueCursor<EnrichedEmailThreadPreview>) -> Self {
let PaginatedOpaqueCursor {
items, next_cursor, ..
} = model;
diff --git a/rust/cloud-storage/email/src/lib.rs b/rust/cloud-storage/email/src/lib.rs
index a65f027d93..f76105df0f 100644
--- a/rust/cloud-storage/email/src/lib.rs
+++ b/rust/cloud-storage/email/src/lib.rs
@@ -1,3 +1,5 @@
pub mod domain;
+#[cfg(feature = "inbound")]
pub mod inbound;
+#[cfg(feature = "outbound")]
pub mod outbound;
diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo.rs
index 6eb0711a06..3626a1d324 100644
--- a/rust/cloud-storage/email/src/outbound/email_pg_repo.rs
+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo.rs
@@ -1,7 +1,7 @@
use crate::domain::{
models::{
- Attachment, AttachmentMacro, Contact, PreviewCursorQuery, PreviewView,
- PreviewViewStandardLabel, ThreadPreviewCursor,
+ Attachment, AttachmentMacro, Contact, EmailThreadPreview, PreviewCursorQuery, PreviewView,
+ PreviewViewStandardLabel,
},
ports::EmailRepo,
};
@@ -31,7 +31,7 @@ impl EmailRepo for EmailPgRepo {
&self,
query: PreviewCursorQuery,
user_id: MacroUserIdStr<'static>,
- ) -> Result<Vec<ThreadPreviewCursor>, Self::Err> {
+ ) -> Result<Vec<EmailThreadPreview>, Self::Err> {
Ok(match query.view {
PreviewView::StandardLabel(ref label) => match label {
PreviewViewStandardLabel::Inbox => {
diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs
index 8d31a2422a..7b560b4770 100644
--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs
+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs
@@ -1,4 +1,4 @@
-use crate::domain::models::{Attachment, AttachmentMacro, ThreadPreviewCursor};
+use crate::domain::models::{Attachment, AttachmentMacro, EmailThreadPreview};
use chrono::{DateTime, Utc};
use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
use uuid::Uuid;
@@ -99,7 +99,7 @@ pub struct ThreadPreviewCursorDbRow {
}
impl ThreadPreviewCursorDbRow {
- pub fn with_user_id(self, owner_id: MacroUserIdStr<'_>) -> ThreadPreviewCursor {
+ pub fn with_user_id(self, owner_id: MacroUserIdStr<'_>) -> EmailThreadPreview {
let ThreadPreviewCursorDbRow {
id,
provider_id,
@@ -118,7 +118,7 @@ impl ThreadPreviewCursorDbRow {
updated_at,
} = self;
- ThreadPreviewCursor {
+ EmailThreadPreview {
id,
provider_id,
owner_id: owner_id.into_owned(),
diff --git a/rust/cloud-storage/email_service/Cargo.toml b/rust/cloud-storage/email_service/Cargo.toml
index 6082e74705..cc54badd2f 100644
--- a/rust/cloud-storage/email_service/Cargo.toml
+++ b/rust/cloud-storage/email_service/Cargo.toml
@@ -43,7 +43,7 @@ cloudfront_sign = { workspace = true }
connection_gateway = { path = "../connection_gateway" }
document_storage_service_client = { path = "../document_storage_service_client" }
ego-tree = { workspace = true }
-email = { path = "../email", features = ["axum"] }
+email = { path = "../email", features = ["axum", "inbound", "outbound"] }
email_db_client = { path = "../email_db_client" }
email_utils = { path = "../email_utils"}
frecency = { path = "../frecency", features = ["postgres"] }
diff --git a/rust/cloud-storage/email_service_client/Cargo.toml b/rust/cloud-storage/email_service_client/Cargo.toml
index 43ccf71d80..cdd247eabc 100644
--- a/rust/cloud-storage/email_service_client/Cargo.toml
+++ b/rust/cloud-storage/email_service_client/Cargo.toml
@@ -6,7 +6,7 @@ version = "0.1.0"
[dependencies]
anyhow = { workspace = true }
-email = { path = "../email", features = ["axum"] }
+email = { path = "../email", features = ["axum", "inbound"] }
model = { path = "../model" }
models_email = { path = "../models_email" }
reqwest = { workspace = true }
diff --git a/rust/cloud-storage/frecency/Cargo.toml b/rust/cloud-storage/frecency/Cargo.toml
index dcda34e993..9a6b032d0b 100644
--- a/rust/cloud-storage/frecency/Cargo.toml
+++ b/rust/cloud-storage/frecency/Cargo.toml
@@ -5,31 +5,32 @@ publish = false
version = "0.1.0"
[features]
+inbound = ["ports"]
mock = ["dep:mockall"]
-postgres = ["dep:serde_json", "dep:sqlx"]
+outbound = ["ports"]
+ports = ["dep:tokio", "dep:tracing"]
+postgres = ["dep:recursion", "dep:serde_json", "dep:sqlx"]
+
[dependencies]
anyhow = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
filter_ast = { path = "../filter_ast" }
-futures = { workspace = true }
item_filters = { path = "../item_filters" }
-macro_env = { path = "../macro_env" }
macro_env_var = { path = "../macro_env_var", optional = true }
macro_user_id = { path = "../macro_user_id" }
mockall = { workspace = true, optional = true }
model-entity = { path = "../model-entity" }
-models_pagination = { path = "../models_pagination" }
num-traits = { version = "0.2" }
ordered-float = "5"
-recursion = { workspace = true }
+recursion = { workspace = true, optional = true }
serde = { workspace = true }
serde_json = { workspace = true, optional = true }
sqlx = { workspace = true, optional = true }
thiserror = { workspace = true }
-tokio = { workspace = true, features = ["sync", "time"] }
+tokio = { workspace = true, optional = true, features = ["sync", "time"] }
tower = { workspace = true, optional = true }
-tracing = { workspace = true }
+tracing = { workspace = true, optional = true }
[dev-dependencies]
cool_asserts = "2"
diff --git a/rust/cloud-storage/frecency/src/domain.rs b/rust/cloud-storage/frecency/src/domain.rs
index 88b622f66e..caa5c3e890 100644
--- a/rust/cloud-storage/frecency/src/domain.rs
+++ b/rust/cloud-storage/frecency/src/domain.rs
@@ -2,5 +2,7 @@
//! Please research hexagonal architecture pattern for more info
pub mod models;
+#[cfg(feature = "ports")]
pub mod ports;
+#[cfg(feature = "ports")]
pub mod services;
diff --git a/rust/cloud-storage/frecency/src/domain/models.rs b/rust/cloud-storage/frecency/src/domain/models.rs
index 82d8ca992b..9b6423ea8e 100644
--- a/rust/cloud-storage/frecency/src/domain/models.rs
+++ b/rust/cloud-storage/frecency/src/domain/models.rs
@@ -13,6 +13,7 @@ use num_traits::ToPrimitive;
use ordered_float::OrderedFloat;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, VecDeque};
+use thiserror::Error;
#[cfg(test)]
mod tests;
@@ -375,3 +376,8 @@ pub trait JoinFrecency: Iterator + Sized {
}
impl<T> JoinFrecency for T where T: Iterator + Sized {}
+
+/// The error that is produced by the [FrecencyQueryService]
+#[derive(Debug, Error)]
+#[error(transparent)]
+pub struct FrecencyQueryErr(#[from] anyhow::Error);
diff --git a/rust/cloud-storage/frecency/src/domain/ports.rs b/rust/cloud-storage/frecency/src/domain/ports.rs
index 4b2eb38104..6d9a578ed0 100644
--- a/rust/cloud-storage/frecency/src/domain/ports.rs
+++ b/rust/cloud-storage/frecency/src/domain/ports.rs
@@ -3,11 +3,10 @@
use chrono::{DateTime, Utc};
use macro_user_id::user_id::MacroUserIdStr;
use model_entity::Entity;
-use thiserror::Error;
use crate::domain::models::{
AggregateFrecency, AggregateId, EventAggregationStats, EventRecord, EventRecordWithId,
- FrecencyByIdsRequest, FrecencyPageRequest, FrecencyPageResponse,
+ FrecencyByIdsRequest, FrecencyPageRequest, FrecencyPageResponse, FrecencyQueryErr,
};
/// Trait for interacting with the storage of [EventRecord] records
@@ -112,11 +111,6 @@ pub trait PullEventAggregatorService: Send + Sync + 'static {
) -> impl Future<Output = Result<EventAggregationStats, anyhow::Error>> + Send + '_;
}
-/// The error that is produced by the [FrecencyQueryService]
-#[derive(Debug, Error)]
-#[error(transparent)]
-pub struct FrecencyQueryErr(#[from] anyhow::Error);
-
/// The service level interface for querying frecency data
#[cfg_attr(feature = "mock", mockall::automock)]
pub trait FrecencyQueryService: Send + Sync + 'static {
diff --git a/rust/cloud-storage/frecency/src/domain/services.rs b/rust/cloud-storage/frecency/src/domain/services.rs
index 897ce3228d..b1a3af3c32 100644
--- a/rust/cloud-storage/frecency/src/domain/services.rs
+++ b/rust/cloud-storage/frecency/src/domain/services.rs
@@ -1,17 +1,13 @@
//! This module defines the services that are exposed by this crate
-
-use crate::{
- domain::{
- models::{
- AggregateFrecency, AggregateId, EventAggregationStats, EventRecordWithId,
- FrecencyByIdsRequest, FrecencyPageRequest, FrecencyPageResponse,
- },
- ports::{
- AggregateFrecencyStorage, EventIngestorService, EventRecordStorage, FrecencyQueryErr,
- FrecencyQueryService, PullEventAggregatorService, TimeGetter, UnprocessedEventsRepo,
- },
+use crate::domain::{
+ models::{
+ AggregateFrecency, AggregateId, EventAggregationStats, EventRecordWithId,
+ FrecencyByIdsRequest, FrecencyPageRequest, FrecencyPageResponse, FrecencyQueryErr,
+ },
+ ports::{
+ AggregateFrecencyStorage, EventIngestorService, EventRecordStorage, FrecencyQueryService,
+ PullEventAggregatorService, TimeGetter, UnprocessedEventsRepo,
},
- outbound::time::DefaultTime,
};
use chrono::{DateTime, Utc};
use macro_user_id::cowlike::CowLike;
@@ -171,17 +167,6 @@ where
}
}
-impl<S> PullAggregatorImpl<S, DefaultTime>
-where
- S: UnprocessedEventsRepo,
- anyhow::Error: From<S::Err>,
-{
- /// create an instance of self passing the default impl for [TimeGetter]
- pub fn new_with_default_time(event_storage: S) -> Self {
- Self::new(event_storage, DefaultTime)
- }
-}
-
impl<S, T> PullEventAggregatorService for PullAggregatorImpl<S, T>
where
S: UnprocessedEventsRepo,
diff --git a/rust/cloud-storage/frecency/src/lib.rs b/rust/cloud-storage/frecency/src/lib.rs
index 28ef0c957b..e104048060 100644
--- a/rust/cloud-storage/frecency/src/lib.rs
+++ b/rust/cloud-storage/frecency/src/lib.rs
@@ -3,5 +3,7 @@
//! hexagonal architecture pattern
pub mod domain;
+#[cfg(feature = "inbound")]
pub mod inbound;
+#[cfg(feature = "outbound")]
pub mod outbound;
diff --git a/rust/cloud-storage/macro_db_client/Cargo.toml b/rust/cloud-storage/macro_db_client/Cargo.toml
index ce63b9f64c..47a6465280 100644
--- a/rust/cloud-storage/macro_db_client/Cargo.toml
+++ b/rust/cloud-storage/macro_db_client/Cargo.toml
@@ -17,15 +17,16 @@ async-trait = { workspace = true }
cached = { workspace = true }
chrono = { workspace = true }
futures = { workspace = true }
+macro_user_id = { path = "../macro_user_id" }
macro_uuid = { path = "../macro_uuid" }
mockall = { workspace = true }
model = { path = "../model" }
model-entity = { path = "../model-entity" }
models_dcs = { path = "../models_dcs" }
+models_opensearch = { path = "../models_opensearch" }
models_pagination = { path = "../models_pagination" }
models_permissions = { path = "../models_permissions" }
models_search = { path = "../models_search" }
-models_soup = { path = "../models_soup" }
models_team = { path = "../models_team", optional = true }
rand = { workspace = true, optional = true }
serde = { workspace = true }
@@ -34,7 +35,5 @@ sqlx = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
-uuid = { workspace = true }
user_quota = { path = "../user_quota" }
-macro_user_id = { path = "../macro_user_id" }
-models_opensearch = { path = "../models_opensearch" }
+uuid = { workspace = true }
diff --git a/rust/cloud-storage/macro_user_id/Cargo.toml b/rust/cloud-storage/macro_user_id/Cargo.toml
index 71e1ec9591..af11cc8cd6 100644
--- a/rust/cloud-storage/macro_user_id/Cargo.toml
+++ b/rust/cloud-storage/macro_user_id/Cargo.toml
@@ -5,6 +5,7 @@ publish = false
version = "0.1.0"
[dependencies]
+doppleganger = { workspace = true }
nom = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
diff --git a/rust/cloud-storage/macro_user_id/src/user_id.rs b/rust/cloud-storage/macro_user_id/src/user_id.rs
index 92c468e391..98c0446501 100644
--- a/rust/cloud-storage/macro_user_id/src/user_id.rs
+++ b/rust/cloud-storage/macro_user_id/src/user_id.rs
@@ -67,6 +67,8 @@ where
#[serde(try_from = "String", into = "String")]
pub struct MacroUserIdStr<'a>(pub MacroUserId<ArcCowStr<'a>>);
+impl<'a> doppleganger::Primitive for MacroUserIdStr<'a> {}
+
impl<'a> std::fmt::Display for MacroUserIdStr<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0.as_ref())
diff --git a/rust/cloud-storage/model-entity/src/lib.rs b/rust/cloud-storage/model-entity/src/lib.rs
index 0eb6b9a3de..80a1f6140a 100644
--- a/rust/cloud-storage/model-entity/src/lib.rs
+++ b/rust/cloud-storage/model-entity/src/lib.rs
@@ -44,6 +44,8 @@ pub enum EntityType {
Project,
/// The entity is an email
Email,
+ /// The entity is an email thread
+ EmailThread,
/// The entity is a team
Team,
}
diff --git a/rust/cloud-storage/models_soup/Cargo.toml b/rust/cloud-storage/models_soup/Cargo.toml
index c36a5af439..1d5c6b4f72 100644
--- a/rust/cloud-storage/models_soup/Cargo.toml
+++ b/rust/cloud-storage/models_soup/Cargo.toml
@@ -11,6 +11,8 @@ schema = ["dep:utoipa"]
[dependencies]
anyhow = { workspace = true }
chrono = { workspace = true }
+doppleganger = { workspace = true, features = ["chrono", "uuid"] }
+email = { path = "../email" }
macro_user_id = { path = "../macro_user_id" }
model-entity = { path = "../model-entity" }
models_pagination = { path = "../models_pagination" }
diff --git a/rust/cloud-storage/models_soup/src/email_thread.rs b/rust/cloud-storage/models_soup/src/email_thread.rs
new file mode 100644
index 0000000000..62e39eaacd
--- /dev/null
+++ b/rust/cloud-storage/models_soup/src/email_thread.rs
@@ -0,0 +1,95 @@
+use chrono::{DateTime, Utc};
+use doppleganger::Doppleganger;
+use macro_user_id::user_id::MacroUserIdStr;
+use serde::{Deserialize, Serialize};
+use uuid::Uuid;
+
+#[derive(Debug, Doppleganger, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]
+#[dg(backward = email::domain::models::Contact)]
+#[serde(rename_all = "camelCase")]
+pub struct SoupContact {
+ pub id: Uuid,
+ pub link_id: Uuid,
+ pub name: Option<String>,
+ pub email_address: Option<String>,
+ pub sfs_photo_url: Option<String>,
+}
+
+#[derive(Debug, Doppleganger, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]
+#[dg(backward = email::domain::models::AttachmentMacro)]
+#[serde(rename_all = "camelCase")]
+pub struct SoupMacroAttachment {
+ pub thread_id: Uuid,
+ pub db_id: Uuid,
+ pub message_id: Uuid,
+ pub item_id: Uuid,
+ pub item_type: String,
+}
+
+#[derive(Debug, Doppleganger, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]
+#[dg(backward = email::domain::models::Attachment)]
+#[serde(rename_all = "camelCase")]
+pub struct SoupAttachment {
+ pub id: Uuid,
+ pub message_id: Uuid,
+ pub provider_attachment_id: Option<String>,
+ pub filename: Option<String>,
+ pub mime_type: Option<String>,
+ pub size_bytes: Option<i64>,
+ pub content_id: Option<String>,
+ #[serde(with = "chrono::serde::ts_milliseconds")]
+ #[cfg_attr(feature = "schema", schema(value_type = i64))]
+ pub created_at: DateTime<Utc>,
+}
+
+#[derive(Debug, Doppleganger, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]
+#[dg(backward = email::domain::models::EmailThreadPreview)]
+#[serde(rename_all = "camelCase")]
+pub struct SoupEmailThreadPreview {
+ pub id: Uuid,
+ pub provider_id: Option<String>,
+ #[cfg_attr(feature = "schema", schema(value_type = String))]
+ pub owner_id: MacroUserIdStr<'static>,
+ pub inbox_visible: bool,
+ pub is_read: bool,
+ pub is_draft: bool,
+ pub is_important: bool,
+ pub name: Option<String>,
+ pub snippet: Option<String>,
+ pub sender_email: Option<String>,
+ pub sender_name: Option<String>,
+ pub sender_photo_url: Option<String>,
+ #[serde(with = "chrono::serde::ts_milliseconds")]
+ #[cfg_attr(feature = "schema", schema(value_type = i64))]
+ pub sort_ts: DateTime<Utc>,
+ #[serde(with = "chrono::serde::ts_milliseconds")]
+ #[cfg_attr(feature = "schema", schema(value_type = i64))]
+ pub created_at: DateTime<Utc>,
+ #[serde(with = "chrono::serde::ts_milliseconds")]
+ #[cfg_attr(feature = "schema", schema(value_type = i64))]
+ pub updated_at: DateTime<Utc>,
+ #[serde(with = "chrono::serde::ts_milliseconds_option")]
+ #[cfg_attr(feature = "schema", schema(value_type = i64, nullable = true))]
+ pub viewed_at: Option<DateTime<Utc>>,
+}
+
+#[derive(Debug, Doppleganger, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]
+#[dg(backward = email::domain::models::EnrichedEmailThreadPreview)]
+#[serde(rename_all = "camelCase")]
+pub struct SoupEnrichedEmailThreadPreview {
+ #[serde(flatten)]
+ pub thread: SoupEmailThreadPreview,
+ pub attachments: Vec<SoupAttachment>,
+ pub attachments_macro: Vec<SoupMacroAttachment>,
+ pub participants: Vec<SoupContact>,
+}
diff --git a/rust/cloud-storage/models_soup/src/item.rs b/rust/cloud-storage/models_soup/src/item.rs
index 6c9be711f6..0446a2a909 100644
--- a/rust/cloud-storage/models_soup/src/item.rs
+++ b/rust/cloud-storage/models_soup/src/item.rs
@@ -1,10 +1,11 @@
use crate::chat::SoupChat;
use crate::document::SoupDocument;
+use crate::email_thread::SoupEnrichedEmailThreadPreview;
use crate::project::SoupProject;
use chrono::{DateTime, Utc};
use model_entity::{Entity, EntityType};
use models_pagination::{Identify, SimpleSortMethod, SortOn};
-use serde::{Deserialize, Serialize, Serializer};
+use serde::{Deserialize, Serialize};
use strum::EnumString;
use uuid::Uuid;
@@ -16,20 +17,18 @@ pub enum SoupItemType {
Document,
Chat,
Project,
+ EmailThread,
}
-#[derive(Deserialize, Clone, Debug)]
+#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]
-#[serde(untagged)]
-#[cfg_attr(feature = "schema", derive(utoipa::ToSchema), schema(discriminator(property_name = "type", mapping(
- ("document" = "#/components/schemas/SoupDocument"),
- ("chat" = "#/components/schemas/SoupChat"),
- ("project" = "#/components/schemas/SoupProject"),
-))))]
+#[serde(rename_all = "camelCase", tag = "tag", content = "data")]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
pub enum SoupItem {
Document(SoupDocument),
Chat(SoupChat),
Project(SoupProject),
+ EmailThread(SoupEnrichedEmailThreadPreview),
}
impl SoupItem {
@@ -45,6 +44,9 @@ impl SoupItem {
SoupItem::Project(soup_project) => {
EntityType::Project.with_entity_string(soup_project.id.to_string())
}
+ SoupItem::EmailThread(email_thread) => {
+ EntityType::EmailThread.with_entity_string(email_thread.thread.id.to_string())
+ }
}
}
@@ -53,42 +55,7 @@ impl SoupItem {
SoupItem::Document(soup_document) => soup_document.updated_at,
SoupItem::Chat(soup_chat) => soup_chat.updated_at,
SoupItem::Project(soup_project) => soup_project.updated_at,
- }
- }
-}
-
-impl Serialize for SoupItem {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- macro_rules! flatten_variant {
- ($tag:expr, $tag_ty:ty, $inner_ty:ty, $inner_val:expr) => {{
- #[derive(Serialize)]
- struct Inline<'a> {
- #[serde(rename = "type")]
- tag: &'a $tag_ty,
- #[serde(flatten)]
- data: &'a $inner_ty,
- }
- let tmp = Inline {
- tag: $tag,
- data: $inner_val,
- };
- tmp.serialize(serializer)
- }};
- }
-
- match self {
- SoupItem::Document(doc) => {
- flatten_variant!(&SoupItemType::Document, SoupItemType, SoupDocument, doc)
- }
- SoupItem::Chat(chat) => {
- flatten_variant!(&SoupItemType::Chat, SoupItemType, SoupChat, chat)
- }
- SoupItem::Project(project) => {
- flatten_variant!(&SoupItemType::Project, SoupItemType, SoupProject, project)
- }
+ SoupItem::EmailThread(soup_thread) => soup_thread.thread.updated_at,
}
}
}
@@ -128,6 +95,18 @@ impl SoupItem {
(SoupItem::Project(soup_project), SimpleSortMethod::ViewedUpdated) => {
soup_project.viewed_at.unwrap_or(soup_project.updated_at)
}
+ (SoupItem::EmailThread(thread), SimpleSortMethod::ViewedAt) => {
+ thread.thread.viewed_at.unwrap_or_default()
+ }
+ (SoupItem::EmailThread(thread), SimpleSortMethod::UpdatedAt) => {
+ thread.thread.updated_at
+ }
+ (SoupItem::EmailThread(thread), SimpleSortMethod::CreatedAt) => {
+ thread.thread.created_at
+ }
+ (SoupItem::EmailThread(thread), SimpleSortMethod::ViewedUpdated) => {
+ thread.thread.viewed_at.unwrap_or(thread.thread.updated_at)
+ }
}
}
}
@@ -140,6 +119,7 @@ impl Identify for SoupItem {
SoupItem::Document(soup_document) => soup_document.id,
SoupItem::Chat(soup_chat) => soup_chat.id,
SoupItem::Project(soup_project) => soup_project.id,
+ SoupItem::EmailThread(thread) => thread.thread.id,
}
}
}
diff --git a/rust/cloud-storage/models_soup/src/lib.rs b/rust/cloud-storage/models_soup/src/lib.rs
index aad51c90b9..9bc875b4aa 100644
--- a/rust/cloud-storage/models_soup/src/lib.rs
+++ b/rust/cloud-storage/models_soup/src/lib.rs
@@ -1,4 +1,5 @@
pub mod chat;
pub mod document;
+pub mod email_thread;
pub mod item;
pub mod project;
diff --git a/rust/cloud-storage/soup/Cargo.toml b/rust/cloud-storage/soup/Cargo.toml
index 2711e69414..1b5e70d4d4 100644
--- a/rust/cloud-storage/soup/Cargo.toml
+++ b/rust/cloud-storage/soup/Cargo.toml
@@ -13,12 +13,16 @@ axum = [
"models_pagination/axum",
"models_soup/schema",
]
+inbound = ["ports"]
+outbound = ["ports"]
+ports = ["frecency/ports"]
[dependencies]
anyhow = { workspace = true }
axum = { workspace = true, optional = true }
chrono = { workspace = true }
+doppleganger = { workspace = true, features = ["chrono", "uuid"] }
either = { workspace = true }
filter_ast = { path = "../filter_ast" }
frecency = { path = "../frecency" }
@@ -41,7 +45,7 @@ uuid = { workspace = true }
[dev-dependencies]
cool_asserts = "2"
filter_ast = { path = "../filter_ast" }
-frecency = { path = "../frecency", features = ["mock"] }
+frecency = { path = "../frecency", features = ["mock", "outbound"] }
futures = { workspace = true }
http-body-util = { workspace = true }
item_filters = { path = "../item_filters", features = ["mock"] }
diff --git a/rust/cloud-storage/soup/src/domain.rs b/rust/cloud-storage/soup/src/domain.rs
index 901e625fda..60276d3351 100644
--- a/rust/cloud-storage/soup/src/domain.rs
+++ b/rust/cloud-storage/soup/src/domain.rs
@@ -1,3 +1,5 @@
pub mod models;
+#[cfg(feature = "ports")]
pub mod ports;
+#[cfg(feature = "ports")]
pub mod service;
diff --git a/rust/cloud-storage/soup/src/domain/models.rs b/rust/cloud-storage/soup/src/domain/models.rs
index db731e2e0f..fe739e50cf 100644
--- a/rust/cloud-storage/soup/src/domain/models.rs
+++ b/rust/cloud-storage/soup/src/domain/models.rs
@@ -1,4 +1,4 @@
-use frecency::domain::{models::AggregateFrecency, ports::FrecencyQueryErr};
+use frecency::domain::models::{AggregateFrecency, FrecencyQueryErr};
use item_filters::ast::EntityFilterAst;
use macro_user_id::user_id::MacroUserIdStr;
use model_entity::Entity;
diff --git a/rust/cloud-storage/soup/src/lib.rs b/rust/cloud-storage/soup/src/lib.rs
index a65f027d93..f76105df0f 100644
--- a/rust/cloud-storage/soup/src/lib.rs
+++ b/rust/cloud-storage/soup/src/lib.rs
@@ -1,3 +1,5 @@
pub mod domain;
+#[cfg(feature = "inbound")]
pub mod inbound;
+#[cfg(feature = "outbound")]
pub mod outbound;
diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs
index b1d58fc272..0bfbc412aa 100644
--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs
+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs
@@ -7,6 +7,7 @@ use item_filters::ast::EntityFilterAst;
use macro_db_migrator::MACRO_DB_MIGRATIONS;
use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
use model_entity::EntityType;
+use models_pagination::Identify;
use models_pagination::{Frecency, PaginateOn, Query, SimpleSortMethod};
use models_soup::item::SoupItem;
use sqlx::{PgPool, Pool, Postgres};
@@ -40,6 +41,7 @@ async fn test_viewed_at_orders_nulls_last(pool: Pool<Postgres>) -> anyhow::Resul
SoupItem::Chat(c) => c.id,
SoupItem::Document(d) => d.id,
SoupItem::Project(p) => p.id,
+ SoupItem::EmailThread(t) => t.thread.id,
})
.collect();
@@ -68,14 +70,7 @@ async fn test_viewed_at_orders_nulls_last(pool: Pool<Postgres>) -> anyhow::Resul
);
// Check that items are ordered by their UserHistory.updatedAt timestamp.
- let ordered_ids: Vec<Uuid> = items
- .iter()
- .map(|item| match item {
- SoupItem::Chat(c) => c.id,
- SoupItem::Document(d) => d.id,
- SoupItem::Project(p) => p.id,
- })
- .collect();
+ let ordered_ids: Vec<Uuid> = items.iter().map(|item| item.id()).collect();
let expected_order: Vec<Uuid> = vec![
Uuid::parse_str("11111111-bbbb-bbbb-bbbb-bbbbbbbbbbbb").unwrap(), // doc-in-B - 2024-01-10
@@ -98,19 +93,8 @@ async fn test_viewed_at_orders_nulls_last(pool: Pool<Postgres>) -> anyhow::Resul
);
// Map for easier lookup when checking item details
- let items_map: std::collections::HashMap<Uuid, &SoupItem> = items
- .iter()
- .map(|item| {
- (
- match item {
- SoupItem::Chat(c) => c.id,
- SoupItem::Document(d) => d.id,
- SoupItem::Project(p) => p.id,
- },
- item,
- )
- })
- .collect();
+ let items_map: std::collections::HashMap<Uuid, &SoupItem> =
+ items.iter().map(|item| (item.id(), item)).collect();
// Check a standalone item that is still present
let chat_uuid = Uuid::parse_str("22222222-0000-0000-0000-000000000000").unwrap(); // chat-standalone
@@ -220,16 +204,8 @@ async fn test_expanded_generic_sorting_methods(pool: Pool<Postgres>) -> anyhow::
let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
// --- Helper to extract IDs for easy comparison ---
- let get_item_ids = |items: &[SoupItem]| -> Vec<Uuid> {
- items
- .iter()
- .map(|item| match item {
- SoupItem::Document(d) => d.id,
- SoupItem::Chat(c) => c.id,
- SoupItem::Project(p) => p.id,
- })
- .collect()
- };
+ let get_item_ids =
+ |items: &[SoupItem]| -> Vec<Uuid> { items.iter().map(|item| item.id()).collect() };
// --- Case 1: Test SortMethod::LastViewed ---
// Should FILTER to only the 3 items with a history entry.
@@ -361,7 +337,7 @@ async fn test_expanded_soup_by_ids(pool: Pool<Postgres>) {
.iter()
.find_map(|x| match x {
SoupItem::Document(soup_document) => Some(soup_document),
- SoupItem::Chat(_) | SoupItem::Project(_) => None,
+ SoupItem::Chat(_) | SoupItem::Project(_) | _ => None,
})
.expect("The document should exist");
let expected_doc_id = Uuid::parse_str("11111111-aaaa-aaaa-aaaa-aaaaaaaaaaaa").unwrap(); // doc-in-A
@@ -375,7 +351,7 @@ async fn test_expanded_soup_by_ids(pool: Pool<Postgres>) {
.iter()
.find_map(|x| match x {
SoupItem::Chat(soup_chat) => Some(soup_chat),
- SoupItem::Document(_) | SoupItem::Project(_) => None,
+ SoupItem::Document(_) | SoupItem::Project(_) | _ => None,
})
.expect("The chat should exist");
let expected_chat_id = Uuid::parse_str("22222222-bbbb-bbbb-bbbb-bbbbbbbbbbbb").unwrap(); // chat-in-B
@@ -455,14 +431,7 @@ async fn test_no_frecency_expanded_filters_out_frecency_items(
);
// Verify the returned items are the ones WITHOUT frecency
- let returned_ids: HashSet<Uuid> = items
- .iter()
- .map(|item| match item {
- SoupItem::Chat(c) => c.id,
- SoupItem::Document(d) => d.id,
- SoupItem::Project(p) => p.id,
- })
- .collect();
+ let returned_ids: HashSet<Uuid> = items.iter().map(|item| item.id()).collect();
let expected_ids: HashSet<Uuid> = [
"44444444-4444-4444-4444-444444444444", // doc-no-frecency-1
@@ -509,16 +478,8 @@ async fn test_no_frecency_expanded_filters_out_frecency_items(
async fn test_no_frecency_expanded_sorting_methods(pool: Pool<Postgres>) -> anyhow::Result<()> {
let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
- let get_item_ids = |items: &[SoupItem]| -> Vec<Uuid> {
- items
- .iter()
- .map(|item| match item {
- SoupItem::Document(d) => d.id,
- SoupItem::Chat(c) => c.id,
- SoupItem::Project(p) => p.id,
- })
- .collect()
- };
+ let get_item_ids =
+ |items: &[SoupItem]| -> Vec<Uuid> { items.iter().map(|item| item.id()).collect() };
// Test UpdatedAt sorting
{
@@ -732,23 +693,9 @@ async fn empty_ast_returns_same_as_static_query(db: PgPool) {
.unwrap();
// Compare the IDs since SoupItem doesn't implement PartialEq
- let ast_ids: Vec<Uuid> = ast_res
- .iter()
- .map(|item| match item {
- SoupItem::Chat(c) => c.id,
- SoupItem::Document(d) => d.id,
- SoupItem::Project(p) => p.id,
- })
- .collect();
+ let ast_ids: Vec<Uuid> = ast_res.iter().map(|item| item.id()).collect();
- let static_ids: Vec<Uuid> = static_res
- .iter()
- .map(|item| match item {
- SoupItem::Chat(c) => c.id,
- SoupItem::Document(d) => d.id,
- SoupItem::Project(p) => p.id,
- })
- .collect();
+ let static_ids: Vec<Uuid> = static_res.iter().map(|item| item.id()).collect();
assert_eq!(ast_ids, static_ids);
}
@@ -813,6 +760,9 @@ async fn test_filter_by_document_file_type(db: PgPool) -> anyhow::Result<()> {
SoupItem::Project(_) => {
project_count += 1;
}
+ _ => {
+ unimplemented!("encountered an unexpected value");
+ }
}
}
@@ -880,6 +830,7 @@ async fn test_filter_by_document_ids(db: PgPool) -> anyhow::Result<()> {
SoupItem::Project(_) => {
project_count += 1;
}
+ _ => unimplemented!("encountered unexpected entity"),
}
}
@@ -962,6 +913,7 @@ async fn test_filter_documents_by_project_id(db: PgPool) -> anyhow::Result<()> {
SoupItem::Project(_) => {
project_count += 1;
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
@@ -1033,6 +985,7 @@ async fn test_filter_chats_by_project_id(db: PgPool) -> anyhow::Result<()> {
SoupItem::Project(_) => {
project_count += 1;
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
@@ -1101,6 +1054,7 @@ async fn test_filter_by_chat_ids(db: PgPool) -> anyhow::Result<()> {
SoupItem::Project(_) => {
project_count += 1;
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
@@ -1177,6 +1131,7 @@ async fn test_filter_by_project_ids(db: PgPool) -> anyhow::Result<()> {
SoupItem::Chat(_) => {
chat_count += 1;
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
@@ -1288,6 +1243,7 @@ async fn test_combined_entity_filters(db: PgPool) -> anyhow::Result<()> {
SoupItem::Project(_project) => {
project_count += 1;
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
@@ -1361,6 +1317,7 @@ async fn test_multiple_filter_criteria_documents(db: PgPool) -> anyhow::Result<(
SoupItem::Project(_) => {
project_count += 1;
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
@@ -1438,6 +1395,7 @@ async fn test_filters_respect_access_control(db: PgPool) -> anyhow::Result<()> {
SoupItem::Project(_) => {
project_count += 1;
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
@@ -1507,6 +1465,7 @@ async fn test_filter_by_owner(db: PgPool) -> anyhow::Result<()> {
SoupItem::Project(_) => {
project_count += 1;
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
@@ -1568,6 +1527,7 @@ async fn test_filter_non_existent_items(db: PgPool) -> anyhow::Result<()> {
SoupItem::Project(_) => {
project_count += 1;
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
@@ -1671,25 +1631,15 @@ async fn test_cursor_pagination_with_document_filter(db: PgPool) -> anyhow::Resu
SoupItem::Project(_) => {
// Projects are fine
}
+ _ => unimplemented!("encounted unexpected entity"),
}
}
// Verify no duplicate items between pages
- let first_page_ids: HashSet<Uuid> = first_page_items
- .iter()
- .map(|item| match item {
- SoupItem::Document(d) => d.id,
- SoupItem::Chat(c) => c.id,
- SoupItem::Project(p) => p.id,
- })
- .collect();
+ let first_page_ids: HashSet<Uuid> = first_page_items.iter().map(|item| item.id()).collect();
for item in &second_page_items {
- let id = match item {
- SoupItem::Document(d) => d.id,
- SoupItem::Chat(c) => c.id,
- SoupItem::Project(p) => p.id,
- };
+ let id = item.id();
assert!(
!first_page_ids.contains(&id),
"No item should appear on both pages"
@@ -1790,6 +1740,7 @@ async fn test_cursor_pagination_with_combined_filters(db: PgPool) -> anyhow::Res
SoupItem::Project(_) => {
// All projects should be included
}
+ _ => unimplemented!("encountered an unknown entity"),
}
}
}
@@ -1890,14 +1841,7 @@ async fn test_cursor_pagination_filter_consistency(db: PgPool) -> anyhow::Result
);
// Verify no duplicate items
- let all_ids: Vec<Uuid> = all_items
- .iter()
- .map(|item| match item {
- SoupItem::Document(d) => d.id,
- SoupItem::Chat(c) => c.id,
- SoupItem::Project(p) => p.id,
- })
- .collect();
+ let all_ids: Vec<Uuid> = all_items.iter().map(|item| item.id()).collect();
let unique_ids: HashSet<_> = all_ids.iter().collect();
assert_eq!(
diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/tests.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/tests.rs
index 21d0047c66..1548804920 100644
--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/tests.rs
+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/tests.rs
@@ -5,6 +5,7 @@ use crate::outbound::pg_soup_repo::unexpanded::{
use macro_db_migrator::MACRO_DB_MIGRATIONS;
use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
use model_entity::EntityType;
+use models_pagination::Identify;
use models_pagination::{PaginateOn, Query, SimpleSortMethod};
use models_soup::item::SoupItem;
use sqlx::{Pool, Postgres};
@@ -22,16 +23,8 @@ use uuid::Uuid;
async fn test_unexpanded_generic_sorting_methods(pool: Pool<Postgres>) -> anyhow::Result<()> {
let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
- let get_item_ids = |items: &[SoupItem]| -> Vec<Uuid> {
- items
- .iter()
- .map(|item| match item {
- SoupItem::Document(d) => d.id,
- SoupItem::Chat(c) => c.id,
- SoupItem::Project(p) => p.id,
- })
- .collect()
- };
+ let get_item_ids =
+ |items: &[SoupItem]| -> Vec<Uuid> { items.iter().map(|item| item.id()).collect() };
{
let result = unexpanded_generic_cursor_soup(
@@ -114,16 +107,8 @@ async fn test_unexpanded_generic_mixed_types_sorting(pool: Pool<Postgres>) -> an
let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
// --- Helper to extract IDs for easy comparison ---
- let get_item_ids = |items: &[SoupItem]| -> Vec<Uuid> {
- items
- .iter()
- .map(|item| match item {
- SoupItem::Document(d) => d.id,
- SoupItem::Chat(c) => c.id,
- SoupItem::Project(p) => p.id,
- })
- .collect()
- };
+ let get_item_ids =
+ |items: &[SoupItem]| -> Vec<Uuid> { items.iter().map(|item| item.id()).collect() };
// --- Case 1: Test SortMethod::LastViewed ---
{
@@ -151,11 +136,7 @@ async fn test_unexpanded_generic_mixed_types_sorting(pool: Pool<Postgres>) -> an
let items_map: std::collections::HashMap<Uuid, &SoupItem> = result
.iter()
.map(|item| {
- let id = match item {
- SoupItem::Document(d) => d.id,
- SoupItem::Chat(c) => c.id,
- SoupItem::Project(p) => p.id,
- };
+ let id = item.id();
(id, item)
})
.collect();
@@ -488,14 +469,7 @@ async fn test_no_frecency_unexpanded_filters_out_frecency_items(
);
// Verify the returned items are the ones WITHOUT frecency
- let returned_ids: HashSet<Uuid> = items
- .iter()
- .map(|item| match item {
- SoupItem::Chat(c) => c.id,
- SoupItem::Document(d) => d.id,
- SoupItem::Project(p) => p.id,
- })
- .collect();
+ let returned_ids: HashSet<Uuid> = items.iter().map(|item| item.id()).collect();
let expected_ids: HashSet<Uuid> = [
"44444444-4444-4444-4444-444444444444", // doc-no-frecency-1
@@ -542,16 +516,8 @@ async fn test_no_frecency_unexpanded_filters_out_frecency_items(
async fn test_no_frecency_unexpanded_sorting_methods(pool: Pool<Postgres>) -> anyhow::Result<()> {
let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
- let get_item_ids = |items: &[SoupItem]| -> Vec<Uuid> {
- items
- .iter()
- .map(|item| match item {
- SoupItem::Document(d) => d.id,
- SoupItem::Chat(c) => c.id,
- SoupItem::Project(p) => p.id,
- })
- .collect()
- };
+ let get_item_ids =
+ |items: &[SoupItem]| -> Vec<Uuid> { items.iter().map(|item| item.id()).collect() };
// Test UpdatedAt sorting
{