@open-mercato/core 0.4.2-canary-19353c5970 → 0.4.2-canary-ad4e7882e9
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/dist/modules/auth/api/login.js +25 -6
- package/dist/modules/auth/api/login.js.map +2 -2
- package/dist/modules/auth/data/validators.js +2 -1
- package/dist/modules/auth/data/validators.js.map +2 -2
- package/dist/modules/auth/frontend/login.js +85 -1
- package/dist/modules/auth/frontend/login.js.map +2 -2
- package/dist/modules/auth/lib/setup-app.js +25 -12
- package/dist/modules/auth/lib/setup-app.js.map +2 -2
- package/dist/modules/auth/services/authService.js +21 -0
- package/dist/modules/auth/services/authService.js.map +2 -2
- package/dist/modules/business_rules/cli.js +2 -1
- package/dist/modules/business_rules/cli.js.map +2 -2
- package/dist/modules/directory/api/get/tenants/lookup.js +70 -0
- package/dist/modules/directory/api/get/tenants/lookup.js.map +7 -0
- package/dist/modules/notifications/migrations/Migration20260129082610.js +13 -0
- package/dist/modules/notifications/migrations/Migration20260129082610.js.map +7 -0
- package/dist/modules/query_index/cli.js +63 -7
- package/dist/modules/query_index/cli.js.map +2 -2
- package/dist/modules/workflows/cli.js +12 -12
- package/dist/modules/workflows/cli.js.map +2 -2
- package/package.json +2 -2
- package/src/modules/auth/api/__tests__/login.test.ts +2 -0
- package/src/modules/auth/api/login.ts +26 -7
- package/src/modules/auth/data/validators.ts +1 -0
- package/src/modules/auth/frontend/login.tsx +106 -2
- package/src/modules/auth/i18n/de.json +5 -0
- package/src/modules/auth/i18n/en.json +5 -0
- package/src/modules/auth/i18n/es.json +5 -0
- package/src/modules/auth/i18n/pl.json +5 -0
- package/src/modules/auth/lib/setup-app.ts +37 -15
- package/src/modules/auth/services/authService.ts +23 -0
- package/src/modules/business_rules/cli.ts +2 -1
- package/src/modules/directory/api/get/tenants/lookup.ts +75 -0
- package/src/modules/notifications/migrations/.snapshot-open-mercato.json +36 -0
- package/src/modules/notifications/migrations/Migration20260129082610.ts +13 -0
- package/src/modules/query_index/cli.ts +82 -13
- package/src/modules/workflows/cli.ts +12 -12
|
@@ -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
|
|
554
|
-
const
|
|
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
|
-
|
|
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
|
|
681
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
735
|
-
|
|
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(
|
|
@@ -56,7 +56,7 @@ const seedDemo: ModuleCli = {
|
|
|
56
56
|
})
|
|
57
57
|
|
|
58
58
|
if (existing) {
|
|
59
|
-
console.log(
|
|
59
|
+
console.log(`ℹ️ Demo workflow '${demoData.workflowId}' already exists (ID: ${existing.id})`)
|
|
60
60
|
return
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -69,7 +69,7 @@ const seedDemo: ModuleCli = {
|
|
|
69
69
|
|
|
70
70
|
await em.persistAndFlush(workflow)
|
|
71
71
|
|
|
72
|
-
console.log(
|
|
72
|
+
console.log(`✅ Seeded demo workflow: ${workflow.workflowName}`)
|
|
73
73
|
console.log(` - ID: ${workflow.id}`)
|
|
74
74
|
console.log(` - Workflow ID: ${workflow.workflowId}`)
|
|
75
75
|
console.log(` - Version: ${workflow.version}`)
|
|
@@ -107,15 +107,15 @@ const seedDemoWithRules: ModuleCli = {
|
|
|
107
107
|
return
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
console.log('🧩 Seeding demo workflow with guard rules...\n')
|
|
111
111
|
|
|
112
112
|
try {
|
|
113
113
|
// Seed the workflow definition
|
|
114
|
-
console.log('1. Seeding demo workflow...')
|
|
114
|
+
console.log('1. 🧩 Seeding demo workflow...')
|
|
115
115
|
await seedDemo.run(rest)
|
|
116
116
|
|
|
117
117
|
// Seed the guard rules
|
|
118
|
-
console.log('\n2. Seeding guard rules...')
|
|
118
|
+
console.log('\n2. 🧠 Seeding guard rules...')
|
|
119
119
|
const { resolve } = await createRequestContainer()
|
|
120
120
|
const em = resolve<EntityManager>('em')
|
|
121
121
|
|
|
@@ -153,7 +153,7 @@ const seedDemoWithRules: ModuleCli = {
|
|
|
153
153
|
seededCount++
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
console.log(`\n
|
|
156
|
+
console.log(`\n✅ Demo workflow with guard rules seeded successfully!`)
|
|
157
157
|
console.log(` - Workflow: checkout_simple_v1`)
|
|
158
158
|
console.log(` - Guard rules seeded: ${seededCount}`)
|
|
159
159
|
console.log(` - Guard rules skipped: ${skippedCount}`)
|
|
@@ -195,7 +195,7 @@ const seedSalesPipeline: ModuleCli = {
|
|
|
195
195
|
})
|
|
196
196
|
|
|
197
197
|
if (existing) {
|
|
198
|
-
console.log(
|
|
198
|
+
console.log(`ℹ️ Sales pipeline workflow '${pipelineData.workflowId}' already exists (ID: ${existing.id})`)
|
|
199
199
|
return
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -208,7 +208,7 @@ const seedSalesPipeline: ModuleCli = {
|
|
|
208
208
|
|
|
209
209
|
await em.persistAndFlush(workflow)
|
|
210
210
|
|
|
211
|
-
console.log(
|
|
211
|
+
console.log(`✅ Seeded sales pipeline workflow: ${workflow.workflowName}`)
|
|
212
212
|
console.log(` - ID: ${workflow.id}`)
|
|
213
213
|
console.log(` - Workflow ID: ${workflow.workflowId}`)
|
|
214
214
|
console.log(` - Version: ${workflow.version}`)
|
|
@@ -255,7 +255,7 @@ const seedSimpleApproval: ModuleCli = {
|
|
|
255
255
|
})
|
|
256
256
|
|
|
257
257
|
if (existing) {
|
|
258
|
-
console.log(
|
|
258
|
+
console.log(`ℹ️ Simple approval workflow '${approvalData.workflowId}' already exists (ID: ${existing.id})`)
|
|
259
259
|
return
|
|
260
260
|
}
|
|
261
261
|
|
|
@@ -268,7 +268,7 @@ const seedSimpleApproval: ModuleCli = {
|
|
|
268
268
|
|
|
269
269
|
await em.persistAndFlush(workflow)
|
|
270
270
|
|
|
271
|
-
console.log(
|
|
271
|
+
console.log(`✅ Seeded simple approval workflow: ${workflow.workflowName}`)
|
|
272
272
|
console.log(` - ID: ${workflow.id}`)
|
|
273
273
|
console.log(` - Workflow ID: ${workflow.workflowId}`)
|
|
274
274
|
console.log(` - Version: ${workflow.version}`)
|
|
@@ -351,7 +351,7 @@ const seedAll: ModuleCli = {
|
|
|
351
351
|
return
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
console.log('Seeding all example workflows...\n')
|
|
354
|
+
console.log('🧩 Seeding all example workflows...\n')
|
|
355
355
|
|
|
356
356
|
try {
|
|
357
357
|
// Seed demo checkout with rules
|
|
@@ -366,7 +366,7 @@ const seedAll: ModuleCli = {
|
|
|
366
366
|
await seedSimpleApproval.run(rest)
|
|
367
367
|
console.log('')
|
|
368
368
|
|
|
369
|
-
console.log('
|
|
369
|
+
console.log('✅ All example workflows seeded successfully!')
|
|
370
370
|
} catch (error) {
|
|
371
371
|
console.error('Error seeding workflows:', error)
|
|
372
372
|
throw error
|