{
  "repo": "tidbcloud/dataservices",
  "binary": "central",
  "binary_path": "cmd/central/main.go",
  "dependencies": {
    "CentralLifecycle.LoadConfigAndLogger": {
      "infrastructure": {
        "filesystem": {
          "conditions": [
            "Always at startup"
          ],
          "operations": [
            {
              "operation": "READ FILE",
              "trigger": "Load central config before service setup and route startup",
              "conditions": [
                "Always"
              ],
              "implementation": "config.InitConfig(configPath)"
            }
          ]
        }
      },
      "services": []
    },
    "CentralLifecycle.StartTracing": {
      "infrastructure": {},
      "services": []
    },
    "CentralLifecycle.ConnectDatabase": {
      "infrastructure": {
        "mysql": {
          "conditions": [
            "Always after config initialization succeeds"
          ],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the shared SQL connection consumed by central service, eventbus, and repository code",
              "conditions": [
                "config.InitConfig(configPath) succeeded"
              ],
              "implementation": "database.Connect(ctx, ...)"
            }
          ]
        }
      },
      "services": []
    },
    "CentralLifecycle.StartEventbus": {
      "infrastructure": {
        "mysql": {
          "conditions": [
            "Only when local mode is disabled"
          ],
          "operations": [
            {
              "operation": "SUBSCRIBE / RUN LOOP",
              "trigger": "Start the dataservice_central eventbus consumer",
              "conditions": [
                "!config.IsLocalMode()"
              ],
              "implementation": "eventbusStartup(ctx, sqlDB) -> eventbus.Init(\"dataservice_central\", db); service.RegisterEventbusHandler(bus); bus.Run()"
            }
          ]
        }
      },
      "services": [
        {
          "name": "central-eventbus-handlers",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "RegisterEventbusHandler",
          "operation_type": "local_service_call",
          "conditions": [
            "Only when local mode is disabled"
          ],
          "operations": [
            {
              "operation": "REGISTER HANDLERS",
              "trigger": "Attach central service event handlers before starting the eventbus loop",
              "conditions": [
                "!config.IsLocalMode()"
              ],
              "implementation": "service.RegisterEventbusHandler(bus)"
            }
          ]
        }
      ]
    },
    "CentralLifecycle.InitApikeyEncrypter": {
      "infrastructure": {},
      "services": []
    },
    "CentralLifecycle.InitRegionalBackends": {
      "infrastructure": {
        "dynamodb": {
          "conditions": [
            "Only when server local mode is disabled"
          ],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Initialize the DynamoDB client backing dataapp and custom domain helpers",
              "conditions": [
                "!config.ServerConf.LocalMode"
              ],
              "implementation": "ddb.Init(ctx, config)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "infra-api / gardener discovery",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "dbhubsdk.InitSdk",
          "operation_type": "sdk_init",
          "conditions": [
            "Only when server local mode is disabled"
          ],
          "operations": [
            {
              "operation": "INITIALIZE SDK",
              "trigger": "Prepare regional and gardener helpers used by central service flows",
              "conditions": [
                "!config.ServerConf.LocalMode"
              ],
              "implementation": "dbhubsdk.InitSdk(config.DBHubSdkConf.KubeConfigPath, config.DBHubSdkConf.GardenerProjectName, config.DBHubSdkConf.InfraAPIConfigPath)"
            }
          ]
        }
      ]
    },
    "CentralLifecycle.InitRedis": {
      "infrastructure": {
        "redis": {
          "conditions": [
            "Always at startup"
          ],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Initialize the Redis client used by central request paths and workers",
              "conditions": [
                "Always"
              ],
              "implementation": "redisutil.NewRedisClient(ctx, config)"
            }
          ]
        }
      },
      "services": []
    },
    "CentralLifecycle.RegisterHTTPRoutes": {
      "infrastructure": {},
      "services": [
        {
          "name": "account-provider",
          "target_repo": "tidbcloud/account",
          "target_interface": "GetAccountProviderSvcClient",
          "operation_type": "grpc_connect",
          "conditions": [
            "Always when RouteCentralAPI installs auth and RBAC middleware"
          ],
          "operations": [
            {
              "operation": "INITIALIZE ACCOUNT CLIENT",
              "trigger": "Prepare the client used by CheckRBACPermission",
              "conditions": [
                "RouteCentralAPI() reached installAuthAndRBACPlugin()"
              ],
              "implementation": "grpc.GetAccountProviderSvcClient()"
            }
          ]
        }
      ]
    },
    "CentralLifecycle.StartMetricsServer": {
      "infrastructure": {
        "tcp": {
          "conditions": [
            "Always after route registration"
          ],
          "operations": [
            {
              "operation": "LISTEN",
              "trigger": "Expose Prometheus metrics on the dedicated metrics port",
              "conditions": [
                "Always"
              ],
              "implementation": "go mEng.Run(\"0.0.0.0:\" + config.Global().ServerConf.MetricsPort)"
            }
          ]
        }
      },
      "services": []
    },
    "CentralLifecycle.StartHTTPServer": {
      "infrastructure": {
        "tcp": {
          "conditions": [
            "Always after RouteCentralAPI finishes"
          ],
          "operations": [
            {
              "operation": "LISTEN",
              "trigger": "Serve the central HTTP API on the configured business port",
              "conditions": [
                "Always"
              ],
              "implementation": "ginEng.Run(\":\" + serverConfig.HttpPort)"
            }
          ]
        }
      },
      "services": []
    },
    "HTTP GET /healthz": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /swagger/*any": {
      "infrastructure": {},
      "services": []
    },
    "HTTP POST /inner/create_ddb_table": {
      "infrastructure": {
        "dynamodb": {
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "CREATE GLOBAL TABLE",
              "trigger": "Create or reconcile the shared DynamoDB global table",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.CreateDynamoDBGlobalTable(ctx, params.Region, params.Replica, params.Tolerant)"
            }
          ]
        }
      },
      "services": []
    },
    "HTTP POST /inner/sync_data_to_ddb": {
      "infrastructure": {
        "dynamodb": {
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "SYNC DATA",
              "trigger": "Push central metadata into DynamoDB-backed regional caches",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.SyncDataToDDB(ctx, params)"
            }
          ]
        }
      },
      "services": []
    },
    "HTTP POST /inner/refresh_dataapp": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "RefreshDataapiAPP",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after optional app_ids parsing succeeds"
          ],
          "operations": [
            {
              "operation": "REFRESH APP SNAPSHOTS",
              "trigger": "Rebuild one or more central app views from source state",
              "conditions": [
                "If app_ids is present, every id parsed successfully"
              ],
              "implementation": "service.RefreshDataapiAPP(ctx, appIDs)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/refresh_chat2query": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "RefreshChat2QueryApp",
          "operation_type": "local_service_call",
          "conditions": [
            "Always"
          ],
          "operations": [
            {
              "operation": "REFRESH CHAT2QUERY APPS",
              "trigger": "Rebuild chat2query app projections",
              "conditions": [
                "Always"
              ],
              "implementation": "service.RefreshChat2QueryApp(ctx)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/download_log_res": {
      "infrastructure": {
        "mysql": {
          "conditions": [
            "Only after task_id parsing succeeds"
          ],
          "operations": [
            {
              "operation": "UPDATE",
              "trigger": "Persist the final download result callback from the regional downloader",
              "conditions": [
                "Request body parsed successfully",
                "task_id parsed successfully"
              ],
              "implementation": "repository.UpdateDataAppLogDownloadTask(ctx, taskId, req.Result, req.URL, \"\")"
            }
          ]
        }
      },
      "services": []
    },
    "HTTP GET /api/v1/dataservices/external/appexport/postman": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ExportDataappToPostmanCollection",
          "operation_type": "local_service_call",
          "conditions": [
            "Only when the JWT scene is postman"
          ],
          "operations": [
            {
              "operation": "EXPORT COLLECTION",
              "trigger": "Generate a Postman collection for the externally authorized dataapp",
              "conditions": [
                "dataappClaims.Sence == postman"
              ],
              "implementation": "service.ExportDataappToPostmanCollection(ctx, dataappClaims.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "CreateDataApp",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after every cluster_ids entry parses to a non-zero uint64 and at least one cluster is provided"
          ],
          "operations": [
            {
              "operation": "CREATE DATAAPP",
              "trigger": "Create the dataapp and any bootstrap endpoints bound to the requested clusters",
              "conditions": [
                "All cluster_ids parsed successfully",
                "len(input.ClusterIDs) > 0"
              ],
              "implementation": "service.CreateDataApp(ctx, params.OrgID, params.ProjectID, createdBy, &input)"
            }
          ]
        }
      ]
    },
    "HTTP DELETE /orgs/:org_id/projects/:project_id/apps/:app_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DeleteDataApp",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "DELETE DATAAPP",
              "trigger": "Soft-delete the target app and its related resources",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.DeleteDataApp(ctx, params.AppID, createdBy, account.OperatorType_OPERATOR_TYPE_USER)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListDataApps|ListEndpointsByAppIDs|ListPublishedEndpointByIDs",
          "operation_type": "local_service_call",
          "conditions": [
            "ListEndpointsByAppIDs and ListPublishedEndpointByIDs only run when the initial app list is non-empty"
          ],
          "operations": [
            {
              "operation": "LIST DATAAPPS",
              "trigger": "Fetch the project's dataapps filtered by optional app types",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ListDataApps(ctx, params.ProjectID, appTypeList...)"
            },
            {
              "operation": "LOAD ENDPOINT SUMMARIES",
              "trigger": "Enrich each listed dataapp with endpoint summaries and publish status",
              "conditions": [
                "len(resp) > 0"
              ],
              "implementation": "service.ListEndpointsByAppIDs(ctx, appIDs); service.ListPublishedEndpointByIDs(ctx, endpointIDs)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetDataApp",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "GET DATAAPP",
              "trigger": "Load the full dataapp detail payload",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetDataApp(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP PUT /orgs/:org_id/projects/:project_id/apps/:app_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "UpdateDataApp",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "UPDATE DATAAPP",
              "trigger": "Persist mutable app settings and metadata",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.UpdateDataApp(ctx, params.AppID, &input, createdBy)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/exportlink": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetDataApp|GetWebConsoleHost",
          "operation_type": "local_service_call",
          "conditions": [
            "GenerateJWT only runs after GetDataApp succeeds"
          ],
          "operations": [
            {
              "operation": "LOOK UP DATAAPP",
              "trigger": "Resolve the external app id before generating the export JWT",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetDataApp(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/postmanstatus": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataappHasEndpointCanTest",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "CHECK POSTMAN ELIGIBILITY",
              "trigger": "Determine whether the app has runnable endpoints for export/testing",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.DataappHasEndpointCanTest(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/samplestatus": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetSampleDataappStates",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LOAD SAMPLE APP STATE",
              "trigger": "Return sample app status plus task records",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetSampleDataappStates(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/batchexample": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "BatchGetCodeExample",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "GENERATE CODE EXAMPLES",
              "trigger": "Build batch endpoint usage examples for the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.BatchGetCodeExample(ctx, params.AppID, createdBy)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/updatestatus": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "UpdateSampleDataappStatus",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "UPDATE SAMPLE STATUS",
              "trigger": "Move the sample app back to normal state",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.UpdateSampleDataappStatus(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/systemendpoint": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetSystemEndpointConfig",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "GET SYSTEM ENDPOINT CONFIG",
              "trigger": "Load the derived system endpoint configuration for the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetSystemEndpointConfig(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/systemendpoint": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "SaveSystemEndpointConfig",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after auth0 token extraction and request bind both succeed"
          ],
          "operations": [
            {
              "operation": "SAVE SYSTEM ENDPOINT CONFIG",
              "trigger": "Persist system endpoint settings using an AUTH0 credential",
              "conditions": [
                "getAuth0Token(c, ctx) succeeded",
                "Request body parsed successfully"
              ],
              "implementation": "service.SaveSystemEndpointConfig(ctx, params.ProjectID, params.AppID, &systemEndpointConfigData, createdBy, credential)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/list_dataapp_usage": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListDataAppUsage",
          "operation_type": "local_service_call",
          "conditions": [
            "Only when input.Region is non-empty"
          ],
          "operations": [
            {
              "operation": "QUERY USAGE",
              "trigger": "Query app usage from observability-derived data",
              "conditions": [
                "ShouldBindQuery(input) succeeded",
                "len(input.Region) > 0"
              ],
              "implementation": "service.ListDataAppUsage(ctx, *input, params.ProjectID, params.OrgID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/deploy/config": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetDataAppDeploySetting",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "GET DEPLOY SETTING",
              "trigger": "Load the current dataapp deployment switch config",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetDataAppDeploySetting(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP PUT /orgs/:org_id/projects/:project_id/apps/:app_id/deploy/config": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "SaveDataAppDeploymentSettingSwithConfig",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "SAVE DEPLOY SETTING",
              "trigger": "Persist deployment switch config changes",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.SaveDataAppDeploymentSettingSwithConfig(ctx, params.AppID, &input)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/deploy/logs/:log_id/diff": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetDiffBetweenCurrDeployAndPreviousSuccDeploy|GetDiffBetweenCurrDeployAndLastestSuccDeploy",
          "operation_type": "local_service_call",
          "conditions": [
            "detail uses previous successful deploy; redeploy uses latest successful deploy"
          ],
          "operations": [
            {
              "operation": "BUILD DEPLOY DIFF",
              "trigger": "Compare the chosen deployment snapshot against the requested baseline",
              "conditions": [
                "sence == detail or sence == redeploy"
              ],
              "implementation": "service.GetDiffBetweenCurrDeployAndPreviousSuccDeploy(...) or service.GetDiffBetweenCurrDeployAndLastestSuccDeploy(...)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/deploy/diff": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetEndpoint|GetDiffBetweenEndpointAndLastestSuccDeploy",
          "operation_type": "local_service_call",
          "conditions": [
            "GetEndpoint only runs when endpoint_id query param is provided"
          ],
          "operations": [
            {
              "operation": "VALIDATE OPTIONAL ENDPOINT",
              "trigger": "Ensure the requested endpoint belongs to the target app before building the diff",
              "conditions": [
                "endpoint_id query param is present"
              ],
              "implementation": "service.GetEndpoint(ctx, endpointIDInt)"
            },
            {
              "operation": "BUILD APP OR ENDPOINT DIFF",
              "trigger": "Compare current draft state against the latest successful deploy",
              "conditions": [
                "Endpoint validation passed when endpoint_id is present"
              ],
              "implementation": "service.GetDiffBetweenEndpointAndLastestSuccDeploy(ctx, params.AppID, endpointIDInt, entity.SnapshotDiffType(diffType))"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/deploy/status": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetDataAppDeploymentStatus",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "GET DEPLOY STATUS",
              "trigger": "Return the message-bar deployment status for the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetDataAppDeploymentStatus(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/deploy/logs": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListDataAppDeployLogs",
          "operation_type": "local_service_call",
          "conditions": [
            "Only when limit parses successfully and is <= 25"
          ],
          "operations": [
            {
              "operation": "LIST DEPLOY LOGS",
              "trigger": "Load recent deploy logs for the app",
              "conditions": [
                "limit query param parsed successfully",
                "limit <= 25"
              ],
              "implementation": "service.ListDataAppDeployLogs(ctx, params.AppID, limit)"
            }
          ]
        }
      ]
    },
    "HTTP PUT /orgs/:org_id/projects/:project_id/apps/:app_id/deploy/logs/:log_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "SaveDataAppDeploymentName",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "RENAME DEPLOY LOG",
              "trigger": "Update the user-facing deployment name",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.SaveDataAppDeploymentName(ctx, params.DeployLogID, input.DeployName)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/deploy": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "TriggerDataAppDeployFromUI",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "CREATE DEPLOY TASK",
              "trigger": "Create a new deploy log and queue deployment from the UI path",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.TriggerDataAppDeployFromUI(ctx, params.AppID, createdBy, input.DeployName)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/discard": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DiscardDataApp",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "DISCARD DRAFT",
              "trigger": "Discard the current app draft state",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.DiscardDataApp(ctx, params.AppID, createdBy)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/deploy/logs/:log_id/deploy": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "TriggerRedeploy",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "CREATE REDEPLOY TASK",
              "trigger": "Queue a redeploy based on a prior deployment log",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.TriggerRedeploy(ctx, params.DeployLogID, createdBy, input.DeployName)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/discard": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DiscardEndpoint",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "DISCARD ENDPOINT DRAFT",
              "trigger": "Discard the current endpoint draft state",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.DiscardEndpoint(ctx, params.AppID, params.EndpointID, createdBy)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/apikeys": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "CheckUserHasCreateWriteKeyPermission|RbacCreateApikey",
          "operation_type": "local_service_call",
          "conditions": [
            "Permission check only runs for roles in ableToCreateApiKeyRoleMapper"
          ],
          "operations": [
            {
              "operation": "CHECK WRITE-KEY PERMISSION",
              "trigger": "Gate creation of write-capable API keys",
              "conditions": [
                "ableToCreateApiKeyRoleMapper[input.Role] is true"
              ],
              "implementation": "service.CheckUserHasCreateWriteKeyPermission(ctx, userId, params.OrgID, params.ProjectID)"
            },
            {
              "operation": "CREATE API KEY",
              "trigger": "Create the RBAC-backed API key after role validation",
              "conditions": [
                "validApiKeyRoleMapper[input.Role] is true",
                "Permission check passed when required"
              ],
              "implementation": "service.RbacCreateApikey(ctx, params.AppID, input.Name, input.Role, entity.DataAPISourceDataAPIConsole, createdBy, input.RateLimitRpm, account.OperatorType_OPERATOR_TYPE_USER, input.TTLInMin)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/apikeys/expire_all": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "RbacListApiKeys|RbacUpdateApikey",
          "operation_type": "local_service_call",
          "conditions": [
            "RbacUpdateApikey only runs for keys that are not already expired"
          ],
          "operations": [
            {
              "operation": "LIST API KEYS",
              "trigger": "Load all RBAC API keys before expiring them in parallel",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.RbacListApiKeys(ctx, params.AppID, true)"
            },
            {
              "operation": "EXPIRE KEYS IN PARALLEL",
              "trigger": "Set each live key to the fixed expired TTL value",
              "conditions": [
                "localkey.IsExpired() is false"
              ],
              "implementation": "service.RbacUpdateApikey(errCtx, params.AppID, localkey.Id, localkey.Name, localkey.Role, localkey.Role, createdBy, localkey.RateLimitRpm, account.OperatorType_OPERATOR_TYPE_USER, localkey.TTLInMin, CONST_expire_key_ttl_val)"
            }
          ]
        }
      ]
    },
    "HTTP DELETE /orgs/:org_id/projects/:project_id/apps/:app_id/apikeys/:apikey_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "RbacDeleteApikey",
          "operation_type": "local_service_call",
          "conditions": [
            "If role query param is empty, owner is assumed"
          ],
          "operations": [
            {
              "operation": "DELETE API KEY",
              "trigger": "Delete the RBAC API key using the requested or default role",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.RbacDeleteApikey(ctx, params.AppID, params.APIKeyID, role, createdBy, account.OperatorType_OPERATOR_TYPE_USER)"
            }
          ]
        }
      ]
    },
    "HTTP PUT /orgs/:org_id/projects/:project_id/apps/:app_id/apikeys/:apikey_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "RbacGetApiKey|RbacUpdateApikey",
          "operation_type": "local_service_call",
          "conditions": [
            "RbacGetApiKey only runs when NewTTLInMin differs from OldTTLInMin"
          ],
          "operations": [
            {
              "operation": "LOAD KEY BEFORE TTL CHANGE",
              "trigger": "Prevent extending or changing TTL on an already expired key",
              "conditions": [
                "int(input.NewTTLInMin) != input.OldTTLInMin"
              ],
              "implementation": "service.RbacGetApiKey(ctx, params.AppID, params.APIKeyID)"
            },
            {
              "operation": "UPDATE API KEY",
              "trigger": "Persist the requested RBAC API key changes",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.RbacUpdateApikey(ctx, params.AppID, params.APIKeyID, input.Name, input.OldRole, input.NewRole, createdBy, input.RateLimitRpm, account.OperatorType_OPERATOR_TYPE_USER, input.OldTTLInMin, int(input.NewTTLInMin))"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/apikeys/:apikey_id/expire_key": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "RbacGetApiKey|RbacUpdateApikey",
          "operation_type": "local_service_call",
          "conditions": [
            "RbacUpdateApikey only runs when the key is not already expired"
          ],
          "operations": [
            {
              "operation": "LOAD API KEY",
              "trigger": "Check whether the target key is already expired",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.RbacGetApiKey(ctx, params.AppID, params.APIKeyID)"
            },
            {
              "operation": "EXPIRE API KEY",
              "trigger": "Force the key TTL to the fixed expired sentinel",
              "conditions": [
                "key.IsExpired() is false"
              ],
              "implementation": "service.RbacUpdateApikey(ctx, params.AppID, params.APIKeyID, key.Name, key.Role, key.Role, createdBy, key.RateLimitRpm, account.OperatorType_OPERATOR_TYPE_USER, key.TTLInMin, CONST_expire_key_ttl_val)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/apikeys": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "RbacListApiKeys",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LIST API KEYS",
              "trigger": "Return the RBAC API key list for the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.RbacListApiKeys(ctx, params.AppID, true)"
            }
          ]
        }
      ]
    },
    "Runtime CentralHTTP.Chat2QueryProxy": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetDataApp",
          "operation_type": "local_service_call",
          "conditions": [
            "Always before proxying"
          ],
          "operations": [
            {
              "operation": "LOAD DATAAPP",
              "trigger": "Resolve the target app and confirm its type",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetDataApp(ctx, params.AppID)"
            }
          ]
        },
        {
          "name": "eda-service",
          "target_repo": "external/eda-service",
          "target_interface": "ProxyToEDAService",
          "operation_type": "http_proxy",
          "conditions": [
            "Only when appInfo.AppType == entity.DataAppTypeChat2Query"
          ],
          "operations": [
            {
              "operation": "PROXY REQUEST",
              "trigger": "Forward the chat2query request to the global EDA service",
              "conditions": [
                "appInfo.AppType == entity.DataAppTypeChat2Query"
              ],
              "implementation": "commonhttp.ProxyToEDAService(ctx, appInfo, c.Request, c.Request.Method, timeout)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "SaveEndpoint|ConvertEndpoint|GetRegionSuccessfulDomainsMap|GetAPPServiceUrl",
          "operation_type": "local_service_call",
          "conditions": [
            "GetRegionSuccessfulDomainsMap and GetAPPServiceUrl only run after SaveEndpoint succeeds"
          ],
          "operations": [
            {
              "operation": "CREATE ENDPOINT",
              "trigger": "Persist a new endpoint after request parsing and semantic validation",
              "conditions": [
                "input.Parse() succeeded"
              ],
              "implementation": "service.SaveEndpoint(ctx, params.AppID, input, createdBy, nil)"
            },
            {
              "operation": "BUILD OUTPUT URL",
              "trigger": "Resolve region-specific service URLs for the newly created endpoint",
              "conditions": [
                "service.SaveEndpoint(...) succeeded"
              ],
              "implementation": "service.GetRegionSuccessfulDomainsMap(ctx, resp.DataappId); service.GetAPPServiceUrl(ctx, resp.DataappId, input.ClusterId, regionSuccessfulDomainsMap)"
            }
          ]
        }
      ]
    },
    "HTTP DELETE /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DeleteEndpoint",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "DELETE ENDPOINT",
              "trigger": "Delete the target endpoint draft and related state",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.DeleteEndpoint(ctx, params.AppID, params.EndpointID, createdBy)"
            }
          ]
        }
      ]
    },
    "HTTP PUT /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "SaveEndpoint|GetEndpoint|ConvertEndpoint|HasEndpointModified",
          "operation_type": "local_service_call",
          "conditions": [
            "GetEndpoint only runs when input.EndpointID > 0 and input.Vid == 0"
          ],
          "operations": [
            {
              "operation": "UPDATE ENDPOINT",
              "trigger": "Persist a full endpoint update",
              "conditions": [
                "input.Parse() succeeded"
              ],
              "implementation": "service.SaveEndpoint(ctx, params.AppID, input, createdBy, nil)"
            },
            {
              "operation": "RELOAD FOR RESPONSE",
              "trigger": "Reload the endpoint when the request targets the draft record rather than a version",
              "conditions": [
                "input.EndpointID > 0",
                "input.Vid == 0"
              ],
              "implementation": "service.GetEndpoint(ctx, input.EndpointID)"
            },
            {
              "operation": "CHECK MODIFIED FLAG",
              "trigger": "Compute whether the endpoint differs from the latest published version",
              "conditions": [
                "An endpoint object is available for response formatting"
              ],
              "implementation": "service.HasEndpointModified(ctx, endpoint)"
            }
          ]
        }
      ]
    },
    "HTTP PATCH /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "SaveEndpoint|GetEndpoint|ConvertEndpoint|HasEndpointModified",
          "operation_type": "local_service_call",
          "conditions": [
            "Patch semantics depend on params.JsonParams"
          ],
          "operations": [
            {
              "operation": "PATCH ENDPOINT",
              "trigger": "Persist a partial endpoint update",
              "conditions": [
                "input.Parse() succeeded"
              ],
              "implementation": "service.SaveEndpoint(ctx, params.AppID, input, createdBy, params.JsonParams)"
            },
            {
              "operation": "RELOAD + CHECK MODIFIED",
              "trigger": "Reload the endpoint and compute its modified state for the response",
              "conditions": [
                "service.SaveEndpoint(...) succeeded"
              ],
              "implementation": "service.GetEndpoint(ctx, input.EndpointID); service.HasEndpointModified(ctx, endpoint)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetEndpoint|ConvertEndpoint|GetRegionSuccessfulDomainsMap|GetAPPServiceUrl|HasEndpointModified",
          "operation_type": "local_service_call",
          "conditions": [
            "GetAPPServiceUrl only enriches the response; failure there does not abort earlier endpoint fetch"
          ],
          "operations": [
            {
              "operation": "GET ENDPOINT",
              "trigger": "Load the endpoint detail payload",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetEndpoint(ctx, params.EndpointID)"
            },
            {
              "operation": "RESOLVE SERVICE URL + MODIFIED FLAG",
              "trigger": "Attach the user-facing service URL and publish-drift flag",
              "conditions": [
                "service.GetEndpoint(...) succeeded"
              ],
              "implementation": "service.GetRegionSuccessfulDomainsMap(ctx, resp.DataappId); service.GetAPPServiceUrl(ctx, resp.DataappId, resp.ClusterId, regionSuccessfulDomainsMap); service.HasEndpointModified(ctx, resp)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListEndpoints",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LIST ENDPOINTS",
              "trigger": "Return all endpoints bound to the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ListEndpoints(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/dump": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetEndpoint|DumpEndpoint|ConvertEndpoint|GetRegionSuccessfulDomainsMap|GetAPPServiceUrl",
          "operation_type": "local_service_call",
          "conditions": [
            "DumpEndpoint only runs after the existing endpoint is loaded and renamed locally"
          ],
          "operations": [
            {
              "operation": "LOAD + DUPLICATE ENDPOINT",
              "trigger": "Clone the endpoint into a new draft with a randomized suffix",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetEndpoint(ctx, params.EndpointID); service.DumpEndpoint(ctx, endpoint, createdBy)"
            },
            {
              "operation": "RESOLVE SERVICE URL",
              "trigger": "Attach the new endpoint's service URL to the response",
              "conditions": [
                "service.DumpEndpoint(...) succeeded"
              ],
              "implementation": "service.GetRegionSuccessfulDomainsMap(ctx, resp.DataappId); service.GetAPPServiceUrl(ctx, resp.DataappId, endpoint.ClusterId, regionSuccessfulDomainsMap)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/auto/endpoints": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "CreateAutoGenerateEndpoints",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after auth0 token extraction, request bind, and region regexp parsing all succeed"
          ],
          "operations": [
            {
              "operation": "AUTO-GENERATE ENDPOINTS",
              "trigger": "Generate endpoint drafts from the provided schema and auth context",
              "conditions": [
                "getAuth0Token(c, ctx) succeeded",
                "Request body parsed successfully",
                "Region regexp parse succeeded"
              ],
              "implementation": "service.CreateAutoGenerateEndpoints(ctx, params.AppID, params.ProjectID, input.ClusterId, auth0Token, createdBy, &input)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/draft/diff": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetDiffBetweenDraftEndpointAndSubmitData",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind and semantic parse both succeed"
          ],
          "operations": [
            {
              "operation": "BUILD DRAFT DIFF",
              "trigger": "Compare the submitted endpoint payload against the saved draft",
              "conditions": [
                "input.Parse() succeeded"
              ],
              "implementation": "service.GetDiffBetweenDraftEndpointAndSubmitData(ctx, params.AppID, &input, entity.SnapshotDiffType(diffType))"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/online": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "TriggerEndpointDeployFromUI",
          "operation_type": "local_service_call",
          "conditions": [
            "deployName falls back to endpoint.Endpoint when request body omits it"
          ],
          "operations": [
            {
              "operation": "CREATE ENDPOINT DEPLOY TASK",
              "trigger": "Queue endpoint deployment from the UI path",
              "conditions": [
                "repository.GetEndpoint(params.EndpointID) succeeded"
              ],
              "implementation": "service.TriggerEndpointDeployFromUI(ctx, params.AppID, params.EndpointID, createdBy, deployName)"
            }
          ]
        }
      ]
    },
    "HTTP PUT /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/offline": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "TriggerEndpointUndeployFromUI",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after repository.GetEndpoint(params.EndpointID) succeeds"
          ],
          "operations": [
            {
              "operation": "CREATE ENDPOINT UNDEPLOY TASK",
              "trigger": "Queue endpoint undeploy from the UI path",
              "conditions": [
                "repository.GetEndpoint(params.EndpointID) succeeded"
              ],
              "implementation": "service.TriggerEndpointUndeployFromUI(ctx, params.AppID, params.EndpointID, createdBy, \"Undeploy Endpoint: \"+endpoint.Endpoint)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/versions": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListEndpointPublishLog",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LIST PUBLISH HISTORY",
              "trigger": "Return publish history for the endpoint",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ListEndpointPublishLog(ctx, params.EndpointID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/version/:version/status": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "CheckEndpointDeployComplete",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "CHECK DEPLOY COMPLETION",
              "trigger": "Check whether the endpoint deployment version has completed",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.CheckEndpointDeployComplete(ctx, endpointID, version)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/test": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "PublishTest",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after auth0 token extraction and request bind both succeed"
          ],
          "operations": [
            {
              "operation": "TEST ENDPOINT",
              "trigger": "Execute the endpoint test flow with auth0 credentials",
              "conditions": [
                "getAuth0Token(c, ctx) succeeded",
                "Request body parsed successfully"
              ],
              "implementation": "service.PublishTest(ctx, input)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/example": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "CodeExample",
          "operation_type": "local_service_call",
          "conditions": [
            "Only when auth_type is basic|digest and language is curl|js"
          ],
          "operations": [
            {
              "operation": "GENERATE CODE EXAMPLE",
              "trigger": "Build a runnable request example for the endpoint",
              "conditions": [
                "auth_type in {basic, digest}",
                "language in {curl, js}"
              ],
              "implementation": "service.CodeExample(ctx, params.EndpointID, entity.CodeExampleInput{...})"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/baseurl": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetRegionSuccessfulDomainsMap|GetAPPServiceUrl",
          "operation_type": "local_service_call",
          "conditions": [
            "cluster_id query param is optional, but must parse when provided"
          ],
          "operations": [
            {
              "operation": "RESOLVE BASE URL",
              "trigger": "Return the service base URL for the endpoint's app and optional cluster",
              "conditions": [
                "cluster_id parsed successfully when provided"
              ],
              "implementation": "service.GetRegionSuccessfulDomainsMap(ctx, params.AppID); service.GetAPPServiceUrl(ctx, params.AppID, clusterID, regionSuccessfulDomainsMap)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/sessions": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "CreateSession",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after auth0 token extraction and request bind both succeed"
          ],
          "operations": [
            {
              "operation": "CREATE SQL SESSION",
              "trigger": "Create a temporary query session for the target cluster/database",
              "conditions": [
                "getAuth0Token(c, ctx) succeeded",
                "Request body parsed successfully"
              ],
              "implementation": "service.CreateSession(ctx, dto.CreateSessionIn{...})"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/endpoints/:endpoint_id/statements": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "Statements",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after auth0 token extraction, request bind, and cluster_id parsing all succeed"
          ],
          "operations": [
            {
              "operation": "EXECUTE STATEMENTS",
              "trigger": "Run endpoint SQL using auth0-backed central execution flow",
              "conditions": [
                "getAuth0Token(c, ctx) succeeded",
                "Request body parsed successfully",
                "cluster_id parsed successfully"
              ],
              "implementation": "service.Statements(ctx, createdBy, input)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/clusters/:cluster_id/dbs": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ShowDBs",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after auth0 token extraction succeeds"
          ],
          "operations": [
            {
              "operation": "SHOW DATABASES",
              "trigger": "List databases visible to the auth0 credential",
              "conditions": [
                "getAuth0Token(c, ctx) succeeded"
              ],
              "implementation": "service.ShowDBs(ctx, input, credential)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/clusters/:cluster_id/dbs/:db_name/tables": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ShowTables",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after auth0 token extraction succeeds"
          ],
          "operations": [
            {
              "operation": "SHOW TABLES",
              "trigger": "List tables in the requested database",
              "conditions": [
                "getAuth0Token(c, ctx) succeeded"
              ],
              "implementation": "service.ShowTables(ctx, input)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/clusters/:cluster_id/dbs/:db_name/tables/:table_name/vector/fields": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ShowVectorFields",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after auth0 token extraction succeeds"
          ],
          "operations": [
            {
              "operation": "SHOW VECTOR FIELDS",
              "trigger": "List vector fields for the requested table",
              "conditions": [
                "getAuth0Token(c, ctx) succeeded"
              ],
              "implementation": "service.ShowVectorFields(ctx, input)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/log": {
      "infrastructure": {},
      "services": [
        {
          "name": "core-svc",
          "target_repo": "tidbcloud/core-svc",
          "target_interface": "GetCluster",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only after query params parse successfully, including cluster_id"
          ],
          "operations": [
            {
              "operation": "LOOK UP CLUSTER",
              "trigger": "Resolve the cluster region before forwarding the log query",
              "conditions": [
                "fetchDataAppLogQueryParam(...) succeeded"
              ],
              "implementation": "rpc.GetCluster(ctx, params.OrgID, params.ProjectID, clusterId)"
            }
          ]
        },
        {
          "name": "regional-dataapp-control",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "POST /inner/dataservice/apps/:app_id/dataapp-log/query",
          "operation_type": "http_post",
          "conditions": [
            "Only after cluster lookup succeeds, region is non-empty, and GuardRegionalCapabilityForCluster passes"
          ],
          "operations": [
            {
              "operation": "QUERY REGIONAL LOGS",
              "trigger": "Fetch paged execution logs from the regional control plane",
              "conditions": [
                "rpc.GetCluster(...) succeeded",
                "clusterInfo.RegionName != \"\"",
                "service.GuardRegionalCapabilityForCluster(clusterInfo, service.RegionalCapabilityDataAppLog) passed"
              ],
              "implementation": "httpRegion.QueryDataAppLog(ctx, region, params.AppID, req)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/download_log_task": {
      "infrastructure": {
        "mysql": {
          "conditions": [
            "Only after log query param parsing and cluster capability checks succeed"
          ],
          "operations": [
            {
              "operation": "INSERT",
              "trigger": "Create the download task record before notifying the regional service",
              "conditions": [
                "fetchDataAppLogQueryParam(...) succeeded",
                "service.GuardRegionalCapabilityForCluster(...) passed"
              ],
              "implementation": "repository.SubmitDataAppLogDownloadTask(ctx, task)"
            },
            {
              "operation": "SELECT",
              "trigger": "Load the app name that will be embedded into the regional download task",
              "conditions": [
                "Download task row inserted successfully"
              ],
              "implementation": "repository.GetDataApp(params.AppID)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "core-svc",
          "target_repo": "tidbcloud/core-svc",
          "target_interface": "GetCluster",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only after query params parse successfully, including cluster_id"
          ],
          "operations": [
            {
              "operation": "LOOK UP CLUSTER",
              "trigger": "Resolve the cluster region for the download job",
              "conditions": [
                "fetchDataAppLogQueryParam(...) succeeded"
              ],
              "implementation": "rpc.GetCluster(ctx, params.OrgID, params.ProjectID, clusterId)"
            }
          ]
        },
        {
          "name": "regional-dataapp-control",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "POST /inner/dataservice/apps/:app_id/dataapp-log/download",
          "operation_type": "http_post",
          "conditions": [
            "Only after task row creation, app lookup, and regional capability checks all succeed"
          ],
          "operations": [
            {
              "operation": "SUBMIT DOWNLOAD TASK",
              "trigger": "Ask the regional control service to generate a downloadable log artifact",
              "conditions": [
                "repository.SubmitDataAppLogDownloadTask(...) succeeded",
                "repository.GetDataApp(params.AppID) succeeded"
              ],
              "implementation": "httpRegion.SubmitDataAppLogDownloadTask(ctx, region, params.AppID, &cdto.DownloadLogReq{...})"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/download_log_task/:task_id": {
      "infrastructure": {
        "mysql": {
          "conditions": [
            "Only after task_id parses successfully"
          ],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Load the download task and verify it belongs to the caller's org/project",
              "conditions": [
                "task_id parsed successfully"
              ],
              "implementation": "repository.GetDataAppLogDownloadTask(ctx, id)"
            }
          ]
        }
      },
      "services": []
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/log_response_body_switch": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "UpdateDataAppLogResSwitch",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds and NewStatus is one of on/off"
          ],
          "operations": [
            {
              "operation": "TOGGLE LOG RESPONSE BODY SWITCH",
              "trigger": "Update whether response bodies are persisted in logs",
              "conditions": [
                "Request body parsed successfully",
                "input.NewStatus == entity.SwitchOff or entity.SwitchOn"
              ],
              "implementation": "service.UpdateDataAppLogResSwitch(ctx, params.AppID, input.NewStatus == entity.SwitchOn)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/metrics/misc_statistic": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForDataApp|GetDataAppExtIdAndRegions|GetDataAppEndpointsStatic|QueryDataappMetricsCurrentErrorRate",
          "operation_type": "local_service_call",
          "conditions": [
            "Endpoint statistics and current error rate run in parallel after regional capability check passes"
          ],
          "operations": [
            {
              "operation": "CHECK REGIONAL SUPPORT",
              "trigger": "Fast-fail unsupported metrics queries before fan-out",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "ensureDataAppMetricsSupported(ctx, params.AppID)"
            },
            {
              "operation": "LOAD METRICS CONTEXT",
              "trigger": "Resolve app external id and regions before launching metric fan-out",
              "conditions": [
                "ensureDataAppMetricsSupported(...) passed"
              ],
              "implementation": "service.GetDataAppExtIdAndRegions(ctx, params.AppID)"
            },
            {
              "operation": "FETCH ENDPOINT STAT + ERROR RATE",
              "trigger": "Compute draft/deployed endpoint counts and current availability in parallel",
              "conditions": [
                "GetDataAppExtIdAndRegions(...) succeeded"
              ],
              "implementation": "service.GetDataAppEndpointsStatic(ctx, params.AppID) || service.QueryDataappMetricsCurrentErrorRate(ctx, params.AppID, extId, regions)"
            }
          ]
        },
        {
          "name": "regional-dataapp-control",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "POST /inner/dataservice/apps/:app_id/dataapp-metrics/query",
          "operation_type": "http_post",
          "conditions": [
            "Only when the app has at least one supported region"
          ],
          "operations": [
            {
              "operation": "QUERY ERROR RATE METRICS",
              "trigger": "Fetch the live regional error-rate signal used to derive availability",
              "conditions": [
                "len(regions) > 0"
              ],
              "implementation": "service.QueryDataappMetricsCurrentErrorRate(ctx, params.AppID, extId, regions)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/metrics/avg_request_rate": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForDataApp|GetDataAppExtIdAndRegions|QueryDataappMetricsReqCount",
          "operation_type": "local_service_call",
          "conditions": [
            "Regional request-count query only runs when len(regions) > 0"
          ],
          "operations": [
            {
              "operation": "QUERY REQUEST COUNT",
              "trigger": "Fetch request counters and normalize them by the query window",
              "conditions": [
                "ensureDataAppMetricsSupported(...) passed",
                "fetchDataAppMetricsRangeQueryParam(query) succeeded",
                "len(regions) > 0"
              ],
              "implementation": "service.QueryDataappMetricsReqCount(ctx, *req, params.AppID, regions)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/metrics/error_rate": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForDataApp|GetDataAppExtIdAndRegions|QueryDataappMetricsReqCount|QueryDataappMetricsErrorCount|ReduceMetricsDiv",
          "operation_type": "local_service_call",
          "conditions": [
            "Regional queries only run when len(regions) > 0"
          ],
          "operations": [
            {
              "operation": "QUERY REQUEST + ERROR COUNT",
              "trigger": "Build error-rate timeseries by dividing error counts by request counts",
              "conditions": [
                "ensureDataAppMetricsSupported(...) passed",
                "fetchDataAppMetricsRangeQueryParam(query) succeeded",
                "len(regions) > 0"
              ],
              "implementation": "service.QueryDataappMetricsReqCount(...); service.QueryDataappMetricsErrorCount(...); service.ReduceMetricsDiv(...)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/metrics/avg_response_time": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForDataApp|GetDataAppExtIdAndRegions|QueryDataappMetricsLatencyPT99|QueryDataappMetricsReqCount|QueryDataappMetricsLantencySum|ReduceMetricsDiv",
          "operation_type": "local_service_call",
          "conditions": [
            "Latency PT99 fan-out runs concurrently with request-count and latency-sum queries after len(regions) > 0"
          ],
          "operations": [
            {
              "operation": "QUERY AVG + TP99 LATENCY",
              "trigger": "Return average response time together with tp99 latency",
              "conditions": [
                "ensureDataAppMetricsSupported(...) passed",
                "fetchDataAppMetricsRangeQueryParam(query) succeeded",
                "len(regions) > 0"
              ],
              "implementation": "service.QueryDataappMetricsLatencyPT99(...) || service.QueryDataappMetricsReqCount(...) + service.QueryDataappMetricsLantencySum(...) + service.ReduceMetricsDiv(...)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/metrics/response_time_tp99": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForDataApp|GetDataAppExtIdAndRegions|QueryDataappMetricsLatencyPT99",
          "operation_type": "local_service_call",
          "conditions": [
            "Regional query only runs when len(regions) > 0"
          ],
          "operations": [
            {
              "operation": "QUERY TP99 LATENCY",
              "trigger": "Return tp99 response-time series for the app",
              "conditions": [
                "ensureDataAppMetricsSupported(...) passed",
                "fetchDataAppMetricsRangeQueryParam(query) succeeded",
                "len(regions) > 0"
              ],
              "implementation": "service.QueryDataappMetricsLatencyPT99(ctx, *req, params.AppID, regions)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/metrics/unauth_req_num": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForDataApp|GetDataAppExtIdAndRegions|QueryDataappMetricsUnauthCount",
          "operation_type": "local_service_call",
          "conditions": [
            "Regional query only runs when len(regions) > 0"
          ],
          "operations": [
            {
              "operation": "QUERY UNAUTHORIZED REQUEST COUNT",
              "trigger": "Return the unauthenticated request counter series",
              "conditions": [
                "ensureDataAppMetricsSupported(...) passed",
                "fetchDataAppMetricsRangeQueryParam(query) succeeded",
                "len(regions) > 0"
              ],
              "implementation": "service.QueryDataappMetricsUnauthCount(ctx, *req, params.AppID, regions)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/metrics/endpoints_rank/most_request": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForDataApp|GetDataAppExtIdAndRegions|QueryDataappMetricsTopKReq|GetEndpointsNameByIdStr",
          "operation_type": "local_service_call",
          "conditions": [
            "TopK query only runs when len(regions) > 0 and topK instant-query params parse successfully"
          ],
          "operations": [
            {
              "operation": "QUERY TOP-K REQUEST RANK",
              "trigger": "Build the endpoint request rank and resolve endpoint ids back to names",
              "conditions": [
                "topKQueryWrapper(...) path for QueryDataappMetricsTopKReq"
              ],
              "implementation": "service.QueryDataappMetricsTopKReq(ctx, *req, params.AppID, regions); service.GetEndpointsNameByIdStr(ctx, ids)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/metrics/endpoints_rank/most_error": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForDataApp|GetDataAppExtIdAndRegions|QueryDataappMetricsTopKError|GetEndpointsNameByIdStr",
          "operation_type": "local_service_call",
          "conditions": [
            "TopK query only runs when len(regions) > 0 and topK instant-query params parse successfully"
          ],
          "operations": [
            {
              "operation": "QUERY TOP-K ERROR RANK",
              "trigger": "Build the endpoint error rank and resolve endpoint ids back to names",
              "conditions": [
                "topKQueryWrapper(...) path for QueryDataappMetricsTopKError"
              ],
              "implementation": "service.QueryDataappMetricsTopKError(ctx, *req, params.AppID, regions); service.GetEndpointsNameByIdStr(ctx, ids)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/metrics/endpoints_rank/high_latency": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForDataApp|GetDataAppExtIdAndRegions|QueryDataappMetricsTopKLatency|GetEndpointsNameByIdStr",
          "operation_type": "local_service_call",
          "conditions": [
            "TopK query only runs when len(regions) > 0 and topK instant-query params parse successfully"
          ],
          "operations": [
            {
              "operation": "QUERY TOP-K LATENCY RANK",
              "trigger": "Build the endpoint latency rank and resolve endpoint ids back to names",
              "conditions": [
                "topKQueryWrapper(...) path for QueryDataappMetricsTopKLatency"
              ],
              "implementation": "service.QueryDataappMetricsTopKLatency(ctx, *req, params.AppID, regions); service.GetEndpointsNameByIdStr(ctx, ids)"
            }
          ]
        }
      ]
    },
    "HTTP GET /metrics": {
      "infrastructure": {},
      "services": []
    },
    "HTTP POST /inner/fix_sync_cluster": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "SyncClusterWithPrivateLink",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "SYNC CLUSTER PRIVATE LINK STATE",
              "trigger": "Synchronize private-link metadata for the provided cluster ids",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.SyncClusterWithPrivateLink(ctx, params.ClusterIDs)"
            }
          ]
        }
      ]
    },
    "HTTP GET /inner/dataservice/projects/:project_id/clusters/:cluster_id/account/playground": {
      "infrastructure": {},
      "services": [
        {
          "name": "infra-api",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "dbhubsdk.Serverless.InfraApi.GetUserMeta",
          "operation_type": "sdk_call",
          "conditions": [
            "Always after path params parse successfully"
          ],
          "operations": [
            {
              "operation": "GET PLAYGROUND ACCOUNT",
              "trigger": "Fetch serverless playground connection metadata",
              "conditions": [
                "URL params parsed successfully"
              ],
              "implementation": "dbhubsdk.Serverless.InfraApi.GetUserMeta(ctx, params.ProjectID, params.ClusterID)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/event_record": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "HandleEndpointExecRecord",
          "operation_type": "local_service_call",
          "conditions": [
            "Only when request.RecordType == dto.EndpointExecRecordType"
          ],
          "operations": [
            {
              "operation": "HANDLE EXEC RECORD",
              "trigger": "Persist endpoint execution history records from regional producers",
              "conditions": [
                "Request body parsed successfully",
                "request.RecordType == dto.EndpointExecRecordType"
              ],
              "implementation": "service.HandleEndpointExecRecord(ctx, &request)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/custom-domains/notify": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "NotifyCustomDomainExpired",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after JSON bind succeeds"
          ],
          "operations": [
            {
              "operation": "NOTIFY CUSTOM DOMAIN EXPIRATION",
              "trigger": "Handle custom-domain expiration callbacks from inner systems",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.NotifyCustomDomainExpired(ctx, req.CustomDomainName, req.DefaultDomainName)"
            }
          ]
        }
      ]
    },
    "HTTP POST /api/v1/dataservices/ghapp/webhook": {
      "infrastructure": {},
      "services": [
        {
          "name": "github-app",
          "target_repo": "external/github",
          "target_interface": "ValidatePayload|ParseWebHook",
          "operation_type": "webhook",
          "conditions": [
            "ParseWebHook only runs after ValidatePayload succeeds"
          ],
          "operations": [
            {
              "operation": "VALIDATE AND PARSE WEBHOOK",
              "trigger": "Authenticate and parse the GitHub webhook payload",
              "conditions": [
                "github.ValidatePayload(c.Request, secret) succeeded"
              ],
              "implementation": "github.ValidatePayload(...); github.ParseWebHook(github.WebHookType(c.Request), payload)"
            }
          ]
        },
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "SaveGithubEvent|ProcessInstallationEvent|ProcessInstallationRepositoriesEvent|ProcessRepositoriesEvent|ProcessGithubAuthorizationEvent|ProcessPushEvent|ProcessDeleteEvent",
          "operation_type": "local_service_call",
          "conditions": [
            "Processor depends on the concrete GitHub event type"
          ],
          "operations": [
            {
              "operation": "SAVE AND DISPATCH EVENT",
              "trigger": "Persist the raw event and hand it to the matching central GitHub handler",
              "conditions": [
                "Payload validation and parse both succeeded"
              ],
              "implementation": "service.SaveGithubEvent(...); service.ProcessInstallationEvent / ProcessInstallationRepositoriesEvent / ProcessRepositoriesEvent / ProcessGithubAuthorizationEvent / ProcessPushEvent / ProcessDeleteEvent"
            }
          ]
        }
      ]
    },
    "HTTP GET /api/v1/dataservices/ghapp/callback": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ProcessAuthorizationCallback",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after code and state query extraction"
          ],
          "operations": [
            {
              "operation": "PROCESS AUTH CALLBACK",
              "trigger": "Exchange the GitHub app callback into a redirect decision",
              "conditions": [
                "code and state query params extracted"
              ],
              "implementation": "service.ProcessAuthorizationCallback(ctx, code, state)"
            }
          ]
        }
      ]
    },
    "HTTP GET /api/v1/dataservices/external/appexport/openapi": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ValidateAppOpenapiFormat|GetDataAppByExtId|GenerateOpenApiSpecification",
          "operation_type": "local_service_call",
          "conditions": [
            "GenerateOpenApiSpecification only runs when the JWT scene is openapi and GetDataAppByExtId succeeds"
          ],
          "operations": [
            {
              "operation": "GENERATE EXTERNAL OAS",
              "trigger": "Validate format, resolve the app by external id, and build the external OpenAPI document",
              "conditions": [
                "dataappClaims.Sence == openapi",
                "service.ValidateAppOpenapiFormat(format) succeeded"
              ],
              "implementation": "service.GetDataAppByExtId(ctx, dataappClaims.AppID); service.GenerateOpenApiSpecification(ctx, dataapp.ID, credential, format)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/clusters": {
      "infrastructure": {},
      "services": [
        {
          "name": "core-svc",
          "target_repo": "tidbcloud/core-svc",
          "target_interface": "ListClusterByIds",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when input.ClusterIDs is non-empty"
          ],
          "operations": [
            {
              "operation": "LOOK UP CLUSTERS",
              "trigger": "Load cluster metadata so datasource-binding capability checks can run",
              "conditions": [
                "Cluster id parsing succeeded",
                "len(input.ClusterIDs) > 0"
              ],
              "implementation": "grpc.ListClusterByIds(ctx, orgID, projectID, clusterIDs)"
            }
          ]
        },
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GuardRegionalCapabilityForCluster|CreateAppCluster",
          "operation_type": "local_service_call",
          "conditions": [
            "CreateAppCluster only runs after every target cluster passes datasource-binding capability checks"
          ],
          "operations": [
            {
              "operation": "CHECK BINDING CAPABILITY AND CREATE BINDING",
              "trigger": "Validate provider support then persist the app-cluster bindings",
              "conditions": [
                "grpc.ListClusterByIds(...) succeeded"
              ],
              "implementation": "service.GuardRegionalCapabilityForCluster(...); service.CreateAppCluster(ctx, input)"
            }
          ]
        }
      ]
    },
    "HTTP DELETE /orgs/:org_id/projects/:project_id/apps/:app_id/clusters/:cluster_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DeleteAppCluster",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "DELETE APP-CLUSTER BINDING",
              "trigger": "Remove the cluster binding from the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.DeleteAppCluster(ctx, req)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/clusters": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListAppCluster",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LIST APP-CLUSTER BINDINGS",
              "trigger": "Return clusters bound to the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ListAppCluster(ctx, req)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/clusters/:cluster_id/apps": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListClusterLinkedAPP|ConvertDataappInfo",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LIST APPS BY CLUSTER",
              "trigger": "Return apps currently linked to the target cluster",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ListClusterLinkedAPP(ctx, params.ProjectID, params.ClusterID)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/preflight-request": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GeneratePreflightRequest",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "GENERATE PREFLIGHT REQUEST",
              "trigger": "Create a GitHub authorization preflight record for the project",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GeneratePreflightRequest(ctx, params.OrgID, params.ProjectID, createdBy)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/preflight-request/:request_id/repositories": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ValidatePreflightRequestId|ListAuthorizedRepositories",
          "operation_type": "local_service_call",
          "conditions": [
            "ListAuthorizedRepositories only runs after the preflight request id validates"
          ],
          "operations": [
            {
              "operation": "VALIDATE PREFLIGHT REQUEST AND LIST REPOS",
              "trigger": "Validate the preflight request then list authorized repositories",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ValidatePreflightRequestId(...); service.ListAuthorizedRepositories(ctx, 0, params.PreflightRequestId)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/preflight-request/:request_id/repositories/:repo_id/branches": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ValidatePreflightRequestId|ListBranches",
          "operation_type": "local_service_call",
          "conditions": [
            "ListBranches only runs after the preflight request id validates"
          ],
          "operations": [
            {
              "operation": "VALIDATE PREFLIGHT REQUEST AND LIST BRANCHES",
              "trigger": "Validate the preflight request then list repository branches",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ValidatePreflightRequestId(...); service.ListBranches(ctx, 0, params.PreflightRequestId, params.RepoID)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/preflight-request/:request_id/repositories/:repo_id/validate": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ValidatePreflightRequestId|ValidateRepoBranchDir",
          "operation_type": "local_service_call",
          "conditions": [
            "ValidateRepoBranchDir only runs after preflight validation and request bind succeed"
          ],
          "operations": [
            {
              "operation": "VALIDATE PREFLIGHT REQUEST AND REPO DIRECTORY",
              "trigger": "Validate repo/branch/directory under the preflight request",
              "conditions": [
                "URL params validated successfully",
                "Request body parsed successfully"
              ],
              "implementation": "service.ValidatePreflightRequestId(...); service.ValidateRepoBranchDir(ctx, 0, params.PreflightRequestId, params.RepoID, input.Branch, input.Directory)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/authorize-url": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetAuthorizeUrl",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "GET AUTHORIZE URL",
              "trigger": "Return the GitHub authorization URL for the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetAuthorizeUrl(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/repositories": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListAuthorizedRepositories",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LIST AUTHORIZED REPOSITORIES",
              "trigger": "List repositories currently authorized for the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ListAuthorizedRepositories(ctx, params.AppID, 0)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/repositories/:repo_id/branches": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListBranches",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LIST REPOSITORY BRANCHES",
              "trigger": "List branches for a repository authorized to the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ListBranches(ctx, params.AppID, 0, params.RepoID)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/repositories/:repo_id/validate": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ValidateRepoBranchDir",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "VALIDATE REPO BRANCH DIRECTORY",
              "trigger": "Validate repo/branch/directory against the app's GitHub linkage",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.ValidateRepoBranchDir(ctx, params.AppID, 0, params.RepoID, input.Branch, input.Directory)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/github": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "GetDataappGithubLinkageStatus",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "GET GITHUB LINKAGE STATUS",
              "trigger": "Return current GitHub linkage and auto-deploy state",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.GetDataappGithubLinkageStatus(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/github/link": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "EnableDataAppGithubAutoDeploy",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "LINK GITHUB REPOSITORY",
              "trigger": "Enable GitHub linkage and optional auto deploy for the app",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.EnableDataAppGithubAutoDeploy(ctx, params.AppID, param, input.EnableAutoDeploy)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/github/unlink": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "UnlinkDataappWithGithub",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "UNLINK GITHUB REPOSITORY",
              "trigger": "Remove GitHub linkage from the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.UnlinkDataappWithGithub(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/oas": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ValidateAppOpenapiFormat|GenerateOpenApiSpecification",
          "operation_type": "local_service_call",
          "conditions": [
            "GenerateOpenApiSpecification only runs after format validation succeeds"
          ],
          "operations": [
            {
              "operation": "GENERATE OAS",
              "trigger": "Generate OpenAPI spec for the target app",
              "conditions": [
                "service.ValidateAppOpenapiFormat(format) succeeded"
              ],
              "implementation": "service.GenerateOpenApiSpecification(ctx, params.AppID, credential, format)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/external-apps/:external_app_id/oas": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ValidateAppOpenapiFormat|GetDataAppByExtId|GenerateOpenApiSpecification",
          "operation_type": "local_service_call",
          "conditions": [
            "GenerateOpenApiSpecification only runs when GetDataAppByExtId succeeds and the app belongs to the current project"
          ],
          "operations": [
            {
              "operation": "LOAD APP BY EXTERNAL ID AND GENERATE OAS",
              "trigger": "Resolve the app by external id, verify project ownership, then build the spec",
              "conditions": [
                "service.ValidateAppOpenapiFormat(format) succeeded"
              ],
              "implementation": "service.GetDataAppByExtId(ctx, params.ExternalAppId); service.GenerateOpenApiSpecification(ctx, params.AppID, credential, format)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/oas/download": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ValidateAppOpenapiFormat|GenerateOpenApiSpecification",
          "operation_type": "local_service_call",
          "conditions": [
            "GenerateOpenApiSpecification only runs after format validation succeeds"
          ],
          "operations": [
            {
              "operation": "GENERATE OAS FOR DOWNLOAD",
              "trigger": "Generate OpenAPI spec and stream it as an attachment",
              "conditions": [
                "service.ValidateAppOpenapiFormat(format) succeeded"
              ],
              "implementation": "service.GenerateOpenApiSpecification(ctx, params.AppID, credential, format)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/oas/authorize": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "AuthorizeOpenApiSpecification",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "AUTHORIZE OAS",
              "trigger": "Authorize OpenAPI specification publication for the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.AuthorizeOpenApiSpecification(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/default-domains": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListDefaultDomains",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LIST DEFAULT DOMAINS",
              "trigger": "List default service domains for the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ListDefaultDomains(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP POST /orgs/:org_id/projects/:project_id/apps/:app_id/custom-domains": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "CreateCustomDomain",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "CREATE CUSTOM DOMAIN",
              "trigger": "Create a custom domain binding for the app",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.CreateCustomDomain(ctx, params.AppID, &req, createdBy)"
            }
          ]
        }
      ]
    },
    "HTTP GET /orgs/:org_id/projects/:project_id/apps/:app_id/custom-domains": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "ListCustomDomains",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "LIST CUSTOM DOMAINS",
              "trigger": "List custom domains configured for the app",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.ListCustomDomains(ctx, params.AppID)"
            }
          ]
        }
      ]
    },
    "HTTP DELETE /orgs/:org_id/projects/:project_id/apps/:app_id/custom-domains/:custom_domain_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DeleteCustomDomain",
          "operation_type": "local_service_call",
          "conditions": [
            "Always after URL validation succeeds"
          ],
          "operations": [
            {
              "operation": "DELETE CUSTOM DOMAIN",
              "trigger": "Delete the custom domain binding",
              "conditions": [
                "URL params validated successfully"
              ],
              "implementation": "service.DeleteCustomDomain(ctx, params.AppID, params.CustomDomainId)"
            }
          ]
        }
      ]
    },
    "HTTP PUT /orgs/:org_id/projects/:project_id/apps/:app_id/custom-domains/:custom_domain_id": {
      "infrastructure": {},
      "services": [
        {
          "name": "central-service",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "EditCustomDomain",
          "operation_type": "local_service_call",
          "conditions": [
            "Only after request bind succeeds"
          ],
          "operations": [
            {
              "operation": "EDIT CUSTOM DOMAIN",
              "trigger": "Edit the custom domain binding",
              "conditions": [
                "Request body parsed successfully"
              ],
              "implementation": "service.EditCustomDomain(ctx, params.AppID, params.CustomDomainId, &req, createdBy)"
            }
          ]
        }
      ]
    }
  }
}
