@open-mercato/core 0.4.11-develop.1309.4b37381a7a → 0.4.11-develop.1347.c693e6dfee

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/modules/customers/api/companies/[id]/route.js +3 -2
  2. package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
  3. package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js +59 -91
  4. package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js.map +2 -2
  5. package/dist/modules/customers/api/interactions/tasks/route.js +115 -0
  6. package/dist/modules/customers/api/interactions/tasks/route.js.map +7 -0
  7. package/dist/modules/customers/api/people/[id]/route.js +3 -2
  8. package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
  9. package/dist/modules/customers/api/todos/route.js +14 -134
  10. package/dist/modules/customers/api/todos/route.js.map +2 -2
  11. package/dist/modules/customers/backend/customer-tasks/page.js +10 -0
  12. package/dist/modules/customers/backend/customer-tasks/page.js.map +7 -0
  13. package/dist/modules/customers/backend/customer-tasks/page.meta.js +25 -0
  14. package/dist/modules/customers/backend/customer-tasks/page.meta.js.map +7 -0
  15. package/dist/modules/customers/commands/interactions.js +40 -4
  16. package/dist/modules/customers/commands/interactions.js.map +2 -2
  17. package/dist/modules/customers/components/CustomerTodosTable.js +77 -47
  18. package/dist/modules/customers/components/CustomerTodosTable.js.map +2 -2
  19. package/dist/modules/customers/components/detail/TasksSection.js +4 -4
  20. package/dist/modules/customers/components/detail/TasksSection.js.map +2 -2
  21. package/dist/modules/customers/components/detail/hooks/usePersonTasks.js +2 -1
  22. package/dist/modules/customers/components/detail/hooks/usePersonTasks.js.map +2 -2
  23. package/dist/modules/customers/components/detail/utils.js +3 -0
  24. package/dist/modules/customers/components/detail/utils.js.map +2 -2
  25. package/dist/modules/customers/data/entities.js +2 -2
  26. package/dist/modules/customers/data/entities.js.map +2 -2
  27. package/dist/modules/customers/data/validators.js +2 -2
  28. package/dist/modules/customers/data/validators.js.map +2 -2
  29. package/dist/modules/customers/lib/interactionCompatibility.js +12 -2
  30. package/dist/modules/customers/lib/interactionCompatibility.js.map +2 -2
  31. package/dist/modules/customers/lib/todoCompatibility.js +167 -4
  32. package/dist/modules/customers/lib/todoCompatibility.js.map +2 -2
  33. package/dist/modules/customers/migrations/Migration20260401172819.js +45 -0
  34. package/dist/modules/customers/migrations/Migration20260401172819.js.map +7 -0
  35. package/dist/modules/customers/search.js +3 -2
  36. package/dist/modules/customers/search.js.map +2 -2
  37. package/dist/modules/customers/widgets/dashboard/customer-todos/widget.client.js +10 -2
  38. package/dist/modules/customers/widgets/dashboard/customer-todos/widget.client.js.map +2 -2
  39. package/package.json +3 -3
  40. package/src/modules/customers/api/companies/[id]/route.ts +6 -5
  41. package/src/modules/customers/api/dashboard/widgets/customer-todos/route.ts +69 -126
  42. package/src/modules/customers/api/interactions/tasks/route.ts +122 -0
  43. package/src/modules/customers/api/people/[id]/route.ts +3 -2
  44. package/src/modules/customers/api/todos/route.ts +13 -181
  45. package/src/modules/customers/backend/customer-tasks/page.meta.ts +23 -0
  46. package/src/modules/customers/backend/customer-tasks/page.tsx +12 -0
  47. package/src/modules/customers/commands/interactions.ts +50 -2
  48. package/src/modules/customers/components/CustomerTodosTable.tsx +91 -66
  49. package/src/modules/customers/components/detail/TasksSection.tsx +8 -8
  50. package/src/modules/customers/components/detail/hooks/usePersonTasks.ts +2 -1
  51. package/src/modules/customers/components/detail/types.ts +6 -0
  52. package/src/modules/customers/components/detail/utils.ts +3 -0
  53. package/src/modules/customers/data/entities.ts +2 -2
  54. package/src/modules/customers/data/validators.ts +2 -2
  55. package/src/modules/customers/lib/interactionCompatibility.ts +16 -0
  56. package/src/modules/customers/lib/todoCompatibility.ts +229 -10
  57. package/src/modules/customers/migrations/.snapshot-open-mercato.json +1 -1
  58. package/src/modules/customers/migrations/Migration20260401172819.ts +45 -0
  59. package/src/modules/customers/search.ts +3 -2
  60. package/src/modules/customers/widgets/dashboard/customer-todos/widget.client.tsx +24 -23
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/customers/search.ts"],
4
- "sourcesContent": ["import type { QueryCustomFieldSource, QueryEngine } from '@open-mercato/shared/lib/query/types'\nimport type {\n SearchModuleConfig,\n SearchBuildContext,\n SearchResultPresenter,\n SearchResultLink,\n SearchIndexSource,\n} from '@open-mercato/shared/modules/search'\n\n// =============================================================================\n// Context Types\n// =============================================================================\n\ntype SearchContext = SearchBuildContext & {\n tenantId: string\n queryEngine?: QueryEngine\n}\n\nfunction assertTenantContext(ctx: SearchBuildContext): asserts ctx is SearchContext {\n if (typeof ctx.tenantId !== 'string' || ctx.tenantId.length === 0) {\n throw new Error('[search.customers] Missing tenantId in search build context')\n }\n}\n\ntype CustomerProfileKind = 'person' | 'company'\n\ntype LoadedCustomerEntity = {\n entity: Record<string, unknown> | null\n customFields: Record<string, unknown>\n}\n\n// =============================================================================\n// Caching\n// =============================================================================\n\nconst entityIdCache = new Map<string, LoadedCustomerEntity | null>()\nconst profileEntityCache = new WeakMap<Record<string, unknown>, Partial<Record<CustomerProfileKind, LoadedCustomerEntity | null>>>()\nconst todoCache = new WeakMap<Record<string, unknown>, unknown>()\n\n// =============================================================================\n// Query Configuration\n// =============================================================================\n\nconst CUSTOMER_ENTITY_FIELDS = [\n 'id',\n 'kind',\n 'display_name',\n 'description',\n 'primary_email',\n 'primary_phone',\n 'status',\n 'lifecycle_stage',\n 'owner_user_id',\n 'source',\n 'next_interaction_at',\n 'next_interaction_name',\n 'next_interaction_ref_id',\n 'next_interaction_icon',\n 'next_interaction_color',\n 'organization_id',\n 'tenant_id',\n 'created_at',\n 'updated_at',\n 'deleted_at',\n] satisfies string[]\n\nconst CUSTOMER_CUSTOM_FIELD_SOURCES: QueryCustomFieldSource[] = [\n {\n entityId: 'customers:customer_person_profile',\n table: 'customer_people',\n alias: 'person_profile',\n recordIdColumn: 'id',\n join: { fromField: 'id', toField: 'entity_id' },\n },\n {\n entityId: 'customers:customer_company_profile',\n table: 'customer_companies',\n alias: 'company_profile',\n recordIdColumn: 'id',\n join: { fromField: 'id', toField: 'entity_id' },\n },\n]\n\n// =============================================================================\n// Helper Functions\n// =============================================================================\n\nfunction extractCustomFieldMap(source: Record<string, unknown> | null | undefined): Record<string, unknown> {\n if (!source) return {}\n const result: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(source)) {\n if (value === undefined) continue\n if (key.startsWith('cf:')) {\n result[key.slice(3)] = value\n } else if (key.startsWith('cf_')) {\n result[key.slice(3)] = value\n }\n }\n return result\n}\n\nfunction normalizeCustomerEntity(row: Record<string, unknown>): Record<string, unknown> {\n const normalized: Record<string, unknown> = {\n id: row.id ?? row.entity_id ?? row.entityId ?? null,\n kind: row.kind ?? null,\n }\n const assign = (snake: string, camel?: string) => {\n const value = row[snake] ?? (camel ? row[camel] : undefined)\n if (value !== undefined) {\n normalized[snake] = value\n if (camel) normalized[camel] = value\n }\n }\n assign('display_name', 'displayName')\n assign('description')\n assign('primary_email', 'primaryEmail')\n assign('primary_phone', 'primaryPhone')\n assign('status')\n assign('lifecycle_stage', 'lifecycleStage')\n assign('owner_user_id', 'ownerUserId')\n assign('source')\n assign('next_interaction_at', 'nextInteractionAt')\n assign('next_interaction_name', 'nextInteractionName')\n assign('next_interaction_ref_id', 'nextInteractionRefId')\n assign('next_interaction_icon', 'nextInteractionIcon')\n assign('next_interaction_color', 'nextInteractionColor')\n assign('organization_id', 'organizationId')\n assign('tenant_id', 'tenantId')\n assign('created_at', 'createdAt')\n assign('updated_at', 'updatedAt')\n assign('deleted_at', 'deletedAt')\n return normalized\n}\n\nfunction getProfileCache(record: Record<string, unknown>): Partial<Record<CustomerProfileKind, LoadedCustomerEntity | null>> {\n let cache = profileEntityCache.get(record)\n if (!cache) {\n cache = {}\n profileEntityCache.set(record, cache)\n }\n return cache\n}\n\nfunction subtractCustomFields(\n primary: Record<string, unknown>,\n secondary: Record<string, unknown>,\n): Record<string, unknown> {\n if (!secondary || Object.keys(secondary).length === 0) return {}\n const primaryKeys = new Set(Object.keys(primary))\n const result: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(secondary)) {\n if (!primaryKeys.has(key)) {\n result[key] = value\n }\n }\n return result\n}\n\n// =============================================================================\n// Entity Loading Functions\n// =============================================================================\n\ntype CustomerEntityQueryOptions = {\n entityId?: string | null\n profileKind?: CustomerProfileKind\n profileId?: string | null\n}\n\nasync function loadCustomerEntityBundle(ctx: SearchContext, opts: CustomerEntityQueryOptions): Promise<LoadedCustomerEntity | null> {\n if (!ctx.queryEngine) return null\n const filters: Record<string, unknown> = {}\n const resolvedEntityId = typeof opts.entityId === 'string' && opts.entityId.length ? opts.entityId : null\n const resolvedProfileId =\n opts.profileId != null && String(opts.profileId).trim().length > 0 ? String(opts.profileId).trim() : null\n if (resolvedEntityId) {\n filters.id = { $eq: resolvedEntityId }\n }\n if (opts.profileKind && resolvedProfileId) {\n const alias = opts.profileKind === 'person' ? 'person_profile' : 'company_profile'\n filters[`${alias}.id`] = { $eq: resolvedProfileId }\n }\n if (!Object.keys(filters).length) return null\n try {\n const result = await ctx.queryEngine.query('customers:customer_entity', {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId ?? undefined,\n filters,\n includeCustomFields: true,\n customFieldSources: CUSTOMER_CUSTOM_FIELD_SOURCES,\n fields: CUSTOMER_ENTITY_FIELDS,\n page: { page: 1, pageSize: 1 },\n })\n const row = result.items[0] as Record<string, unknown> | undefined\n if (!row) return null\n const entity = normalizeCustomerEntity(row)\n const customFields = extractCustomFieldMap(row)\n return { entity, customFields }\n } catch (error) {\n console.warn('[search.customers] Failed to load customer entity via QueryEngine', {\n entityId: resolvedEntityId ?? null,\n profileKind: opts.profileKind ?? null,\n profileId: resolvedProfileId ?? null,\n error: error instanceof Error ? error.message : error,\n })\n return null\n }\n}\n\nasync function loadCustomerEntityForProfile(ctx: SearchContext, kind: CustomerProfileKind): Promise<LoadedCustomerEntity | null> {\n const cache = getProfileCache(ctx.record)\n if (cache[kind] !== undefined) return cache[kind] ?? null\n const entityIdHint = resolveCustomerEntityId(ctx.record)\n const profileIdRaw = ctx.record.id ?? null\n const profileId = profileIdRaw != null ? String(profileIdRaw) : null\n if (!entityIdHint && !profileId) {\n cache[kind] = null\n return null\n }\n const loaded = await loadCustomerEntityBundle(ctx, {\n entityId: entityIdHint,\n profileKind: kind,\n profileId,\n })\n cache[kind] = loaded ?? null\n const resolvedId = loaded?.entity?.id ?? entityIdHint\n if (resolvedId && typeof resolvedId === 'string') {\n ctx.record.entity_id ??= resolvedId\n ctx.record.entityId ??= resolvedId\n entityIdCache.set(resolvedId, loaded ?? null)\n }\n if (loaded?.entity) {\n if (!ctx.record.entity) ctx.record.entity = loaded.entity\n if (!ctx.record.customer_entity) ctx.record.customer_entity = loaded.entity\n }\n return loaded ?? null\n}\n\nasync function loadCustomerEntityById(ctx: SearchContext, entityId: string | null | undefined): Promise<LoadedCustomerEntity | null> {\n const resolvedId = typeof entityId === 'string' && entityId.length ? entityId : null\n if (!resolvedId) return null\n if (entityIdCache.has(resolvedId)) {\n return entityIdCache.get(resolvedId) ?? null\n }\n const loaded = await loadCustomerEntityBundle(ctx, { entityId: resolvedId })\n entityIdCache.set(resolvedId, loaded ?? null)\n return loaded ?? null\n}\n\nasync function getCustomerEntity(ctx: SearchContext, entityId?: string | null): Promise<Record<string, unknown> | null> {\n const profileCache = profileEntityCache.get(ctx.record)\n if (profileCache) {\n const cached = Object.values(profileCache).find((entry) => {\n if (!entry?.entity) return false\n if (!entityId) return true\n return entry.entity.id === entityId\n })\n if (cached?.entity) return cached.entity\n }\n const inline = getInlineCustomerEntity(ctx.record)\n if (inline && (!entityId || inline.id === entityId)) {\n if (inline.id && typeof inline.id === 'string') {\n entityIdCache.set(inline.id, { entity: inline, customFields: {} })\n }\n return inline\n }\n const resolvedId = entityId ?? resolveCustomerEntityId(ctx.record)\n const loaded = await loadCustomerEntityById(ctx, resolvedId)\n return loaded?.entity ?? null\n}\n\ntype HydratedProfileContext = {\n entity: Record<string, unknown> | null\n entityId: string | null\n profileCustomFields: Record<string, unknown>\n entityCustomFields: Record<string, unknown>\n entityOnlyCustomFields: Record<string, unknown>\n}\n\nasync function hydrateProfileContext(ctx: SearchContext, kind: CustomerProfileKind): Promise<HydratedProfileContext> {\n const profileCustomFields = ctx.customFields ?? {}\n const loaded = await loadCustomerEntityForProfile(ctx, kind)\n let entity = loaded?.entity ?? getInlineCustomerEntity(ctx.record)\n let entityCustomFields = loaded?.customFields ?? {}\n let entityId = (entity?.id as string | undefined) ?? resolveCustomerEntityId(ctx.record)\n if (!entity && entityId) {\n const fetched = await loadCustomerEntityById(ctx, entityId)\n entity = fetched?.entity ?? null\n if (fetched?.customFields) {\n entityCustomFields = Object.keys(entityCustomFields).length ? entityCustomFields : fetched.customFields\n }\n }\n if (!entity && !entityId) {\n entityId = resolveCustomerEntityId(ctx.record)\n }\n if (entity?.id && typeof entity.id === 'string') {\n entityId = entity.id\n ctx.record.entity_id ??= entity.id\n ctx.record.entityId ??= entity.id\n if (!ctx.record.entity) ctx.record.entity = entity\n if (!ctx.record.customer_entity) ctx.record.customer_entity = entity\n }\n const entityOnlyCustomFields = subtractCustomFields(profileCustomFields, entityCustomFields)\n return {\n entity: entity ?? null,\n entityId: entityId ?? null,\n profileCustomFields,\n entityCustomFields,\n entityOnlyCustomFields,\n }\n}\n\nasync function loadRecord(ctx: SearchContext, entityId: string, recordId?: string | null) {\n if (!recordId || !ctx.queryEngine) return null\n const res = await ctx.queryEngine.query(entityId, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId ?? undefined,\n filters: { id: recordId },\n includeCustomFields: true,\n page: { page: 1, pageSize: 1 },\n })\n return res.items[0] as Record<string, unknown> | undefined\n}\n\nfunction resolveCustomerEntityId(record: Record<string, unknown>): string | null {\n const direct =\n record.customer_entity_id ??\n record.entityId ??\n record.entity_id ??\n record.customerEntityId ??\n record.customerEntityID ??\n (typeof record.entity === 'object' && record.entity ? (record.entity as Record<string, unknown>).id : undefined) ??\n (typeof record.customer_entity === 'object' && record.customer_entity ? (record.customer_entity as Record<string, unknown>).id : undefined)\n const value = typeof direct === 'string' && direct.length ? direct : null\n return value\n}\n\nfunction getInlineCustomerEntity(record: Record<string, unknown>): Record<string, unknown> | null {\n const inline =\n (typeof record.entity === 'object' && record.entity) ||\n (typeof record.customer_entity === 'object' && record.customer_entity) ||\n null\n return inline as Record<string, unknown> | null\n}\n\nasync function getLinkedTodo(ctx: SearchContext) {\n if (todoCache.has(ctx.record)) {\n return todoCache.get(ctx.record)\n }\n const sourceRaw = typeof ctx.record.todo_source === 'string' ? ctx.record.todo_source : 'example:todo'\n const [moduleId, entityName] = sourceRaw.split(':')\n const entityId = moduleId && entityName ? `${moduleId}:${entityName}` : 'example:todo'\n const todo = await loadRecord(ctx, entityId, ctx.record.todo_id as string ?? ctx.record.todoId as string)\n todoCache.set(ctx.record, todo ?? null)\n return todo ?? null\n}\n\n// =============================================================================\n// URL and Formatting Helpers\n// =============================================================================\n\nfunction buildCustomerUrl(kind: string | null | undefined, id?: string | null): string | null {\n if (!id) return null\n const encoded = encodeURIComponent(id)\n if (kind === 'person') return `/backend/customers/people/${encoded}`\n if (kind === 'company') return `/backend/customers/companies/${encoded}`\n return `/backend/customers/companies/${encoded}`\n}\n\nfunction formatDealValue(record: Record<string, unknown>): string | undefined {\n const amount = record.value_amount ?? record.valueAmount\n if (!amount) return undefined\n const currency = record.value_currency ?? record.valueCurrency ?? ''\n return currency ? `${amount} ${currency}` : String(amount)\n}\n\nfunction snippet(text: unknown, max = 140): string | undefined {\n if (typeof text !== 'string') return undefined\n const trimmed = text.trim()\n if (!trimmed.length) return undefined\n if (trimmed.length <= max) return trimmed\n return `${trimmed.slice(0, max - 3)}...`\n}\n\nfunction appendLine(lines: string[], label: string, value: unknown) {\n if (value === null || value === undefined) return\n const text = Array.isArray(value)\n ? value.map((item) => (item === null || item === undefined ? '' : String(item))).filter(Boolean).join(', ')\n : (typeof value === 'object' ? JSON.stringify(value) : String(value))\n if (!text.trim()) return\n lines.push(`${label}: ${text}`)\n}\n\nfunction friendlyLabel(input: string): string {\n return input\n .replace(/^cf:/, '')\n .replace(/_/g, ' ')\n .replace(/([a-z])([A-Z])/g, (_, a, b) => `${a} ${b}`)\n .replace(/\\b\\w/g, (char) => char.toUpperCase())\n}\n\nfunction appendCustomFieldLines(lines: string[], customFields: Record<string, unknown>, prefix: string) {\n for (const [key, value] of Object.entries(customFields)) {\n if (value === null || value === undefined) continue\n const label = prefix ? `${prefix} ${friendlyLabel(key)}` : friendlyLabel(key)\n appendLine(lines, label, value)\n }\n}\n\nfunction pickValue(source: Record<string, unknown> | null | undefined, ...keys: string[]): unknown {\n if (!source) return undefined\n for (const key of keys) {\n if (key in source && source[key] != null) return source[key]\n }\n return undefined\n}\n\nfunction pickString(...candidates: unknown[]): string | null {\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.trim().length) {\n return candidate.trim()\n }\n }\n return null\n}\n\nfunction pickLabel(...candidates: Array<unknown>): string | null {\n for (const candidate of candidates) {\n if (candidate === null || candidate === undefined) continue\n const value = typeof candidate === 'string' ? candidate : String(candidate)\n const trimmed = value.trim()\n if (trimmed.length) return trimmed\n }\n return null\n}\n\nfunction appendCustomerEntityLines(\n lines: string[],\n entity: Record<string, unknown> | null,\n contactLabel: 'Customer' | 'Primary' = 'Customer',\n) {\n if (!entity) return\n appendLine(lines, 'Customer', pickValue(entity, 'display_name', 'displayName') ?? entity.id)\n appendLine(lines, `${contactLabel} email`, pickValue(entity, 'primary_email', 'primaryEmail'))\n appendLine(lines, `${contactLabel} phone`, pickValue(entity, 'primary_phone', 'primaryPhone'))\n appendLine(lines, 'Lifecycle stage', pickValue(entity, 'lifecycle_stage', 'lifecycleStage'))\n appendLine(lines, 'Status', pickValue(entity, 'status'))\n}\n\nfunction ensureFallbackLines(lines: string[], record: Record<string, unknown>, options: { includeId?: boolean } = {}) {\n if (lines.length) return\n const excluded = new Set(['tenant_id', 'organization_id', 'created_at', 'updated_at', 'deleted_at'])\n for (const [key, value] of Object.entries(record)) {\n if (value === null || value === undefined) continue\n if (excluded.has(key)) continue\n if (key === 'id') continue\n appendLine(lines, friendlyLabel(key), value)\n }\n if (!lines.length && options.includeId !== false) {\n const fallbackId =\n record.id ??\n record.entity_id ??\n record.customer_entity_id ??\n record.entityId ??\n record.customerEntityId ??\n null\n if (fallbackId) {\n appendLine(lines, 'Record ID', fallbackId)\n }\n }\n}\n\n// =============================================================================\n// Presenter Functions\n// =============================================================================\n\nfunction resolvePersonPresenter(\n record: Record<string, unknown>,\n entity: Record<string, unknown> | null,\n customFields: Record<string, unknown>,\n): SearchResultPresenter {\n const fallbackEntityId = resolveCustomerEntityId(record)\n const firstName = record.first_name ?? record.firstName ?? customFields.first_name ?? customFields.firstName ?? ''\n const lastName = record.last_name ?? record.lastName ?? customFields.last_name ?? customFields.lastName ?? ''\n const nameParts = [firstName, lastName].filter(Boolean).join(' ')\n const title =\n (pickValue(entity, 'display_name', 'displayName') as string | undefined) ??\n (record.preferred_name as string | undefined) ??\n (record.preferredName as string | undefined) ??\n (nameParts.length ? nameParts : undefined) ??\n fallbackEntityId ??\n (record.id as string | undefined) ??\n 'Person'\n const subtitlePieces: string[] = []\n const jobTitle = record.job_title ?? record.jobTitle ?? customFields.job_title ?? customFields.jobTitle\n if (jobTitle) subtitlePieces.push(String(jobTitle))\n const department = record.department ?? customFields.department\n if (department) subtitlePieces.push(String(department))\n const primaryEmail = pickValue(entity, 'primary_email', 'primaryEmail')\n if (primaryEmail) subtitlePieces.push(String(primaryEmail))\n const primaryPhone = pickValue(entity, 'primary_phone', 'primaryPhone')\n if (primaryPhone) subtitlePieces.push(String(primaryPhone))\n const summary = snippet(\n (pickValue(entity, 'description') as string | undefined) ??\n (customFields.summary as string | undefined) ??\n (customFields.description as string | undefined),\n )\n if (summary) subtitlePieces.push(summary)\n return {\n title: String(title),\n subtitle: subtitlePieces.length ? subtitlePieces.join(' \u00B7 ') : undefined,\n icon: 'user',\n badge: pickValue(entity, 'display_name', 'displayName') ? 'Person' : undefined,\n }\n}\n\nfunction resolveCompanyPresenter(\n record: Record<string, unknown>,\n entity: Record<string, unknown> | null,\n customFields: Record<string, unknown>,\n): SearchResultPresenter {\n const fallbackEntityId = resolveCustomerEntityId(record)\n const title =\n (pickValue(entity, 'display_name', 'displayName') as string | undefined) ??\n (customFields.display_name as string | undefined) ??\n (customFields.displayName as string | undefined) ??\n (record.brand_name as string | undefined) ??\n (record.legal_name as string | undefined) ??\n (record.domain as string | undefined) ??\n (record.brandName as string | undefined) ??\n (record.legalName as string | undefined) ??\n (entity?.id && entity?.display_name ? entity.display_name as string : undefined) ??\n fallbackEntityId ??\n (record.id as string | undefined) ??\n 'Company'\n const subtitlePieces: string[] = []\n const industry = record.industry\n if (industry) subtitlePieces.push(String(industry))\n const sizeBucket = record.size_bucket ?? record.sizeBucket\n if (sizeBucket) subtitlePieces.push(String(sizeBucket))\n if (entity) {\n const primaryEmail = pickValue(entity, 'primary_email', 'primaryEmail')\n if (primaryEmail) subtitlePieces.push(String(primaryEmail))\n }\n const summary = snippet(\n (pickValue(entity, 'description') as string | undefined) ??\n (customFields.summary as string | undefined) ??\n (customFields.description as string | undefined) ??\n (record.summary as string | undefined) ??\n (record.description as string | undefined),\n )\n if (summary) subtitlePieces.push(summary)\n if (!entity && (!title || title === fallbackEntityId)) {\n console.warn('[search.customers] Missing customer entity during company presenter build', {\n recordId: record.id ?? null,\n entityId: fallbackEntityId,\n recordKeys: Object.keys(record),\n })\n }\n return {\n title: String(title),\n subtitle: subtitlePieces.length ? subtitlePieces.join(' \u00B7 ') : undefined,\n icon: 'building',\n badge: pickValue(entity, 'display_name', 'displayName') ? 'Company' : undefined,\n }\n}\n\nfunction logMissingPresenterTitle(\n kind: 'person' | 'company',\n record: Record<string, unknown>,\n entity: Record<string, unknown> | null,\n presenter: SearchResultPresenter,\n) {\n const fallbackId = record.id ?? record.entity_id ?? resolveCustomerEntityId(record)\n if (!fallbackId) return\n if (presenter.title && presenter.title !== String(fallbackId)) return\n console.warn('[search.customers] Presenter fell back to record id', {\n kind,\n recordId: fallbackId,\n entityId: resolveCustomerEntityId(record),\n entityDisplayName: entity?.display_name ?? null,\n })\n}\n\n// =============================================================================\n// Search Module Configuration\n// =============================================================================\n\nexport const searchConfig: SearchModuleConfig = {\n entities: [\n // =========================================================================\n // Person Profile\n // =========================================================================\n {\n entityId: 'customers:customer_person_profile',\n enabled: true,\n priority: 10,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const lines: string[] = []\n const record = ctx.record\n appendLine(lines, 'Preferred name', record.preferred_name ?? record.preferredName ?? ctx.customFields.preferred_name)\n appendLine(lines, 'First name', record.first_name ?? record.firstName ?? ctx.customFields.first_name)\n appendLine(lines, 'Last name', record.last_name ?? record.lastName ?? ctx.customFields.last_name)\n appendLine(lines, 'Job title', record.job_title ?? record.jobTitle ?? ctx.customFields.job_title)\n appendLine(lines, 'Department', record.department ?? record.department_name ?? record.departmentName ?? ctx.customFields.department)\n appendLine(lines, 'Seniority', record.seniority ?? record.seniority_level ?? record.seniorityLevel ?? ctx.customFields.seniority)\n appendLine(lines, 'Timezone', record.timezone ?? record.time_zone ?? record.timeZone ?? ctx.customFields.timezone)\n appendLine(lines, 'LinkedIn', record.linked_in_url ?? record.linkedInUrl ?? ctx.customFields.linked_in_url)\n appendLine(lines, 'Twitter', record.twitter_url ?? record.twitterUrl ?? ctx.customFields.twitter_url)\n\n const { entity, entityId, profileCustomFields, entityCustomFields, entityOnlyCustomFields } =\n await hydrateProfileContext(ctx, 'person')\n appendCustomFieldLines(lines, profileCustomFields, 'Person custom')\n if (Object.keys(entityOnlyCustomFields).length) {\n appendCustomFieldLines(lines, entityOnlyCustomFields, 'Customer custom')\n }\n if (!entity) {\n console.warn('[search.customers] Failed to load customer entity for person profile', {\n recordId: record.id,\n entityId,\n recordKeys: Object.keys(record),\n })\n }\n appendCustomerEntityLines(lines, entity, 'Customer')\n ensureFallbackLines(lines, record)\n if (!lines.length) return null\n\n if (!entityId) {\n console.warn('[search.customers] person profile missing entity id', {\n recordId: record.id,\n recordKeys: Object.keys(record),\n })\n }\n\n const presenter = resolvePersonPresenter(record, entity, ctx.customFields)\n logMissingPresenterTitle('person', record, entity, presenter)\n const presenterLabel = pickLabel(presenter.title) ?? 'Open person'\n const links: SearchResultLink[] = []\n if (entityId) {\n const href = buildCustomerUrl('person', entityId)\n if (href) {\n links.push({ href, label: presenterLabel, kind: 'primary' })\n }\n }\n\n return {\n text: lines,\n presenter,\n links,\n checksumSource: {\n record: ctx.record,\n customFields: profileCustomFields,\n entity,\n entityCustomFields,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const entity = await getCustomerEntity(ctx, resolveCustomerEntityId(ctx.record))\n return resolvePersonPresenter(ctx.record, entity, ctx.customFields)\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n const entityId = resolveCustomerEntityId(ctx.record)\n return buildCustomerUrl('person', entityId)\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const entityId = resolveCustomerEntityId(ctx.record)\n if (!entityId) return null\n const href = buildCustomerUrl('person', entityId)\n if (!href) return null\n return [{ href: `${href}/edit`, label: 'Edit', kind: 'secondary' }]\n },\n\n fieldPolicy: {\n searchable: [\n 'preferred_name',\n 'first_name',\n 'last_name',\n 'job_title',\n 'department',\n 'seniority',\n 'timezone',\n 'linked_in_url',\n 'twitter_url',\n ],\n hashOnly: ['primary_email', 'primary_phone', 'personal_email'],\n excluded: ['date_of_birth', 'government_id', 'ssn', 'tax_id'],\n },\n },\n\n // =========================================================================\n // Company Profile\n // =========================================================================\n {\n entityId: 'customers:customer_company_profile',\n enabled: true,\n priority: 10,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const lines: string[] = []\n const record = ctx.record\n appendLine(lines, 'Legal name', record.legal_name ?? record.legalName ?? ctx.customFields.legal_name)\n appendLine(lines, 'Brand name', record.brand_name ?? record.brandName ?? ctx.customFields.brand_name)\n appendLine(lines, 'Domain', record.domain ?? record.website_domain ?? record.websiteDomain ?? ctx.customFields.domain)\n appendLine(lines, 'Website', record.website_url ?? record.websiteUrl ?? ctx.customFields.website_url)\n appendLine(lines, 'Industry', record.industry ?? ctx.customFields.industry)\n appendLine(lines, 'Company size', record.size_bucket ?? record.sizeBucket ?? ctx.customFields.size_bucket)\n appendLine(lines, 'Annual revenue', record.annual_revenue ?? record.annualRevenue ?? ctx.customFields.annual_revenue)\n\n const { entity, entityId, profileCustomFields, entityCustomFields, entityOnlyCustomFields } =\n await hydrateProfileContext(ctx, 'company')\n appendCustomFieldLines(lines, profileCustomFields, 'Company custom')\n if (Object.keys(entityOnlyCustomFields).length) {\n appendCustomFieldLines(lines, entityOnlyCustomFields, 'Customer custom')\n }\n appendCustomerEntityLines(lines, entity, 'Primary')\n ensureFallbackLines(lines, record)\n if (!lines.length) return null\n\n const presenter = resolveCompanyPresenter(record, entity, ctx.customFields)\n logMissingPresenterTitle('company', record, entity, presenter)\n const primaryLabel = pickLabel(presenter.title) ?? 'Open company'\n const links: SearchResultLink[] = []\n if (entityId) {\n const href = buildCustomerUrl('company', entityId)\n if (href) {\n links.push({ href, label: primaryLabel, kind: 'primary' })\n }\n }\n\n return {\n text: lines,\n presenter,\n links,\n checksumSource: {\n record: ctx.record,\n customFields: profileCustomFields,\n entity,\n entityCustomFields,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const entity = await getCustomerEntity(ctx, resolveCustomerEntityId(ctx.record))\n return resolveCompanyPresenter(ctx.record, entity, ctx.customFields)\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n const entityId = resolveCustomerEntityId(ctx.record)\n return buildCustomerUrl('company', entityId)\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const entityId = resolveCustomerEntityId(ctx.record)\n if (!entityId) return null\n const href = buildCustomerUrl('company', entityId)\n if (!href) return null\n return [{ href: `${href}/edit`, label: 'Edit', kind: 'secondary' }]\n },\n\n fieldPolicy: {\n searchable: [\n 'legal_name',\n 'brand_name',\n 'display_name',\n 'domain',\n 'website_url',\n 'industry',\n 'size_bucket',\n 'description',\n ],\n hashOnly: ['tax_id', 'registration_number'],\n excluded: ['bank_account', 'billing_info', 'credit_info'],\n },\n },\n\n // =========================================================================\n // Customer Comment\n // =========================================================================\n {\n entityId: 'customers:customer_comment',\n enabled: true,\n priority: 6,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const lines: string[] = []\n if (parent?.display_name) lines.push(`Customer: ${parent.display_name}`)\n lines.push(`Note: ${ctx.record.body ?? ''}`)\n if (ctx.record.appearance_icon) lines.push(`Icon: ${ctx.record.appearance_icon}`)\n if (ctx.record.appearance_color) lines.push(`Color: ${ctx.record.appearance_color}`)\n\n const presenter: SearchResultPresenter | undefined = parent?.display_name\n ? {\n title: parent.display_name as string,\n subtitle: snippet(ctx.record.body),\n icon: parent.kind === 'person' ? 'user' : 'building',\n }\n : undefined\n\n return {\n text: lines,\n presenter,\n checksumSource: {\n body: ctx.record.body,\n entityId: ctx.record.entity_id ?? null,\n updatedAt: ctx.record.updated_at ?? ctx.record.updatedAt ?? null,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const title = (parent?.display_name as string | undefined) ?? 'Customer note'\n return {\n title,\n subtitle: snippet(ctx.record.body),\n icon: 'sticky-note',\n }\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const base = buildCustomerUrl(parent?.kind as string ?? null, (parent?.id ?? ctx.record.entity_id ?? ctx.record.entityId) as string)\n return base ? `${base}#notes` : null\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n assertTenantContext(ctx)\n const links: SearchResultLink[] = []\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const parentUrl = buildCustomerUrl(parent?.kind as string ?? null, (parent?.id ?? ctx.record.entity_id ?? ctx.record.entityId) as string)\n if (parentUrl) {\n links.push({ href: parentUrl, label: (parent?.display_name as string | undefined) ?? 'View customer', kind: 'primary' })\n }\n if (ctx.record.deal_id) {\n const dealUrl = `/backend/customers/deals/${encodeURIComponent(ctx.record.deal_id as string)}`\n links.push({ href: dealUrl, label: 'Open deal', kind: 'secondary' })\n }\n return links.length ? links : null\n },\n\n fieldPolicy: {\n searchable: ['body'],\n hashOnly: [],\n excluded: [],\n },\n },\n\n // =========================================================================\n // Customer Deal\n // =========================================================================\n {\n entityId: 'customers:customer_deal',\n enabled: true,\n priority: 8,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n const lines: string[] = []\n const record = ctx.record\n appendLine(lines, 'Title', record.title)\n appendLine(lines, 'Stage', record.pipeline_stage)\n appendLine(lines, 'Status', record.status)\n appendLine(lines, 'Source', record.source)\n const value = formatDealValue(record)\n if (value) appendLine(lines, 'Value', value)\n if (!lines.length) return null\n\n const subtitleParts: string[] = []\n if (record.pipeline_stage) subtitleParts.push(String(record.pipeline_stage))\n if (record.status) subtitleParts.push(String(record.status))\n if (value) subtitleParts.push(value)\n\n return {\n text: lines,\n presenter: {\n title: String(record.title ?? 'Deal'),\n subtitle: subtitleParts.join(' \u00B7 ') || undefined,\n icon: 'briefcase',\n badge: 'Deal',\n },\n checksumSource: {\n title: record.title,\n status: record.status,\n stage: record.pipeline_stage,\n value: value,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n const { record } = ctx\n const title = pickString(record.title as string, 'Deal')\n const subtitleParts: string[] = []\n if (record.pipeline_stage) subtitleParts.push(String(record.pipeline_stage))\n if (record.status) subtitleParts.push(String(record.status))\n const amount = record.value_amount ?? record.valueAmount\n const currency = record.value_currency ?? record.valueCurrency\n if (amount) {\n subtitleParts.push(currency ? `${amount} ${currency}` : String(amount))\n }\n\n return {\n title: title ?? 'Deal',\n subtitle: subtitleParts.length ? subtitleParts.join(' \u00B7 ') : undefined,\n icon: 'briefcase',\n badge: 'Deal',\n }\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n const id = ctx.record.id\n if (!id) return null\n return `/backend/customers/deals/${encodeURIComponent(String(id))}`\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const id = ctx.record.id\n if (!id) return null\n return [\n {\n href: `/backend/customers/deals/${encodeURIComponent(String(id))}/edit`,\n label: 'Edit',\n kind: 'secondary',\n },\n ]\n },\n\n fieldPolicy: {\n searchable: ['title', 'description', 'pipeline_stage', 'status', 'source'],\n hashOnly: [],\n excluded: ['value_amount', 'value_currency'],\n },\n },\n\n // =========================================================================\n // Customer Activity\n // =========================================================================\n {\n entityId: 'customers:customer_activity',\n enabled: true,\n priority: 5,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const lines: string[] = []\n if (parent?.display_name) lines.push(`Customer: ${parent.display_name}`)\n if (ctx.record.activity_type) lines.push(`Type: ${ctx.record.activity_type}`)\n if (ctx.record.subject) lines.push(`Subject: ${ctx.record.subject}`)\n if (ctx.record.body) lines.push(`Body: ${ctx.record.body}`)\n\n const presenter: SearchResultPresenter = {\n title: ctx.record.subject ? String(ctx.record.subject) : `Activity: ${ctx.record.activity_type ?? 'update'}`,\n subtitle: (parent?.display_name as string | undefined) ?? snippet(ctx.record.body),\n icon: 'bolt',\n }\n\n return {\n text: lines,\n presenter,\n checksumSource: {\n subject: ctx.record.subject,\n body: ctx.record.body,\n entityId: ctx.record.entity_id ?? null,\n updatedAt: ctx.record.updated_at ?? ctx.record.updatedAt ?? null,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n return {\n title: ctx.record.subject ? String(ctx.record.subject) : `Activity: ${ctx.record.activity_type ?? 'update'}`,\n subtitle: (parent?.display_name as string | undefined) ?? snippet(ctx.record.body),\n icon: 'bolt',\n badge: 'Activity',\n }\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const base = buildCustomerUrl(parent?.kind as string ?? null, (parent?.id ?? ctx.record.entity_id ?? ctx.record.entityId) as string)\n return base ? `${base}#activity-${ctx.record.id ?? ctx.record.activity_id ?? ''}` : null\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const links: SearchResultLink[] = []\n if (ctx.record.deal_id) {\n links.push({\n href: `/backend/customers/deals/${encodeURIComponent(ctx.record.deal_id as string)}`,\n label: 'Open deal',\n kind: 'secondary',\n })\n }\n return links.length ? links : null\n },\n\n fieldPolicy: {\n searchable: ['subject', 'body', 'activity_type'],\n hashOnly: [],\n excluded: [],\n },\n },\n\n // =========================================================================\n // Customer Todo Link\n // =========================================================================\n {\n entityId: 'customers:customer_todo_link',\n enabled: true,\n priority: 4,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const todo = await getLinkedTodo(ctx) as Record<string, unknown> | null\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const lines: string[] = []\n if (todo?.title) lines.push(`Todo: ${todo.title}`)\n if (todo?.is_done !== undefined) lines.push(`Status: ${todo.is_done ? 'Done' : 'Open'}`)\n if (parent?.display_name) lines.push(`Customer: ${parent.display_name}`)\n if (!lines.length) return null\n\n return {\n text: lines,\n presenter: todo?.title\n ? { title: todo.title as string, subtitle: parent?.display_name as string | undefined, icon: 'check-square' }\n : undefined,\n checksumSource: {\n todoId: ctx.record.todo_id ?? ctx.record.todoId,\n todoSource: ctx.record.todo_source ?? ctx.record.todoSource,\n entityId: ctx.record.entity_id ?? ctx.record.entityId,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const todo = await getLinkedTodo(ctx) as Record<string, unknown> | null\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n return {\n title: (todo?.title as string | undefined) ?? 'Customer task',\n subtitle: parent?.display_name as string | undefined,\n icon: 'check-square',\n }\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const base = buildCustomerUrl(parent?.kind as string ?? null, (parent?.id ?? ctx.record.entity_id ?? ctx.record.entityId) as string)\n return base ? `${base}#tasks` : null\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const todoId = ctx.record.todo_id ?? ctx.record.todoId\n if (!todoId) return null\n return [{\n href: `/backend/todos/${encodeURIComponent(todoId as string)}/edit`,\n label: 'Open todo',\n kind: 'secondary',\n }]\n },\n\n fieldPolicy: {\n searchable: [],\n hashOnly: [],\n excluded: [],\n },\n },\n ],\n}\n\nexport default searchConfig\nexport const config = searchConfig\n"],
5
- "mappings": "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AM;AAAA,QACR;AAAA,MACF;AAAA,MAEA,YAAY,OAAO,QAAoD;AACrE,4BAAoB,GAAG;AACvB,cAAM,SAAS,MAAM,kBAAkB,KAAK,IAAI,OAAO,aAAuB,IAAI,OAAO,QAAkB;AAC3G,cAAM,OAAO,iBAAiB,QAAQ,QAAkB,MAAO,QAAQ,MAAM,IAAI,OAAO,aAAa,IAAI,OAAO,QAAmB;AACnI,eAAO,OAAO,GAAG,IAAI,WAAW;AAAA,MAClC;AAAA,MAEA,cAAc,OAAO,QAAgE;AACnF,cAAM,SAAS,IAAI,OAAO,WAAW,IAAI,OAAO;AAChD,YAAI,CAAC,OAAQ,QAAO;AACpB,eAAO,CAAC;AAAA,UACN,MAAM,kBAAkB,mBAAmB,MAAgB,CAAC;AAAA,UAC5D,OAAO;AAAA,UACP,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AAAA,MAEA,aAAa;AAAA,QACX,YAAY,CAAC;AAAA,QACb,UAAU,CAAC;AAAA,QACX,UAAU,CAAC;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,iBAAQ;AACR,MAAM,SAAS;",
4
+ "sourcesContent": ["import type { QueryCustomFieldSource, QueryEngine } from '@open-mercato/shared/lib/query/types'\nimport type {\n SearchModuleConfig,\n SearchBuildContext,\n SearchResultPresenter,\n SearchResultLink,\n SearchIndexSource,\n} from '@open-mercato/shared/modules/search'\nimport { CUSTOMER_INTERACTION_TASK_SOURCE, EXAMPLE_TODO_SOURCE } from './lib/interactionCompatibility'\n\n// =============================================================================\n// Context Types\n// =============================================================================\n\ntype SearchContext = SearchBuildContext & {\n tenantId: string\n queryEngine?: QueryEngine\n}\n\nfunction assertTenantContext(ctx: SearchBuildContext): asserts ctx is SearchContext {\n if (typeof ctx.tenantId !== 'string' || ctx.tenantId.length === 0) {\n throw new Error('[search.customers] Missing tenantId in search build context')\n }\n}\n\ntype CustomerProfileKind = 'person' | 'company'\n\ntype LoadedCustomerEntity = {\n entity: Record<string, unknown> | null\n customFields: Record<string, unknown>\n}\n\n// =============================================================================\n// Caching\n// =============================================================================\n\nconst entityIdCache = new Map<string, LoadedCustomerEntity | null>()\nconst profileEntityCache = new WeakMap<Record<string, unknown>, Partial<Record<CustomerProfileKind, LoadedCustomerEntity | null>>>()\nconst todoCache = new WeakMap<Record<string, unknown>, unknown>()\n\n// =============================================================================\n// Query Configuration\n// =============================================================================\n\nconst CUSTOMER_ENTITY_FIELDS = [\n 'id',\n 'kind',\n 'display_name',\n 'description',\n 'primary_email',\n 'primary_phone',\n 'status',\n 'lifecycle_stage',\n 'owner_user_id',\n 'source',\n 'next_interaction_at',\n 'next_interaction_name',\n 'next_interaction_ref_id',\n 'next_interaction_icon',\n 'next_interaction_color',\n 'organization_id',\n 'tenant_id',\n 'created_at',\n 'updated_at',\n 'deleted_at',\n] satisfies string[]\n\nconst CUSTOMER_CUSTOM_FIELD_SOURCES: QueryCustomFieldSource[] = [\n {\n entityId: 'customers:customer_person_profile',\n table: 'customer_people',\n alias: 'person_profile',\n recordIdColumn: 'id',\n join: { fromField: 'id', toField: 'entity_id' },\n },\n {\n entityId: 'customers:customer_company_profile',\n table: 'customer_companies',\n alias: 'company_profile',\n recordIdColumn: 'id',\n join: { fromField: 'id', toField: 'entity_id' },\n },\n]\n\n// =============================================================================\n// Helper Functions\n// =============================================================================\n\nfunction extractCustomFieldMap(source: Record<string, unknown> | null | undefined): Record<string, unknown> {\n if (!source) return {}\n const result: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(source)) {\n if (value === undefined) continue\n if (key.startsWith('cf:')) {\n result[key.slice(3)] = value\n } else if (key.startsWith('cf_')) {\n result[key.slice(3)] = value\n }\n }\n return result\n}\n\nfunction normalizeCustomerEntity(row: Record<string, unknown>): Record<string, unknown> {\n const normalized: Record<string, unknown> = {\n id: row.id ?? row.entity_id ?? row.entityId ?? null,\n kind: row.kind ?? null,\n }\n const assign = (snake: string, camel?: string) => {\n const value = row[snake] ?? (camel ? row[camel] : undefined)\n if (value !== undefined) {\n normalized[snake] = value\n if (camel) normalized[camel] = value\n }\n }\n assign('display_name', 'displayName')\n assign('description')\n assign('primary_email', 'primaryEmail')\n assign('primary_phone', 'primaryPhone')\n assign('status')\n assign('lifecycle_stage', 'lifecycleStage')\n assign('owner_user_id', 'ownerUserId')\n assign('source')\n assign('next_interaction_at', 'nextInteractionAt')\n assign('next_interaction_name', 'nextInteractionName')\n assign('next_interaction_ref_id', 'nextInteractionRefId')\n assign('next_interaction_icon', 'nextInteractionIcon')\n assign('next_interaction_color', 'nextInteractionColor')\n assign('organization_id', 'organizationId')\n assign('tenant_id', 'tenantId')\n assign('created_at', 'createdAt')\n assign('updated_at', 'updatedAt')\n assign('deleted_at', 'deletedAt')\n return normalized\n}\n\nfunction getProfileCache(record: Record<string, unknown>): Partial<Record<CustomerProfileKind, LoadedCustomerEntity | null>> {\n let cache = profileEntityCache.get(record)\n if (!cache) {\n cache = {}\n profileEntityCache.set(record, cache)\n }\n return cache\n}\n\nfunction subtractCustomFields(\n primary: Record<string, unknown>,\n secondary: Record<string, unknown>,\n): Record<string, unknown> {\n if (!secondary || Object.keys(secondary).length === 0) return {}\n const primaryKeys = new Set(Object.keys(primary))\n const result: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(secondary)) {\n if (!primaryKeys.has(key)) {\n result[key] = value\n }\n }\n return result\n}\n\n// =============================================================================\n// Entity Loading Functions\n// =============================================================================\n\ntype CustomerEntityQueryOptions = {\n entityId?: string | null\n profileKind?: CustomerProfileKind\n profileId?: string | null\n}\n\nasync function loadCustomerEntityBundle(ctx: SearchContext, opts: CustomerEntityQueryOptions): Promise<LoadedCustomerEntity | null> {\n if (!ctx.queryEngine) return null\n const filters: Record<string, unknown> = {}\n const resolvedEntityId = typeof opts.entityId === 'string' && opts.entityId.length ? opts.entityId : null\n const resolvedProfileId =\n opts.profileId != null && String(opts.profileId).trim().length > 0 ? String(opts.profileId).trim() : null\n if (resolvedEntityId) {\n filters.id = { $eq: resolvedEntityId }\n }\n if (opts.profileKind && resolvedProfileId) {\n const alias = opts.profileKind === 'person' ? 'person_profile' : 'company_profile'\n filters[`${alias}.id`] = { $eq: resolvedProfileId }\n }\n if (!Object.keys(filters).length) return null\n try {\n const result = await ctx.queryEngine.query('customers:customer_entity', {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId ?? undefined,\n filters,\n includeCustomFields: true,\n customFieldSources: CUSTOMER_CUSTOM_FIELD_SOURCES,\n fields: CUSTOMER_ENTITY_FIELDS,\n page: { page: 1, pageSize: 1 },\n })\n const row = result.items[0] as Record<string, unknown> | undefined\n if (!row) return null\n const entity = normalizeCustomerEntity(row)\n const customFields = extractCustomFieldMap(row)\n return { entity, customFields }\n } catch (error) {\n console.warn('[search.customers] Failed to load customer entity via QueryEngine', {\n entityId: resolvedEntityId ?? null,\n profileKind: opts.profileKind ?? null,\n profileId: resolvedProfileId ?? null,\n error: error instanceof Error ? error.message : error,\n })\n return null\n }\n}\n\nasync function loadCustomerEntityForProfile(ctx: SearchContext, kind: CustomerProfileKind): Promise<LoadedCustomerEntity | null> {\n const cache = getProfileCache(ctx.record)\n if (cache[kind] !== undefined) return cache[kind] ?? null\n const entityIdHint = resolveCustomerEntityId(ctx.record)\n const profileIdRaw = ctx.record.id ?? null\n const profileId = profileIdRaw != null ? String(profileIdRaw) : null\n if (!entityIdHint && !profileId) {\n cache[kind] = null\n return null\n }\n const loaded = await loadCustomerEntityBundle(ctx, {\n entityId: entityIdHint,\n profileKind: kind,\n profileId,\n })\n cache[kind] = loaded ?? null\n const resolvedId = loaded?.entity?.id ?? entityIdHint\n if (resolvedId && typeof resolvedId === 'string') {\n ctx.record.entity_id ??= resolvedId\n ctx.record.entityId ??= resolvedId\n entityIdCache.set(resolvedId, loaded ?? null)\n }\n if (loaded?.entity) {\n if (!ctx.record.entity) ctx.record.entity = loaded.entity\n if (!ctx.record.customer_entity) ctx.record.customer_entity = loaded.entity\n }\n return loaded ?? null\n}\n\nasync function loadCustomerEntityById(ctx: SearchContext, entityId: string | null | undefined): Promise<LoadedCustomerEntity | null> {\n const resolvedId = typeof entityId === 'string' && entityId.length ? entityId : null\n if (!resolvedId) return null\n if (entityIdCache.has(resolvedId)) {\n return entityIdCache.get(resolvedId) ?? null\n }\n const loaded = await loadCustomerEntityBundle(ctx, { entityId: resolvedId })\n entityIdCache.set(resolvedId, loaded ?? null)\n return loaded ?? null\n}\n\nasync function getCustomerEntity(ctx: SearchContext, entityId?: string | null): Promise<Record<string, unknown> | null> {\n const profileCache = profileEntityCache.get(ctx.record)\n if (profileCache) {\n const cached = Object.values(profileCache).find((entry) => {\n if (!entry?.entity) return false\n if (!entityId) return true\n return entry.entity.id === entityId\n })\n if (cached?.entity) return cached.entity\n }\n const inline = getInlineCustomerEntity(ctx.record)\n if (inline && (!entityId || inline.id === entityId)) {\n if (inline.id && typeof inline.id === 'string') {\n entityIdCache.set(inline.id, { entity: inline, customFields: {} })\n }\n return inline\n }\n const resolvedId = entityId ?? resolveCustomerEntityId(ctx.record)\n const loaded = await loadCustomerEntityById(ctx, resolvedId)\n return loaded?.entity ?? null\n}\n\ntype HydratedProfileContext = {\n entity: Record<string, unknown> | null\n entityId: string | null\n profileCustomFields: Record<string, unknown>\n entityCustomFields: Record<string, unknown>\n entityOnlyCustomFields: Record<string, unknown>\n}\n\nasync function hydrateProfileContext(ctx: SearchContext, kind: CustomerProfileKind): Promise<HydratedProfileContext> {\n const profileCustomFields = ctx.customFields ?? {}\n const loaded = await loadCustomerEntityForProfile(ctx, kind)\n let entity = loaded?.entity ?? getInlineCustomerEntity(ctx.record)\n let entityCustomFields = loaded?.customFields ?? {}\n let entityId = (entity?.id as string | undefined) ?? resolveCustomerEntityId(ctx.record)\n if (!entity && entityId) {\n const fetched = await loadCustomerEntityById(ctx, entityId)\n entity = fetched?.entity ?? null\n if (fetched?.customFields) {\n entityCustomFields = Object.keys(entityCustomFields).length ? entityCustomFields : fetched.customFields\n }\n }\n if (!entity && !entityId) {\n entityId = resolveCustomerEntityId(ctx.record)\n }\n if (entity?.id && typeof entity.id === 'string') {\n entityId = entity.id\n ctx.record.entity_id ??= entity.id\n ctx.record.entityId ??= entity.id\n if (!ctx.record.entity) ctx.record.entity = entity\n if (!ctx.record.customer_entity) ctx.record.customer_entity = entity\n }\n const entityOnlyCustomFields = subtractCustomFields(profileCustomFields, entityCustomFields)\n return {\n entity: entity ?? null,\n entityId: entityId ?? null,\n profileCustomFields,\n entityCustomFields,\n entityOnlyCustomFields,\n }\n}\n\nasync function loadRecord(ctx: SearchContext, entityId: string, recordId?: string | null) {\n if (!recordId || !ctx.queryEngine) return null\n const res = await ctx.queryEngine.query(entityId, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId ?? undefined,\n filters: { id: recordId },\n includeCustomFields: true,\n page: { page: 1, pageSize: 1 },\n })\n return res.items[0] as Record<string, unknown> | undefined\n}\n\nfunction resolveCustomerEntityId(record: Record<string, unknown>): string | null {\n const direct =\n record.customer_entity_id ??\n record.entityId ??\n record.entity_id ??\n record.customerEntityId ??\n record.customerEntityID ??\n (typeof record.entity === 'object' && record.entity ? (record.entity as Record<string, unknown>).id : undefined) ??\n (typeof record.customer_entity === 'object' && record.customer_entity ? (record.customer_entity as Record<string, unknown>).id : undefined)\n const value = typeof direct === 'string' && direct.length ? direct : null\n return value\n}\n\nfunction getInlineCustomerEntity(record: Record<string, unknown>): Record<string, unknown> | null {\n const inline =\n (typeof record.entity === 'object' && record.entity) ||\n (typeof record.customer_entity === 'object' && record.customer_entity) ||\n null\n return inline as Record<string, unknown> | null\n}\n\nasync function getLinkedTodo(ctx: SearchContext) {\n if (todoCache.has(ctx.record)) {\n return todoCache.get(ctx.record)\n }\n const sourceRaw = typeof ctx.record.todo_source === 'string' ? ctx.record.todo_source : EXAMPLE_TODO_SOURCE\n const [moduleId, entityName] = sourceRaw.split(':')\n const entityId = moduleId && entityName ? `${moduleId}:${entityName}` : CUSTOMER_INTERACTION_TASK_SOURCE\n const todo = await loadRecord(ctx, entityId, ctx.record.todo_id as string ?? ctx.record.todoId as string)\n todoCache.set(ctx.record, todo ?? null)\n return todo ?? null\n}\n\n// =============================================================================\n// URL and Formatting Helpers\n// =============================================================================\n\nfunction buildCustomerUrl(kind: string | null | undefined, id?: string | null): string | null {\n if (!id) return null\n const encoded = encodeURIComponent(id)\n if (kind === 'person') return `/backend/customers/people/${encoded}`\n if (kind === 'company') return `/backend/customers/companies/${encoded}`\n return `/backend/customers/companies/${encoded}`\n}\n\nfunction formatDealValue(record: Record<string, unknown>): string | undefined {\n const amount = record.value_amount ?? record.valueAmount\n if (!amount) return undefined\n const currency = record.value_currency ?? record.valueCurrency ?? ''\n return currency ? `${amount} ${currency}` : String(amount)\n}\n\nfunction snippet(text: unknown, max = 140): string | undefined {\n if (typeof text !== 'string') return undefined\n const trimmed = text.trim()\n if (!trimmed.length) return undefined\n if (trimmed.length <= max) return trimmed\n return `${trimmed.slice(0, max - 3)}...`\n}\n\nfunction appendLine(lines: string[], label: string, value: unknown) {\n if (value === null || value === undefined) return\n const text = Array.isArray(value)\n ? value.map((item) => (item === null || item === undefined ? '' : String(item))).filter(Boolean).join(', ')\n : (typeof value === 'object' ? JSON.stringify(value) : String(value))\n if (!text.trim()) return\n lines.push(`${label}: ${text}`)\n}\n\nfunction friendlyLabel(input: string): string {\n return input\n .replace(/^cf:/, '')\n .replace(/_/g, ' ')\n .replace(/([a-z])([A-Z])/g, (_, a, b) => `${a} ${b}`)\n .replace(/\\b\\w/g, (char) => char.toUpperCase())\n}\n\nfunction appendCustomFieldLines(lines: string[], customFields: Record<string, unknown>, prefix: string) {\n for (const [key, value] of Object.entries(customFields)) {\n if (value === null || value === undefined) continue\n const label = prefix ? `${prefix} ${friendlyLabel(key)}` : friendlyLabel(key)\n appendLine(lines, label, value)\n }\n}\n\nfunction pickValue(source: Record<string, unknown> | null | undefined, ...keys: string[]): unknown {\n if (!source) return undefined\n for (const key of keys) {\n if (key in source && source[key] != null) return source[key]\n }\n return undefined\n}\n\nfunction pickString(...candidates: unknown[]): string | null {\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.trim().length) {\n return candidate.trim()\n }\n }\n return null\n}\n\nfunction pickLabel(...candidates: Array<unknown>): string | null {\n for (const candidate of candidates) {\n if (candidate === null || candidate === undefined) continue\n const value = typeof candidate === 'string' ? candidate : String(candidate)\n const trimmed = value.trim()\n if (trimmed.length) return trimmed\n }\n return null\n}\n\nfunction appendCustomerEntityLines(\n lines: string[],\n entity: Record<string, unknown> | null,\n contactLabel: 'Customer' | 'Primary' = 'Customer',\n) {\n if (!entity) return\n appendLine(lines, 'Customer', pickValue(entity, 'display_name', 'displayName') ?? entity.id)\n appendLine(lines, `${contactLabel} email`, pickValue(entity, 'primary_email', 'primaryEmail'))\n appendLine(lines, `${contactLabel} phone`, pickValue(entity, 'primary_phone', 'primaryPhone'))\n appendLine(lines, 'Lifecycle stage', pickValue(entity, 'lifecycle_stage', 'lifecycleStage'))\n appendLine(lines, 'Status', pickValue(entity, 'status'))\n}\n\nfunction ensureFallbackLines(lines: string[], record: Record<string, unknown>, options: { includeId?: boolean } = {}) {\n if (lines.length) return\n const excluded = new Set(['tenant_id', 'organization_id', 'created_at', 'updated_at', 'deleted_at'])\n for (const [key, value] of Object.entries(record)) {\n if (value === null || value === undefined) continue\n if (excluded.has(key)) continue\n if (key === 'id') continue\n appendLine(lines, friendlyLabel(key), value)\n }\n if (!lines.length && options.includeId !== false) {\n const fallbackId =\n record.id ??\n record.entity_id ??\n record.customer_entity_id ??\n record.entityId ??\n record.customerEntityId ??\n null\n if (fallbackId) {\n appendLine(lines, 'Record ID', fallbackId)\n }\n }\n}\n\n// =============================================================================\n// Presenter Functions\n// =============================================================================\n\nfunction resolvePersonPresenter(\n record: Record<string, unknown>,\n entity: Record<string, unknown> | null,\n customFields: Record<string, unknown>,\n): SearchResultPresenter {\n const fallbackEntityId = resolveCustomerEntityId(record)\n const firstName = record.first_name ?? record.firstName ?? customFields.first_name ?? customFields.firstName ?? ''\n const lastName = record.last_name ?? record.lastName ?? customFields.last_name ?? customFields.lastName ?? ''\n const nameParts = [firstName, lastName].filter(Boolean).join(' ')\n const title =\n (pickValue(entity, 'display_name', 'displayName') as string | undefined) ??\n (record.preferred_name as string | undefined) ??\n (record.preferredName as string | undefined) ??\n (nameParts.length ? nameParts : undefined) ??\n fallbackEntityId ??\n (record.id as string | undefined) ??\n 'Person'\n const subtitlePieces: string[] = []\n const jobTitle = record.job_title ?? record.jobTitle ?? customFields.job_title ?? customFields.jobTitle\n if (jobTitle) subtitlePieces.push(String(jobTitle))\n const department = record.department ?? customFields.department\n if (department) subtitlePieces.push(String(department))\n const primaryEmail = pickValue(entity, 'primary_email', 'primaryEmail')\n if (primaryEmail) subtitlePieces.push(String(primaryEmail))\n const primaryPhone = pickValue(entity, 'primary_phone', 'primaryPhone')\n if (primaryPhone) subtitlePieces.push(String(primaryPhone))\n const summary = snippet(\n (pickValue(entity, 'description') as string | undefined) ??\n (customFields.summary as string | undefined) ??\n (customFields.description as string | undefined),\n )\n if (summary) subtitlePieces.push(summary)\n return {\n title: String(title),\n subtitle: subtitlePieces.length ? subtitlePieces.join(' \u00B7 ') : undefined,\n icon: 'user',\n badge: pickValue(entity, 'display_name', 'displayName') ? 'Person' : undefined,\n }\n}\n\nfunction resolveCompanyPresenter(\n record: Record<string, unknown>,\n entity: Record<string, unknown> | null,\n customFields: Record<string, unknown>,\n): SearchResultPresenter {\n const fallbackEntityId = resolveCustomerEntityId(record)\n const title =\n (pickValue(entity, 'display_name', 'displayName') as string | undefined) ??\n (customFields.display_name as string | undefined) ??\n (customFields.displayName as string | undefined) ??\n (record.brand_name as string | undefined) ??\n (record.legal_name as string | undefined) ??\n (record.domain as string | undefined) ??\n (record.brandName as string | undefined) ??\n (record.legalName as string | undefined) ??\n (entity?.id && entity?.display_name ? entity.display_name as string : undefined) ??\n fallbackEntityId ??\n (record.id as string | undefined) ??\n 'Company'\n const subtitlePieces: string[] = []\n const industry = record.industry\n if (industry) subtitlePieces.push(String(industry))\n const sizeBucket = record.size_bucket ?? record.sizeBucket\n if (sizeBucket) subtitlePieces.push(String(sizeBucket))\n if (entity) {\n const primaryEmail = pickValue(entity, 'primary_email', 'primaryEmail')\n if (primaryEmail) subtitlePieces.push(String(primaryEmail))\n }\n const summary = snippet(\n (pickValue(entity, 'description') as string | undefined) ??\n (customFields.summary as string | undefined) ??\n (customFields.description as string | undefined) ??\n (record.summary as string | undefined) ??\n (record.description as string | undefined),\n )\n if (summary) subtitlePieces.push(summary)\n if (!entity && (!title || title === fallbackEntityId)) {\n console.warn('[search.customers] Missing customer entity during company presenter build', {\n recordId: record.id ?? null,\n entityId: fallbackEntityId,\n recordKeys: Object.keys(record),\n })\n }\n return {\n title: String(title),\n subtitle: subtitlePieces.length ? subtitlePieces.join(' \u00B7 ') : undefined,\n icon: 'building',\n badge: pickValue(entity, 'display_name', 'displayName') ? 'Company' : undefined,\n }\n}\n\nfunction logMissingPresenterTitle(\n kind: 'person' | 'company',\n record: Record<string, unknown>,\n entity: Record<string, unknown> | null,\n presenter: SearchResultPresenter,\n) {\n const fallbackId = record.id ?? record.entity_id ?? resolveCustomerEntityId(record)\n if (!fallbackId) return\n if (presenter.title && presenter.title !== String(fallbackId)) return\n console.warn('[search.customers] Presenter fell back to record id', {\n kind,\n recordId: fallbackId,\n entityId: resolveCustomerEntityId(record),\n entityDisplayName: entity?.display_name ?? null,\n })\n}\n\n// =============================================================================\n// Search Module Configuration\n// =============================================================================\n\nexport const searchConfig: SearchModuleConfig = {\n entities: [\n // =========================================================================\n // Person Profile\n // =========================================================================\n {\n entityId: 'customers:customer_person_profile',\n enabled: true,\n priority: 10,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const lines: string[] = []\n const record = ctx.record\n appendLine(lines, 'Preferred name', record.preferred_name ?? record.preferredName ?? ctx.customFields.preferred_name)\n appendLine(lines, 'First name', record.first_name ?? record.firstName ?? ctx.customFields.first_name)\n appendLine(lines, 'Last name', record.last_name ?? record.lastName ?? ctx.customFields.last_name)\n appendLine(lines, 'Job title', record.job_title ?? record.jobTitle ?? ctx.customFields.job_title)\n appendLine(lines, 'Department', record.department ?? record.department_name ?? record.departmentName ?? ctx.customFields.department)\n appendLine(lines, 'Seniority', record.seniority ?? record.seniority_level ?? record.seniorityLevel ?? ctx.customFields.seniority)\n appendLine(lines, 'Timezone', record.timezone ?? record.time_zone ?? record.timeZone ?? ctx.customFields.timezone)\n appendLine(lines, 'LinkedIn', record.linked_in_url ?? record.linkedInUrl ?? ctx.customFields.linked_in_url)\n appendLine(lines, 'Twitter', record.twitter_url ?? record.twitterUrl ?? ctx.customFields.twitter_url)\n\n const { entity, entityId, profileCustomFields, entityCustomFields, entityOnlyCustomFields } =\n await hydrateProfileContext(ctx, 'person')\n appendCustomFieldLines(lines, profileCustomFields, 'Person custom')\n if (Object.keys(entityOnlyCustomFields).length) {\n appendCustomFieldLines(lines, entityOnlyCustomFields, 'Customer custom')\n }\n if (!entity) {\n console.warn('[search.customers] Failed to load customer entity for person profile', {\n recordId: record.id,\n entityId,\n recordKeys: Object.keys(record),\n })\n }\n appendCustomerEntityLines(lines, entity, 'Customer')\n ensureFallbackLines(lines, record)\n if (!lines.length) return null\n\n if (!entityId) {\n console.warn('[search.customers] person profile missing entity id', {\n recordId: record.id,\n recordKeys: Object.keys(record),\n })\n }\n\n const presenter = resolvePersonPresenter(record, entity, ctx.customFields)\n logMissingPresenterTitle('person', record, entity, presenter)\n const presenterLabel = pickLabel(presenter.title) ?? 'Open person'\n const links: SearchResultLink[] = []\n if (entityId) {\n const href = buildCustomerUrl('person', entityId)\n if (href) {\n links.push({ href, label: presenterLabel, kind: 'primary' })\n }\n }\n\n return {\n text: lines,\n presenter,\n links,\n checksumSource: {\n record: ctx.record,\n customFields: profileCustomFields,\n entity,\n entityCustomFields,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const entity = await getCustomerEntity(ctx, resolveCustomerEntityId(ctx.record))\n return resolvePersonPresenter(ctx.record, entity, ctx.customFields)\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n const entityId = resolveCustomerEntityId(ctx.record)\n return buildCustomerUrl('person', entityId)\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const entityId = resolveCustomerEntityId(ctx.record)\n if (!entityId) return null\n const href = buildCustomerUrl('person', entityId)\n if (!href) return null\n return [{ href: `${href}/edit`, label: 'Edit', kind: 'secondary' }]\n },\n\n fieldPolicy: {\n searchable: [\n 'preferred_name',\n 'first_name',\n 'last_name',\n 'job_title',\n 'department',\n 'seniority',\n 'timezone',\n 'linked_in_url',\n 'twitter_url',\n ],\n hashOnly: ['primary_email', 'primary_phone', 'personal_email'],\n excluded: ['date_of_birth', 'government_id', 'ssn', 'tax_id'],\n },\n },\n\n // =========================================================================\n // Company Profile\n // =========================================================================\n {\n entityId: 'customers:customer_company_profile',\n enabled: true,\n priority: 10,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const lines: string[] = []\n const record = ctx.record\n appendLine(lines, 'Legal name', record.legal_name ?? record.legalName ?? ctx.customFields.legal_name)\n appendLine(lines, 'Brand name', record.brand_name ?? record.brandName ?? ctx.customFields.brand_name)\n appendLine(lines, 'Domain', record.domain ?? record.website_domain ?? record.websiteDomain ?? ctx.customFields.domain)\n appendLine(lines, 'Website', record.website_url ?? record.websiteUrl ?? ctx.customFields.website_url)\n appendLine(lines, 'Industry', record.industry ?? ctx.customFields.industry)\n appendLine(lines, 'Company size', record.size_bucket ?? record.sizeBucket ?? ctx.customFields.size_bucket)\n appendLine(lines, 'Annual revenue', record.annual_revenue ?? record.annualRevenue ?? ctx.customFields.annual_revenue)\n\n const { entity, entityId, profileCustomFields, entityCustomFields, entityOnlyCustomFields } =\n await hydrateProfileContext(ctx, 'company')\n appendCustomFieldLines(lines, profileCustomFields, 'Company custom')\n if (Object.keys(entityOnlyCustomFields).length) {\n appendCustomFieldLines(lines, entityOnlyCustomFields, 'Customer custom')\n }\n appendCustomerEntityLines(lines, entity, 'Primary')\n ensureFallbackLines(lines, record)\n if (!lines.length) return null\n\n const presenter = resolveCompanyPresenter(record, entity, ctx.customFields)\n logMissingPresenterTitle('company', record, entity, presenter)\n const primaryLabel = pickLabel(presenter.title) ?? 'Open company'\n const links: SearchResultLink[] = []\n if (entityId) {\n const href = buildCustomerUrl('company', entityId)\n if (href) {\n links.push({ href, label: primaryLabel, kind: 'primary' })\n }\n }\n\n return {\n text: lines,\n presenter,\n links,\n checksumSource: {\n record: ctx.record,\n customFields: profileCustomFields,\n entity,\n entityCustomFields,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const entity = await getCustomerEntity(ctx, resolveCustomerEntityId(ctx.record))\n return resolveCompanyPresenter(ctx.record, entity, ctx.customFields)\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n const entityId = resolveCustomerEntityId(ctx.record)\n return buildCustomerUrl('company', entityId)\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const entityId = resolveCustomerEntityId(ctx.record)\n if (!entityId) return null\n const href = buildCustomerUrl('company', entityId)\n if (!href) return null\n return [{ href: `${href}/edit`, label: 'Edit', kind: 'secondary' }]\n },\n\n fieldPolicy: {\n searchable: [\n 'legal_name',\n 'brand_name',\n 'display_name',\n 'domain',\n 'website_url',\n 'industry',\n 'size_bucket',\n 'description',\n ],\n hashOnly: ['tax_id', 'registration_number'],\n excluded: ['bank_account', 'billing_info', 'credit_info'],\n },\n },\n\n // =========================================================================\n // Customer Comment\n // =========================================================================\n {\n entityId: 'customers:customer_comment',\n enabled: true,\n priority: 6,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const lines: string[] = []\n if (parent?.display_name) lines.push(`Customer: ${parent.display_name}`)\n lines.push(`Note: ${ctx.record.body ?? ''}`)\n if (ctx.record.appearance_icon) lines.push(`Icon: ${ctx.record.appearance_icon}`)\n if (ctx.record.appearance_color) lines.push(`Color: ${ctx.record.appearance_color}`)\n\n const presenter: SearchResultPresenter | undefined = parent?.display_name\n ? {\n title: parent.display_name as string,\n subtitle: snippet(ctx.record.body),\n icon: parent.kind === 'person' ? 'user' : 'building',\n }\n : undefined\n\n return {\n text: lines,\n presenter,\n checksumSource: {\n body: ctx.record.body,\n entityId: ctx.record.entity_id ?? null,\n updatedAt: ctx.record.updated_at ?? ctx.record.updatedAt ?? null,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const title = (parent?.display_name as string | undefined) ?? 'Customer note'\n return {\n title,\n subtitle: snippet(ctx.record.body),\n icon: 'sticky-note',\n }\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const base = buildCustomerUrl(parent?.kind as string ?? null, (parent?.id ?? ctx.record.entity_id ?? ctx.record.entityId) as string)\n return base ? `${base}#notes` : null\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n assertTenantContext(ctx)\n const links: SearchResultLink[] = []\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const parentUrl = buildCustomerUrl(parent?.kind as string ?? null, (parent?.id ?? ctx.record.entity_id ?? ctx.record.entityId) as string)\n if (parentUrl) {\n links.push({ href: parentUrl, label: (parent?.display_name as string | undefined) ?? 'View customer', kind: 'primary' })\n }\n if (ctx.record.deal_id) {\n const dealUrl = `/backend/customers/deals/${encodeURIComponent(ctx.record.deal_id as string)}`\n links.push({ href: dealUrl, label: 'Open deal', kind: 'secondary' })\n }\n return links.length ? links : null\n },\n\n fieldPolicy: {\n searchable: ['body'],\n hashOnly: [],\n excluded: [],\n },\n },\n\n // =========================================================================\n // Customer Deal\n // =========================================================================\n {\n entityId: 'customers:customer_deal',\n enabled: true,\n priority: 8,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n const lines: string[] = []\n const record = ctx.record\n appendLine(lines, 'Title', record.title)\n appendLine(lines, 'Stage', record.pipeline_stage)\n appendLine(lines, 'Status', record.status)\n appendLine(lines, 'Source', record.source)\n const value = formatDealValue(record)\n if (value) appendLine(lines, 'Value', value)\n if (!lines.length) return null\n\n const subtitleParts: string[] = []\n if (record.pipeline_stage) subtitleParts.push(String(record.pipeline_stage))\n if (record.status) subtitleParts.push(String(record.status))\n if (value) subtitleParts.push(value)\n\n return {\n text: lines,\n presenter: {\n title: String(record.title ?? 'Deal'),\n subtitle: subtitleParts.join(' \u00B7 ') || undefined,\n icon: 'briefcase',\n badge: 'Deal',\n },\n checksumSource: {\n title: record.title,\n status: record.status,\n stage: record.pipeline_stage,\n value: value,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n const { record } = ctx\n const title = pickString(record.title as string, 'Deal')\n const subtitleParts: string[] = []\n if (record.pipeline_stage) subtitleParts.push(String(record.pipeline_stage))\n if (record.status) subtitleParts.push(String(record.status))\n const amount = record.value_amount ?? record.valueAmount\n const currency = record.value_currency ?? record.valueCurrency\n if (amount) {\n subtitleParts.push(currency ? `${amount} ${currency}` : String(amount))\n }\n\n return {\n title: title ?? 'Deal',\n subtitle: subtitleParts.length ? subtitleParts.join(' \u00B7 ') : undefined,\n icon: 'briefcase',\n badge: 'Deal',\n }\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n const id = ctx.record.id\n if (!id) return null\n return `/backend/customers/deals/${encodeURIComponent(String(id))}`\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const id = ctx.record.id\n if (!id) return null\n return [\n {\n href: `/backend/customers/deals/${encodeURIComponent(String(id))}/edit`,\n label: 'Edit',\n kind: 'secondary',\n },\n ]\n },\n\n fieldPolicy: {\n searchable: ['title', 'description', 'pipeline_stage', 'status', 'source'],\n hashOnly: [],\n excluded: ['value_amount', 'value_currency'],\n },\n },\n\n // =========================================================================\n // Customer Activity\n // =========================================================================\n {\n entityId: 'customers:customer_activity',\n enabled: true,\n priority: 5,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const lines: string[] = []\n if (parent?.display_name) lines.push(`Customer: ${parent.display_name}`)\n if (ctx.record.activity_type) lines.push(`Type: ${ctx.record.activity_type}`)\n if (ctx.record.subject) lines.push(`Subject: ${ctx.record.subject}`)\n if (ctx.record.body) lines.push(`Body: ${ctx.record.body}`)\n\n const presenter: SearchResultPresenter = {\n title: ctx.record.subject ? String(ctx.record.subject) : `Activity: ${ctx.record.activity_type ?? 'update'}`,\n subtitle: (parent?.display_name as string | undefined) ?? snippet(ctx.record.body),\n icon: 'bolt',\n }\n\n return {\n text: lines,\n presenter,\n checksumSource: {\n subject: ctx.record.subject,\n body: ctx.record.body,\n entityId: ctx.record.entity_id ?? null,\n updatedAt: ctx.record.updated_at ?? ctx.record.updatedAt ?? null,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n return {\n title: ctx.record.subject ? String(ctx.record.subject) : `Activity: ${ctx.record.activity_type ?? 'update'}`,\n subtitle: (parent?.display_name as string | undefined) ?? snippet(ctx.record.body),\n icon: 'bolt',\n badge: 'Activity',\n }\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const base = buildCustomerUrl(parent?.kind as string ?? null, (parent?.id ?? ctx.record.entity_id ?? ctx.record.entityId) as string)\n return base ? `${base}#activity-${ctx.record.id ?? ctx.record.activity_id ?? ''}` : null\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const links: SearchResultLink[] = []\n if (ctx.record.deal_id) {\n links.push({\n href: `/backend/customers/deals/${encodeURIComponent(ctx.record.deal_id as string)}`,\n label: 'Open deal',\n kind: 'secondary',\n })\n }\n return links.length ? links : null\n },\n\n fieldPolicy: {\n searchable: ['subject', 'body', 'activity_type'],\n hashOnly: [],\n excluded: [],\n },\n },\n\n // =========================================================================\n // Customer Todo Link\n // =========================================================================\n {\n entityId: 'customers:customer_todo_link',\n enabled: true,\n priority: 4,\n\n buildSource: async (ctx: SearchBuildContext): Promise<SearchIndexSource | null> => {\n assertTenantContext(ctx)\n const todo = await getLinkedTodo(ctx) as Record<string, unknown> | null\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const lines: string[] = []\n if (todo?.title) lines.push(`Todo: ${todo.title}`)\n if (todo?.is_done !== undefined) lines.push(`Status: ${todo.is_done ? 'Done' : 'Open'}`)\n if (parent?.display_name) lines.push(`Customer: ${parent.display_name}`)\n if (!lines.length) return null\n\n return {\n text: lines,\n presenter: todo?.title\n ? { title: todo.title as string, subtitle: parent?.display_name as string | undefined, icon: 'check-square' }\n : undefined,\n checksumSource: {\n todoId: ctx.record.todo_id ?? ctx.record.todoId,\n todoSource: ctx.record.todo_source ?? ctx.record.todoSource,\n entityId: ctx.record.entity_id ?? ctx.record.entityId,\n },\n }\n },\n\n formatResult: async (ctx: SearchBuildContext): Promise<SearchResultPresenter | null> => {\n assertTenantContext(ctx)\n const todo = await getLinkedTodo(ctx) as Record<string, unknown> | null\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n return {\n title: (todo?.title as string | undefined) ?? 'Customer task',\n subtitle: parent?.display_name as string | undefined,\n icon: 'check-square',\n }\n },\n\n resolveUrl: async (ctx: SearchBuildContext): Promise<string | null> => {\n assertTenantContext(ctx)\n const parent = await getCustomerEntity(ctx, ctx.record.entity_id as string ?? ctx.record.entityId as string)\n const base = buildCustomerUrl(parent?.kind as string ?? null, (parent?.id ?? ctx.record.entity_id ?? ctx.record.entityId) as string)\n return base ? `${base}#tasks` : null\n },\n\n resolveLinks: async (ctx: SearchBuildContext): Promise<SearchResultLink[] | null> => {\n const todoId = ctx.record.todo_id ?? ctx.record.todoId\n if (!todoId) return null\n return [{\n href: `/backend/todos/${encodeURIComponent(todoId as string)}/edit`,\n label: 'Open todo',\n kind: 'secondary',\n }]\n },\n\n fieldPolicy: {\n searchable: [],\n hashOnly: [],\n excluded: [],\n },\n },\n ],\n}\n\nexport default searchConfig\nexport const config = searchConfig\n"],
5
+ "mappings": "AAQA,SAAS,kCAAkC,2BAA2B;AAWtE,SAAS,oBAAoB,KAAuD;AAClF,MAAI,OAAO,IAAI,aAAa,YAAY,IAAI,SAAS,WAAW,GAAG;AACjE,UAAM,IAAI,MAAM,6DAA6D;AAAA,EAC/E;AACF;AAaA,MAAM,gBAAgB,oBAAI,IAAyC;AACnE,MAAM,qBAAqB,oBAAI,QAAoG;AACnI,MAAM,YAAY,oBAAI,QAA0C;AAMhE,MAAM,yBAAyB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM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AA,UACP,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AAAA,MAEA,aAAa;AAAA,QACX,YAAY,CAAC;AAAA,QACb,UAAU,CAAC;AAAA,QACX,UAAU,CAAC;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,iBAAQ;AACR,MAAM,SAAS;",
6
6
  "names": []
7
7
  }
@@ -6,6 +6,8 @@ import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
6
6
  import { Spinner } from "@open-mercato/ui/primitives/spinner";
7
7
  import { useT } from "@open-mercato/shared/lib/i18n/context";
8
8
  import { DEFAULT_SETTINGS, hydrateCustomerTodoSettings } from "./config.js";
9
+ import { resolveExampleIntegrationHref } from "../../../lib/interactionCompatibility.js";
10
+ import { resolveTodoHref } from "../../../components/detail/utils.js";
9
11
  async function loadTodos(settings) {
10
12
  const params = new URLSearchParams({
11
13
  limit: String(settings.pageSize)
@@ -29,6 +31,7 @@ async function loadTodos(settings) {
29
31
  todoSource: typeof data.todoSource === "string" ? data.todoSource : "",
30
32
  todoTitle: typeof data.todoTitle === "string" ? data.todoTitle : null,
31
33
  createdAt: typeof data.createdAt === "string" ? data.createdAt : "",
34
+ _integrations: data._integrations && typeof data._integrations === "object" ? data._integrations : void 0,
32
35
  entity: {
33
36
  id: typeof entity.id === "string" ? entity.id : null,
34
37
  displayName: typeof entity.displayName === "string" ? entity.displayName : null,
@@ -44,7 +47,7 @@ function formatDate(value, locale) {
44
47
  return date.toLocaleString(locale ?? void 0);
45
48
  }
46
49
  function resolveDetailHref(entity) {
47
- if (!entity.id) return null;
50
+ if (!entity?.id) return null;
48
51
  if (entity.kind === "company") return `/backend/customers/companies-v2/${encodeURIComponent(entity.id)}`;
49
52
  if (entity.kind === "person") return `/backend/customers/people-v2/${encodeURIComponent(entity.id)}`;
50
53
  return `/backend/customers/people-v2/${encodeURIComponent(entity.id)}`;
@@ -112,6 +115,8 @@ const CustomerTodosWidget = ({
112
115
  return /* @__PURE__ */ jsx("div", { className: "space-y-4", children: error ? /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }) : loading ? /* @__PURE__ */ jsx("div", { className: "flex h-32 items-center justify-center", children: /* @__PURE__ */ jsx(Spinner, { className: "h-6 w-6 text-muted-foreground" }) }) : items.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("customers.widgets.todos.empty") }) : /* @__PURE__ */ jsx("ul", { className: "space-y-3", children: items.map((item) => {
113
116
  const createdLabel = formatDate(item.createdAt, locale);
114
117
  const href = resolveDetailHref(item.entity);
118
+ const exampleHref = resolveExampleIntegrationHref(item);
119
+ const taskHref = exampleHref ?? resolveTodoHref(item.todoSource, item.todoId);
115
120
  return /* @__PURE__ */ jsxs("li", { className: "rounded-md border p-3", children: [
116
121
  /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3 text-sm font-medium", children: [
117
122
  /* @__PURE__ */ jsx("span", { children: item.entity.displayName ?? t("customers.widgets.common.unknown") }),
@@ -121,7 +126,10 @@ const CustomerTodosWidget = ({
121
126
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-foreground", children: item.todoTitle ?? t("customers.widgets.todos.untitled") }),
122
127
  item.todoSource ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: item.todoSource }) : null
123
128
  ] }),
124
- href ? /* @__PURE__ */ jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ jsx(Link, { className: "text-primary hover:underline", href, children: t("customers.widgets.common.viewRecord") }) }) : null
129
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-wrap gap-3 text-xs", children: [
130
+ href ? /* @__PURE__ */ jsx(Link, { className: "text-primary hover:underline", href, children: t("customers.widgets.common.viewRecord") }) : null,
131
+ taskHref ? /* @__PURE__ */ jsx(Link, { className: "text-primary hover:underline", href: taskHref, children: t("customers.workPlan.customerTodos.table.actions.openTask") }) : null
132
+ ] })
125
133
  ] }, item.id);
126
134
  }) }) });
127
135
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/modules/customers/widgets/dashboard/customer-todos/widget.client.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport type { DashboardWidgetComponentProps } from '@open-mercato/shared/modules/dashboard/widgets'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { DEFAULT_SETTINGS, hydrateCustomerTodoSettings, type CustomerTodoWidgetSettings } from './config'\n\ntype TodoLinkSummary = {\n id: string\n todoId: string\n todoSource: string\n todoTitle: string | null\n createdAt: string\n entity: {\n id: string | null\n displayName: string | null\n kind: string | null\n }\n}\n\n// SPEC-046b: To enable canonical interactions mode, switch from\n// /api/customers/dashboard/widgets/customer-todos to\n// /api/customers/interactions?status=planned&pageSize={pageSize}\n//\n// Response mapping (InteractionSummary \u2192 TodoLinkSummary):\n// interaction.id \u2192 id, todoId\n// interaction.interactionType \u2192 todoSource\n// interaction.title \u2192 todoTitle\n// interaction.createdAt \u2192 createdAt\n// interaction.entityId \u2192 entity.id (kind/displayName need enrichment\n// or a follow-up customer lookup)\n//\n// The main gap is the `entity` sub-object: the interactions API returns a flat\n// entityId but not customer displayName/kind. Options:\n// a) Add an enricher to the interactions list API that resolves entity details\n// b) Batch-fetch customer details client-side after loading interactions\n// c) Add a dedicated /api/customers/interactions/widget endpoint\nasync function loadTodos(settings: CustomerTodoWidgetSettings): Promise<TodoLinkSummary[]> {\n const params = new URLSearchParams({\n limit: String(settings.pageSize),\n })\n const call = await apiCall<{ items?: unknown[]; error?: string }>(\n `/api/customers/dashboard/widgets/customer-todos?${params.toString()}`,\n )\n if (!call.ok) {\n const message =\n typeof (call.result as Record<string, unknown> | null)?.error === 'string'\n ? ((call.result as Record<string, unknown>).error as string)\n : `Request failed with status ${call.status}`\n throw new Error(message)\n }\n const payload = call.result ?? {}\n const rawItems = Array.isArray((payload as { items?: unknown }).items)\n ? ((payload as { items: unknown[] }).items)\n : []\n return rawItems\n .map((item): TodoLinkSummary | null => {\n if (!item || typeof item !== 'object') return null\n const data = item as any\n const entity = data.entity ?? {}\n return {\n id: typeof data.id === 'string' ? data.id : null,\n todoId: typeof data.todoId === 'string' ? data.todoId : '',\n todoSource: typeof data.todoSource === 'string' ? data.todoSource : '',\n todoTitle: typeof data.todoTitle === 'string' ? data.todoTitle : null,\n createdAt: typeof data.createdAt === 'string' ? data.createdAt : '',\n entity: {\n id: typeof entity.id === 'string' ? entity.id : null,\n displayName: typeof entity.displayName === 'string' ? entity.displayName : null,\n kind: typeof entity.kind === 'string' ? entity.kind : null,\n },\n }\n })\n .filter((item): item is TodoLinkSummary => !!item && !!item.id)\n}\n\nfunction formatDate(value: string | null, locale?: string): string {\n if (!value) return ''\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return ''\n return date.toLocaleString(locale ?? undefined)\n}\n\nfunction resolveDetailHref(entity: { id: string | null; kind: string | null }): string | null {\n if (!entity.id) return null\n if (entity.kind === 'company') return `/backend/customers/companies-v2/${encodeURIComponent(entity.id)}`\n if (entity.kind === 'person') return `/backend/customers/people-v2/${encodeURIComponent(entity.id)}`\n return `/backend/customers/people-v2/${encodeURIComponent(entity.id)}`\n}\n\nconst CustomerTodosWidget: React.FC<DashboardWidgetComponentProps<CustomerTodoWidgetSettings>> = ({\n mode,\n settings = DEFAULT_SETTINGS,\n onSettingsChange,\n refreshToken,\n onRefreshStateChange,\n}) => {\n const t = useT()\n const hydrated = React.useMemo(() => hydrateCustomerTodoSettings(settings), [settings])\n const [items, setItems] = React.useState<TodoLinkSummary[]>([])\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [locale, setLocale] = React.useState<string | undefined>(undefined)\n\n React.useEffect(() => {\n if (typeof navigator !== 'undefined') {\n setLocale(navigator.language)\n }\n }, [])\n\n const refresh = React.useCallback(async () => {\n onRefreshStateChange?.(true)\n setLoading(true)\n setError(null)\n try {\n const data = await loadTodos(hydrated)\n setItems(data)\n } catch (err) {\n console.error('Failed to load customer todos widget data', err)\n setError(t('customers.widgets.todos.error'))\n } finally {\n setLoading(false)\n onRefreshStateChange?.(false)\n }\n }, [hydrated, onRefreshStateChange, t])\n\n React.useEffect(() => {\n refresh().catch(() => {})\n }, [refresh, refreshToken])\n\n if (mode === 'settings') {\n return (\n <div className=\"space-y-4 text-sm\">\n <div className=\"space-y-1.5\">\n <label htmlFor=\"customer-todos-page-size\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {t('customers.widgets.todos.settings.pageSize')}\n </label>\n <input\n id=\"customer-todos-page-size\"\n type=\"number\"\n min={1}\n max={20}\n className=\"w-24 rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={hydrated.pageSize}\n onChange={(event) => {\n const next = Number(event.target.value)\n onSettingsChange({ ...hydrated, pageSize: Number.isFinite(next) ? next : hydrated.pageSize })\n }}\n />\n </div>\n <p className=\"text-xs text-muted-foreground\">{t('customers.widgets.todos.settings.help')}</p>\n </div>\n )\n }\n\n return (\n <div className=\"space-y-4\">\n {error ? (\n <p className=\"text-sm text-destructive\">{error}</p>\n ) : loading ? (\n <div className=\"flex h-32 items-center justify-center\">\n <Spinner className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n ) : items.length === 0 ? (\n <p className=\"text-sm text-muted-foreground\">{t('customers.widgets.todos.empty')}</p>\n ) : (\n <ul className=\"space-y-3\">\n {items.map((item) => {\n const createdLabel = formatDate(item.createdAt, locale)\n const href = resolveDetailHref(item.entity)\n return (\n <li key={item.id} className=\"rounded-md border p-3\">\n <div className=\"flex items-start justify-between gap-3 text-sm font-medium\">\n <span>{item.entity.displayName ?? t('customers.widgets.common.unknown')}</span>\n <span className=\"text-xs text-muted-foreground\">{createdLabel || t('customers.widgets.common.unknownDate')}</span>\n </div>\n <div className=\"mt-1 space-y-0.5\">\n <p className=\"text-sm font-medium text-foreground\">\n {item.todoTitle ?? t('customers.widgets.todos.untitled')}\n </p>\n {item.todoSource ? (\n <p className=\"text-xs text-muted-foreground\">{item.todoSource}</p>\n ) : null}\n </div>\n {href ? (\n <div className=\"mt-2 text-xs\">\n <Link className=\"text-primary hover:underline\" href={href}>\n {t('customers.widgets.common.viewRecord')}\n </Link>\n </div>\n ) : null}\n </li>\n )\n })}\n </ul>\n )}\n </div>\n )\n}\n\nexport default CustomerTodosWidget\n"],
5
- "mappings": ";AAwIQ,SACE,KADF;AAtIR,YAAY,WAAW;AACvB,OAAO,UAAU;AAEjB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,kBAAkB,mCAAoE;AAgC/F,eAAe,UAAU,UAAkE;AACzF,QAAM,SAAS,IAAI,gBAAgB;AAAA,IACjC,OAAO,OAAO,SAAS,QAAQ;AAAA,EACjC,CAAC;AACD,QAAM,OAAO,MAAM;AAAA,IACjB,mDAAmD,OAAO,SAAS,CAAC;AAAA,EACtE;AACA,MAAI,CAAC,KAAK,IAAI;AACZ,UAAM,UACJ,OAAQ,KAAK,QAA2C,UAAU,WAC5D,KAAK,OAAmC,QAC1C,8BAA8B,KAAK,MAAM;AAC/C,UAAM,IAAI,MAAM,OAAO;AAAA,EACzB;AACA,QAAM,UAAU,KAAK,UAAU,CAAC;AAChC,QAAM,WAAW,MAAM,QAAS,QAAgC,KAAK,IAC/D,QAAiC,QACnC,CAAC;AACL,SAAO,SACJ,IAAI,CAAC,SAAiC;AACrC,QAAI,CAAC,QAAQ,OAAO,SAAS,SAAU,QAAO;AAC9C,UAAM,OAAO;AACb,UAAM,SAAS,KAAK,UAAU,CAAC;AAC/B,WAAO;AAAA,MACL,IAAI,OAAO,KAAK,OAAO,WAAW,KAAK,KAAK;AAAA,MAC5C,QAAQ,OAAO,KAAK,WAAW,WAAW,KAAK,SAAS;AAAA,MACxD,YAAY,OAAO,KAAK,eAAe,WAAW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uC,GAAE;AAAA,OAC3F;AAAA,EAEJ;AAEA,SACE,oBAAC,SAAI,WAAU,aACZ,kBACC,oBAAC,OAAE,WAAU,4BAA4B,iBAAM,IAC7C,UACF,oBAAC,SAAI,WAAU,yCACb,8BAAC,WAAQ,WAAU,iCAAgC,GACrD,IACE,MAAM,WAAW,IACnB,oBAAC,OAAE,WAAU,iCAAiC,YAAE,+BAA+B,GAAE,IAEjF,oBAAC,QAAG,WAAU,aACX,gBAAM,IAAI,CAAC,SAAS;AACnB,UAAM,eAAe,WAAW,KAAK,WAAW,MAAM;AACtD,UAAM,OAAO,kBAAkB,KAAK,MAAM;AAC1C,WACE,qBAAC,QAAiB,WAAU,yBAC1B;AAAA,2BAAC,SAAI,WAAU,8DACb;AAAA,4BAAC,UAAM,eAAK,OAAO,eAAe,EAAE,kCAAkC,GAAE;AAAA,QACxE,oBAAC,UAAK,WAAU,iCAAiC,0BAAgB,EAAE,sCAAsC,GAAE;AAAA,SAC7G;AAAA,MACA,qBAAC,SAAI,WAAU,oBACb;AAAA,4BAAC,OAAE,WAAU,uCACV,eAAK,aAAa,EAAE,kCAAkC,GACzD;AAAA,QACC,KAAK,aACJ,oBAAC,OAAE,WAAU,iCAAiC,eAAK,YAAW,IAC5D;AAAA,SACN;AAAA,MACC,OACC,oBAAC,SAAI,WAAU,gBACb,8BAAC,QAAK,WAAU,gCAA+B,MAC5C,YAAE,qCAAqC,GAC1C,GACF,IACE;AAAA,SAnBG,KAAK,EAoBd;AAAA,EAEJ,CAAC,GACH,GAEJ;AAEJ;AAEA,IAAO,wBAAQ;",
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport type { DashboardWidgetComponentProps } from '@open-mercato/shared/modules/dashboard/widgets'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { DEFAULT_SETTINGS, hydrateCustomerTodoSettings, type CustomerTodoWidgetSettings } from './config'\nimport { resolveExampleIntegrationHref } from '../../../lib/interactionCompatibility'\nimport { resolveTodoHref } from '../../../components/detail/utils'\n\ntype TodoLinkSummary = {\n id: string\n todoId: string\n todoSource: string\n todoTitle: string | null\n createdAt: string\n _integrations?: {\n example?: {\n href?: string | null\n }\n [key: string]: unknown\n }\n entity: {\n id: string | null\n displayName: string | null\n kind: string | null\n }\n}\n\nasync function loadTodos(settings: CustomerTodoWidgetSettings): Promise<TodoLinkSummary[]> {\n const params = new URLSearchParams({\n limit: String(settings.pageSize),\n })\n const call = await apiCall<{ items?: unknown[]; error?: string }>(\n `/api/customers/dashboard/widgets/customer-todos?${params.toString()}`,\n )\n if (!call.ok) {\n const message =\n typeof (call.result as Record<string, unknown> | null)?.error === 'string'\n ? ((call.result as Record<string, unknown>).error as string)\n : `Request failed with status ${call.status}`\n throw new Error(message)\n }\n const payload = call.result ?? {}\n const rawItems = Array.isArray((payload as { items?: unknown }).items)\n ? ((payload as { items: unknown[] }).items)\n : []\n return rawItems\n .map((item): TodoLinkSummary | null => {\n if (!item || typeof item !== 'object') return null\n const data = item as any\n const entity = data.entity ?? {}\n return {\n id: typeof data.id === 'string' ? data.id : null,\n todoId: typeof data.todoId === 'string' ? data.todoId : '',\n todoSource: typeof data.todoSource === 'string' ? data.todoSource : '',\n todoTitle: typeof data.todoTitle === 'string' ? data.todoTitle : null,\n createdAt: typeof data.createdAt === 'string' ? data.createdAt : '',\n _integrations: data._integrations && typeof data._integrations === 'object'\n ? (data._integrations as TodoLinkSummary['_integrations'])\n : undefined,\n entity: {\n id: typeof entity.id === 'string' ? entity.id : null,\n displayName: typeof entity.displayName === 'string' ? entity.displayName : null,\n kind: typeof entity.kind === 'string' ? entity.kind : null,\n },\n }\n })\n .filter((item): item is TodoLinkSummary => !!item && !!item.id)\n}\n\nfunction formatDate(value: string | null, locale?: string): string {\n if (!value) return ''\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return ''\n return date.toLocaleString(locale ?? undefined)\n}\n\nfunction resolveDetailHref(entity: { id: string | null; kind: string | null } | null | undefined): string | null {\n if (!entity?.id) return null\n if (entity.kind === 'company') return `/backend/customers/companies-v2/${encodeURIComponent(entity.id)}`\n if (entity.kind === 'person') return `/backend/customers/people-v2/${encodeURIComponent(entity.id)}`\n return `/backend/customers/people-v2/${encodeURIComponent(entity.id)}`\n}\n\nconst CustomerTodosWidget: React.FC<DashboardWidgetComponentProps<CustomerTodoWidgetSettings>> = ({\n mode,\n settings = DEFAULT_SETTINGS,\n onSettingsChange,\n refreshToken,\n onRefreshStateChange,\n}) => {\n const t = useT()\n const hydrated = React.useMemo(() => hydrateCustomerTodoSettings(settings), [settings])\n const [items, setItems] = React.useState<TodoLinkSummary[]>([])\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [locale, setLocale] = React.useState<string | undefined>(undefined)\n\n React.useEffect(() => {\n if (typeof navigator !== 'undefined') {\n setLocale(navigator.language)\n }\n }, [])\n\n const refresh = React.useCallback(async () => {\n onRefreshStateChange?.(true)\n setLoading(true)\n setError(null)\n try {\n const data = await loadTodos(hydrated)\n setItems(data)\n } catch (err) {\n console.error('Failed to load customer todos widget data', err)\n setError(t('customers.widgets.todos.error'))\n } finally {\n setLoading(false)\n onRefreshStateChange?.(false)\n }\n }, [hydrated, onRefreshStateChange, t])\n\n React.useEffect(() => {\n refresh().catch(() => {})\n }, [refresh, refreshToken])\n\n if (mode === 'settings') {\n return (\n <div className=\"space-y-4 text-sm\">\n <div className=\"space-y-1.5\">\n <label htmlFor=\"customer-todos-page-size\" className=\"text-xs font-semibold uppercase text-muted-foreground\">\n {t('customers.widgets.todos.settings.pageSize')}\n </label>\n <input\n id=\"customer-todos-page-size\"\n type=\"number\"\n min={1}\n max={20}\n className=\"w-24 rounded-md border px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={hydrated.pageSize}\n onChange={(event) => {\n const next = Number(event.target.value)\n onSettingsChange({ ...hydrated, pageSize: Number.isFinite(next) ? next : hydrated.pageSize })\n }}\n />\n </div>\n <p className=\"text-xs text-muted-foreground\">{t('customers.widgets.todos.settings.help')}</p>\n </div>\n )\n }\n\n return (\n <div className=\"space-y-4\">\n {error ? (\n <p className=\"text-sm text-destructive\">{error}</p>\n ) : loading ? (\n <div className=\"flex h-32 items-center justify-center\">\n <Spinner className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n ) : items.length === 0 ? (\n <p className=\"text-sm text-muted-foreground\">{t('customers.widgets.todos.empty')}</p>\n ) : (\n <ul className=\"space-y-3\">\n {items.map((item) => {\n const createdLabel = formatDate(item.createdAt, locale)\n const href = resolveDetailHref(item.entity)\n const exampleHref = resolveExampleIntegrationHref(item)\n const taskHref = exampleHref ?? resolveTodoHref(item.todoSource, item.todoId)\n return (\n <li key={item.id} className=\"rounded-md border p-3\">\n <div className=\"flex items-start justify-between gap-3 text-sm font-medium\">\n <span>{item.entity.displayName ?? t('customers.widgets.common.unknown')}</span>\n <span className=\"text-xs text-muted-foreground\">{createdLabel || t('customers.widgets.common.unknownDate')}</span>\n </div>\n <div className=\"mt-1 space-y-0.5\">\n <p className=\"text-sm font-medium text-foreground\">\n {item.todoTitle ?? t('customers.widgets.todos.untitled')}\n </p>\n {item.todoSource ? (\n <p className=\"text-xs text-muted-foreground\">{item.todoSource}</p>\n ) : null}\n </div>\n <div className=\"mt-2 flex flex-wrap gap-3 text-xs\">\n {href ? (\n <Link className=\"text-primary hover:underline\" href={href}>\n {t('customers.widgets.common.viewRecord')}\n </Link>\n ) : null}\n {taskHref ? (\n <Link className=\"text-primary hover:underline\" href={taskHref}>\n {t('customers.workPlan.customerTodos.table.actions.openTask')}\n </Link>\n ) : null}\n </div>\n </li>\n )\n })}\n </ul>\n )}\n </div>\n )\n}\n\nexport default CustomerTodosWidget\n"],
5
+ "mappings": ";AAkIQ,SACE,KADF;AAhIR,YAAY,WAAW;AACvB,OAAO,UAAU;AAEjB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,WAAU,aACX,gBAAM,IAAI,CAAC,SAAS;AACnB,UAAM,eAAe,WAAW,KAAK,WAAW,MAAM;AACtD,UAAM,OAAO,kBAAkB,KAAK,MAAM;AAC1C,UAAM,cAAc,8BAA8B,IAAI;AACtD,UAAM,WAAW,eAAe,gBAAgB,KAAK,YAAY,KAAK,MAAM;AAC5E,WACE,qBAAC,QAAiB,WAAU,yBAC1B;AAAA,2BAAC,SAAI,WAAU,8DACb;AAAA,4BAAC,UAAM,eAAK,OAAO,eAAe,EAAE,kCAAkC,GAAE;AAAA,QACxE,oBAAC,UAAK,WAAU,iCAAiC,0BAAgB,EAAE,sCAAsC,GAAE;AAAA,SAC7G;AAAA,MACA,qBAAC,SAAI,WAAU,oBACb;AAAA,4BAAC,OAAE,WAAU,uCACV,eAAK,aAAa,EAAE,kCAAkC,GACzD;AAAA,QACC,KAAK,aACJ,oBAAC,OAAE,WAAU,iCAAiC,eAAK,YAAW,IAC5D;AAAA,SACN;AAAA,MACA,qBAAC,SAAI,WAAU,qCACZ;AAAA,eACC,oBAAC,QAAK,WAAU,gCAA+B,MAC5C,YAAE,qCAAqC,GAC1C,IACE;AAAA,QACH,WACC,oBAAC,QAAK,WAAU,gCAA+B,MAAM,UAClD,YAAE,yDAAyD,GAC9D,IACE;AAAA,SACN;AAAA,SAxBO,KAAK,EAyBd;AAAA,EAEJ,CAAC,GACH,GAEJ;AAEJ;AAEA,IAAO,wBAAQ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/core",
3
- "version": "0.4.11-develop.1309.4b37381a7a",
3
+ "version": "0.4.11-develop.1347.c693e6dfee",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -230,10 +230,10 @@
230
230
  "ts-pattern": "^5.0.0"
231
231
  },
232
232
  "peerDependencies": {
233
- "@open-mercato/shared": "0.4.11-develop.1309.4b37381a7a"
233
+ "@open-mercato/shared": "0.4.11-develop.1347.c693e6dfee"
234
234
  },
235
235
  "devDependencies": {
236
- "@open-mercato/shared": "0.4.11-develop.1309.4b37381a7a",
236
+ "@open-mercato/shared": "0.4.11-develop.1347.c693e6dfee",
237
237
  "@testing-library/dom": "^10.4.1",
238
238
  "@testing-library/jest-dom": "^6.9.1",
239
239
  "@testing-library/react": "^16.3.1",
@@ -27,6 +27,7 @@ import {
27
27
  } from '../../../lib/customFieldRouting'
28
28
  import {
29
29
  CUSTOMER_INTERACTION_ACTIVITY_ADAPTER_SOURCE,
30
+ EXAMPLE_TODO_SOURCE,
30
31
  CUSTOMER_INTERACTION_TODO_ADAPTER_SOURCE,
31
32
  mapInteractionRecordToActivitySummary,
32
33
  mapInteractionRecordToTodoSummary,
@@ -150,7 +151,7 @@ async function resolveTodoDetails(
150
151
 
151
152
  const idsBySource = new Map<string, Set<string>>()
152
153
  for (const link of links) {
153
- const source = typeof link.todoSource === 'string' && link.todoSource.trim().length > 0 ? link.todoSource : 'example:todo'
154
+ const source = typeof link.todoSource === 'string' && link.todoSource.trim().length > 0 ? link.todoSource : EXAMPLE_TODO_SOURCE
154
155
  const id = typeof link.todoId === 'string' && link.todoId.trim().length > 0 ? link.todoId : String(link.todoId ?? '')
155
156
  if (!id) continue
156
157
  if (!idsBySource.has(source)) idsBySource.set(source, new Set<string>())
@@ -633,10 +634,10 @@ export async function GET(_req: Request, ctx: { params?: { id?: string } }) {
633
634
  interactionFlags.unified
634
635
  ? canonicalTodoItems
635
636
  : [
636
- ...todoLinks
637
- .filter((link) => !canonicalTodoBridgeIds.has(link.todoId))
638
- .map((link) => {
639
- const source = typeof link.todoSource === 'string' && link.todoSource.trim().length > 0 ? link.todoSource : 'example:todo'
637
+ ...todoLinks
638
+ .filter((link) => !canonicalTodoBridgeIds.has(link.todoId))
639
+ .map((link) => {
640
+ const source = typeof link.todoSource === 'string' && link.todoSource.trim().length > 0 ? link.todoSource : EXAMPLE_TODO_SOURCE
640
641
  const key = `${source}:${link.todoId}`
641
642
  const detail = todoDetails.get(key)
642
643
  return {