@mostajs/setup 2.1.28 → 2.1.30
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/components/SetupWizard.js +25 -82
- package/package.json +1 -1
|
@@ -849,49 +849,24 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
|
|
|
849
849
|
padding: 12, borderRadius: 8, marginBottom: 16,
|
|
850
850
|
backgroundColor: netTestResult.ok ? '#f0fdf4' : '#fef2f2',
|
|
851
851
|
border: `1px solid ${netTestResult.ok ? '#bbf7d0' : '#fecaca'}`,
|
|
852
|
-
}, children: netTestResult.ok ? (_jsxs("div", { children: [_jsx("div", { style: { fontWeight: 600, color: '#166534', marginBottom: 4 }, children: "\u2705 Serveur connecte" }), netTestResult.entities && (_jsxs("div", { style: { fontSize: 13, color: '#374151' }, children: [_jsx("strong", { children: netTestResult.entities.length }), " entites : ", netTestResult.entities.join(', ')] })), netTestResult.transports && (_jsxs("div", { style: { fontSize: 13, color: '#6b7280', marginTop: 4 }, children: ["Transports : ", netTestResult.transports.join(', ')] }))] })) : (_jsxs("div", { style: { color: '#991b1b' }, children: ["\u274C ", netTestResult.error || 'Connexion echouee'] })) })), netTestResult?.ok &&
|
|
853
|
-
padding: 16, borderRadius: 8, marginBottom: 16,
|
|
854
|
-
backgroundColor: '#fffbeb', border: '1px solid #fde68a',
|
|
855
|
-
}, children: [_jsx("div", { style: { fontWeight: 600, color: '#92400e', marginBottom: 8 }, children: "\u26A0\uFE0F Le serveur n'a aucun schema \u2014 envoyez les schemas pour continuer" }), _jsxs("div", { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 8 }, children: [_jsx("button", { style: { ...S.btn('primary'), fontSize: 13 }, onClick: () => document.getElementById('schemaFileInput')?.click(), children: "\uD83D\uDCC4 Envoyer schemas.json" }), _jsx("input", { id: "schemaFileInput", type: "file", accept: ".json", style: { display: 'none' }, onChange: async (e) => {
|
|
852
|
+
}, children: netTestResult.ok ? (_jsxs("div", { children: [_jsx("div", { style: { fontWeight: 600, color: '#166534', marginBottom: 4 }, children: "\u2705 Serveur connecte" }), netTestResult.entities && (_jsxs("div", { style: { fontSize: 13, color: '#374151' }, children: [_jsx("strong", { children: netTestResult.entities.length }), " entites : ", netTestResult.entities.join(', ')] })), netTestResult.transports && (_jsxs("div", { style: { fontSize: 13, color: '#6b7280', marginTop: 4 }, children: ["Transports : ", netTestResult.transports.join(', ')] }))] })) : (_jsxs("div", { style: { color: '#991b1b' }, children: ["\u274C ", netTestResult.error || 'Connexion echouee'] })) })), netTestResult?.ok && (_jsxs("div", { style: { padding: 16, borderRadius: 8, marginBottom: 16, backgroundColor: '#f8fafc', border: '1px solid #e2e8f0' }, children: [_jsxs("div", { style: { display: 'flex', gap: 8, alignItems: 'center', marginBottom: 12, flexWrap: 'wrap' }, children: [_jsx("span", { style: { fontSize: 13, fontWeight: 600, color: '#64748b', minWidth: 65 }, children: "Etape 1:" }), _jsx("button", { style: { ...S.btn('primary'), fontSize: 13 }, onClick: () => document.getElementById('schemaFileInput')?.click(), children: "Uploader schemas.json" }), _jsx("input", { id: "schemaFileInput", type: "file", accept: ".json", style: { display: 'none' }, onChange: async (e) => {
|
|
856
853
|
const file = e.target.files?.[0];
|
|
857
854
|
if (!file)
|
|
858
855
|
return;
|
|
859
|
-
setSchemaUploadStatus({ phase: '
|
|
856
|
+
setSchemaUploadStatus({ phase: 'Envoi...', color: '#2563eb' });
|
|
860
857
|
try {
|
|
861
858
|
const text = await file.text();
|
|
862
859
|
const schemas = JSON.parse(text);
|
|
863
|
-
const res = await fetch(netUrl + '/api/upload-schemas
|
|
864
|
-
method: 'POST',
|
|
865
|
-
|
|
866
|
-
body: JSON.stringify({ schemas }),
|
|
860
|
+
const res = await fetch(netUrl + '/api/upload-schemas', {
|
|
861
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
862
|
+
body: JSON.stringify({ schemas: Array.isArray(schemas) ? schemas : [schemas] }),
|
|
867
863
|
});
|
|
868
864
|
const data = await res.json();
|
|
869
865
|
if (data.ok) {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
await new Promise(r => setTimeout(r, 1500));
|
|
875
|
-
setSchemaUploadStatus({ phase: `⏳ En attente du serveur... (${i + 1}/30)`, color: '#d97706' });
|
|
876
|
-
try {
|
|
877
|
-
const h = await fetch(netUrl + '/health');
|
|
878
|
-
if (h.ok) {
|
|
879
|
-
const hd = await h.json();
|
|
880
|
-
if (hd.entities?.length > 0) {
|
|
881
|
-
setSchemaUploadStatus({ phase: `✅ Serveur prêt — ${hd.entities.length} entités`, color: '#16a34a' });
|
|
882
|
-
setSchemasReady(true);
|
|
883
|
-
setNetTestResult({ ...netTestResult, entities: hd.entities });
|
|
884
|
-
break;
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
catch { }
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
else {
|
|
892
|
-
setSchemaUploadStatus({ phase: `✅ ${data.count} schemas chargés`, color: '#16a34a' });
|
|
893
|
-
setSchemasReady(true);
|
|
894
|
-
}
|
|
866
|
+
setSchemaUploadStatus({ phase: `✅ ${data.count} schemas uploades`, color: '#16a34a' });
|
|
867
|
+
const h = await fetch(netUrl + '/health').then(r => r.json());
|
|
868
|
+
if (h.entities)
|
|
869
|
+
setNetTestResult({ ...netTestResult, entities: h.entities });
|
|
895
870
|
}
|
|
896
871
|
else {
|
|
897
872
|
setSchemaUploadStatus({ phase: `❌ ${data.error}`, color: '#dc2626' });
|
|
@@ -901,74 +876,42 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
|
|
|
901
876
|
setSchemaUploadStatus({ phase: `❌ ${err.message}`, color: '#dc2626' });
|
|
902
877
|
}
|
|
903
878
|
e.target.value = '';
|
|
904
|
-
} }), _jsx("
|
|
905
|
-
|
|
906
|
-
if (!file)
|
|
907
|
-
return;
|
|
908
|
-
setSchemaUploadStatus({ phase: '📤 Envoi du ZIP...', color: '#2563eb' });
|
|
879
|
+
} }), _jsx("span", { style: { fontSize: 12, color: schemaUploadStatus?.color || '#94a3b8' }, children: schemaUploadStatus?.phase || ((netTestResult.entities?.length ?? 0) > 0 ? `✅ ${netTestResult.entities.length} schemas` : 'Aucun schema') })] }), _jsxs("div", { style: { display: 'flex', gap: 8, alignItems: 'center', marginBottom: 12, flexWrap: 'wrap' }, children: [_jsx("span", { style: { fontSize: 13, fontWeight: 600, color: '#64748b', minWidth: 65 }, children: "Etape 2:" }), _jsx("button", { style: { ...S.btn('primary'), fontSize: 13, backgroundColor: '#22c55e' }, disabled: (netTestResult.entities?.length ?? 0) === 0, onClick: async () => {
|
|
880
|
+
setSchemaUploadStatus({ phase: 'Enregistrement...', color: '#2563eb' });
|
|
909
881
|
try {
|
|
910
|
-
const
|
|
911
|
-
formData.append('file', file);
|
|
912
|
-
const res = await fetch(netUrl + '/api/upload-schemas', {
|
|
913
|
-
method: 'POST',
|
|
914
|
-
body: formData,
|
|
915
|
-
});
|
|
882
|
+
const res = await fetch(netUrl + '/api/save-config', { method: 'POST' });
|
|
916
883
|
const data = await res.json();
|
|
917
884
|
if (data.ok) {
|
|
918
|
-
setSchemaUploadStatus({ phase:
|
|
885
|
+
setSchemaUploadStatus({ phase: '✅ Config enregistree', color: '#16a34a' });
|
|
919
886
|
setSchemasReady(true);
|
|
920
|
-
// Refresh test result
|
|
921
|
-
const h = await fetch(netUrl + '/health').then(r => r.json());
|
|
922
|
-
if (h.entities)
|
|
923
|
-
setNetTestResult({ ...netTestResult, entities: h.entities });
|
|
924
887
|
}
|
|
925
888
|
else {
|
|
926
|
-
setSchemaUploadStatus({ phase: `❌ ${data.error}`, color: '#dc2626' });
|
|
889
|
+
setSchemaUploadStatus({ phase: `❌ ${data.error || data.message}`, color: '#dc2626' });
|
|
927
890
|
}
|
|
928
891
|
}
|
|
929
892
|
catch (err) {
|
|
930
893
|
setSchemaUploadStatus({ phase: `❌ ${err.message}`, color: '#dc2626' });
|
|
931
894
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
const schemasPath = prompt('Chemin vers le répertoire des schemas (*.schema.ts) :', './src/dal/schemas');
|
|
935
|
-
if (!schemasPath)
|
|
936
|
-
return;
|
|
937
|
-
setSchemaUploadStatus({ phase: '🔍 Scan en cours...', color: '#2563eb' });
|
|
895
|
+
}, children: "Enregistrer la config" })] }), _jsxs("div", { style: { display: 'flex', gap: 8, alignItems: 'center', marginBottom: 8, flexWrap: 'wrap' }, children: [_jsx("span", { style: { fontSize: 13, fontWeight: 600, color: '#64748b', minWidth: 65 }, children: "Etape 3:" }), _jsx("button", { style: { ...S.btn('primary'), fontSize: 13, backgroundColor: '#f59e0b', color: '#000' }, disabled: (netTestResult.entities?.length ?? 0) === 0, onClick: async () => {
|
|
896
|
+
setSchemaUploadStatus({ phase: 'Application du schema...', color: '#2563eb' });
|
|
938
897
|
try {
|
|
939
|
-
const res = await fetch(netUrl + '/api/
|
|
940
|
-
method: 'POST',
|
|
941
|
-
headers: { 'Content-Type': 'application/json' },
|
|
942
|
-
body: JSON.stringify({ path: schemasPath }),
|
|
943
|
-
});
|
|
898
|
+
const res = await fetch(netUrl + '/api/apply-schema', { method: 'POST' });
|
|
944
899
|
const data = await res.json();
|
|
945
|
-
if (data.ok
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
});
|
|
952
|
-
const genData = await genRes.json();
|
|
953
|
-
if (genData.ok) {
|
|
954
|
-
setSchemaUploadStatus({ phase: `✅ ${genData.count} schemas scannés et générés`, color: '#16a34a' });
|
|
955
|
-
setSchemasReady(true);
|
|
956
|
-
const h = await fetch(netUrl + '/health').then(r => r.json());
|
|
957
|
-
if (h.entities)
|
|
958
|
-
setNetTestResult({ ...netTestResult, entities: h.entities });
|
|
959
|
-
}
|
|
900
|
+
if (data.ok) {
|
|
901
|
+
setSchemaUploadStatus({ phase: `✅ ${data.message || 'Schema applique'}`, color: '#16a34a' });
|
|
902
|
+
setSchemasReady(true);
|
|
903
|
+
}
|
|
904
|
+
else if (data.needsCreateDb) {
|
|
905
|
+
setSchemaUploadStatus({ phase: `⚠️ ${data.error} — creez la base depuis le dashboard OctoNet`, color: '#d97706' });
|
|
960
906
|
}
|
|
961
907
|
else {
|
|
962
|
-
setSchemaUploadStatus({ phase: `❌
|
|
908
|
+
setSchemaUploadStatus({ phase: `❌ ${data.error || data.message}`, color: '#dc2626' });
|
|
963
909
|
}
|
|
964
910
|
}
|
|
965
911
|
catch (err) {
|
|
966
912
|
setSchemaUploadStatus({ phase: `❌ ${err.message}`, color: '#dc2626' });
|
|
967
913
|
}
|
|
968
|
-
}, children: "
|
|
969
|
-
padding: 12, borderRadius: 8, marginBottom: 16,
|
|
970
|
-
backgroundColor: '#f0fdf4', border: '1px solid #bbf7d0',
|
|
971
|
-
}, children: _jsxs("div", { style: { fontWeight: 600, color: '#166534' }, children: ["\u2705 Serveur pr\u00EAt \u2014 ", netTestResult.entities?.length, " entit\u00E9s charg\u00E9es"] }) })), _jsxs("div", { style: S.navRow, children: [_jsxs("button", { style: S.btn('outline'), onClick: goBack, children: ["\u2190 ", t('setup.back')] }), _jsxs("button", { style: S.btn('primary', !canGoNext()), onClick: goNext, disabled: !canGoNext(), children: [t('setup.next'), " \u2192"] })] })] })), step === 'admin' && (_jsxs("div", { children: [_jsxs("div", { style: S.sectionHeader, children: [_jsx("span", { style: S.sectionIcon, children: "\uD83D\uDC64" }), _jsxs("div", { children: [_jsx("div", { style: S.sectionTitle, children: t('setup.admin.title') }), _jsx("div", { style: S.sectionDesc, children: t('setup.admin.description') })] })] }), _jsxs("div", { style: S.formRow, children: [_jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.firstName') }), _jsx("input", { style: S.input, value: adminConfig.firstName, onChange: e => setAdminConfig({ ...adminConfig, firstName: e.target.value }) })] }), _jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.lastName') }), _jsx("input", { style: S.input, value: adminConfig.lastName, onChange: e => setAdminConfig({ ...adminConfig, lastName: e.target.value }) })] })] }), _jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.email') }), _jsx("input", { style: S.input, type: "email", value: adminConfig.email, onChange: e => setAdminConfig({ ...adminConfig, email: e.target.value }), placeholder: "admin@example.com" })] }), _jsxs("div", { style: S.formRow, children: [_jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.password') }), _jsx("input", { style: S.input, type: "password", value: adminConfig.password, onChange: e => setAdminConfig({ ...adminConfig, password: e.target.value }) })] }), _jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.confirmPassword') }), _jsx("input", { style: S.input, type: "password", value: adminConfig.confirmPassword, onChange: e => setAdminConfig({ ...adminConfig, confirmPassword: e.target.value }) })] })] }), adminConfig.password && adminConfig.confirmPassword && adminConfig.password !== adminConfig.confirmPassword && (_jsx("p", { style: { fontSize: 13, color: '#dc2626' }, children: t('setup.admin.passwordMismatch') })), setupMode === 'net' && (_jsxs("div", { style: { marginTop: 16, marginBottom: 16 }, children: [_jsx("button", { style: { ...S.btn('primary'), backgroundColor: '#16a34a' }, disabled: adminSaving || !adminConfig.email || !adminConfig.password || !adminConfig.firstName || adminConfig.password !== adminConfig.confirmPassword, onClick: async () => {
|
|
914
|
+
}, children: "Appliquer le schema" })] }), schemaUploadStatus && (_jsx("div", { style: { fontSize: 13, fontWeight: 500, color: schemaUploadStatus.color, marginTop: 4 }, children: schemaUploadStatus.phase }))] })), _jsxs("div", { style: S.navRow, children: [_jsxs("button", { style: S.btn('outline'), onClick: goBack, children: ["\u2190 ", t('setup.back')] }), _jsxs("button", { style: S.btn('primary', !canGoNext()), onClick: goNext, disabled: !canGoNext(), children: [t('setup.next'), " \u2192"] })] })] })), step === 'admin' && (_jsxs("div", { children: [_jsxs("div", { style: S.sectionHeader, children: [_jsx("span", { style: S.sectionIcon, children: "\uD83D\uDC64" }), _jsxs("div", { children: [_jsx("div", { style: S.sectionTitle, children: t('setup.admin.title') }), _jsx("div", { style: S.sectionDesc, children: t('setup.admin.description') })] })] }), _jsxs("div", { style: S.formRow, children: [_jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.firstName') }), _jsx("input", { style: S.input, value: adminConfig.firstName, onChange: e => setAdminConfig({ ...adminConfig, firstName: e.target.value }) })] }), _jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.lastName') }), _jsx("input", { style: S.input, value: adminConfig.lastName, onChange: e => setAdminConfig({ ...adminConfig, lastName: e.target.value }) })] })] }), _jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.email') }), _jsx("input", { style: S.input, type: "email", value: adminConfig.email, onChange: e => setAdminConfig({ ...adminConfig, email: e.target.value }), placeholder: "admin@example.com" })] }), _jsxs("div", { style: S.formRow, children: [_jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.password') }), _jsx("input", { style: S.input, type: "password", value: adminConfig.password, onChange: e => setAdminConfig({ ...adminConfig, password: e.target.value }) })] }), _jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.confirmPassword') }), _jsx("input", { style: S.input, type: "password", value: adminConfig.confirmPassword, onChange: e => setAdminConfig({ ...adminConfig, confirmPassword: e.target.value }) })] })] }), adminConfig.password && adminConfig.confirmPassword && adminConfig.password !== adminConfig.confirmPassword && (_jsx("p", { style: { fontSize: 13, color: '#dc2626' }, children: t('setup.admin.passwordMismatch') })), setupMode === 'net' && (_jsxs("div", { style: { marginTop: 16, marginBottom: 16 }, children: [_jsx("button", { style: { ...S.btn('primary'), backgroundColor: '#16a34a' }, disabled: adminSaving || !adminConfig.email || !adminConfig.password || !adminConfig.firstName || adminConfig.password !== adminConfig.confirmPassword, onClick: async () => {
|
|
972
915
|
setAdminSaving(true);
|
|
973
916
|
setAdminSaveResult(null);
|
|
974
917
|
try {
|
package/package.json
CHANGED