mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
code: cpp,hpp,dbal (7 files)
This commit is contained in:
50
dbal/cpp/src/entities/workflow/create_workflow.hpp
Normal file
50
dbal/cpp/src/entities/workflow/create_workflow.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @file create_workflow.hpp
|
||||
* @brief Create workflow operation
|
||||
*/
|
||||
#ifndef DBAL_CREATE_WORKFLOW_HPP
|
||||
#define DBAL_CREATE_WORKFLOW_HPP
|
||||
|
||||
#include "dbal/types.hpp"
|
||||
#include "dbal/errors.hpp"
|
||||
#include "../../store/in_memory_store.hpp"
|
||||
#include "../../validation/workflow_validation.hpp"
|
||||
|
||||
namespace dbal {
|
||||
namespace entities {
|
||||
namespace workflow {
|
||||
|
||||
/**
|
||||
* Create a new workflow in the store
|
||||
*/
|
||||
inline Result<Workflow> create(InMemoryStore& store, const CreateWorkflowInput& input) {
|
||||
if (input.name.empty() || input.name.length() > 100) {
|
||||
return Error::validationError("Name must be between 1 and 100 characters");
|
||||
}
|
||||
if (input.type.empty()) {
|
||||
return Error::validationError("Workflow type is required");
|
||||
}
|
||||
if (!validation::isValidWorkflowType(input.type)) {
|
||||
return Error::validationError("Invalid workflow type");
|
||||
}
|
||||
|
||||
Workflow workflow;
|
||||
workflow.id = store.generateId("workflow", ++store.workflow_counter);
|
||||
workflow.name = input.name;
|
||||
workflow.description = input.description;
|
||||
workflow.type = input.type;
|
||||
workflow.config = input.config;
|
||||
workflow.is_active = input.is_active;
|
||||
workflow.created_at = std::chrono::system_clock::now();
|
||||
workflow.updated_at = workflow.created_at;
|
||||
|
||||
store.workflows[workflow.id] = workflow;
|
||||
|
||||
return Result<Workflow>(workflow);
|
||||
}
|
||||
|
||||
} // namespace workflow
|
||||
} // namespace entities
|
||||
} // namespace dbal
|
||||
|
||||
#endif
|
||||
38
dbal/cpp/src/entities/workflow/delete_workflow.hpp
Normal file
38
dbal/cpp/src/entities/workflow/delete_workflow.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file delete_workflow.hpp
|
||||
* @brief Delete workflow operation
|
||||
*/
|
||||
#ifndef DBAL_DELETE_WORKFLOW_HPP
|
||||
#define DBAL_DELETE_WORKFLOW_HPP
|
||||
|
||||
#include "dbal/types.hpp"
|
||||
#include "dbal/errors.hpp"
|
||||
#include "../../store/in_memory_store.hpp"
|
||||
|
||||
namespace dbal {
|
||||
namespace entities {
|
||||
namespace workflow {
|
||||
|
||||
/**
|
||||
* Delete a workflow by ID
|
||||
*/
|
||||
inline Result<bool> remove(InMemoryStore& store, const std::string& id) {
|
||||
if (id.empty()) {
|
||||
return Error::validationError("Workflow ID cannot be empty");
|
||||
}
|
||||
|
||||
auto it = store.workflows.find(id);
|
||||
if (it == store.workflows.end()) {
|
||||
return Error::notFound("Workflow not found: " + id);
|
||||
}
|
||||
|
||||
store.workflows.erase(it);
|
||||
|
||||
return Result<bool>(true);
|
||||
}
|
||||
|
||||
} // namespace workflow
|
||||
} // namespace entities
|
||||
} // namespace dbal
|
||||
|
||||
#endif
|
||||
36
dbal/cpp/src/entities/workflow/get_workflow.hpp
Normal file
36
dbal/cpp/src/entities/workflow/get_workflow.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @file get_workflow.hpp
|
||||
* @brief Get workflow by ID operation
|
||||
*/
|
||||
#ifndef DBAL_GET_WORKFLOW_HPP
|
||||
#define DBAL_GET_WORKFLOW_HPP
|
||||
|
||||
#include "dbal/types.hpp"
|
||||
#include "dbal/errors.hpp"
|
||||
#include "../../store/in_memory_store.hpp"
|
||||
|
||||
namespace dbal {
|
||||
namespace entities {
|
||||
namespace workflow {
|
||||
|
||||
/**
|
||||
* Get a workflow by ID
|
||||
*/
|
||||
inline Result<Workflow> get(InMemoryStore& store, const std::string& id) {
|
||||
if (id.empty()) {
|
||||
return Error::validationError("Workflow ID cannot be empty");
|
||||
}
|
||||
|
||||
auto it = store.workflows.find(id);
|
||||
if (it == store.workflows.end()) {
|
||||
return Error::notFound("Workflow not found: " + id);
|
||||
}
|
||||
|
||||
return Result<Workflow>(it->second);
|
||||
}
|
||||
|
||||
} // namespace workflow
|
||||
} // namespace entities
|
||||
} // namespace dbal
|
||||
|
||||
#endif
|
||||
14
dbal/cpp/src/entities/workflow/index.hpp
Normal file
14
dbal/cpp/src/entities/workflow/index.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @file index.hpp
|
||||
* @brief Barrel include for workflow operations
|
||||
*/
|
||||
#ifndef DBAL_WORKFLOW_INDEX_HPP
|
||||
#define DBAL_WORKFLOW_INDEX_HPP
|
||||
|
||||
#include "create_workflow.hpp"
|
||||
#include "get_workflow.hpp"
|
||||
#include "update_workflow.hpp"
|
||||
#include "delete_workflow.hpp"
|
||||
#include "list_workflows.hpp"
|
||||
|
||||
#endif
|
||||
62
dbal/cpp/src/entities/workflow/list_workflows.hpp
Normal file
62
dbal/cpp/src/entities/workflow/list_workflows.hpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @file list_workflows.hpp
|
||||
* @brief List workflows with filtering and pagination
|
||||
*/
|
||||
#ifndef DBAL_LIST_WORKFLOWS_HPP
|
||||
#define DBAL_LIST_WORKFLOWS_HPP
|
||||
|
||||
#include "dbal/types.hpp"
|
||||
#include "dbal/errors.hpp"
|
||||
#include "../../store/in_memory_store.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
namespace dbal {
|
||||
namespace entities {
|
||||
namespace workflow {
|
||||
|
||||
/**
|
||||
* List workflows with filtering and pagination
|
||||
*/
|
||||
inline Result<std::vector<Workflow>> list(InMemoryStore& store, const ListOptions& options) {
|
||||
std::vector<Workflow> workflows;
|
||||
|
||||
for (const auto& [id, workflow] : store.workflows) {
|
||||
bool matches = true;
|
||||
|
||||
if (options.filter.find("is_active") != options.filter.end()) {
|
||||
bool filter_active = options.filter.at("is_active") == "true";
|
||||
if (workflow.is_active != filter_active) matches = false;
|
||||
}
|
||||
|
||||
if (options.filter.find("type") != options.filter.end()) {
|
||||
if (workflow.type != options.filter.at("type")) matches = false;
|
||||
}
|
||||
|
||||
if (matches) workflows.push_back(workflow);
|
||||
}
|
||||
|
||||
if (options.sort.find("name") != options.sort.end()) {
|
||||
std::sort(workflows.begin(), workflows.end(), [](const Workflow& a, const Workflow& b) {
|
||||
return a.name < b.name;
|
||||
});
|
||||
} else if (options.sort.find("created_at") != options.sort.end()) {
|
||||
std::sort(workflows.begin(), workflows.end(), [](const Workflow& a, const Workflow& b) {
|
||||
return a.created_at < b.created_at;
|
||||
});
|
||||
}
|
||||
|
||||
int start = (options.page - 1) * options.limit;
|
||||
int end = std::min(start + options.limit, static_cast<int>(workflows.size()));
|
||||
|
||||
if (start < static_cast<int>(workflows.size())) {
|
||||
return Result<std::vector<Workflow>>(std::vector<Workflow>(workflows.begin() + start, workflows.begin() + end));
|
||||
}
|
||||
|
||||
return Result<std::vector<Workflow>>(std::vector<Workflow>());
|
||||
}
|
||||
|
||||
} // namespace workflow
|
||||
} // namespace entities
|
||||
} // namespace dbal
|
||||
|
||||
#endif
|
||||
58
dbal/cpp/src/entities/workflow/update_workflow.hpp
Normal file
58
dbal/cpp/src/entities/workflow/update_workflow.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @file update_workflow.hpp
|
||||
* @brief Update workflow operation
|
||||
*/
|
||||
#ifndef DBAL_UPDATE_WORKFLOW_HPP
|
||||
#define DBAL_UPDATE_WORKFLOW_HPP
|
||||
|
||||
#include "dbal/types.hpp"
|
||||
#include "dbal/errors.hpp"
|
||||
#include "../../store/in_memory_store.hpp"
|
||||
#include "../../validation/workflow_validation.hpp"
|
||||
|
||||
namespace dbal {
|
||||
namespace entities {
|
||||
namespace workflow {
|
||||
|
||||
/**
|
||||
* Update an existing workflow
|
||||
*/
|
||||
inline Result<Workflow> update(InMemoryStore& store, const std::string& id, const UpdateWorkflowInput& input) {
|
||||
if (id.empty()) {
|
||||
return Error::validationError("Workflow ID cannot be empty");
|
||||
}
|
||||
|
||||
auto it = store.workflows.find(id);
|
||||
if (it == store.workflows.end()) {
|
||||
return Error::notFound("Workflow not found: " + id);
|
||||
}
|
||||
|
||||
Workflow& workflow = it->second;
|
||||
|
||||
if (input.name.has_value()) {
|
||||
if (input.name.value().empty() || input.name.value().length() > 100) {
|
||||
return Error::validationError("Name must be between 1 and 100 characters");
|
||||
}
|
||||
workflow.name = input.name.value();
|
||||
}
|
||||
|
||||
if (input.type.has_value()) {
|
||||
if (!validation::isValidWorkflowType(input.type.value())) {
|
||||
return Error::validationError("Invalid workflow type");
|
||||
}
|
||||
workflow.type = input.type.value();
|
||||
}
|
||||
|
||||
if (input.description.has_value()) workflow.description = input.description.value();
|
||||
if (input.config.has_value()) workflow.config = input.config.value();
|
||||
if (input.is_active.has_value()) workflow.is_active = input.is_active.value();
|
||||
|
||||
workflow.updated_at = std::chrono::system_clock::now();
|
||||
return Result<Workflow>(workflow);
|
||||
}
|
||||
|
||||
} // namespace workflow
|
||||
} // namespace entities
|
||||
} // namespace dbal
|
||||
|
||||
#endif
|
||||
18
packages/codegen_studio/static_content/cli/main.cpp
Normal file
18
packages/codegen_studio/static_content/cli/main.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::string project = "starter-app";
|
||||
if (argc > 1 && argv[1] != nullptr) {
|
||||
project = argv[1];
|
||||
}
|
||||
|
||||
std::cout << "Codegen Studio CLI" << std::endl;
|
||||
std::cout << "Project: " << project << std::endl;
|
||||
std::cout << "Zip entries:" << std::endl;
|
||||
std::cout << "- " << project << "/README.md" << std::endl;
|
||||
std::cout << "- " << project << "/package.json" << std::endl;
|
||||
std::cout << "- " << project << "/src/app/page.tsx" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user