@open-mercato/cli 0.4.7 → 0.4.8-canary-d3f23076fd

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.
@@ -295,6 +295,10 @@ async function generateModuleRegistry(options) {
295
295
  const analyticsChecksumFile = path.join(outputDir, "analytics.generated.checksum");
296
296
  const transFieldsOutFile = path.join(outputDir, "translations-fields.generated.ts");
297
297
  const transFieldsChecksumFile = path.join(outputDir, "translations-fields.generated.checksum");
298
+ const securityMfaProvidersOutFile = path.join(outputDir, "security-mfa-providers.generated.ts");
299
+ const securityMfaProvidersChecksumFile = path.join(outputDir, "security-mfa-providers.generated.checksum");
300
+ const securitySudoOutFile = path.join(outputDir, "security-sudo.generated.ts");
301
+ const securitySudoChecksumFile = path.join(outputDir, "security-sudo.generated.checksum");
298
302
  const enrichersOutFile = path.join(outputDir, "enrichers.generated.ts");
299
303
  const enrichersChecksumFile = path.join(outputDir, "enrichers.generated.checksum");
300
304
  const interceptorsOutFile = path.join(outputDir, "interceptors.generated.ts");
@@ -307,6 +311,10 @@ async function generateModuleRegistry(options) {
307
311
  const guardsChecksumFile = path.join(outputDir, "guards.generated.checksum");
308
312
  const commandInterceptorsOutFile = path.join(outputDir, "command-interceptors.generated.ts");
309
313
  const commandInterceptorsChecksumFile = path.join(outputDir, "command-interceptors.generated.checksum");
314
+ const frontendMiddlewareOutFile = path.join(outputDir, "frontend-middleware.generated.ts");
315
+ const frontendMiddlewareChecksumFile = path.join(outputDir, "frontend-middleware.generated.checksum");
316
+ const backendMiddlewareOutFile = path.join(outputDir, "backend-middleware.generated.ts");
317
+ const backendMiddlewareChecksumFile = path.join(outputDir, "backend-middleware.generated.checksum");
310
318
  const enabled = resolver.loadEnabledModules();
311
319
  const imports = [];
312
320
  const moduleDecls = [];
@@ -336,6 +344,10 @@ async function generateModuleRegistry(options) {
336
344
  const analyticsImports = [];
337
345
  const transFieldsConfigs = [];
338
346
  const transFieldsImports = [];
347
+ const securityMfaProviderConfigs = [];
348
+ const securityMfaProviderImports = [];
349
+ const securitySudoConfigs = [];
350
+ const securitySudoImports = [];
339
351
  const enricherConfigs = [];
340
352
  const enricherImports = [];
341
353
  const interceptorConfigs = [];
@@ -348,6 +360,10 @@ async function generateModuleRegistry(options) {
348
360
  const guardImports = [];
349
361
  const commandInterceptorConfigs = [];
350
362
  const commandInterceptorImports = [];
363
+ const frontendMiddlewareConfigs = [];
364
+ const frontendMiddlewareImports = [];
365
+ const backendMiddlewareConfigs = [];
366
+ const backendMiddlewareImports = [];
351
367
  const umesConflictSources = [];
352
368
  for (const entry of enabled) {
353
369
  const modId = entry.id;
@@ -599,6 +615,28 @@ async function generateModuleRegistry(options) {
599
615
  sharedImports: imports,
600
616
  configExpr: (n, id) => `{ moduleId: '${id}', fields: (${n}.default ?? ${n}.translatableFields ?? {}) as Record<string, string[]> }`
601
617
  });
618
+ processStandaloneConfig({
619
+ roots,
620
+ imps,
621
+ modId,
622
+ importIdRef,
623
+ relativePath: "security.mfa-providers.ts",
624
+ prefix: "SECURITY_MFA_PROVIDERS",
625
+ standaloneImports: securityMfaProviderImports,
626
+ standaloneConfigs: securityMfaProviderConfigs,
627
+ configExpr: (n, id) => `{ moduleId: '${id}', providers: ((${n}.default ?? ${n}.mfaProviders ?? []) as unknown[]) }`
628
+ });
629
+ processStandaloneConfig({
630
+ roots,
631
+ imps,
632
+ modId,
633
+ importIdRef,
634
+ relativePath: "security.sudo.ts",
635
+ prefix: "SECURITY_SUDO",
636
+ standaloneImports: securitySudoImports,
637
+ standaloneConfigs: securitySudoConfigs,
638
+ configExpr: (n, id) => `{ moduleId: '${id}', targets: ((${n}.default ?? ${n}.sudoTargets ?? []) as Array<Record<string, unknown>>) }`
639
+ });
602
640
  {
603
641
  const resolved = resolveModuleFile(roots, imps, "inbox-actions.ts");
604
642
  if (resolved) {
@@ -632,6 +670,28 @@ async function generateModuleRegistry(options) {
632
670
  standaloneConfigs: commandInterceptorConfigs,
633
671
  configExpr: (n, id) => `{ moduleId: '${id}', interceptors: ((${n} as any).interceptors ?? (${n} as any).default ?? []) }`
634
672
  });
673
+ processStandaloneConfig({
674
+ roots,
675
+ imps,
676
+ modId,
677
+ importIdRef,
678
+ relativePath: "frontend/middleware.ts",
679
+ prefix: "FRONTEND_MIDDLEWARE",
680
+ standaloneImports: frontendMiddlewareImports,
681
+ standaloneConfigs: frontendMiddlewareConfigs,
682
+ configExpr: (n, id) => `{ moduleId: '${id}', middleware: ((${n} as any).middleware ?? (${n} as any).default ?? []) }`
683
+ });
684
+ processStandaloneConfig({
685
+ roots,
686
+ imps,
687
+ modId,
688
+ importIdRef,
689
+ relativePath: "backend/middleware.ts",
690
+ prefix: "BACKEND_MIDDLEWARE",
691
+ standaloneImports: backendMiddlewareImports,
692
+ standaloneConfigs: backendMiddlewareConfigs,
693
+ configExpr: (n, id) => `{ moduleId: '${id}', middleware: ((${n} as any).middleware ?? (${n} as any).default ?? []) }`
694
+ });
635
695
  {
636
696
  const setup = resolveConventionFile(roots, imps, "setup.ts", "SETUP", modId, importIdRef, imports);
637
697
  if (setup) setupImportName = setup.importName;
@@ -985,6 +1045,34 @@ export const allTranslatableEntityTypes = Object.keys(allFields)
985
1045
 
986
1046
  // Auto-register on import (side-effect)
987
1047
  registerTranslatableFields(allFields)
1048
+ `;
1049
+ const securityMfaProviderEntriesLiteral = securityMfaProviderConfigs.join(",\n ");
1050
+ const securityMfaProviderImportSection = securityMfaProviderImports.join("\n");
1051
+ const securityMfaProvidersOutput = `// AUTO-GENERATED by mercato generate registry
1052
+ ${securityMfaProviderImportSection ? `${securityMfaProviderImportSection}
1053
+ ` : ""}type SecurityMfaProviderEntry = { moduleId: string; providers: unknown[] }
1054
+
1055
+ export const securityMfaProviderEntries: SecurityMfaProviderEntry[] = [
1056
+ ${securityMfaProviderEntriesLiteral ? ` ${securityMfaProviderEntriesLiteral}
1057
+ ` : ""}]
1058
+ `;
1059
+ const securitySudoEntriesLiteral = securitySudoConfigs.join(",\n ");
1060
+ const securitySudoImportSection = securitySudoImports.join("\n");
1061
+ const securitySudoOutput = `// AUTO-GENERATED by mercato generate registry
1062
+ import type { SecuritySudoTarget, SecuritySudoTargetEntry } from '@open-mercato/enterprise/modules/security'
1063
+ ${securitySudoImportSection ? `
1064
+ ${securitySudoImportSection}
1065
+ ` : "\n"}
1066
+ type SecuritySudoTargetEntryRaw = { moduleId: string; targets: Array<Record<string, unknown>> }
1067
+
1068
+ const entriesRaw: SecuritySudoTargetEntryRaw[] = [
1069
+ ${securitySudoEntriesLiteral ? ` ${securitySudoEntriesLiteral}
1070
+ ` : ""}]
1071
+
1072
+ export const securitySudoTargetEntries: SecuritySudoTargetEntry[] = entriesRaw.map((entry) => ({
1073
+ moduleId: entry.moduleId,
1074
+ targets: entry.targets as SecuritySudoTarget[],
1075
+ }))
988
1076
  `;
989
1077
  const notificationEntriesLiteral = notificationTypes.join(",\n ");
990
1078
  const notificationImportSection = notificationImports.join("\n");
@@ -1269,6 +1357,8 @@ export const allAiTools = aiToolConfigEntries.flatMap(e => e.tools)
1269
1357
  writeGeneratedFile({ outFile: eventsOutFile, checksumFile: eventsChecksumFile, content: eventsOutput, structureChecksum, result, quiet });
1270
1358
  writeGeneratedFile({ outFile: analyticsOutFile, checksumFile: analyticsChecksumFile, content: analyticsOutput, structureChecksum, result, quiet });
1271
1359
  writeGeneratedFile({ outFile: transFieldsOutFile, checksumFile: transFieldsChecksumFile, content: transFieldsOutput, structureChecksum, result, quiet });
1360
+ writeGeneratedFile({ outFile: securityMfaProvidersOutFile, checksumFile: securityMfaProvidersChecksumFile, content: securityMfaProvidersOutput, structureChecksum, result, quiet });
1361
+ writeGeneratedFile({ outFile: securitySudoOutFile, checksumFile: securitySudoChecksumFile, content: securitySudoOutput, structureChecksum, result, quiet });
1272
1362
  const enricherEntriesLiteral = enricherConfigs.join(",\n ");
1273
1363
  const enricherImportSection = enricherImports.join("\n");
1274
1364
  const enrichersOutput = `// AUTO-GENERATED by mercato generate registry
@@ -1368,6 +1458,50 @@ ${commandInterceptorEntriesLiteral ? ` ${commandInterceptorEntriesLiteral}
1368
1458
  ` : ""}]
1369
1459
  `;
1370
1460
  writeGeneratedFile({ outFile: commandInterceptorsOutFile, checksumFile: commandInterceptorsChecksumFile, content: commandInterceptorsOutput, structureChecksum, result, quiet });
1461
+ const frontendMiddlewareEntriesLiteral = frontendMiddlewareConfigs.join(",\n ");
1462
+ const frontendMiddlewareImportSection = frontendMiddlewareImports.join("\n");
1463
+ const frontendMiddlewareOutput = `// AUTO-GENERATED by mercato generate registry
1464
+ import type { PageMiddlewareRegistryEntry, PageRouteMiddleware } from '@open-mercato/shared/modules/middleware/page'
1465
+ ${frontendMiddlewareImportSection ? `
1466
+ ${frontendMiddlewareImportSection}
1467
+ ` : "\n"}type FrontendMiddlewareEntry = { moduleId: string; middleware: PageRouteMiddleware[] }
1468
+
1469
+ const entriesRaw: FrontendMiddlewareEntry[] = [
1470
+ ${frontendMiddlewareEntriesLiteral ? ` ${frontendMiddlewareEntriesLiteral}
1471
+ ` : ""}]
1472
+
1473
+ export const frontendMiddlewareEntries: PageMiddlewareRegistryEntry[] = entriesRaw
1474
+ `;
1475
+ writeGeneratedFile({
1476
+ outFile: frontendMiddlewareOutFile,
1477
+ checksumFile: frontendMiddlewareChecksumFile,
1478
+ content: frontendMiddlewareOutput,
1479
+ structureChecksum,
1480
+ result,
1481
+ quiet
1482
+ });
1483
+ const backendMiddlewareEntriesLiteral = backendMiddlewareConfigs.join(",\n ");
1484
+ const backendMiddlewareImportSection = backendMiddlewareImports.join("\n");
1485
+ const backendMiddlewareOutput = `// AUTO-GENERATED by mercato generate registry
1486
+ import type { PageMiddlewareRegistryEntry, PageRouteMiddleware } from '@open-mercato/shared/modules/middleware/page'
1487
+ ${backendMiddlewareImportSection ? `
1488
+ ${backendMiddlewareImportSection}
1489
+ ` : "\n"}type BackendMiddlewareEntry = { moduleId: string; middleware: PageRouteMiddleware[] }
1490
+
1491
+ const entriesRaw: BackendMiddlewareEntry[] = [
1492
+ ${backendMiddlewareEntriesLiteral ? ` ${backendMiddlewareEntriesLiteral}
1493
+ ` : ""}]
1494
+
1495
+ export const backendMiddlewareEntries: PageMiddlewareRegistryEntry[] = entriesRaw
1496
+ `;
1497
+ writeGeneratedFile({
1498
+ outFile: backendMiddlewareOutFile,
1499
+ checksumFile: backendMiddlewareChecksumFile,
1500
+ content: backendMiddlewareOutput,
1501
+ structureChecksum,
1502
+ result,
1503
+ quiet
1504
+ });
1371
1505
  return result;
1372
1506
  }
1373
1507
  async function generateModuleRegistryCli(options) {