@open-mercato/core 0.6.6-develop.6256.1.9fc16aedc4 → 0.6.6-develop.6286.1.d985c5c374
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.
- package/.turbo/turbo-build.log +2 -2
- package/dist/generated/entities/carrier_shipment_idempotency_key/index.js +19 -0
- package/dist/generated/entities/carrier_shipment_idempotency_key/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +2 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +10 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/catalog/lib/productResolution.js +45 -0
- package/dist/modules/catalog/lib/productResolution.js.map +7 -0
- package/dist/modules/communication_channels/workers/channel-import-history.js +1 -1
- package/dist/modules/communication_channels/workers/channel-import-history.js.map +2 -2
- package/dist/modules/currencies/api/fetch-configs/route.js +34 -0
- package/dist/modules/currencies/api/fetch-configs/route.js.map +2 -2
- package/dist/modules/currencies/components/CurrencyFetchingConfig.js +17 -15
- package/dist/modules/currencies/components/CurrencyFetchingConfig.js.map +2 -2
- package/dist/modules/customers/api/companies/[id]/route.js +176 -161
- package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/route.js +75 -59
- package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
- package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js +17 -10
- package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js.map +2 -2
- package/dist/modules/customers/components/detail/ActivitiesAddNewMenu.js +6 -4
- package/dist/modules/customers/components/detail/ActivitiesAddNewMenu.js.map +2 -2
- package/dist/modules/customers/components/detail/AiActionChips.js +5 -2
- package/dist/modules/customers/components/detail/AiActionChips.js.map +2 -2
- package/dist/modules/customers/components/detail/schedule/ParticipantsField.js +19 -21
- package/dist/modules/customers/components/detail/schedule/ParticipantsField.js.map +2 -2
- package/dist/modules/data_sync/api/runs/[id]/cancel.js +1 -1
- package/dist/modules/data_sync/api/runs/[id]/cancel.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/page.js +9 -45
- package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js +11 -17
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js.map +2 -2
- package/dist/modules/data_sync/components/IntegrationScheduleTab.js +12 -10
- package/dist/modules/data_sync/components/IntegrationScheduleTab.js.map +2 -2
- package/dist/modules/data_sync/lib/id-mapping.js +46 -1
- package/dist/modules/data_sync/lib/id-mapping.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-engine.js +2 -2
- package/dist/modules/data_sync/lib/sync-engine.js.map +2 -2
- package/dist/modules/data_sync/lib/syncRunStatus.js +30 -0
- package/dist/modules/data_sync/lib/syncRunStatus.js.map +7 -0
- package/dist/modules/entities/api/records.js +6 -0
- package/dist/modules/entities/api/records.js.map +2 -2
- package/dist/modules/feature_toggles/api/global/route.js +17 -15
- package/dist/modules/feature_toggles/api/global/route.js.map +2 -2
- package/dist/modules/feature_toggles/api/openapi.js +2 -2
- package/dist/modules/feature_toggles/api/openapi.js.map +2 -2
- package/dist/modules/feature_toggles/commands/global.js +14 -0
- package/dist/modules/feature_toggles/commands/global.js.map +2 -2
- package/dist/modules/inbox_ops/backend/inbox-ops/page.js +6 -0
- package/dist/modules/inbox_ops/backend/inbox-ops/page.js.map +2 -2
- package/dist/modules/messages/api/[id]/conversation/archive/route.js +25 -7
- package/dist/modules/messages/api/[id]/conversation/archive/route.js.map +2 -2
- package/dist/modules/messages/api/[id]/conversation/read/route.js +24 -6
- package/dist/modules/messages/api/[id]/conversation/read/route.js.map +2 -2
- package/dist/modules/messages/api/[id]/route.js +13 -1
- package/dist/modules/messages/api/[id]/route.js.map +2 -2
- package/dist/modules/messages/api/openapi.js +3 -1
- package/dist/modules/messages/api/openapi.js.map +2 -2
- package/dist/modules/messages/commands/conversation.js +77 -0
- package/dist/modules/messages/commands/conversation.js.map +2 -2
- package/dist/modules/messages/components/MessageDetailPageClient.js +16 -4
- package/dist/modules/messages/components/MessageDetailPageClient.js.map +2 -2
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetails.js +3 -1
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetails.js.map +2 -2
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsActions.js +29 -4
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsActions.js.map +2 -2
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsQueries.js +10 -1
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsQueries.js.map +2 -2
- package/dist/modules/messages/components/message-detail/panels/MainMessageHeader.js +13 -11
- package/dist/modules/messages/components/message-detail/panels/MainMessageHeader.js.map +2 -2
- package/dist/modules/payment_gateways/api/cancel/route.js +5 -0
- package/dist/modules/payment_gateways/api/cancel/route.js.map +2 -2
- package/dist/modules/payment_gateways/api/capture/route.js +5 -0
- package/dist/modules/payment_gateways/api/capture/route.js.map +2 -2
- package/dist/modules/payment_gateways/api/refund/route.js +5 -0
- package/dist/modules/payment_gateways/api/refund/route.js.map +2 -2
- package/dist/modules/payment_gateways/lib/gateway-service.js +52 -25
- package/dist/modules/payment_gateways/lib/gateway-service.js.map +2 -2
- package/dist/modules/payment_gateways/lib/status-machine.js +13 -0
- package/dist/modules/payment_gateways/lib/status-machine.js.map +2 -2
- package/dist/modules/perspectives/api/[tableId]/route.js +8 -2
- package/dist/modules/perspectives/api/[tableId]/route.js.map +2 -2
- package/dist/modules/perspectives/data/entities.js +33 -3
- package/dist/modules/perspectives/data/entities.js.map +2 -2
- package/dist/modules/perspectives/migrations/Migration20260619120000_perspectives_live_row_uniqueness.js +63 -0
- package/dist/modules/perspectives/migrations/Migration20260619120000_perspectives_live_row_uniqueness.js.map +7 -0
- package/dist/modules/perspectives/services/perspectiveService.js +17 -0
- package/dist/modules/perspectives/services/perspectiveService.js.map +2 -2
- package/dist/modules/planner/commands/availability-weekly.js +33 -1
- package/dist/modules/planner/commands/availability-weekly.js.map +2 -2
- package/dist/modules/planner/components/AvailabilityRulesEditor.js +14 -2
- package/dist/modules/planner/components/AvailabilityRulesEditor.js.map +2 -2
- package/dist/modules/progress/api/active/route.js +1 -1
- package/dist/modules/progress/api/active/route.js.map +2 -2
- package/dist/modules/progress/lib/progressService.js.map +1 -1
- package/dist/modules/progress/lib/progressServiceImpl.js +33 -8
- package/dist/modules/progress/lib/progressServiceImpl.js.map +2 -2
- package/dist/modules/query_index/api/status.js +19 -24
- package/dist/modules/query_index/api/status.js.map +3 -3
- package/dist/modules/query_index/lib/coverage.js +35 -0
- package/dist/modules/query_index/lib/coverage.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +11 -6
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/resources/api/resource-types.js +5 -37
- package/dist/modules/resources/api/resource-types.js.map +2 -2
- package/dist/modules/resources/api/resourceTypeCounts.js +35 -0
- package/dist/modules/resources/api/resourceTypeCounts.js.map +7 -0
- package/dist/modules/resources/backend/resources/resource-types/[id]/edit/page.js +1 -1
- package/dist/modules/resources/backend/resources/resource-types/[id]/edit/page.js.map +1 -1
- package/dist/modules/resources/backend/resources/resource-types/page.js +2 -1
- package/dist/modules/resources/backend/resources/resource-types/page.js.map +2 -2
- package/dist/modules/sales/components/documents/ReturnDialog.js +4 -1
- package/dist/modules/sales/components/documents/ReturnDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/ShipmentDialog.js +17 -2
- package/dist/modules/sales/components/documents/ShipmentDialog.js.map +2 -2
- package/dist/modules/sales/di.js +4 -0
- package/dist/modules/sales/di.js.map +2 -2
- package/dist/modules/sales/services/salesOrderService.js +26 -0
- package/dist/modules/sales/services/salesOrderService.js.map +7 -0
- package/dist/modules/shipping_carriers/api/shipments/route.js +8 -0
- package/dist/modules/shipping_carriers/api/shipments/route.js.map +2 -2
- package/dist/modules/shipping_carriers/data/entities.js +38 -0
- package/dist/modules/shipping_carriers/data/entities.js.map +2 -2
- package/dist/modules/shipping_carriers/data/validators.js +2 -1
- package/dist/modules/shipping_carriers/data/validators.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/shipment-idempotency.js +76 -0
- package/dist/modules/shipping_carriers/lib/shipment-idempotency.js.map +7 -0
- package/dist/modules/shipping_carriers/lib/shipment-wizard/hooks/shipmentApi.js +2 -1
- package/dist/modules/shipping_carriers/lib/shipment-wizard/hooks/shipmentApi.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/shipment-wizard/hooks/useShipmentWizard.js +20 -2
- package/dist/modules/shipping_carriers/lib/shipment-wizard/hooks/useShipmentWizard.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/shipping-service.js +82 -43
- package/dist/modules/shipping_carriers/lib/shipping-service.js.map +2 -2
- package/dist/modules/shipping_carriers/migrations/Migration20260618173616_shipping_carriers.js +14 -0
- package/dist/modules/shipping_carriers/migrations/Migration20260618173616_shipping_carriers.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/ListView.js +15 -6
- package/dist/modules/staff/lib/timesheets-ui/ListView.js.map +2 -2
- package/dist/modules/translations/components/TranslationManager.js +9 -18
- package/dist/modules/translations/components/TranslationManager.js.map +2 -2
- package/generated/entities/carrier_shipment_idempotency_key/index.ts +8 -0
- package/generated/entities.ids.generated.ts +2 -1
- package/generated/entity-fields-registry.ts +10 -0
- package/package.json +9 -8
- package/src/modules/catalog/lib/productResolution.ts +75 -0
- package/src/modules/communication_channels/workers/channel-import-history.ts +1 -1
- package/src/modules/currencies/api/fetch-configs/route.ts +36 -0
- package/src/modules/currencies/components/CurrencyFetchingConfig.tsx +20 -17
- package/src/modules/currencies/i18n/de.json +2 -1
- package/src/modules/currencies/i18n/en.json +2 -1
- package/src/modules/currencies/i18n/es.json +2 -1
- package/src/modules/currencies/i18n/pl.json +2 -1
- package/src/modules/customers/api/companies/[id]/route.ts +214 -189
- package/src/modules/customers/api/people/[id]/route.ts +106 -80
- package/src/modules/customers/backend/config/customers/pipeline-stages/page.tsx +19 -12
- package/src/modules/customers/components/detail/ActivitiesAddNewMenu.tsx +8 -6
- package/src/modules/customers/components/detail/AiActionChips.tsx +6 -3
- package/src/modules/customers/components/detail/schedule/ParticipantsField.tsx +16 -18
- package/src/modules/data_sync/api/runs/[id]/cancel.ts +1 -1
- package/src/modules/data_sync/backend/data-sync/page.tsx +11 -58
- package/src/modules/data_sync/backend/data-sync/runs/[id]/page.tsx +13 -20
- package/src/modules/data_sync/components/IntegrationScheduleTab.tsx +10 -8
- package/src/modules/data_sync/lib/id-mapping.ts +58 -1
- package/src/modules/data_sync/lib/sync-engine.ts +2 -2
- package/src/modules/data_sync/lib/syncRunStatus.ts +39 -0
- package/src/modules/entities/api/records.ts +14 -0
- package/src/modules/feature_toggles/api/global/route.ts +16 -14
- package/src/modules/feature_toggles/api/openapi.ts +2 -2
- package/src/modules/feature_toggles/commands/global.ts +15 -0
- package/src/modules/inbox_ops/backend/inbox-ops/page.tsx +7 -0
- package/src/modules/messages/api/[id]/conversation/archive/route.ts +29 -6
- package/src/modules/messages/api/[id]/conversation/read/route.ts +29 -6
- package/src/modules/messages/api/[id]/route.ts +15 -0
- package/src/modules/messages/api/openapi.ts +2 -0
- package/src/modules/messages/commands/conversation.ts +87 -0
- package/src/modules/messages/components/MessageDetailPageClient.tsx +16 -4
- package/src/modules/messages/components/message-detail/hooks/useMessageDetails.ts +2 -0
- package/src/modules/messages/components/message-detail/hooks/useMessageDetailsActions.ts +39 -4
- package/src/modules/messages/components/message-detail/hooks/useMessageDetailsQueries.ts +15 -1
- package/src/modules/messages/components/message-detail/panels/MainMessageHeader.tsx +29 -14
- package/src/modules/messages/components/message-detail/types.ts +2 -0
- package/src/modules/messages/i18n/de.json +4 -0
- package/src/modules/messages/i18n/en.json +4 -0
- package/src/modules/messages/i18n/es.json +4 -0
- package/src/modules/messages/i18n/pl.json +4 -0
- package/src/modules/payment_gateways/api/cancel/route.ts +5 -0
- package/src/modules/payment_gateways/api/capture/route.ts +5 -0
- package/src/modules/payment_gateways/api/refund/route.ts +5 -0
- package/src/modules/payment_gateways/lib/gateway-service.ts +58 -25
- package/src/modules/payment_gateways/lib/status-machine.ts +16 -0
- package/src/modules/perspectives/api/[tableId]/route.ts +8 -2
- package/src/modules/perspectives/data/entities.ts +43 -3
- package/src/modules/perspectives/migrations/.snapshot-open-mercato.json +69 -25
- package/src/modules/perspectives/migrations/Migration20260619120000_perspectives_live_row_uniqueness.ts +65 -0
- package/src/modules/perspectives/services/perspectiveService.ts +17 -0
- package/src/modules/planner/commands/availability-weekly.ts +48 -1
- package/src/modules/planner/components/AvailabilityRulesEditor.tsx +31 -10
- package/src/modules/progress/api/active/route.ts +1 -1
- package/src/modules/progress/lib/progressService.ts +2 -2
- package/src/modules/progress/lib/progressServiceImpl.ts +33 -8
- package/src/modules/query_index/api/status.ts +28 -32
- package/src/modules/query_index/lib/coverage.ts +63 -0
- package/src/modules/query_index/lib/engine.ts +37 -24
- package/src/modules/resources/api/resource-types.ts +4 -44
- package/src/modules/resources/api/resourceTypeCounts.ts +74 -0
- package/src/modules/resources/backend/resources/resource-types/[id]/edit/page.tsx +1 -1
- package/src/modules/resources/backend/resources/resource-types/page.tsx +1 -0
- package/src/modules/sales/components/documents/ReturnDialog.tsx +4 -1
- package/src/modules/sales/components/documents/ShipmentDialog.tsx +20 -2
- package/src/modules/sales/di.ts +6 -0
- package/src/modules/sales/services/salesOrderService.ts +38 -0
- package/src/modules/shipping_carriers/api/shipments/route.ts +8 -0
- package/src/modules/shipping_carriers/data/entities.ts +33 -0
- package/src/modules/shipping_carriers/data/validators.ts +1 -0
- package/src/modules/shipping_carriers/i18n/de.json +1 -0
- package/src/modules/shipping_carriers/i18n/en.json +1 -0
- package/src/modules/shipping_carriers/i18n/es.json +1 -0
- package/src/modules/shipping_carriers/i18n/pl.json +1 -0
- package/src/modules/shipping_carriers/lib/shipment-idempotency.ts +119 -0
- package/src/modules/shipping_carriers/lib/shipment-wizard/hooks/shipmentApi.ts +3 -1
- package/src/modules/shipping_carriers/lib/shipment-wizard/hooks/useShipmentWizard.ts +24 -2
- package/src/modules/shipping_carriers/lib/shipping-service.ts +87 -43
- package/src/modules/shipping_carriers/migrations/.snapshot-open-mercato.json +197 -0
- package/src/modules/shipping_carriers/migrations/Migration20260618173616_shipping_carriers.ts +14 -0
- package/src/modules/staff/i18n/de.json +1 -0
- package/src/modules/staff/i18n/en.json +1 -0
- package/src/modules/staff/i18n/es.json +1 -0
- package/src/modules/staff/i18n/pl.json +1 -0
- package/src/modules/staff/lib/timesheets-ui/ListView.tsx +15 -7
- package/src/modules/translations/components/TranslationManager.tsx +17 -24
- package/src/modules/translations/i18n/de.json +1 -0
- package/src/modules/translations/i18n/en.json +1 -0
- package/src/modules/translations/i18n/es.json +1 -0
- package/src/modules/translations/i18n/pl.json +1 -0
|
@@ -335,90 +335,92 @@ async function GET(_req, ctx) {
|
|
|
335
335
|
currentUserId: viewerUserId,
|
|
336
336
|
userFeatures: void 0
|
|
337
337
|
});
|
|
338
|
-
const profile = company.companyProfile ? await findOneWithDecryption(
|
|
339
|
-
em,
|
|
340
|
-
CustomerCompanyProfile,
|
|
341
|
-
{
|
|
342
|
-
id: company.companyProfile.id,
|
|
343
|
-
tenantId: company.tenantId,
|
|
344
|
-
organizationId: company.organizationId
|
|
345
|
-
},
|
|
346
|
-
{},
|
|
347
|
-
companyScope
|
|
348
|
-
) : await findOneWithDecryption(
|
|
349
|
-
em,
|
|
350
|
-
CustomerCompanyProfile,
|
|
351
|
-
{
|
|
352
|
-
entity: company,
|
|
353
|
-
tenantId: company.tenantId,
|
|
354
|
-
organizationId: company.organizationId
|
|
355
|
-
},
|
|
356
|
-
{},
|
|
357
|
-
companyScope
|
|
358
|
-
);
|
|
359
|
-
const addresses = includeAddresses ? await findWithDecryption(
|
|
360
|
-
em,
|
|
361
|
-
CustomerAddress,
|
|
362
|
-
{
|
|
363
|
-
entity: company.id,
|
|
364
|
-
tenantId: company.tenantId,
|
|
365
|
-
organizationId: company.organizationId
|
|
366
|
-
},
|
|
367
|
-
{ orderBy: { isPrimary: "desc", createdAt: "desc" } },
|
|
368
|
-
companyScope
|
|
369
|
-
) : [];
|
|
370
|
-
const tagAssignments = await findWithDecryption(
|
|
371
|
-
em,
|
|
372
|
-
CustomerTagAssignment,
|
|
373
|
-
{
|
|
374
|
-
entity: company.id,
|
|
375
|
-
tenantId: company.tenantId,
|
|
376
|
-
organizationId: company.organizationId
|
|
377
|
-
},
|
|
378
|
-
{ populate: ["tag"] },
|
|
379
|
-
companyScope
|
|
380
|
-
);
|
|
381
|
-
const labelAssignments = await findWithDecryption(
|
|
382
|
-
em,
|
|
383
|
-
CustomerLabelAssignment,
|
|
384
|
-
{
|
|
385
|
-
entity: company.id,
|
|
386
|
-
tenantId: company.tenantId,
|
|
387
|
-
organizationId: company.organizationId
|
|
388
|
-
},
|
|
389
|
-
{ populate: ["label"] },
|
|
390
|
-
companyScope
|
|
391
|
-
);
|
|
392
|
-
const comments = includeComments ? await findWithDecryption(
|
|
393
|
-
em,
|
|
394
|
-
CustomerComment,
|
|
395
|
-
{
|
|
396
|
-
entity: company.id,
|
|
397
|
-
tenantId: company.tenantId,
|
|
398
|
-
organizationId: company.organizationId
|
|
399
|
-
},
|
|
400
|
-
{ orderBy: { createdAt: "desc" }, limit: 50 },
|
|
401
|
-
companyScope
|
|
402
|
-
) : [];
|
|
403
338
|
const shouldLoadCanonicalInteractions = includeInteractions || includeActivities || includeTodos;
|
|
404
|
-
const canonicalInteractionRows =
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
339
|
+
const [profile, addresses, tagAssignments, labelAssignments, comments, canonicalInteractionRows] = await Promise.all([
|
|
340
|
+
company.companyProfile ? findOneWithDecryption(
|
|
341
|
+
em,
|
|
342
|
+
CustomerCompanyProfile,
|
|
343
|
+
{
|
|
344
|
+
id: company.companyProfile.id,
|
|
345
|
+
tenantId: company.tenantId,
|
|
346
|
+
organizationId: company.organizationId
|
|
347
|
+
},
|
|
348
|
+
{},
|
|
349
|
+
companyScope
|
|
350
|
+
) : findOneWithDecryption(
|
|
351
|
+
em,
|
|
352
|
+
CustomerCompanyProfile,
|
|
353
|
+
{
|
|
354
|
+
entity: company,
|
|
355
|
+
tenantId: company.tenantId,
|
|
356
|
+
organizationId: company.organizationId
|
|
357
|
+
},
|
|
358
|
+
{},
|
|
359
|
+
companyScope
|
|
360
|
+
),
|
|
361
|
+
includeAddresses ? findWithDecryption(
|
|
362
|
+
em,
|
|
363
|
+
CustomerAddress,
|
|
364
|
+
{
|
|
365
|
+
entity: company.id,
|
|
366
|
+
tenantId: company.tenantId,
|
|
367
|
+
organizationId: company.organizationId
|
|
368
|
+
},
|
|
369
|
+
{ orderBy: { isPrimary: "desc", createdAt: "desc" } },
|
|
370
|
+
companyScope
|
|
371
|
+
) : Promise.resolve([]),
|
|
372
|
+
findWithDecryption(
|
|
373
|
+
em,
|
|
374
|
+
CustomerTagAssignment,
|
|
375
|
+
{
|
|
376
|
+
entity: company.id,
|
|
377
|
+
tenantId: company.tenantId,
|
|
378
|
+
organizationId: company.organizationId
|
|
379
|
+
},
|
|
380
|
+
{ populate: ["tag"] },
|
|
381
|
+
companyScope
|
|
382
|
+
),
|
|
383
|
+
findWithDecryption(
|
|
384
|
+
em,
|
|
385
|
+
CustomerLabelAssignment,
|
|
386
|
+
{
|
|
387
|
+
entity: company.id,
|
|
388
|
+
tenantId: company.tenantId,
|
|
389
|
+
organizationId: company.organizationId
|
|
390
|
+
},
|
|
391
|
+
{ populate: ["label"] },
|
|
392
|
+
companyScope
|
|
393
|
+
),
|
|
394
|
+
includeComments ? findWithDecryption(
|
|
395
|
+
em,
|
|
396
|
+
CustomerComment,
|
|
397
|
+
{
|
|
398
|
+
entity: company.id,
|
|
399
|
+
tenantId: company.tenantId,
|
|
400
|
+
organizationId: company.organizationId
|
|
401
|
+
},
|
|
402
|
+
{ orderBy: { createdAt: "desc" }, limit: 50 },
|
|
403
|
+
companyScope
|
|
404
|
+
) : Promise.resolve([]),
|
|
405
|
+
shouldLoadCanonicalInteractions ? findWithDecryption(
|
|
406
|
+
em,
|
|
407
|
+
CustomerInteraction,
|
|
408
|
+
interactionFlags.unified ? {
|
|
409
|
+
entity: company.id,
|
|
410
|
+
tenantId: company.tenantId,
|
|
411
|
+
organizationId: company.organizationId,
|
|
412
|
+
deletedAt: null,
|
|
413
|
+
...emailVisibilityFilter
|
|
414
|
+
} : {
|
|
415
|
+
entity: company.id,
|
|
416
|
+
tenantId: company.tenantId,
|
|
417
|
+
organizationId: company.organizationId,
|
|
418
|
+
...emailVisibilityFilter
|
|
419
|
+
},
|
|
420
|
+
{ orderBy: { scheduledAt: "asc", createdAt: "desc" }, limit: 100 },
|
|
421
|
+
companyScope
|
|
422
|
+
) : Promise.resolve([])
|
|
423
|
+
]);
|
|
422
424
|
const canonicalActiveInteractions = canonicalInteractionRows.filter((interaction) => !interaction.deletedAt);
|
|
423
425
|
const canonicalInteractions = shouldLoadCanonicalInteractions ? await hydrateCanonicalInteractions({
|
|
424
426
|
em,
|
|
@@ -624,20 +626,19 @@ async function GET(_req, ctx) {
|
|
|
624
626
|
});
|
|
625
627
|
relatedPeople = Array.from(relatedPeopleById.values());
|
|
626
628
|
}
|
|
627
|
-
const entityCustomFieldValues = await loadCustomFieldValues({
|
|
628
|
-
em,
|
|
629
|
-
entityId: E.customers.customer_entity,
|
|
630
|
-
recordIds: [company.id],
|
|
631
|
-
tenantIdByRecord: { [company.id]: company.tenantId ?? null },
|
|
632
|
-
organizationIdByRecord: { [company.id]: company.organizationId ?? null },
|
|
633
|
-
tenantFallbacks: [
|
|
634
|
-
company.tenantId ?? auth.tenantId ?? null
|
|
635
|
-
].filter((v) => !!v)
|
|
636
|
-
});
|
|
637
|
-
let profileCustomFieldValues = {};
|
|
638
629
|
const profileId = profile?.id ?? null;
|
|
639
|
-
|
|
640
|
-
|
|
630
|
+
const [entityCustomFieldValues, profileCustomFieldValues, routing] = await Promise.all([
|
|
631
|
+
loadCustomFieldValues({
|
|
632
|
+
em,
|
|
633
|
+
entityId: E.customers.customer_entity,
|
|
634
|
+
recordIds: [company.id],
|
|
635
|
+
tenantIdByRecord: { [company.id]: company.tenantId ?? null },
|
|
636
|
+
organizationIdByRecord: { [company.id]: company.organizationId ?? null },
|
|
637
|
+
tenantFallbacks: [
|
|
638
|
+
company.tenantId ?? auth.tenantId ?? null
|
|
639
|
+
].filter((v) => !!v)
|
|
640
|
+
}),
|
|
641
|
+
profileId ? loadCustomFieldValues({
|
|
641
642
|
em,
|
|
642
643
|
entityId: E.customers.customer_company_profile,
|
|
643
644
|
recordIds: [profileId],
|
|
@@ -646,9 +647,9 @@ async function GET(_req, ctx) {
|
|
|
646
647
|
tenantFallbacks: [
|
|
647
648
|
profile?.tenantId ?? company.tenantId ?? auth.tenantId ?? null
|
|
648
649
|
].filter((v) => !!v)
|
|
649
|
-
})
|
|
650
|
-
|
|
651
|
-
|
|
650
|
+
}) : Promise.resolve({}),
|
|
651
|
+
resolveCompanyCustomFieldRouting(em, company.tenantId ?? null, company.organizationId ?? null)
|
|
652
|
+
]);
|
|
652
653
|
const customFields = normalizeCustomerDetailCustomFields(
|
|
653
654
|
mergeCompanyCustomFieldValues(
|
|
654
655
|
routing,
|
|
@@ -656,75 +657,89 @@ async function GET(_req, ctx) {
|
|
|
656
657
|
profileId ? profileCustomFieldValues?.[profileId] ?? {} : {}
|
|
657
658
|
)
|
|
658
659
|
);
|
|
659
|
-
const
|
|
660
|
-
|
|
661
|
-
organizationId: company.organizationId,
|
|
662
|
-
tenantId: company.tenantId,
|
|
663
|
-
deletedAt: null,
|
|
664
|
-
interactionType: { $ne: "task" },
|
|
665
|
-
...emailVisibilityFilter
|
|
666
|
-
});
|
|
667
|
-
const interactionCount = await em.count(CustomerInteraction, {
|
|
668
|
-
entity: company.id,
|
|
669
|
-
organizationId: company.organizationId,
|
|
670
|
-
tenantId: company.tenantId,
|
|
671
|
-
deletedAt: null,
|
|
672
|
-
...emailVisibilityFilter
|
|
673
|
-
});
|
|
674
|
-
const todoCount = interactionFlags.unified ? await em.count(CustomerInteraction, {
|
|
675
|
-
entity: company.id,
|
|
676
|
-
organizationId: company.organizationId,
|
|
677
|
-
tenantId: company.tenantId,
|
|
678
|
-
deletedAt: null,
|
|
679
|
-
interactionType: "task"
|
|
680
|
-
}) : await em.count(CustomerTodoLink, {
|
|
681
|
-
entity: company.id,
|
|
682
|
-
organizationId: company.organizationId,
|
|
683
|
-
tenantId: company.tenantId
|
|
684
|
-
});
|
|
685
|
-
const commentsCount = includeComments ? comments.length : await em.count(CustomerComment, {
|
|
686
|
-
entity: company.id,
|
|
687
|
-
organizationId: company.organizationId,
|
|
688
|
-
tenantId: company.tenantId
|
|
689
|
-
});
|
|
690
|
-
const addressesCount = includeAddresses ? addresses.length : await em.count(CustomerAddress, {
|
|
691
|
-
entity: company.id,
|
|
692
|
-
organizationId: company.organizationId,
|
|
693
|
-
tenantId: company.tenantId
|
|
694
|
-
});
|
|
695
|
-
const peopleCount = includePeople ? relatedPeople.length : filterActivePersonCompanyLinks(
|
|
696
|
-
await findWithDecryption(
|
|
660
|
+
const peopleCountQuery = includePeople ? Promise.resolve(relatedPeople.length) : (async () => {
|
|
661
|
+
const peopleLinkWhere = await withActiveCustomerPersonCompanyLinkFilter(
|
|
697
662
|
em,
|
|
698
|
-
|
|
699
|
-
|
|
663
|
+
{
|
|
664
|
+
company: company.id,
|
|
665
|
+
organizationId: company.organizationId,
|
|
666
|
+
tenantId: company.tenantId
|
|
667
|
+
},
|
|
668
|
+
"customers.companies.GET"
|
|
669
|
+
);
|
|
670
|
+
return filterActivePersonCompanyLinks(
|
|
671
|
+
await findWithDecryption(
|
|
700
672
|
em,
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
673
|
+
CustomerPersonCompanyLink,
|
|
674
|
+
peopleLinkWhere,
|
|
675
|
+
{},
|
|
676
|
+
{ tenantId: company.tenantId, organizationId: company.organizationId }
|
|
677
|
+
)
|
|
678
|
+
).length;
|
|
679
|
+
})();
|
|
680
|
+
const [
|
|
681
|
+
activityCount,
|
|
682
|
+
interactionCount,
|
|
683
|
+
todoCount,
|
|
684
|
+
commentsCount,
|
|
685
|
+
addressesCount,
|
|
686
|
+
peopleCount,
|
|
687
|
+
kpiInteractionRows
|
|
688
|
+
] = await Promise.all([
|
|
689
|
+
em.count(CustomerInteraction, {
|
|
716
690
|
entity: company.id,
|
|
717
691
|
organizationId: company.organizationId,
|
|
718
692
|
tenantId: company.tenantId,
|
|
719
693
|
deletedAt: null,
|
|
694
|
+
interactionType: { $ne: "task" },
|
|
720
695
|
...emailVisibilityFilter
|
|
721
|
-
},
|
|
722
|
-
{
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
696
|
+
}),
|
|
697
|
+
em.count(CustomerInteraction, {
|
|
698
|
+
entity: company.id,
|
|
699
|
+
organizationId: company.organizationId,
|
|
700
|
+
tenantId: company.tenantId,
|
|
701
|
+
deletedAt: null,
|
|
702
|
+
...emailVisibilityFilter
|
|
703
|
+
}),
|
|
704
|
+
interactionFlags.unified ? em.count(CustomerInteraction, {
|
|
705
|
+
entity: company.id,
|
|
706
|
+
organizationId: company.organizationId,
|
|
707
|
+
tenantId: company.tenantId,
|
|
708
|
+
deletedAt: null,
|
|
709
|
+
interactionType: "task"
|
|
710
|
+
}) : em.count(CustomerTodoLink, {
|
|
711
|
+
entity: company.id,
|
|
712
|
+
organizationId: company.organizationId,
|
|
713
|
+
tenantId: company.tenantId
|
|
714
|
+
}),
|
|
715
|
+
includeComments ? Promise.resolve(comments.length) : em.count(CustomerComment, {
|
|
716
|
+
entity: company.id,
|
|
717
|
+
organizationId: company.organizationId,
|
|
718
|
+
tenantId: company.tenantId
|
|
719
|
+
}),
|
|
720
|
+
includeAddresses ? Promise.resolve(addresses.length) : em.count(CustomerAddress, {
|
|
721
|
+
entity: company.id,
|
|
722
|
+
organizationId: company.organizationId,
|
|
723
|
+
tenantId: company.tenantId
|
|
724
|
+
}),
|
|
725
|
+
peopleCountQuery,
|
|
726
|
+
canonicalActiveInteractions.length ? Promise.resolve(canonicalActiveInteractions) : findWithDecryption(
|
|
727
|
+
em,
|
|
728
|
+
CustomerInteraction,
|
|
729
|
+
{
|
|
730
|
+
entity: company.id,
|
|
731
|
+
organizationId: company.organizationId,
|
|
732
|
+
tenantId: company.tenantId,
|
|
733
|
+
deletedAt: null,
|
|
734
|
+
...emailVisibilityFilter
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
fields: ["id", "occurredAt", "scheduledAt", "createdAt"],
|
|
738
|
+
orderBy: { createdAt: "DESC" }
|
|
739
|
+
},
|
|
740
|
+
{ tenantId: company.tenantId, organizationId: company.organizationId }
|
|
741
|
+
)
|
|
742
|
+
]);
|
|
728
743
|
const activityTrend = computeActivityTrend(
|
|
729
744
|
kpiInteractionRows.map((interaction) => interaction.occurredAt ?? interaction.scheduledAt ?? interaction.createdAt).map((value) => value instanceof Date ? value.toISOString() : typeof value === "string" ? value : "").filter((value) => value.length > 0)
|
|
730
745
|
);
|