create-mercato-app 0.6.6-develop.6361.1.e790d2aa34 → 0.6.6-develop.6363.1.03c5e3429a

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mercato-app",
3
- "version": "0.6.6-develop.6361.1.e790d2aa34",
3
+ "version": "0.6.6-develop.6363.1.03c5e3429a",
4
4
  "type": "module",
5
5
  "description": "Create a new Open Mercato application",
6
6
  "main": "./dist/index.js",
@@ -17,6 +17,7 @@ jest.mock('@/bootstrap', () => ({
17
17
  }))
18
18
 
19
19
  jest.mock('@open-mercato/shared/lib/i18n/server', () => ({
20
+ registerAppDictionaryLoader: jest.fn(),
20
21
  detectLocale: jest.fn(async () => 'en'),
21
22
  loadDictionary: jest.fn(async () => ({ common: 'value' })),
22
23
  }))
@@ -0,0 +1,14 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+
4
+ describe('login API route graph', () => {
5
+ it('serves POST /api/auth/login through a direct route instead of the generated API catch-all', () => {
6
+ const routePath = path.join(process.cwd(), 'src/app/api/auth/login/route.ts')
7
+ const source = fs.readFileSync(routePath, 'utf8')
8
+
9
+ expect(source).toContain('@open-mercato/core/modules/auth/api/login')
10
+ expect(source).toContain('@/bootstrap')
11
+ expect(source).not.toContain('api-routes.generated')
12
+ expect(source).not.toContain('[...slug]')
13
+ })
14
+ })
@@ -0,0 +1,13 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+
4
+ describe('login route graph', () => {
5
+ it('serves /login through a direct route instead of the generated frontend catch-all', () => {
6
+ const routePath = path.join(process.cwd(), 'src/app/login/page.tsx')
7
+ const source = fs.readFileSync(routePath, 'utf8')
8
+
9
+ expect(source).toContain('@open-mercato/core/modules/auth/frontend/login')
10
+ expect(source).not.toContain('frontend-routes.generated')
11
+ expect(source).not.toContain('@/bootstrap')
12
+ })
13
+ })
@@ -0,0 +1,7 @@
1
+ import { bootstrap } from '@/bootstrap'
2
+ import { POST as loginPost } from '@open-mercato/core/modules/auth/api/login'
3
+ export { metadata, openApi } from '@open-mercato/core/modules/auth/api/login'
4
+
5
+ bootstrap()
6
+
7
+ export const POST = loginPost
@@ -1,10 +1,8 @@
1
1
  import type { Metadata } from 'next'
2
2
  import './globals.css'
3
- import { bootstrap } from '@/bootstrap'
3
+ import '@/lib/i18n/register-dictionary-loader'
4
4
  import { AppProviders } from '@/components/AppProviders'
5
5
 
6
- // Bootstrap all package registrations at module load time
7
- bootstrap()
8
6
  import { detectLocale, loadDictionary } from '@open-mercato/shared/lib/i18n/server'
9
7
 
10
8
  export const metadata: Metadata = {
@@ -0,0 +1,12 @@
1
+ import { Suspense } from 'react'
2
+ import LoginPage from '@open-mercato/core/modules/auth/frontend/login'
3
+
4
+ export default function LoginRoutePage() {
5
+ return (
6
+ // LoginPage reads query params with useSearchParams; keep this boundary so
7
+ // static builds can prerender the route and hydrate the client-only params.
8
+ <Suspense fallback={null}>
9
+ <LoginPage />
10
+ </Suspense>
11
+ )
12
+ }
@@ -10,23 +10,7 @@
10
10
  */
11
11
 
12
12
  // Register app dictionary loader before bootstrap (required for i18n in standalone packages)
13
- import { registerAppDictionaryLoader } from '@open-mercato/shared/lib/i18n/server'
14
- import type { Locale } from '@open-mercato/shared/lib/i18n/config'
15
-
16
- registerAppDictionaryLoader(async (locale: Locale): Promise<Record<string, unknown>> => {
17
- switch (locale) {
18
- case 'en':
19
- return import('./i18n/en.json').then((m) => m.default)
20
- case 'pl':
21
- return import('./i18n/pl.json').then((m) => m.default)
22
- case 'es':
23
- return import('./i18n/es.json').then((m) => m.default)
24
- case 'de':
25
- return import('./i18n/de.json').then((m) => m.default)
26
- default:
27
- return import('./i18n/en.json').then((m) => m.default)
28
- }
29
- })
13
+ import './lib/i18n/register-dictionary-loader'
30
14
 
31
15
  // modules.ts inline overrides (replace/disable any contract a module
32
16
  // presents through the unified modules.ts override surface).
@@ -39,7 +23,7 @@ import '@open-mercato/ai-assistant'
39
23
  applyModuleOverridesFromEnabledModules(enabledModules)
40
24
 
41
25
  // Generated imports (static - works with bundlers)
42
- import { modules } from '@/.mercato/generated/modules.app.generated'
26
+ import { modules } from '@/.mercato/generated/modules.bootstrap.generated'
43
27
  import { entities } from '@/.mercato/generated/entities.generated'
44
28
  import { diRegistrars } from '@/.mercato/generated/di.generated'
45
29
  import { E } from '@/.mercato/generated/entities.ids.generated'
@@ -0,0 +1,21 @@
1
+ import { registerAppDictionaryLoader } from '@open-mercato/shared/lib/i18n/server'
2
+ import { registerModules } from '@open-mercato/shared/lib/modules/registry'
3
+ import type { Locale } from '@open-mercato/shared/lib/i18n/config'
4
+ import { modules as i18nModules } from '@/.mercato/generated/modules.i18n.generated'
5
+
6
+ registerModules(i18nModules)
7
+
8
+ registerAppDictionaryLoader(async (locale: Locale): Promise<Record<string, unknown>> => {
9
+ switch (locale) {
10
+ case 'en':
11
+ return import('../../i18n/en.json').then((m) => m.default)
12
+ case 'pl':
13
+ return import('../../i18n/pl.json').then((m) => m.default)
14
+ case 'es':
15
+ return import('../../i18n/es.json').then((m) => m.default)
16
+ case 'de':
17
+ return import('../../i18n/de.json').then((m) => m.default)
18
+ default:
19
+ return import('../../i18n/en.json').then((m) => m.default)
20
+ }
21
+ })
@@ -1,7 +1,9 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
1
3
  import { z } from 'zod'
2
4
  import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
3
5
  import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
4
- import { registerGlobalEventTap } from '@open-mercato/events/bus'
6
+ import { registerCrossProcessEventListener, registerGlobalEventTap } from '@open-mercato/events/bus'
5
7
  import { exampleTag } from '../openapi'
6
8
 
7
9
  type CapturedEvent = {
@@ -13,6 +15,7 @@ type CapturedEvent = {
13
15
  const CAPTURED_EVENTS_KEY = '__exampleCapturedQaEvents__'
14
16
  const CAPTURE_TAP_KEY = '__exampleCapturedQaEventsTap__'
15
17
  const MAX_CAPTURED_EVENTS = 200
18
+ const QA_EVENTS_FILE_ENV = 'OM_QA_EVENTS_FILE'
16
19
 
17
20
  const querySchema = z.object({
18
21
  event: z.string().trim().optional(),
@@ -30,24 +33,85 @@ function getCapturedEventsStore(): CapturedEvent[] {
30
33
  return created
31
34
  }
32
35
 
36
+ function getCapturedEventsFilePath(): string {
37
+ const configured = process.env[QA_EVENTS_FILE_ENV]?.trim()
38
+ return configured || path.join(process.cwd(), '.mercato', 'qa-events.jsonl')
39
+ }
40
+
41
+ function readPersistedEvents(): CapturedEvent[] {
42
+ try {
43
+ const filePath = getCapturedEventsFilePath()
44
+ if (!fs.existsSync(filePath)) return []
45
+ return fs.readFileSync(filePath, 'utf8')
46
+ .split('\n')
47
+ .map((line) => line.trim())
48
+ .filter(Boolean)
49
+ .flatMap((line) => {
50
+ try {
51
+ return [JSON.parse(line) as CapturedEvent]
52
+ } catch {
53
+ return []
54
+ }
55
+ })
56
+ .slice(-MAX_CAPTURED_EVENTS)
57
+ } catch {
58
+ return []
59
+ }
60
+ }
61
+
62
+ function appendPersistedEvent(event: CapturedEvent): void {
63
+ try {
64
+ const filePath = getCapturedEventsFilePath()
65
+ fs.mkdirSync(path.dirname(filePath), { recursive: true })
66
+ fs.appendFileSync(filePath, `${JSON.stringify(event)}\n`, 'utf8')
67
+ } catch {
68
+ // QA capture must never break the event bus.
69
+ }
70
+ }
71
+
72
+ function replacePersistedEvents(events: CapturedEvent[]): void {
73
+ try {
74
+ const filePath = getCapturedEventsFilePath()
75
+ fs.mkdirSync(path.dirname(filePath), { recursive: true })
76
+ const serialized = events
77
+ .slice(-MAX_CAPTURED_EVENTS)
78
+ .map((event) => JSON.stringify(event))
79
+ .join('\n')
80
+ fs.writeFileSync(filePath, serialized ? `${serialized}\n` : '', 'utf8')
81
+ } catch {
82
+ // QA cleanup is best-effort.
83
+ }
84
+ }
85
+
86
+ function captureEvent(event: string, payload: unknown): void {
87
+ const normalizedPayload = payload && typeof payload === 'object' && !Array.isArray(payload)
88
+ ? payload as Record<string, unknown>
89
+ : {}
90
+ const capturedEvent = {
91
+ event,
92
+ payload: normalizedPayload,
93
+ capturedAt: new Date().toISOString(),
94
+ }
95
+ const store = getCapturedEventsStore()
96
+ store.push(capturedEvent)
97
+ if (store.length > MAX_CAPTURED_EVENTS) {
98
+ store.splice(0, store.length - MAX_CAPTURED_EVENTS)
99
+ }
100
+ appendPersistedEvent(capturedEvent)
101
+ }
102
+
33
103
  function ensureCaptureTap(): void {
34
104
  const globalScope = globalThis as Record<string, unknown>
35
105
  if (globalScope[CAPTURE_TAP_KEY] === true) return
36
106
  globalScope[CAPTURE_TAP_KEY] = true
37
107
 
38
108
  registerGlobalEventTap((event, payload) => {
39
- const normalizedPayload = payload && typeof payload === 'object' && !Array.isArray(payload)
40
- ? payload as Record<string, unknown>
41
- : {}
42
- const store = getCapturedEventsStore()
43
- store.push({
44
- event,
45
- payload: normalizedPayload,
46
- capturedAt: new Date().toISOString(),
47
- })
48
- if (store.length > MAX_CAPTURED_EVENTS) {
49
- store.splice(0, store.length - MAX_CAPTURED_EVENTS)
50
- }
109
+ captureEvent(event, payload)
110
+ })
111
+
112
+ registerCrossProcessEventListener((envelope) => {
113
+ if (envelope.originPid === process.pid) return
114
+ captureEvent(envelope.event, envelope.payload)
51
115
  })
52
116
  }
53
117
 
@@ -76,7 +140,7 @@ export async function GET(request: Request) {
76
140
  prefix: url.searchParams.get('prefix') ?? undefined,
77
141
  })
78
142
 
79
- const items = getCapturedEventsStore().filter((event) => {
143
+ const items = readPersistedEvents().filter((event) => {
80
144
  if (!matchesScope(event, auth)) return false
81
145
  if (query.event && event.event !== query.event) return false
82
146
  if (query.prefix && !event.event.startsWith(query.prefix)) return false
@@ -99,6 +163,7 @@ export async function DELETE(request: Request) {
99
163
  store.splice(index, 1)
100
164
  }
101
165
  }
166
+ replacePersistedEvents(readPersistedEvents().filter((event) => !matchesScope(event, auth)))
102
167
 
103
168
  return Response.json({ ok: true })
104
169
  }