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.

fix(entity): add PartialEntity type, fix formatting for title extractor (#1519)

Seamus2f5074cbca40
diff --git a/js/app/packages/entity/src/extractors/entity-title.tsx b/js/app/packages/entity/src/extractors/entity-title.tsx
index 1439629ef9..e64ef7b1b8 100644
--- a/js/app/packages/entity/src/extractors/entity-title.tsx
+++ b/js/app/packages/entity/src/extractors/entity-title.tsx
@@ -8,7 +8,13 @@ import { isSearchEntity } from '../types/search';
function extractRawTitle(entity: EntityData): string {
return match(entity)
- .with({ type: 'document' }, (e) => formatDocumentName(e.name))
+ .with({ type: 'document', subType: { type: 'task' } }, (e) =>
+ formatDocumentName(e.name)
+ )
+ .with({ type: 'document', fileType: 'md' }, (e) =>
+ formatDocumentName(e.name)
+ )
+ .with({ type: 'document' }, (e) => formatDocumentName(e.name, e.fileType))
.with({ type: 'project' }, (e) => e.name)
.with({ type: 'channel' }, (e) => e.name)
.with({ type: 'email' }, (e) => e.name || '(No Subject)')
diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.ts
index 25faa2459a..4e5691ab87 100644
--- a/js/app/packages/entity/src/types/entity.ts
+++ b/js/app/packages/entity/src/types/entity.ts
@@ -199,3 +199,15 @@ export const isProjectContainedEntity = <T extends EntityData>(
): entity is ProjectContainedEntity<T> => {
return getEntityProjectId(entity) !== false;
};
+
+/**
+ * Utility type that makes only specified fields required from an EntityData type,
+ * while all other fields become optional.
+ * @example
+ * type MinimalEntity = PartialEntity<'id' | 'name'>;
+ */
+export type PartialEntity<K extends keyof EntityData = keyof EntityData> = Pick<
+ EntityData,
+ K
+> &
+ Partial<Omit<EntityData, K>>;