69 أسطر
1.6 KiB
JavaScript
69 أسطر
1.6 KiB
JavaScript
// API Base URL من متغيرات البيئة
|
|
const API_BASE = import.meta.env.VITE_API_BASE ?? "";
|
|
|
|
// =========================
|
|
// Schemas
|
|
// =========================
|
|
async function getSchemas(type, payload) {
|
|
const r = await fetch(`${API_BASE}/api/get_schemas`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
type,
|
|
...payload
|
|
})
|
|
});
|
|
return r.json();
|
|
}
|
|
|
|
// =========================
|
|
// Tables
|
|
// =========================
|
|
async function getTables(type, payload) {
|
|
const r = await fetch(`${API_BASE}/api/get_tables`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
type,
|
|
...payload
|
|
})
|
|
});
|
|
return r.json();
|
|
}
|
|
|
|
// =========================
|
|
// Start Migration
|
|
// =========================
|
|
async function startMigration(type, payload) {
|
|
const r = await fetch(`${API_BASE}/api/migrate`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
type,
|
|
...payload
|
|
})
|
|
});
|
|
return r.json();
|
|
}
|
|
|
|
// =========================
|
|
// Progress
|
|
// =========================
|
|
async function getProgress(type) {
|
|
const r = await fetch(`${API_BASE}/api/progress/${type}`);
|
|
return r.json();
|
|
}
|
|
|
|
// =========================
|
|
// List Buckets
|
|
// =========================
|
|
async function listBuckets(payload) {
|
|
const r = await fetch(`${API_BASE}/api/list_buckets`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(payload)
|
|
});
|
|
return r.json();
|
|
}
|
|
|
|
export { getSchemas, getTables, startMigration, getProgress, listBuckets }; |