diff --git a/dbal/production/src/daemon/rpc_restful_handler.cpp b/dbal/production/src/daemon/rpc_restful_handler.cpp index 45a494c33..ecd58e7c7 100644 --- a/dbal/production/src/daemon/rpc_restful_handler.cpp +++ b/dbal/production/src/daemon/rpc_restful_handler.cpp @@ -149,7 +149,7 @@ void handleRestfulRequest( Client& client, const RouteInfo& route, const std::string& method, - const Json::Value& body, + const ::Json::Value& body, const std::map& query, ResponseSender send_success, ErrorSender send_error @@ -211,9 +211,9 @@ void handleRestfulRequest( } if (operation == "list") { - Json::Value options(Json::objectValue); - Json::Value filter(Json::objectValue); - Json::Value sort(Json::objectValue); + ::Json::Value options(::Json::objectValue); + ::Json::Value filter(::Json::objectValue); + ::Json::Value sort(::Json::objectValue); bool limit_set = false; bool page_set = false; diff --git a/dbal/production/src/daemon/rpc_restful_handler.hpp b/dbal/production/src/daemon/rpc_restful_handler.hpp index c88b668e9..797e9292f 100644 --- a/dbal/production/src/daemon/rpc_restful_handler.hpp +++ b/dbal/production/src/daemon/rpc_restful_handler.hpp @@ -66,7 +66,7 @@ std::string toPascalCase(const std::string& snake_case); */ std::string toLower(const std::string& str); -using ResponseSender = std::function; +using ResponseSender = std::function; using ErrorSender = std::function; /** @@ -83,7 +83,7 @@ void handleRestfulRequest( Client& client, const RouteInfo& route, const std::string& method, - const Json::Value& body, + const ::Json::Value& body, const std::map& query, ResponseSender send_success, ErrorSender send_error diff --git a/dbal/production/src/daemon/rpc_schema_actions.cpp b/dbal/production/src/daemon/rpc_schema_actions.cpp index 66e82b65a..0e6bf304e 100644 --- a/dbal/production/src/daemon/rpc_schema_actions.cpp +++ b/dbal/production/src/daemon/rpc_schema_actions.cpp @@ -19,30 +19,30 @@ namespace { /** * @brief Load schema registry from JSON file */ -Json::Value load_registry(const std::string& path) { - Json::Value registry; +::Json::Value load_registry(const std::string& path) { + ::Json::Value registry; if (!fs::exists(path)) { registry["version"] = "1.0.0"; - registry["packages"] = Json::Value(Json::objectValue); - registry["migrationQueue"] = Json::Value(Json::arrayValue); + registry["packages"] = ::Json::Value(::Json::objectValue); + registry["migrationQueue"] = ::Json::Value(::Json::arrayValue); return registry; } std::ifstream file(path); if (!file.is_open()) { registry["version"] = "1.0.0"; - registry["packages"] = Json::Value(Json::objectValue); - registry["migrationQueue"] = Json::Value(Json::arrayValue); + registry["packages"] = ::Json::Value(::Json::objectValue); + registry["migrationQueue"] = ::Json::Value(::Json::arrayValue); return registry; } - Json::CharReaderBuilder reader; + ::Json::CharReaderBuilder reader; JSONCPP_STRING errs; - if (!Json::parseFromStream(reader, file, ®istry, &errs)) { + if (!::Json::parseFromStream(reader, file, ®istry, &errs)) { registry["version"] = "1.0.0"; - registry["packages"] = Json::Value(Json::objectValue); - registry["migrationQueue"] = Json::Value(Json::arrayValue); + registry["packages"] = ::Json::Value(::Json::objectValue); + registry["migrationQueue"] = ::Json::Value(::Json::arrayValue); } return registry; @@ -51,15 +51,15 @@ Json::Value load_registry(const std::string& path) { /** * @brief Save schema registry to JSON file */ -bool save_registry(const Json::Value& registry, const std::string& path) { +bool save_registry(const ::Json::Value& registry, const std::string& path) { std::ofstream file(path); if (!file.is_open()) { return false; } - Json::StreamWriterBuilder writer; + ::Json::StreamWriterBuilder writer; writer["indentation"] = " "; - std::unique_ptr stream_writer(writer.newStreamWriter()); + std::unique_ptr<::Json::StreamWriter> stream_writer(writer.newStreamWriter()); stream_writer->write(registry, &file); return true; } @@ -122,8 +122,8 @@ std::string get_table_name(const std::string& packageId, const std::string& enti /** * @brief Get pending migrations from registry */ -Json::Value get_pending_migrations(const Json::Value& registry) { - Json::Value pending(Json::arrayValue); +::Json::Value get_pending_migrations(const ::Json::Value& registry) { + ::Json::Value pending(::Json::arrayValue); const auto& queue = registry["migrationQueue"]; for (const auto& migration : queue) { @@ -138,8 +138,8 @@ Json::Value get_pending_migrations(const Json::Value& registry) { /** * @brief Get approved migrations from registry */ -Json::Value get_approved_migrations(const Json::Value& registry) { - Json::Value approved(Json::arrayValue); +::Json::Value get_approved_migrations(const ::Json::Value& registry) { + ::Json::Value approved(::Json::arrayValue); const auto& queue = registry["migrationQueue"]; for (const auto& migration : queue) { @@ -168,7 +168,7 @@ std::string yaml_type_to_prisma(const std::string& yaml_type) { /** * @brief Generate Prisma model for an entity */ -std::string entity_to_prisma(const Json::Value& entity, const std::string& packageId) { +std::string entity_to_prisma(const ::Json::Value& entity, const std::string& packageId) { const std::string name = entity["name"].asString(); const std::string prefixed = get_prefixed_name(packageId, name); const std::string table = get_table_name(packageId, name); @@ -218,7 +218,7 @@ void handle_schema_list(const std::string& registry_path, auto registry = load_registry(registry_path); auto pending = get_pending_migrations(registry); - Json::Value response; + ::Json::Value response; response["status"] = "ok"; response["pendingCount"] = pending.size(); response["migrations"] = pending; @@ -239,7 +239,7 @@ void handle_schema_scan(const std::string& registry_path, int scanned = 0; int queued = 0; - Json::Value errors(Json::arrayValue); + ::Json::Value errors(::Json::arrayValue); if (!fs::exists(packages_path)) { send_error("Packages directory not found: " + packages_path, 404); @@ -263,7 +263,7 @@ void handle_schema_scan(const std::string& registry_path, save_registry(registry, registry_path); - Json::Value response; + ::Json::Value response; response["status"] = "ok"; response["action"] = "scan"; response["packagesScanned"] = scanned; @@ -307,7 +307,7 @@ void handle_schema_approve(const std::string& registry_path, save_registry(registry, registry_path); - Json::Value response; + ::Json::Value response; response["status"] = "ok"; response["action"] = "approve"; response["approved"] = approved_count; @@ -344,7 +344,7 @@ void handle_schema_reject(const std::string& registry_path, save_registry(registry, registry_path); - Json::Value response; + ::Json::Value response; response["status"] = "ok"; response["action"] = "reject"; response["id"] = id; @@ -365,7 +365,7 @@ void handle_schema_generate(const std::string& registry_path, auto approved = get_approved_migrations(registry); if (approved.empty()) { - Json::Value response; + ::Json::Value response; response["status"] = "ok"; response["action"] = "generate"; response["generated"] = false; @@ -398,7 +398,7 @@ void handle_schema_generate(const std::string& registry_path, out << oss.str(); out.close(); - Json::Value response; + ::Json::Value response; response["status"] = "ok"; response["action"] = "generate"; response["generated"] = true; diff --git a/dbal/production/src/daemon/rpc_schema_actions.hpp b/dbal/production/src/daemon/rpc_schema_actions.hpp index a9a11057d..69e0c6716 100644 --- a/dbal/production/src/daemon/rpc_schema_actions.hpp +++ b/dbal/production/src/daemon/rpc_schema_actions.hpp @@ -9,7 +9,7 @@ namespace dbal { namespace daemon { namespace rpc { -using ResponseSender = std::function; +using ResponseSender = std::function; using ErrorSender = std::function; /** diff --git a/dbal/production/src/daemon/rpc_user_actions.cpp b/dbal/production/src/daemon/rpc_user_actions.cpp index efe4d7357..d2870d746 100644 --- a/dbal/production/src/daemon/rpc_user_actions.cpp +++ b/dbal/production/src/daemon/rpc_user_actions.cpp @@ -9,7 +9,7 @@ namespace rpc { void handle_user_list(Client& client, const std::string& tenantId, - const Json::Value& options, + const ::Json::Value& options, ResponseSender send_success, ErrorSender send_error) { if (tenantId.empty()) { @@ -57,7 +57,7 @@ void handle_user_read(Client& client, void handle_user_create(Client& client, const std::string& tenantId, - const Json::Value& payload, + const ::Json::Value& payload, ResponseSender send_success, ErrorSender send_error) { if (tenantId.empty()) { @@ -92,7 +92,7 @@ void handle_user_create(Client& client, void handle_user_update(Client& client, const std::string& tenantId, const std::string& id, - const Json::Value& payload, + const ::Json::Value& payload, ResponseSender send_success, ErrorSender send_error) { if (tenantId.empty()) { @@ -177,7 +177,7 @@ void handle_user_delete(Client& client, return; } - Json::Value body; + ::Json::Value body; body["deleted"] = result.value(); send_success(body); } diff --git a/dbal/production/src/daemon/rpc_user_actions.hpp b/dbal/production/src/daemon/rpc_user_actions.hpp index adbf4aa49..ad9f98732 100644 --- a/dbal/production/src/daemon/rpc_user_actions.hpp +++ b/dbal/production/src/daemon/rpc_user_actions.hpp @@ -10,12 +10,12 @@ namespace dbal { namespace daemon { namespace rpc { -using ResponseSender = std::function; +using ResponseSender = std::function; using ErrorSender = std::function; void handle_user_list(Client& client, const std::string& tenantId, - const Json::Value& options, + const ::Json::Value& options, ResponseSender send_success, ErrorSender send_error); @@ -27,14 +27,14 @@ void handle_user_read(Client& client, void handle_user_create(Client& client, const std::string& tenantId, - const Json::Value& payload, + const ::Json::Value& payload, ResponseSender send_success, ErrorSender send_error); void handle_user_update(Client& client, const std::string& tenantId, const std::string& id, - const Json::Value& payload, + const ::Json::Value& payload, ResponseSender send_success, ErrorSender send_error); diff --git a/dbal/production/src/daemon/server_helpers/response.cpp b/dbal/production/src/daemon/server_helpers/response.cpp index 26a5c68e2..2e377cff8 100644 --- a/dbal/production/src/daemon/server_helpers/response.cpp +++ b/dbal/production/src/daemon/server_helpers/response.cpp @@ -5,7 +5,7 @@ namespace dbal { namespace daemon { -drogon::HttpResponsePtr build_json_response(const Json::Value& body) { +drogon::HttpResponsePtr build_json_response(const ::Json::Value& body) { auto response = drogon::HttpResponse::newHttpJsonResponse(body); response->addHeader("Server", "DBAL/1.0.0"); return response; diff --git a/dbal/production/src/daemon/server_helpers/response.hpp b/dbal/production/src/daemon/server_helpers/response.hpp index 9b87ec2b6..d324e66ec 100644 --- a/dbal/production/src/daemon/server_helpers/response.hpp +++ b/dbal/production/src/daemon/server_helpers/response.hpp @@ -8,7 +8,7 @@ namespace dbal { namespace daemon { -drogon::HttpResponsePtr build_json_response(const Json::Value& body); +drogon::HttpResponsePtr build_json_response(const ::Json::Value& body); } // namespace daemon } // namespace dbal diff --git a/dbal/production/src/daemon/server_helpers/serialization.cpp b/dbal/production/src/daemon/server_helpers/serialization.cpp index 1d33c0d21..e96e5ba13 100644 --- a/dbal/production/src/daemon/server_helpers/serialization.cpp +++ b/dbal/production/src/daemon/server_helpers/serialization.cpp @@ -10,14 +10,14 @@ long long timestamp_to_epoch_ms(const Timestamp& timestamp) { return std::chrono::duration_cast(timestamp.time_since_epoch()).count(); } -Json::Value user_to_json(const User& user) { - Json::Value value(Json::objectValue); +::Json::Value user_to_json(const User& user) { + ::Json::Value value(::Json::objectValue); value["id"] = user.id; value["tenantId"] = user.tenantId.value_or(""); value["username"] = user.username; value["email"] = user.email; value["role"] = user.role; - value["createdAt"] = static_cast(timestamp_to_epoch_ms(user.createdAt)); + value["createdAt"] = static_cast<::Json::Int64>(timestamp_to_epoch_ms(user.createdAt)); if (user.profilePicture.has_value()) { value["profilePicture"] = user.profilePicture.value(); } @@ -27,21 +27,21 @@ Json::Value user_to_json(const User& user) { value["isInstanceOwner"] = user.isInstanceOwner; if (user.passwordChangeTimestamp.has_value()) { value["passwordChangeTimestamp"] = - static_cast(timestamp_to_epoch_ms(user.passwordChangeTimestamp.value())); + static_cast<::Json::Int64>(timestamp_to_epoch_ms(user.passwordChangeTimestamp.value())); } value["firstLogin"] = user.firstLogin; return value; } -Json::Value users_to_json(const std::vector& users) { - Json::Value arr(Json::arrayValue); +::Json::Value users_to_json(const std::vector& users) { + ::Json::Value arr(::Json::arrayValue); for (const auto& user : users) { arr.append(user_to_json(user)); } return arr; } -ListOptions list_options_from_json(const Json::Value& json) { +ListOptions list_options_from_json(const ::Json::Value& json) { ListOptions options; if (!json.isNull()) { if (json.isMember("page") && json["page"].isInt()) { @@ -64,13 +64,13 @@ ListOptions list_options_from_json(const Json::Value& json) { return options; } -Json::Value list_response_value(const std::vector& users, const ListOptions& options) { - Json::Value value(Json::objectValue); +::Json::Value list_response_value(const std::vector& users, const ListOptions& options) { + ::Json::Value value(::Json::objectValue); value["data"] = users_to_json(users); - value["total"] = static_cast(users.size()); + value["total"] = static_cast<::Json::Int64>(users.size()); value["page"] = options.page; value["limit"] = options.limit; - value["hasMore"] = Json::Value(false); + value["hasMore"] = ::Json::Value(false); return value; } diff --git a/dbal/production/src/daemon/server_helpers/serialization.hpp b/dbal/production/src/daemon/server_helpers/serialization.hpp index 694e0c627..6897fc93b 100644 --- a/dbal/production/src/daemon/server_helpers/serialization.hpp +++ b/dbal/production/src/daemon/server_helpers/serialization.hpp @@ -10,11 +10,11 @@ namespace dbal { namespace daemon { long long timestamp_to_epoch_ms(const Timestamp& timestamp); -Json::Value user_to_json(const User& user); -Json::Value users_to_json(const std::vector& users); +::Json::Value user_to_json(const User& user); +::Json::Value users_to_json(const std::vector& users); -ListOptions list_options_from_json(const Json::Value& json); -Json::Value list_response_value(const std::vector& users, const ListOptions& options); +ListOptions list_options_from_json(const ::Json::Value& json); +::Json::Value list_response_value(const std::vector& users, const ListOptions& options); } // namespace daemon } // namespace dbal diff --git a/dbal/production/src/daemon/server_routes.cpp b/dbal/production/src/daemon/server_routes.cpp index 0148e3672..f6472d7c0 100644 --- a/dbal/production/src/daemon/server_routes.cpp +++ b/dbal/production/src/daemon/server_routes.cpp @@ -25,7 +25,7 @@ void Server::registerRoutes() { auto health_handler = [](const drogon::HttpRequestPtr&, std::function&& callback) { - Json::Value body; + ::Json::Value body; body["status"] = "healthy"; body["service"] = "dbal"; callback(build_json_response(body)); @@ -33,7 +33,7 @@ void Server::registerRoutes() { auto version_handler = [](const drogon::HttpRequestPtr&, std::function&& callback) { - Json::Value body; + ::Json::Value body; body["version"] = "1.0.0"; body["service"] = "DBAL Daemon"; callback(build_json_response(body)); @@ -41,7 +41,7 @@ void Server::registerRoutes() { auto status_handler = [server_address](const drogon::HttpRequestPtr& request, std::function&& callback) { - Json::Value body; + ::Json::Value body; body["status"] = "running"; body["address"] = server_address; body["real_ip"] = resolve_real_ip(request); @@ -52,7 +52,7 @@ void Server::registerRoutes() { auto rpc_handler = [this](const drogon::HttpRequestPtr& request, std::function&& callback) { auto send_error = [&callback](const std::string& message, int status = 400) { - Json::Value body; + ::Json::Value body; body["success"] = false; body["message"] = message; auto response = drogon::HttpResponse::newHttpJsonResponse(body); @@ -61,10 +61,10 @@ void Server::registerRoutes() { }; std::istringstream stream(request->getBody()); - Json::CharReaderBuilder reader_builder; - Json::Value rpc_request; + ::Json::CharReaderBuilder reader_builder; + ::Json::Value rpc_request; JSONCPP_STRING errs; - if (!Json::parseFromStream(reader_builder, stream, &rpc_request, &errs)) { + if (!::Json::parseFromStream(reader_builder, stream, &rpc_request, &errs)) { send_error("Invalid JSON payload: " + std::string(errs), 400); return; } @@ -87,12 +87,12 @@ void Server::registerRoutes() { std::transform(action.begin(), action.end(), action.begin(), [](unsigned char c) { return static_cast(std::tolower(c)); }); - const auto payload = rpc_request.get("payload", Json::Value(Json::objectValue)); - const auto options_value = rpc_request.get("options", Json::Value(Json::objectValue)); + const auto payload = rpc_request.get("payload", ::Json::Value(::Json::objectValue)); + const auto options_value = rpc_request.get("options", ::Json::Value(::Json::objectValue)); const std::string tenantId = rpc_request.get("tenantId", payload.get("tenantId", "")).asString(); - auto send_success = [&callback](const Json::Value& data) { - Json::Value body; + auto send_success = [&callback](const ::Json::Value& data) { + ::Json::Value body; body["success"] = true; body["data"] = data; callback(build_json_response(body)); @@ -161,12 +161,12 @@ void Server::registerRoutes() { const std::string packages_path = env_packages ? env_packages : "/app/packages"; const std::string output_path = env_output ? env_output : "/app/prisma/generated-from-packages.prisma"; - auto send_success = [&callback](const Json::Value& data) { + auto send_success = [&callback](const ::Json::Value& data) { callback(build_json_response(data)); }; auto send_error = [&callback](const std::string& message, int status) { - Json::Value body; + ::Json::Value body; body["success"] = false; body["error"] = message; auto response = drogon::HttpResponse::newHttpJsonResponse(body); @@ -182,10 +182,10 @@ void Server::registerRoutes() { // Handle POST - actions std::istringstream stream(request->getBody()); - Json::CharReaderBuilder reader_builder; - Json::Value body; + ::Json::CharReaderBuilder reader_builder; + ::Json::Value body; JSONCPP_STRING errs; - if (!Json::parseFromStream(reader_builder, stream, &body, &errs)) { + if (!::Json::parseFromStream(reader_builder, stream, &body, &errs)) { send_error("Invalid JSON payload", 400); return; } @@ -224,15 +224,15 @@ void Server::registerRoutes() { const std::string& tenant, const std::string& package, const std::string& entity) { - auto send_success = [&callback](const Json::Value& data) { - Json::Value body; + auto send_success = [&callback](const ::Json::Value& data) { + ::Json::Value body; body["success"] = true; body["data"] = data; callback(build_json_response(body)); }; auto send_error = [&callback](const std::string& message, int status) { - Json::Value body; + ::Json::Value body; body["success"] = false; body["error"] = message; auto response = drogon::HttpResponse::newHttpJsonResponse(body); @@ -263,12 +263,12 @@ void Server::registerRoutes() { } // Parse body for POST/PUT/PATCH - Json::Value body(Json::objectValue); + ::Json::Value body(::Json::objectValue); if (method == "POST" || method == "PUT" || method == "PATCH") { std::istringstream stream(request->getBody()); - Json::CharReaderBuilder reader; + ::Json::CharReaderBuilder reader; JSONCPP_STRING errs; - Json::parseFromStream(reader, stream, &body, &errs); + ::Json::parseFromStream(reader, stream, &body, &errs); } // Parse query parameters @@ -287,15 +287,15 @@ void Server::registerRoutes() { const std::string& package, const std::string& entity, const std::string& id) { - auto send_success = [&callback](const Json::Value& data) { - Json::Value body; + auto send_success = [&callback](const ::Json::Value& data) { + ::Json::Value body; body["success"] = true; body["data"] = data; callback(build_json_response(body)); }; auto send_error = [&callback](const std::string& message, int status) { - Json::Value body; + ::Json::Value body; body["success"] = false; body["error"] = message; auto response = drogon::HttpResponse::newHttpJsonResponse(body); @@ -321,12 +321,12 @@ void Server::registerRoutes() { default: method = "UNKNOWN"; break; } - Json::Value body(Json::objectValue); + ::Json::Value body(::Json::objectValue); if (method == "POST" || method == "PUT" || method == "PATCH") { std::istringstream stream(request->getBody()); - Json::CharReaderBuilder reader; + ::Json::CharReaderBuilder reader; JSONCPP_STRING errs; - Json::parseFromStream(reader, stream, &body, &errs); + ::Json::parseFromStream(reader, stream, &body, &errs); } std::map query; @@ -345,15 +345,15 @@ void Server::registerRoutes() { const std::string& entity, const std::string& id, const std::string& action) { - auto send_success = [&callback](const Json::Value& data) { - Json::Value body; + auto send_success = [&callback](const ::Json::Value& data) { + ::Json::Value body; body["success"] = true; body["data"] = data; callback(build_json_response(body)); }; auto send_error = [&callback](const std::string& message, int status) { - Json::Value body; + ::Json::Value body; body["success"] = false; body["error"] = message; auto response = drogon::HttpResponse::newHttpJsonResponse(body); @@ -379,12 +379,12 @@ void Server::registerRoutes() { default: method = "UNKNOWN"; break; } - Json::Value body(Json::objectValue); + ::Json::Value body(::Json::objectValue); if (method == "POST" || method == "PUT" || method == "PATCH") { std::istringstream stream(request->getBody()); - Json::CharReaderBuilder reader; + ::Json::CharReaderBuilder reader; JSONCPP_STRING errs; - Json::parseFromStream(reader, stream, &body, &errs); + ::Json::parseFromStream(reader, stream, &body, &errs); } std::map query; diff --git a/frontends/nextjs/src/lib/db/database-admin/import/import-database.ts b/frontends/nextjs/src/lib/db/database-admin/import/import-database.ts index eedccc6b4..476086dae 100644 --- a/frontends/nextjs/src/lib/db/database-admin/import/import-database.ts +++ b/frontends/nextjs/src/lib/db/database-admin/import/import-database.ts @@ -1,7 +1,6 @@ import { setAppConfig } from '../../app-config' import { setComments } from '../../comments' import { setComponentConfigs, setComponentHierarchy } from '../../components' -import { setLuaScripts } from '../../lua-scripts' import { setPages } from '../../pages' import { setSchemas } from '../../schemas' import type { DatabaseSchema } from '../../types' @@ -17,7 +16,6 @@ export async function importDatabase(jsonData: string): Promise { if (data.users !== undefined) await setUsers(data.users) if (data.workflows !== undefined) await setWorkflows(data.workflows) - if (data.luaScripts !== undefined) await setLuaScripts(data.luaScripts) if (data.pages !== undefined) await setPages(data.pages) if (data.schemas !== undefined) await setSchemas(data.schemas) if (data.appConfig !== undefined) await setAppConfig(data.appConfig)