diff --git a/pipeline/__init__.py b/pipeline/__init__.py index 4584e63..93a2ece 100644 --- a/pipeline/__init__.py +++ b/pipeline/__init__.py @@ -2,5 +2,25 @@ from .init import ( load_pipeline, + load_pipeline_sdlc, get_pipeline_config, + sd_project_create, + sd_project_update, + sd_project_delete, + sd_iteration_create, + sd_iteration_update, + sd_iteration_delete, + sd_bug_create, + sd_bug_update, + sd_bug_delete, + sd_bug_close, + sd_test_plan_create, + sd_test_plan_update, + sd_test_plan_delete, + sd_test_case_create, + sd_test_case_update, + sd_test_case_delete, + sd_deploy_env_create, + sd_deploy_env_update, + sd_deploy_env_delete, ) diff --git a/pipeline/init.py b/pipeline/init.py index 748ee41..93e2d2d 100644 --- a/pipeline/init.py +++ b/pipeline/init.py @@ -85,3 +85,205 @@ def load_pipeline(): env.hermes_pipeline_modify = hermes_pipeline_modify env.get_pipeline_config = get_pipeline_config return True + + +# --- SDLC CRUD wrappers (sor.C/U/D on 'pipeline' database) --- + +from sqlor.dbpools import DBPools + +SDLC_DB = "pipeline" + + +def _get_sor(): + return DBPools(), SDLC_DB + + +async def sd_project_create(data): + """Create a project record.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.C('sd_projects', data) + return True + + +async def sd_project_update(data): + """Update a project record (id must be in data dict).""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.U('sd_projects', data) + return True + + +async def sd_project_delete(conditions): + """Delete project records matching conditions.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.D('sd_projects', conditions) + return True + + +async def sd_iteration_create(data): + """Create an iteration record.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.C('sd_iterations', data) + return True + + +async def sd_iteration_update(data): + """Update an iteration record (id must be in data dict).""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.U('sd_iterations', data) + return True + + +async def sd_iteration_delete(conditions): + """Delete iteration records matching conditions.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.D('sd_iterations', conditions) + return True + + +async def sd_bug_create(data): + """Create a bug record.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.C('sd_bugs', data) + return True + + +async def sd_bug_update(data): + """Update a bug record (id must be in data dict).""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.U('sd_bugs', data) + return True + + +async def sd_bug_delete(conditions): + """Delete bug records matching conditions.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.D('sd_bugs', conditions) + return True + + +async def sd_bug_close(data): + """Close a bug (update status to 'closed'). Expects data dict with id.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + data['status'] = 'closed' + await sor.U('sd_bugs', data) + return True + + +async def sd_test_plan_create(data): + """Create a test plan record.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.C('sd_test_plans', data) + return True + + +async def sd_test_plan_update(data): + """Update a test plan record (id must be in data dict).""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.U('sd_test_plans', data) + return True + + +async def sd_test_plan_delete(conditions): + """Delete test plan records matching conditions.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.D('sd_test_plans', conditions) + return True + + +async def sd_test_case_create(data): + """Create a test case record.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.C('sd_test_cases', data) + return True + + +async def sd_test_case_update(data): + """Update a test case record (id must be in data dict).""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.U('sd_test_cases', data) + return True + + +async def sd_test_case_delete(conditions): + """Delete test case records matching conditions.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.D('sd_test_cases', conditions) + return True + + +async def sd_deploy_env_create(data): + """Create a deploy env record.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.C('sd_deploy_envs', data) + return True + + +async def sd_deploy_env_update(data): + """Update a deploy env record (id must be in data dict).""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.U('sd_deploy_envs', data) + return True + + +async def sd_deploy_env_delete(conditions): + """Delete deploy env records matching conditions.""" + db, dbname = _get_sor() + async with db.sqlorContext(dbname) as sor: + await sor.D('sd_deploy_envs', conditions) + return True + + +# --- In-process pipeline engine + SDLC adapter --- + +def load_pipeline_sdlc(): + """Load pipeline-service engine + SDLC adapter for in-process operation.""" + from pipeline_service.init import load_pipeline_service + from pipeline_sdlc.adapter import load_sdlc_adapter + + # Load pipeline engine (registers pipeline_* functions) + load_pipeline_service() + + # Load SDLC adapter (registers step types + handlers) + load_sdlc_adapter() + + # Register SDLC CRUD wrappers + env = ServerEnv() + env.sd_project_create = sd_project_create + env.sd_project_update = sd_project_update + env.sd_project_delete = sd_project_delete + env.sd_iteration_create = sd_iteration_create + env.sd_iteration_update = sd_iteration_update + env.sd_iteration_delete = sd_iteration_delete + env.sd_bug_create = sd_bug_create + env.sd_bug_update = sd_bug_update + env.sd_bug_delete = sd_bug_delete + env.sd_bug_close = sd_bug_close + env.sd_test_plan_create = sd_test_plan_create + env.sd_test_plan_update = sd_test_plan_update + env.sd_test_plan_delete = sd_test_plan_delete + env.sd_test_case_create = sd_test_case_create + env.sd_test_case_update = sd_test_case_update + env.sd_test_case_delete = sd_test_case_delete + env.sd_deploy_env_create = sd_deploy_env_create + env.sd_deploy_env_update = sd_deploy_env_update + env.sd_deploy_env_delete = sd_deploy_env_delete + + return True diff --git a/scripts/load_path.py b/scripts/load_path.py index 7e5662d..b64da56 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -21,6 +21,65 @@ PATHS_LOGINED = [ f"/{MOD}/api/pipeline_node.dspy", ] +# SDLC module paths (pipeline_sdlc) +SDLC_MOD = "pipeline_sdlc" + +SDLC_PATHS_ANY = [ + f"/{SDLC_MOD}/index.ui", + f"/{SDLC_MOD}/styles/sdlc.css", +] + +SDLC_PATHS_LOGINED = [ + f"/{SDLC_MOD}", + f"/{SDLC_MOD}/sd_project/index.ui", + f"/{SDLC_MOD}/sd_project/get_sd_project_list.dspy", + f"/{SDLC_MOD}/sd_project/add_sd_project_list.dspy", + f"/{SDLC_MOD}/sd_project/update_sd_project_list.dspy", + f"/{SDLC_MOD}/sd_project/delete_sd_project_list.dspy", + f"/{SDLC_MOD}/sd_iteration/index.ui", + f"/{SDLC_MOD}/sd_iteration/get_sd_iteration_list.dspy", + f"/{SDLC_MOD}/sd_iteration/add_sd_iteration_list.dspy", + f"/{SDLC_MOD}/sd_iteration/update_sd_iteration_list.dspy", + f"/{SDLC_MOD}/sd_iteration/delete_sd_iteration_list.dspy", + f"/{SDLC_MOD}/sd_test_plan/index.ui", + f"/{SDLC_MOD}/sd_test_plan/get_sd_test_plan_list.dspy", + f"/{SDLC_MOD}/sd_test_plan/add_sd_test_plan_list.dspy", + f"/{SDLC_MOD}/sd_test_plan/update_sd_test_plan_list.dspy", + f"/{SDLC_MOD}/sd_test_plan/delete_sd_test_plan_list.dspy", + f"/{SDLC_MOD}/sd_test_case/index.ui", + f"/{SDLC_MOD}/sd_test_case/get_sd_test_case_list.dspy", + f"/{SDLC_MOD}/sd_test_case/add_sd_test_case_list.dspy", + f"/{SDLC_MOD}/sd_test_case/update_sd_test_case_list.dspy", + f"/{SDLC_MOD}/sd_test_case/delete_sd_test_case_list.dspy", + f"/{SDLC_MOD}/sd_bug/index.ui", + f"/{SDLC_MOD}/sd_bug/get_sd_bug_list.dspy", + f"/{SDLC_MOD}/sd_bug/add_sd_bug_list.dspy", + f"/{SDLC_MOD}/sd_bug/update_sd_bug_list.dspy", + f"/{SDLC_MOD}/sd_bug/delete_sd_bug_list.dspy", + f"/{SDLC_MOD}/sd_deploy_env/index.ui", + f"/{SDLC_MOD}/sd_deploy_env/get_sd_deploy_env_list.dspy", + f"/{SDLC_MOD}/sd_deploy_env/add_sd_deploy_env_list.dspy", + f"/{SDLC_MOD}/sd_deploy_env/update_sd_deploy_env_list.dspy", + f"/{SDLC_MOD}/sd_deploy_env/delete_sd_deploy_env_list.dspy", + # SDLC API endpoints + f"/{SDLC_MOD}/api/create_sd_project.dspy", + f"/{SDLC_MOD}/api/update_sd_project.dspy", + f"/{SDLC_MOD}/api/delete_sd_project.dspy", + f"/{SDLC_MOD}/api/create_sd_iteration.dspy", + f"/{SDLC_MOD}/api/update_sd_iteration.dspy", + f"/{SDLC_MOD}/api/delete_sd_iteration.dspy", + f"/{SDLC_MOD}/api/create_sd_bug.dspy", + f"/{SDLC_MOD}/api/update_sd_bug.dspy", + f"/{SDLC_MOD}/api/close_sd_bug.dspy", + f"/{SDLC_MOD}/api/save_sd_deploy_env.dspy", + f"/{SDLC_MOD}/api/get_project_options.dspy", + f"/{SDLC_MOD}/api/get_iteration_options.dspy", + f"/{SDLC_MOD}/api/check_iteration_bugs.dspy", + f"/{SDLC_MOD}/api/submit_bug.dspy", + # Dashboard + f"/{SDLC_MOD}/sd_dashboard/dashboard.ui", +] + def register_paths(): for path in PATHS_ANY: @@ -31,6 +90,15 @@ def register_paths(): subprocess.run(["py3/bin/python", "set_role_perm.py", "logined", path]) print(f" logined: {path}") + # Register SDLC paths + for path in SDLC_PATHS_ANY: + subprocess.run(["py3/bin/python", "set_role_perm.py", "any", path]) + print(f" any (sdlc): {path}") + + for path in SDLC_PATHS_LOGINED: + subprocess.run(["py3/bin/python", "set_role_perm.py", "logined", path]) + print(f" logined (sdlc): {path}") + if __name__ == "__main__": print(f"=== {MOD} RBAC registration ===")