@open-mercato/core 0.4.2-canary-19703ca707 → 0.4.2-canary-470129ce32

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 (53) hide show
  1. package/dist/modules/customers/widgets/dashboard/customer-todos/widget.js +2 -1
  2. package/dist/modules/customers/widgets/dashboard/customer-todos/widget.js.map +2 -2
  3. package/dist/modules/customers/widgets/dashboard/new-customers/widget.js +2 -1
  4. package/dist/modules/customers/widgets/dashboard/new-customers/widget.js.map +2 -2
  5. package/dist/modules/customers/widgets/dashboard/new-deals/widget.js +2 -1
  6. package/dist/modules/customers/widgets/dashboard/new-deals/widget.js.map +2 -2
  7. package/dist/modules/customers/widgets/dashboard/next-interactions/widget.js +2 -1
  8. package/dist/modules/customers/widgets/dashboard/next-interactions/widget.js.map +2 -2
  9. package/dist/modules/dashboards/widgets/dashboard/aov-kpi/widget.js +2 -1
  10. package/dist/modules/dashboards/widgets/dashboard/aov-kpi/widget.js.map +2 -2
  11. package/dist/modules/dashboards/widgets/dashboard/new-customers-kpi/widget.js +2 -1
  12. package/dist/modules/dashboards/widgets/dashboard/new-customers-kpi/widget.js.map +2 -2
  13. package/dist/modules/dashboards/widgets/dashboard/orders-by-status/widget.js +2 -1
  14. package/dist/modules/dashboards/widgets/dashboard/orders-by-status/widget.js.map +2 -2
  15. package/dist/modules/dashboards/widgets/dashboard/orders-kpi/widget.js +2 -1
  16. package/dist/modules/dashboards/widgets/dashboard/orders-kpi/widget.js.map +2 -2
  17. package/dist/modules/dashboards/widgets/dashboard/pipeline-summary/widget.js +2 -1
  18. package/dist/modules/dashboards/widgets/dashboard/pipeline-summary/widget.js.map +2 -2
  19. package/dist/modules/dashboards/widgets/dashboard/revenue-kpi/widget.js +2 -1
  20. package/dist/modules/dashboards/widgets/dashboard/revenue-kpi/widget.js.map +2 -2
  21. package/dist/modules/dashboards/widgets/dashboard/revenue-trend/widget.js +2 -1
  22. package/dist/modules/dashboards/widgets/dashboard/revenue-trend/widget.js.map +2 -2
  23. package/dist/modules/dashboards/widgets/dashboard/sales-by-region/widget.js +2 -1
  24. package/dist/modules/dashboards/widgets/dashboard/sales-by-region/widget.js.map +2 -2
  25. package/dist/modules/dashboards/widgets/dashboard/top-customers/widget.js +2 -1
  26. package/dist/modules/dashboards/widgets/dashboard/top-customers/widget.js.map +2 -2
  27. package/dist/modules/dashboards/widgets/dashboard/top-products/widget.js +2 -1
  28. package/dist/modules/dashboards/widgets/dashboard/top-products/widget.js.map +2 -2
  29. package/dist/modules/directory/api/get/tenants/lookup.js +2 -0
  30. package/dist/modules/directory/api/get/tenants/lookup.js.map +2 -2
  31. package/dist/modules/notifications/migrations/Migration20260129082610.js +13 -0
  32. package/dist/modules/notifications/migrations/Migration20260129082610.js.map +7 -0
  33. package/dist/modules/query_index/cli.js +63 -7
  34. package/dist/modules/query_index/cli.js.map +2 -2
  35. package/package.json +2 -2
  36. package/src/modules/customers/widgets/dashboard/customer-todos/widget.ts +2 -2
  37. package/src/modules/customers/widgets/dashboard/new-customers/widget.ts +2 -2
  38. package/src/modules/customers/widgets/dashboard/new-deals/widget.ts +2 -2
  39. package/src/modules/customers/widgets/dashboard/next-interactions/widget.ts +2 -2
  40. package/src/modules/dashboards/widgets/dashboard/aov-kpi/widget.ts +2 -2
  41. package/src/modules/dashboards/widgets/dashboard/new-customers-kpi/widget.ts +2 -2
  42. package/src/modules/dashboards/widgets/dashboard/orders-by-status/widget.ts +2 -2
  43. package/src/modules/dashboards/widgets/dashboard/orders-kpi/widget.ts +2 -2
  44. package/src/modules/dashboards/widgets/dashboard/pipeline-summary/widget.ts +2 -2
  45. package/src/modules/dashboards/widgets/dashboard/revenue-kpi/widget.ts +2 -2
  46. package/src/modules/dashboards/widgets/dashboard/revenue-trend/widget.ts +2 -2
  47. package/src/modules/dashboards/widgets/dashboard/sales-by-region/widget.ts +2 -2
  48. package/src/modules/dashboards/widgets/dashboard/top-customers/widget.ts +2 -2
  49. package/src/modules/dashboards/widgets/dashboard/top-products/widget.ts +2 -2
  50. package/src/modules/directory/api/get/tenants/lookup.ts +2 -0
  51. package/src/modules/notifications/migrations/.snapshot-open-mercato.json +36 -0
  52. package/src/modules/notifications/migrations/Migration20260129082610.ts +13 -0
  53. package/src/modules/query_index/cli.ts +82 -13
@@ -22,6 +22,50 @@ import type { VectorIndexService } from '@open-mercato/search/vector'
22
22
 
23
23
  type ParsedArgs = Record<string, string | boolean>
24
24
 
25
+ type PartitionProgressInfo = { processed: number; total: number }
26
+
27
+ function isIndexerVerbose(): boolean {
28
+ const parsed = parseBooleanToken(process.env.OM_INDEXER_VERBOSE ?? '')
29
+ return parsed === true
30
+ }
31
+
32
+ function createGroupedProgress(label: string, partitionTargets: number[]) {
33
+ const totals = new Map<number, number>()
34
+ const processed = new Map<number, number>()
35
+ let bar: ProgressBarHandle | null = null
36
+
37
+ const getTotals = () => {
38
+ let total = 0
39
+ let done = 0
40
+ for (const value of totals.values()) total += value
41
+ for (const value of processed.values()) done += value
42
+ return { total, done }
43
+ }
44
+
45
+ const tryInitBar = () => {
46
+ if (bar) return
47
+ if (totals.size < partitionTargets.length) return
48
+ const { total } = getTotals()
49
+ if (total <= 0) return
50
+ bar = createProgressBar(label, total) as ProgressBarHandle
51
+ }
52
+
53
+ return {
54
+ onProgress(partition: number, info: PartitionProgressInfo) {
55
+ processed.set(partition, info.processed)
56
+ if (!totals.has(partition)) totals.set(partition, info.total)
57
+ tryInitBar()
58
+ if (!bar) return
59
+ const { done } = getTotals()
60
+ bar.update(done)
61
+ },
62
+ complete() {
63
+ if (bar) bar.complete()
64
+ },
65
+ getTotals,
66
+ }
67
+ }
68
+
25
69
  function parseArgs(rest: string[]): ParsedArgs {
26
70
  const args: ParsedArgs = {}
27
71
  for (let i = 0; i < rest.length; i += 1) {
@@ -550,8 +594,14 @@ const reindex: ModuleCli = {
550
594
  await purgeIndexScope(baseEm, { entityType: entity, organizationId: orgId, tenantId })
551
595
  }
552
596
  console.log(`Reindexing ${entity}${force ? ' (forced)' : ''} in ${partitionTargets.length} partition(s)...`)
553
- const progressState = new Map<number, { last: number }>()
554
- const renderProgress = (part: number, entityId: string, info: { processed: number; total: number }) => {
597
+ const verbose = isIndexerVerbose()
598
+ const progressState = verbose ? new Map<number, { last: number }>() : null
599
+ const groupedProgress =
600
+ !verbose && partitionTargets.length > 1
601
+ ? createGroupedProgress(`Reindexing ${entity}`, partitionTargets)
602
+ : null
603
+ const renderProgress = (part: number, entityId: string, info: PartitionProgressInfo) => {
604
+ if (!progressState) return
555
605
  const state = progressState.get(part) ?? { last: 0 }
556
606
  const now = Date.now()
557
607
  if (now - state.last < 1000 && info.processed < info.total) return
@@ -568,7 +618,7 @@ const reindex: ModuleCli = {
568
618
  const label = partitionTargets.length > 1 ? ` [partition ${part + 1}/${partitionCount}]` : ''
569
619
  if (partitionTargets.length === 1) {
570
620
  console.log(` -> processing${label}`)
571
- } else if (idx === 0) {
621
+ } else if (verbose && idx === 0) {
572
622
  console.log(` -> processing partitions in parallel (count=${partitionTargets.length})`)
573
623
  }
574
624
  const partitionContainer = await createRequestContainer()
@@ -596,9 +646,14 @@ const reindex: ModuleCli = {
596
646
  onProgress(info) {
597
647
  if (useBar) {
598
648
  if (info.total > 0 && !progressBar) {
599
- progressBar = createProgressBar(`Reindexing ${entity}${label}`, info.total) as ProgressBarHandle
649
+ progressBar = createProgressBar(
650
+ `Reindexing ${entity}${label}`,
651
+ info.total,
652
+ ) as ProgressBarHandle
600
653
  }
601
654
  progressBar?.update(info.processed)
655
+ } else if (groupedProgress) {
656
+ groupedProgress.onProgress(part, info)
602
657
  } else {
603
658
  renderProgress(part, entity, info)
604
659
  }
@@ -607,7 +662,9 @@ const reindex: ModuleCli = {
607
662
  if (progressBar) {
608
663
  (progressBar as ProgressBarHandle).complete()
609
664
  }
610
- if (!useBar) {
665
+ if (!useBar && groupedProgress) {
666
+ groupedProgress.onProgress(part, { processed: partitionStats.processed, total: partitionStats.total })
667
+ } else if (!useBar) {
611
668
  renderProgress(part, entity, { processed: partitionStats.processed, total: partitionStats.total })
612
669
  } else {
613
670
  console.log(
@@ -622,6 +679,7 @@ const reindex: ModuleCli = {
622
679
  }
623
680
  }),
624
681
  )
682
+ groupedProgress?.complete()
625
683
  const totalProcessed = stats.reduce((acc, value) => acc + value, 0)
626
684
  console.log(`Finished ${entity}: processed ${totalProcessed} row(s) across ${partitionTargets.length} partition(s)`)
627
685
  await recordIndexerLog(
@@ -677,8 +735,14 @@ const reindex: ModuleCli = {
677
735
  console.log(
678
736
  `[${idx + 1}/${entityIds.length}] Reindexing ${id}${force ? ' (forced)' : ''} in ${partitionTargets.length} partition(s)...`,
679
737
  )
680
- const progressState = new Map<number, { last: number }>()
681
- const renderProgress = (part: number, entityId: string, info: { processed: number; total: number }) => {
738
+ const verbose = isIndexerVerbose()
739
+ const progressState = verbose ? new Map<number, { last: number }>() : null
740
+ const groupedProgress =
741
+ !verbose && partitionTargets.length > 1
742
+ ? createGroupedProgress(`Reindexing ${id}`, partitionTargets)
743
+ : null
744
+ const renderProgress = (part: number, entityId: string, info: PartitionProgressInfo) => {
745
+ if (!progressState) return
682
746
  const state = progressState.get(part) ?? { last: 0 }
683
747
  const now = Date.now()
684
748
  if (now - state.last < 1000 && info.processed < info.total) return
@@ -695,7 +759,7 @@ const reindex: ModuleCli = {
695
759
  const label = partitionTargets.length > 1 ? ` [partition ${part + 1}/${partitionCount}]` : ''
696
760
  if (partitionTargets.length === 1) {
697
761
  console.log(` -> processing${label}`)
698
- } else if (partitionIdx === 0) {
762
+ } else if (verbose && partitionIdx === 0) {
699
763
  console.log(` -> processing partitions in parallel (count=${partitionTargets.length})`)
700
764
  }
701
765
  const partitionContainer = await createRequestContainer()
@@ -723,18 +787,22 @@ const reindex: ModuleCli = {
723
787
  onProgress(info) {
724
788
  if (useBar) {
725
789
  if (info.total > 0 && !progressBar) {
726
- progressBar = createProgressBar(`Reindexing ${id}${label}`, info.total) as ProgressBarHandle
790
+ progressBar = createProgressBar(`Reindexing ${id}${label}`, info.total) as ProgressBarHandle
727
791
  }
728
792
  progressBar?.update(info.processed)
793
+ } else if (groupedProgress) {
794
+ groupedProgress.onProgress(part, info)
729
795
  } else {
730
796
  renderProgress(part, id, info)
731
797
  }
732
798
  },
733
799
  })
734
- if (progressBar) {
735
- (progressBar as ProgressBarHandle).complete()
736
- }
737
- if (!useBar) {
800
+ if (progressBar) {
801
+ (progressBar as ProgressBarHandle).complete()
802
+ }
803
+ if (!useBar && groupedProgress) {
804
+ groupedProgress.onProgress(part, { processed: result.processed, total: result.total })
805
+ } else if (!useBar) {
738
806
  renderProgress(part, id, { processed: result.processed, total: result.total })
739
807
  } else {
740
808
  console.log(
@@ -749,6 +817,7 @@ const reindex: ModuleCli = {
749
817
  }
750
818
  }),
751
819
  )
820
+ groupedProgress?.complete()
752
821
  const totalProcessed = partitionResults.reduce((acc, value) => acc + value, 0)
753
822
  console.log(` -> ${id} complete: processed ${totalProcessed} row(s) across ${partitionTargets.length} partition(s)`)
754
823
  await recordIndexerLog(