@mostajs/setup 2.1.31 → 2.1.35

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.
@@ -15,8 +15,14 @@ export function createSetupJsonHandler(needsSetup) {
15
15
  const setupJsonPath = () => path.resolve(process.cwd(), 'setup.json');
16
16
  async function GET() {
17
17
  const filePath = setupJsonPath();
18
+ // Always include env vars for NET config
19
+ const env = {
20
+ netUrl: process.env.MOSTA_NET_URL || '',
21
+ netTransport: process.env.MOSTA_NET_TRANSPORT || 'rest',
22
+ dataMode: process.env.MOSTA_DATA || '',
23
+ };
18
24
  if (!fs.existsSync(filePath)) {
19
- return Response.json({ exists: false });
25
+ return Response.json({ exists: false, env });
20
26
  }
21
27
  try {
22
28
  const raw = fs.readFileSync(filePath, 'utf-8');
@@ -37,6 +43,7 @@ export function createSetupJsonHandler(needsSetup) {
37
43
  })),
38
44
  modules: json.modules ?? [],
39
45
  },
46
+ env,
40
47
  });
41
48
  }
42
49
  catch (err) {
@@ -22,6 +22,10 @@ export interface SetupWizardProps {
22
22
  };
23
23
  /** Default database name prefix (e.g. 'secuaccessdb') */
24
24
  dbNamePrefix?: string;
25
+ /** Initial NET server URL (read from .env.local MOSTA_NET_URL) */
26
+ initialNetUrl?: string;
27
+ /** Initial NET transport (read from .env.local MOSTA_NET_TRANSPORT) */
28
+ initialNetTransport?: 'rest' | 'graphql' | 'jsonrpc' | 'ws';
25
29
  /** Whether to persist wizard state in sessionStorage (default: true) */
26
30
  persistState?: boolean;
27
31
  /**
@@ -45,4 +49,4 @@ export interface SetupWizardProps {
45
49
  dependsOn?: string[];
46
50
  }[];
47
51
  }
48
- export default function SetupWizard({ t: tProp, onComplete, endpoints, dbNamePrefix, persistState, showModules, declaredModules, }: SetupWizardProps): import("react/jsx-runtime").JSX.Element;
52
+ export default function SetupWizard({ t: tProp, onComplete, endpoints, dbNamePrefix, persistState, showModules, declaredModules, initialNetUrl, initialNetTransport, }: SetupWizardProps): import("react/jsx-runtime").JSX.Element;
@@ -346,7 +346,7 @@ function JarUploadInline({ dialect, jarEndpoint, dbConfig }) {
346
346
  return (_jsxs("div", { style: S.jarBox, children: [_jsxs("div", { style: S.flex(8), children: [_jsx("span", { style: S.jarTitle, children: "Driver JDBC" }), jarStatus?.hasJar ? (_jsx("span", { style: { ...S.badge('installed'), marginLeft: 0 }, children: jarStatus.jarFile })) : (_jsx("span", { style: { fontSize: 12, color: '#6b7280' }, children: "Aucun JAR installe" }))] }), _jsxs("div", { style: { marginTop: 8 }, children: [_jsxs("label", { style: { ...S.btn('primary', uploading), cursor: uploading ? 'wait' : 'pointer', fontSize: 12, padding: '6px 12px' }, children: [uploading ? 'Upload...' : 'Uploader un .jar', _jsx("input", { type: "file", accept: ".jar", onChange: handleUpload, disabled: uploading, style: { display: 'none' } })] }), _jsx("span", { style: { fontSize: 11, color: '#9ca3af', marginLeft: 8 }, children: "Ex: hsqldb*.jar, ojdbc*.jar" })] }), isHsqldb && jarStatus?.hasJar && (_jsxs("div", { style: { marginTop: 10, padding: '10px 12px', backgroundColor: '#fef9c3', borderRadius: 6, border: '1px solid #fde68a' }, children: [_jsxs("div", { style: { fontSize: 12, fontWeight: 600, color: '#92400e', marginBottom: 6 }, children: ["Serveur HSQLDB", _jsxs("span", { style: { fontWeight: 400, color: '#6b7280', marginLeft: 4 }, children: ["(port SGBD : ", dbConfig.port || 9001, ")"] }), serverInfo?.running && (_jsxs("span", { style: { fontWeight: 400, color: '#059669', marginLeft: 8 }, children: ["En marche sur port ", serverInfo.port, serverInfo.pid > 0 ? ` — PID ${serverInfo.pid}` : ''] })), !serverInfo?.running && (_jsx("span", { style: { fontWeight: 400, color: '#dc2626', marginLeft: 8 }, children: "Arrete" }))] }), _jsxs("div", { style: { display: 'flex', gap: 8 }, children: [_jsx("button", { style: btnSmall('#059669', loading === 'start-server' || serverInfo?.running), onClick: () => patchAction({ action: 'start-server', dialect, name: dbConfig.name, host: dbConfig.host, port: dbConfig.port || 9001 }, 'start-server'), disabled: loading === 'start-server' || !!serverInfo?.running, children: loading === 'start-server' ? 'Demarrage...' : `Demarrer le serveur (port ${dbConfig.port || 9001})` }), _jsx("button", { style: btnSmall('#dc2626', loading === 'stop-server' || !serverInfo?.running), onClick: () => patchAction({ action: 'stop-server', port: serverInfo?.port || dbConfig.port || 9001 }, 'stop-server'), disabled: loading === 'stop-server' || !serverInfo?.running, children: loading === 'stop-server' ? 'Arret...' : 'Arreter le serveur' })] })] })), jarStatus?.hasJar && (_jsxs("div", { style: { marginTop: 10, padding: '10px 12px', backgroundColor: '#f0fdf4', borderRadius: 6, border: '1px solid #bbf7d0' }, children: [_jsxs("div", { style: { fontSize: 12, fontWeight: 600, color: '#166534', marginBottom: 6 }, children: ["Bridge JDBC", _jsxs("span", { style: { fontWeight: 400, color: '#6b7280', marginLeft: 4 }, children: ["(port bridge : ", bridgePort || 8765, ")"] }), bridgePort && (_jsxs("span", { style: { fontWeight: 400, color: '#059669', marginLeft: 8 }, children: ["Actif sur port ", bridgePort] })), !bridgePort && bridges.length === 0 && (_jsx("span", { style: { fontWeight: 400, color: '#dc2626', marginLeft: 8 }, children: "Inactif" }))] }), _jsx("div", { style: { display: 'flex', gap: 8, marginBottom: bridges.length > 0 ? 8 : 0 }, children: _jsx("button", { style: btnSmall('#059669', loading === 'start-bridge' || bridges.length > 0), onClick: () => patchAction({ action: 'start', dialect, ...dbConfig }, 'start-bridge'), disabled: loading === 'start-bridge' || bridges.length > 0, children: loading === 'start-bridge' ? 'Lancement...' : `Lancer le bridge (SGBD ${dbConfig.host || 'localhost'}:${dbConfig.port || 9001})` }) }), bridges.map(b => (_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, padding: '4px 0', fontSize: 12 }, children: [_jsx("span", { style: { width: 8, height: 8, borderRadius: '50%', backgroundColor: b.status === 'active' ? '#22c55e' : '#f59e0b', flexShrink: 0 } }), _jsxs("span", { style: { color: '#374151', fontFamily: 'monospace', fontSize: 11 }, children: ["Bridge port :", b.port, " ", b.pid > 0 ? `(PID ${b.pid})` : '', " ", b.jdbcUrl ? `— ${b.jdbcUrl}` : ''] }), _jsx("button", { style: { ...btnSmall('#dc2626', loading === `kill-${b.port}`), fontSize: 11, padding: '2px 8px', marginLeft: 'auto' }, onClick: () => patchAction({ action: 'stop', port: b.port, pid: b.pid }, `kill-${b.port}`), disabled: loading === `kill-${b.port}`, children: loading === `kill-${b.port}` ? '...' : 'Kill' })] }, b.port)))] })), message && (_jsx("p", { style: { fontSize: 12, color: message.ok ? '#059669' : '#dc2626', marginTop: 8 }, children: message.text }))] }));
347
347
  }
348
348
  // ── Main Component ───────────────────────────────────────────
349
- export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNamePrefix = 'mydb', persistState = true, showModules = true, declaredModules, }) {
349
+ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNamePrefix = 'mydb', persistState = true, showModules = true, declaredModules, initialNetUrl, initialNetTransport, }) {
350
350
  const t = tProp || ((k) => k);
351
351
  const ep = {
352
352
  detectModules: endpoints.detectModules || '',
@@ -362,8 +362,8 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
362
362
  };
363
363
  // --- State ---
364
364
  const [setupMode, setSetupMode] = useState('orm');
365
- const [netUrl, setNetUrl] = useState('http://localhost:4488');
366
- const [netTransport, setNetTransport] = useState('rest');
365
+ const [netUrl, setNetUrl] = useState(initialNetUrl || 'http://localhost:4488');
366
+ const [netTransport, setNetTransport] = useState(initialNetTransport || 'rest');
367
367
  const [netApiKey, setNetApiKey] = useState('');
368
368
  const [netTestResult, setNetTestResult] = useState(null);
369
369
  const [netTesting, setNetTesting] = useState(false);
@@ -445,6 +445,13 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
445
445
  fetch(ep.setupJson)
446
446
  .then(r => r.json())
447
447
  .then((data) => {
448
+ // Pre-fill NET URL from server env if not already set by props
449
+ if (data.env?.netUrl && netUrl === 'http://localhost:4488') {
450
+ setNetUrl(data.env.netUrl);
451
+ }
452
+ if (data.env?.netTransport && netTransport === 'rest') {
453
+ setNetTransport(data.env.netTransport);
454
+ }
448
455
  const seeds = data.config?.seeds ?? [];
449
456
  setAvailableSeeds(seeds);
450
457
  // Initialize seedOptions from defaults
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostajs/setup",
3
- "version": "2.1.31",
3
+ "version": "2.1.35",
4
4
  "description": "Reusable setup wizard module — multi-dialect DB configuration, .env.local writer, seed runner",
5
5
  "author": "Dr Hamid MADANI <drmdh@msn.com>",
6
6
  "license": "MIT",