feat(import): complete OpenAPI onboarding and verify delivery
This commit is contained in:
1 parent
bb3e376767
commit
e93de7015a
244 files changed
+57020
-5139
No files matched your search
+111
-51
@@ -135,41 +135,6 @@ impl ApiError {
|
||||
"OpenAPI document is invalid or unsupported"
|
||||
}
|
||||
}
|
||||
(_, "literal_credentials_rejected") => {
|
||||
if russian {
|
||||
"документ OpenAPI содержит literal credential и отклонён"
|
||||
} else {
|
||||
"OpenAPI document contains literal credential material and was rejected"
|
||||
}
|
||||
}
|
||||
(_, "auth_mapping_required") => {
|
||||
if russian {
|
||||
"для требования аутентификации выберите доступный профиль"
|
||||
} else {
|
||||
"an available Auth Profile mapping is required for this authentication requirement"
|
||||
}
|
||||
}
|
||||
(_, "auth_mapping_unsupported") => {
|
||||
if russian {
|
||||
"это требование аутентификации не поддерживается импортом"
|
||||
} else {
|
||||
"this authentication requirement is not supported by import"
|
||||
}
|
||||
}
|
||||
(_, "auth_mapping_invalid") => {
|
||||
if russian {
|
||||
"привязка аутентификации в запросе импорта некорректна"
|
||||
} else {
|
||||
"OpenAPI import authentication mapping is invalid"
|
||||
}
|
||||
}
|
||||
(_, "auth_binding_unavailable") => {
|
||||
if russian {
|
||||
"выбранный профиль аутентификации недоступен для этого импорта"
|
||||
} else {
|
||||
"selected Auth Profile is unavailable for this import"
|
||||
}
|
||||
}
|
||||
(_, "no_methods") => {
|
||||
if russian {
|
||||
"документ OpenAPI не содержит поддерживаемых методов"
|
||||
@@ -230,18 +195,6 @@ impl ApiError {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn openapi_auth_binding_unavailable(locale: OpenApiUploadLocale) -> Self {
|
||||
let message = if locale == OpenApiUploadLocale::Ru {
|
||||
"выбранный профиль аутентификации недоступен для этого импорта"
|
||||
} else {
|
||||
"selected Auth Profile is unavailable for this import"
|
||||
};
|
||||
Self::unprocessable_with_context(
|
||||
message,
|
||||
json!({ "error_code": "openapi_auth_binding_unavailable" }),
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn rate_limited_with_context(message: impl Into<String>, context: Value) -> Self {
|
||||
Self::RateLimited {
|
||||
message: message.into(),
|
||||
@@ -711,6 +664,29 @@ impl From<RegistryError> for ApiError {
|
||||
"onboarding domain steps are not complete",
|
||||
json!({"error_code":"onboarding_incomplete"}),
|
||||
),
|
||||
RegistryError::OnboardingImportDraftUnavailable => Self::unprocessable_with_context(
|
||||
"the requested operation is not an actionable imported Draft",
|
||||
json!({
|
||||
"error_code":"onboarding_import_draft_unavailable",
|
||||
"recovery":"reload_import_report"
|
||||
}),
|
||||
),
|
||||
RegistryError::OnboardingImportApplicationUnavailable => {
|
||||
Self::unprocessable_with_context(
|
||||
"no committed import apply report matches the requested application",
|
||||
json!({
|
||||
"error_code":"onboarding_import_application_unavailable",
|
||||
"recovery":"reload_import_report"
|
||||
}),
|
||||
)
|
||||
}
|
||||
RegistryError::OnboardingImportContextUnavailable => Self::unprocessable_with_context(
|
||||
"the workspace has no durable import context for the requested application",
|
||||
json!({
|
||||
"error_code":"onboarding_import_context_unavailable",
|
||||
"recovery":"register_import_context"
|
||||
}),
|
||||
),
|
||||
RegistryError::InvalidEnumRepresentation { field } => Self::validation_with_context(
|
||||
format!("unsupported enum representation for field {field}"),
|
||||
json!({ "field": field }),
|
||||
@@ -722,10 +698,6 @@ impl From<RegistryError> for ApiError {
|
||||
"value": value,
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportAuthBindingUnavailable => Self::unprocessable_with_context(
|
||||
"selected Auth Profile is unavailable for this import",
|
||||
json!({ "error_code": "openapi_auth_binding_unavailable" }),
|
||||
),
|
||||
RegistryError::YamlImportJobNotFound { job_id } => Self::validation_with_context(
|
||||
format!("yaml import job {job_id} was not found"),
|
||||
json!({ "job_id": job_id }),
|
||||
@@ -738,6 +710,94 @@ impl From<RegistryError> for ApiError {
|
||||
format!("import job {job_id} was already applied with different parameters"),
|
||||
json!({ "job_id": job_id }),
|
||||
),
|
||||
RegistryError::InvalidImportPlan { field } => Self::validation_with_context(
|
||||
format!("invalid import plan input for field {field}"),
|
||||
json!({
|
||||
"field": field,
|
||||
"error_code": "import_plan_invalid_input"
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportPlanConflict { plan_id } => Self::conflict_with_context(
|
||||
format!("import plan {plan_id} already exists with different material"),
|
||||
json!({
|
||||
"plan_id": plan_id,
|
||||
"error_code": "import_plan_conflict",
|
||||
"recovery": "repreview_required"
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportPlanJobUnavailable { job_id } => Self::not_found_with_context(
|
||||
format!("import job {job_id} is unavailable for planning"),
|
||||
json!({ "job_id": job_id, "error_code": "import_plan_job_unavailable" }),
|
||||
),
|
||||
RegistryError::ImportPlanJobTerminal { job_id }
|
||||
| RegistryError::ImportPlanJobExpired { job_id } => Self::conflict_with_context(
|
||||
format!("import job {job_id} is not in planning state"),
|
||||
json!({
|
||||
"job_id": job_id,
|
||||
"error_code": "import_plan_job_terminal",
|
||||
"recovery": "repreview_required",
|
||||
"repreview_required": true
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportPlanNotFound { .. } => Self::not_found_with_context(
|
||||
"import plan was not found in this workspace",
|
||||
json!({ "error_code": "import_plan_not_found" }),
|
||||
),
|
||||
RegistryError::ImportPlanExpired { .. } => Self::conflict_with_context(
|
||||
"import plan has expired; create a fresh preview",
|
||||
json!({
|
||||
"error_code": "import_plan_expired",
|
||||
"recovery": "repreview_required",
|
||||
"repreview_required": true
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportPlanPayloadCorrupt { .. } => Self::conflict_with_context(
|
||||
"import plan is invalid; create a fresh preview",
|
||||
json!({
|
||||
"error_code": "import_plan_payload_invalid",
|
||||
"recovery": "repreview_required",
|
||||
"repreview_required": true
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportPlanFingerprintStale { .. } => Self::conflict_with_context(
|
||||
"import plan no longer matches the verified preview; create a fresh preview",
|
||||
json!({
|
||||
"error_code": "import_plan_fingerprint_stale",
|
||||
"recovery": "repreview_required",
|
||||
"repreview_required": true
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportPlanKeyDigestConflict { .. } => Self::conflict_with_context(
|
||||
"idempotency key was already committed for different plan material",
|
||||
json!({
|
||||
"error_code": "import_plan_key_digest_conflict",
|
||||
"recovery": "repreview_required",
|
||||
"repreview_required": true
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportPlanNameConflict { .. } => Self::conflict_with_context(
|
||||
"an operation name changed after the plan was created",
|
||||
json!({
|
||||
"error_code": "import_plan_name_conflict",
|
||||
"recovery": "confirm_skip_rename_or_new_version"
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportPlanTargetStale { .. } => Self::conflict_with_context(
|
||||
"an operation changed after the plan was created; create a fresh preview",
|
||||
json!({
|
||||
"error_code": "import_plan_target_stale",
|
||||
"recovery": "repreview_required",
|
||||
"repreview_required": true
|
||||
}),
|
||||
),
|
||||
RegistryError::ImportPlanAuthUnavailable { .. } => Self::conflict_with_context(
|
||||
"an authentication profile is unavailable; create a fresh preview",
|
||||
json!({
|
||||
"error_code": "import_plan_auth_unavailable",
|
||||
"recovery": "repreview_required",
|
||||
"repreview_required": true
|
||||
}),
|
||||
),
|
||||
RegistryError::SourceNotFound { .. } => Self::not_found_with_context(
|
||||
"artifact source was not found",
|
||||
json!({
|
||||
|
||||
Reference in new issue
Block a user