fix(core,board,ecommerce,plugins): API 문서 미채움 마커 전수 채움 + 미해석 lang 키 정정 + IDV 조회 시도횟수 비노출
이슈 본연: API 레퍼런스의 미채움 마커 5종(실측 제외/TODO/필드 없음/대표 에러 없음)
1,194건을 코드에서 읽어 전수 채우고(0건), api:docgen 재생성이 사람이 채운 내용을
손실·열화시키던 멱등성 결함 4종(CRLF, 표 파이프 이스케이프, 에러 서술 보존, 중복
라우트명 키)을 근본 수정. --check 를 실측 제외와 드리프트가 구분되도록 재정의.
ParameterDescriber/ResourceFieldDescriber 에 leaf 폴백·SEO 스코프·공통 사전 확장.
파생 결함(문서 실측 중 발견): ResponseHelper 기본 메시지 키 6종이 존재하지 않는
messages.* 를 가리켜 응답 message 가 번역문 대신 키 문자열로 노출되던 문제를 common.*
으로 정정하고, 코어 7 + gdpr/marketing/pay_kginicis/verification/ecommerce 확장의
호출부와 누락 lang 키(게시판 10키 + 이커머스 category_images 4키 포함)를 ko/en/ja
전수 정정. 중복 그룹 키 2건은 기존 키로 호출부 통합.
보안: GET /api/identity/challenges/{id} 는 권한 가드 없는 공개 폴링 엔드포인트인데
Service::getStatus 가 attempts/max_attempts 를 응답에 담아 남은 시도 횟수를 추론할 수
있었다. 두 필드를 제거하고, 챌린지 화면(admin_basic/basic)의 서버 attempts 참조를
제거(남은 횟수 UI 는 query fallback + verify 실패 시 로컬 증가로 유지).
부수 정리(변경셋에 들어온 board 컨트롤러의 audit 사전 결함): FormRequest 4개 신설로
base Request 주입 제거, CommentController 의 Board 직접 호출을 BoardService 위임으로
전환, PHPDoc @return 보강. board 스위트에서 발견한 stale test 3건(seed SSoT 불일치,
admin 계정 user 역할 누락)도 같은 세션에서 정정.
버전 정렬(공개 release 기준): 코어 7.0.3→7.0.4, sirsoft-board 1.0.1→1.0.2,
verification_kginicis 1.0.0→1.0.1, admin_basic 1.0.1→1.0.4.
This commit is contained in:
1 parent
b07d6c8953
commit
6c8381f164
155 files changed
+17192
-1829
No files matched your search
@@ -126,6 +126,7 @@ class ApiDocgenCommand extends Command
|
||||
|
||||
$stats = ['files' => 0, 'endpoints' => 0, 'probed' => 0, 'skipped' => 0, 'examples' => 0];
|
||||
$checkFindings = [];
|
||||
$skippedProbes = [];
|
||||
$examplesOnly = (bool) $this->option('examples-only');
|
||||
|
||||
// 대상(코어/확장)별 README 목차 항목 누적: readmeKey => ['label' => ..., 'entries' => [...]]
|
||||
@@ -136,6 +137,17 @@ class ApiDocgenCommand extends Command
|
||||
$sectionKeys = [];
|
||||
$exampleBlocks = [];
|
||||
|
||||
// `Route::match(['get','post'], ...)->name('x')` 는 하나의 라우트명으로 두 엔드포인트를
|
||||
// 등록한다. 생성 블록 키가 라우트명뿐이면 한 문서에 같은 키가 둘 생겨, 블록 조회(strpos)가
|
||||
// 언제나 첫 블록만 잡아 두 번째 블록의 사람 서술이 재생성마다 유실된다.
|
||||
// 문서 안에서 중복되는 라우트명만 골라 키에 메서드를 붙인다 (나머지 키는 그대로 — 전 문서의
|
||||
// 키를 바꾸면 기존 블록과 대조가 어긋나 사람 서술이 통째로 사라진다).
|
||||
$nameCounts = array_count_values(array_map(
|
||||
static fn (array $r): string => $r['name'] ?: $r['uri'],
|
||||
$items,
|
||||
));
|
||||
$duplicatedNames = array_keys(array_filter($nameCounts, static fn (int $n): bool => $n > 1));
|
||||
|
||||
// 목차용 도메인 파일 항목 (소유별). 예시-only/check 모드에서도 목차는 최신화한다.
|
||||
$owner = $items[0]['owner'];
|
||||
$readmeKey = $this->readmeFile($owner);
|
||||
@@ -156,10 +168,14 @@ class ApiDocgenCommand extends Command
|
||||
$stats['probed']++;
|
||||
} else {
|
||||
$stats['skipped']++;
|
||||
$checkFindings[] = "{$route['method']} {$route['uri']} — {$probeMeta['skipped_reason']}";
|
||||
// 실측 제외는 설계상 정상이다 — 부수효과 쓰기·미치환 path·검증 실패는 의도적으로
|
||||
// 호출하지 않고, 그 자리는 사람이 코드 근거로 채운다. drift 로 세면 문서가 완전해도
|
||||
// --check 가 통과할 수 없어 기준이 무의미해진다. 정보로만 남긴다.
|
||||
$skippedProbes[] = "{$route['method']} {$route['uri']} — {$probeMeta['skipped_reason']}";
|
||||
}
|
||||
|
||||
$key = $route['name'] ?: $route['uri'];
|
||||
$methodScopedKey = in_array($route['name'] ?: $route['uri'], $duplicatedNames, true);
|
||||
$key = $scaffolder->generatedKey($route, $methodScopedKey);
|
||||
|
||||
if ($examplesOnly) {
|
||||
// 표·서술을 건드리지 않고 예시 2블록만 산출 (SSoT=스캐폴더 예시 메서드).
|
||||
@@ -179,7 +195,7 @@ class ApiDocgenCommand extends Command
|
||||
}
|
||||
|
||||
$commentMap = $this->columnComments($route, $commentResolver, $sampleMap);
|
||||
$sections[] = $scaffolder->endpointSection($route, $request, $schema, $probeMeta, $commentMap);
|
||||
$sections[] = $scaffolder->endpointSection($route, $request, $schema, $probeMeta, $commentMap, $methodScopedKey);
|
||||
$sectionKeys[] = $key;
|
||||
$stats['endpoints']++;
|
||||
}
|
||||
@@ -187,6 +203,12 @@ class ApiDocgenCommand extends Command
|
||||
if ($this->option('check')) {
|
||||
if (! File::exists($file)) {
|
||||
$checkFindings[] = "문서 파일 없음: {$file}";
|
||||
} else {
|
||||
// 실측 불가 자리를 사람이 채우지 않고 마커로 남겨 두면 문서가 미완이다.
|
||||
// (규정: docs/backend/api-documentation.md "미채움 마커 5종")
|
||||
foreach ($this->unfilledMarkers(File::get($file)) as $marker) {
|
||||
$checkFindings[] = "미채움 마커: {$file} — {$marker}";
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -216,6 +238,15 @@ class ApiDocgenCommand extends Command
|
||||
|
||||
$header = $this->documentHeader($file, $items[0]);
|
||||
$existing = File::exists($file) ? File::get($file) : null;
|
||||
|
||||
// 기존 문서는 중복 라우트명 블록을 구 키(라우트명만)로 갖고 있다. 그대로 두면 새 키
|
||||
// (라우트명::메서드)와 대조되지 않아 이번 재생성에서 그 블록의 사람 서술이 유실된다.
|
||||
// 병합 전에 구 키를 등장 순서대로 새 키로 승격한다 — 문서 내 블록 순서는 $items 순서와
|
||||
// 같으므로(같은 그룹을 같은 순서로 순회) 메서드 대응이 어긋나지 않는다.
|
||||
if ($existing !== null && $duplicatedNames !== []) {
|
||||
$existing = $this->migrateDuplicateBlockKeys($existing, $items, $duplicatedNames, $scaffolder);
|
||||
}
|
||||
|
||||
$content = $scaffolder->mergeDocument($existing, $header, $sections, $sectionKeys);
|
||||
|
||||
File::ensureDirectoryExists(dirname($file));
|
||||
@@ -253,8 +284,20 @@ class ApiDocgenCommand extends Command
|
||||
}
|
||||
|
||||
if ($this->option('check')) {
|
||||
// 실측 제외는 정상 동작이므로 참고 정보로만 표시한다 (drift 아님).
|
||||
if ($skippedProbes !== []) {
|
||||
$this->line('실측 제외 '.count($skippedProbes).'건 (정상 — 해당 자리는 사람이 작성):');
|
||||
foreach (array_slice($skippedProbes, 0, 10) as $s) {
|
||||
$this->line(' · '.$s);
|
||||
}
|
||||
if (count($skippedProbes) > 10) {
|
||||
$this->line(' · ... 외 '.(count($skippedProbes) - 10).'건');
|
||||
}
|
||||
$this->newLine();
|
||||
}
|
||||
|
||||
if ($checkFindings !== []) {
|
||||
$this->warn('실측 제외/문서 누락 '.count($checkFindings).'건:');
|
||||
$this->warn('drift '.count($checkFindings).'건:');
|
||||
foreach (array_slice($checkFindings, 0, 50) as $f) {
|
||||
$this->line(' - '.$f);
|
||||
}
|
||||
@@ -899,6 +942,92 @@ class ApiDocgenCommand extends Command
|
||||
return base_path("{$base}/_bundled/{$owner['id']}/docs/api/README.md");
|
||||
}
|
||||
|
||||
/**
|
||||
* 문서에 남아 있는 미채움 마커를 수집합니다.
|
||||
*
|
||||
* `api:docgen` 은 실측 불가한 자리에 "사람이 작성하세요" 마커를 남긴다. 실측 불가는 그 자리를
|
||||
* 비워둘 사유가 아니며, 컨트롤러/Resource/FormRequest/Enum/lang 을 읽어 채우는 것이 규정이다
|
||||
* (docs/backend/api-documentation.md "미채움 마커 5종"). 마커가 남아 있으면 문서는 미완이다.
|
||||
*
|
||||
* 잔량 전수 집계는 `check-api-doc-unfilled.cjs` 가 담당하고, 여기서는 `--check` 가 자기 scope
|
||||
* 문서의 미완을 drift 로 잡기 위해 마커 종류만 요약한다.
|
||||
*
|
||||
* @param string $content 문서 내용
|
||||
* @return array<int, string> 발견된 마커 요약 (종류 => 건수)
|
||||
*/
|
||||
private function unfilledMarkers(string $content): array
|
||||
{
|
||||
$markers = [
|
||||
'실측 제외:' => '실측 제외 (응답 필드 표 / 응답 예시)',
|
||||
'TODO: 용도' => '요청 파라미터 설명',
|
||||
'TODO: 설명' => '응답 필드 설명',
|
||||
'실측 응답에 필드 없음' => '빈 목록 관측 (응답 필드 표)',
|
||||
'대표 에러 없음' => '도메인 특이 에러',
|
||||
];
|
||||
|
||||
$found = [];
|
||||
|
||||
foreach ($markers as $needle => $label) {
|
||||
$count = substr_count($content, $needle);
|
||||
|
||||
if ($count > 0) {
|
||||
$found[] = "{$label} {$count}건";
|
||||
}
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
/**
|
||||
* 기존 문서의 중복 생성 블록 키를 메서드 스코프 키로 승격합니다.
|
||||
*
|
||||
* `Route::match(['get','post'], ...)->name('x')` 로 등록된 라우트는 한 문서에 같은
|
||||
* `@generated:start:x` 블록을 둘 만든다. 새 키(`x::get` / `x::post`)로 재생성하면 구 키를
|
||||
* 가진 기존 블록과 대조되지 않아 그 블록의 사람 서술이 유실되므로, 병합 전에 구 키를
|
||||
* 등장 순서대로 새 키로 바꿔 준다.
|
||||
*
|
||||
* 문서 내 블록 순서는 `$items` 순서와 같다(같은 그룹을 같은 순서로 순회해 생성했다).
|
||||
* 따라서 n 번째 구 키 블록에는 그 라우트명을 가진 n 번째 라우트의 메서드를 붙인다.
|
||||
*
|
||||
* @param string $existing 기존 문서 내용
|
||||
* @param array<int, array<string, mixed>> $items 이 문서의 라우트 목록 (문서 순서)
|
||||
* @param array<int, string> $duplicatedNames 문서 안에서 중복되는 라우트명
|
||||
* @param ApiDocScaffolder $scaffolder 키 생성기
|
||||
* @return string 키가 승격된 문서 내용
|
||||
*/
|
||||
private function migrateDuplicateBlockKeys(
|
||||
string $existing,
|
||||
array $items,
|
||||
array $duplicatedNames,
|
||||
ApiDocScaffolder $scaffolder
|
||||
): string {
|
||||
foreach ($duplicatedNames as $name) {
|
||||
$methods = array_values(array_map(
|
||||
static fn (array $r): string => $r['method'],
|
||||
array_filter($items, static fn (array $r): bool => ($r['name'] ?: $r['uri']) === $name),
|
||||
));
|
||||
|
||||
$marker = '<!-- @generated:start:'.$name.' -->';
|
||||
$offset = 0;
|
||||
|
||||
foreach ($methods as $method) {
|
||||
$pos = strpos($existing, $marker, $offset);
|
||||
|
||||
if ($pos === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
$newKey = $scaffolder->generatedKey(['name' => $name, 'uri' => $name, 'method' => $method], true);
|
||||
$newMarker = '<!-- @generated:start:'.$newKey.' -->';
|
||||
|
||||
$existing = substr_replace($existing, $newMarker, $pos, strlen($marker));
|
||||
$offset = $pos + strlen($newMarker);
|
||||
}
|
||||
}
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
/**
|
||||
* 문서 헤더(제목 + TL;DR)를 생성합니다.
|
||||
*
|
||||
|
||||
@@ -21,7 +21,7 @@ class ResponseHelper
|
||||
/**
|
||||
* 성공 응답을 생성합니다.
|
||||
*
|
||||
* @param string $messageKey 메시지 키 (기본값: 'messages.success')
|
||||
* @param string $messageKey 메시지 키 (기본값: 'common.success')
|
||||
* @param mixed $data 응답 데이터
|
||||
* @param int $statusCode HTTP 상태 코드 (기본값: 200)
|
||||
* @param array $messageParams 메시지 매개변수
|
||||
@@ -29,7 +29,7 @@ class ResponseHelper
|
||||
* @return JsonResponse JSON 응답
|
||||
*/
|
||||
public static function success(
|
||||
string $messageKey = 'messages.success',
|
||||
string $messageKey = 'common.success',
|
||||
mixed $data = null,
|
||||
int $statusCode = 200,
|
||||
array $messageParams = [],
|
||||
@@ -45,7 +45,7 @@ class ResponseHelper
|
||||
/**
|
||||
* 실패 응답을 생성합니다.
|
||||
*
|
||||
* @param string $messageKey 메시지 키 (기본값: 'messages.failed')
|
||||
* @param string $messageKey 메시지 키 (기본값: 'common.failed')
|
||||
* @param int $statusCode HTTP 상태 코드 (기본값: 400)
|
||||
* @param mixed $errors 오류 정보
|
||||
* @param array $messageParams 메시지 매개변수
|
||||
@@ -53,7 +53,7 @@ class ResponseHelper
|
||||
* @return JsonResponse JSON 응답
|
||||
*/
|
||||
public static function error(
|
||||
string $messageKey = 'messages.failed',
|
||||
string $messageKey = 'common.failed',
|
||||
int $statusCode = 400,
|
||||
mixed $errors = null,
|
||||
array $messageParams = [],
|
||||
@@ -87,14 +87,14 @@ class ResponseHelper
|
||||
* 입력 검증 실패 응답을 생성합니다.
|
||||
*
|
||||
* @param mixed $errors 검증 오류 정보
|
||||
* @param string $messageKey 메시지 키 (기본값: 'messages.validation_failed')
|
||||
* @param string $messageKey 메시지 키 (기본값: 'common.validation_failed')
|
||||
* @param array $messageParams 메시지 매개변수
|
||||
* @param string $domain 번역 도메인 (기본값: 'core')
|
||||
* @return JsonResponse 422 상태 코드를 가진 JSON 응답
|
||||
*/
|
||||
public static function validationError(
|
||||
mixed $errors,
|
||||
string $messageKey = 'messages.validation_failed',
|
||||
string $messageKey = 'common.validation_failed',
|
||||
array $messageParams = [],
|
||||
string $domain = 'core'
|
||||
): JsonResponse {
|
||||
@@ -108,13 +108,13 @@ class ResponseHelper
|
||||
/**
|
||||
* 인증 실패 응답을 생성합니다.
|
||||
*
|
||||
* @param string $messageKey 메시지 키 (기본값: 'messages.unauthorized')
|
||||
* @param string $messageKey 메시지 키 (기본값: 'common.unauthorized')
|
||||
* @param array $messageParams 메시지 매개변수
|
||||
* @param string $domain 번역 도메인 (기본값: 'core')
|
||||
* @return JsonResponse 401 상태 코드를 가진 JSON 응답
|
||||
*/
|
||||
public static function unauthorized(
|
||||
string $messageKey = 'messages.unauthorized',
|
||||
string $messageKey = 'common.unauthorized',
|
||||
array $messageParams = [],
|
||||
string $domain = 'core'
|
||||
): JsonResponse {
|
||||
@@ -127,13 +127,13 @@ class ResponseHelper
|
||||
/**
|
||||
* 권한 부족 응답을 생성합니다.
|
||||
*
|
||||
* @param string $messageKey 멤시지 키 (기본값: 'messages.forbidden')
|
||||
* @param string $messageKey 멤시지 키 (기본값: 'common.forbidden')
|
||||
* @param array $messageParams 멤시지 매개변수
|
||||
* @param string $domain 번역 도메인 (기본값: 'core')
|
||||
* @return JsonResponse 403 상태 코드를 가진 JSON 응답
|
||||
*/
|
||||
public static function forbidden(
|
||||
string $messageKey = 'messages.forbidden',
|
||||
string $messageKey = 'common.forbidden',
|
||||
array $messageParams = [],
|
||||
string $domain = 'core'
|
||||
): JsonResponse {
|
||||
@@ -146,13 +146,13 @@ class ResponseHelper
|
||||
/**
|
||||
* 리소스를 찾을 수 없음 응답을 생성합니다.
|
||||
*
|
||||
* @param string $messageKey 멤시지 키 (기본값: 'messages.not_found')
|
||||
* @param string $messageKey 멤시지 키 (기본값: 'common.not_found')
|
||||
* @param array $messageParams 멤시지 매개변수
|
||||
* @param string $domain 번역 도메인 (기본값: 'core')
|
||||
* @return JsonResponse 404 상태 코드를 가진 JSON 응답
|
||||
*/
|
||||
public static function notFound(
|
||||
string $messageKey = 'messages.not_found',
|
||||
string $messageKey = 'common.not_found',
|
||||
array $messageParams = [],
|
||||
string $domain = 'core'
|
||||
): JsonResponse {
|
||||
@@ -165,14 +165,14 @@ class ResponseHelper
|
||||
/**
|
||||
* 서버 내부 오류 응답을 생성합니다.
|
||||
*
|
||||
* @param string $messageKey 멤시지 키 (기본값: 'messages.error_occurred')
|
||||
* @param string $messageKey 멤시지 키 (기본값: 'common.error_occurred')
|
||||
* @param mixed $error 오류 정보 (디버그 모드에서만 표시)
|
||||
* @param array $messageParams 멤시지 매개변수
|
||||
* @param string $domain 번역 도메인 (기본값: 'core')
|
||||
* @return JsonResponse 500 상태 코드를 가진 JSON 응답
|
||||
*/
|
||||
public static function serverError(
|
||||
string $messageKey = 'messages.error_occurred',
|
||||
string $messageKey = 'common.error_occurred',
|
||||
mixed $error = null,
|
||||
array $messageParams = [],
|
||||
string $domain = 'core'
|
||||
@@ -341,7 +341,7 @@ class ResponseHelper
|
||||
* (색인 누락 안내)가 사라지면 검색이 0건을 돌려주는 사실을 운영자가 알 방법이 없습니다.
|
||||
* `success`/`message`/`data` 키는 부가 데이터로 덮어쓰지 않습니다.
|
||||
*
|
||||
* @param string $messageKey 멤시지 키 (기본값: 'messages.success')
|
||||
* @param string $messageKey 메시지 키 (기본값: 'common.success')
|
||||
* @param JsonResource|ResourceCollection|null $resource JSON 리소스
|
||||
* @param int $statusCode HTTP 상태 코드 (기본값: 200)
|
||||
* @param array $messageParams 멤시지 매개변수
|
||||
@@ -349,7 +349,7 @@ class ResponseHelper
|
||||
* @return JsonResponse JSON 응답
|
||||
*/
|
||||
public static function successWithResource(
|
||||
string $messageKey = 'messages.success',
|
||||
string $messageKey = 'common.success',
|
||||
JsonResource|ResourceCollection|null $resource = null,
|
||||
int $statusCode = 200,
|
||||
array $messageParams = [],
|
||||
@@ -415,14 +415,14 @@ class ResponseHelper
|
||||
/**
|
||||
* 페이지네이션된 리소스 응답을 생성합니다.
|
||||
*
|
||||
* @param string $messageKey 멤시지 키 (기본값: 'messages.success')
|
||||
* @param string $messageKey 메시지 키 (기본값: 'common.success')
|
||||
* @param ResourceCollection|null $collection 페이지네이션된 리소스 컬렉션
|
||||
* @param array $messageParams 멤시지 매개변수
|
||||
* @param string $domain 번역 도메인 (기본값: 'core')
|
||||
* @return JsonResponse 페이지네이션 메타 데이터를 포함한 JSON 응답
|
||||
*/
|
||||
public static function successWithPagination(
|
||||
string $messageKey = 'messages.success',
|
||||
string $messageKey = 'common.success',
|
||||
?ResourceCollection $collection = null,
|
||||
array $messageParams = [],
|
||||
string $domain = 'core'
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\Admin\Identity;
|
||||
|
||||
use App\Enums\PermissionType;
|
||||
use App\Http\Controllers\Api\Base\AdminBaseController;
|
||||
use App\Http\Requests\Identity\AdminIdentityLogIndexRequest;
|
||||
use App\Http\Requests\Identity\AdminIdentityLogPurgeRequest;
|
||||
@@ -45,7 +46,7 @@ class AdminIdentityLogController extends AdminBaseController
|
||||
|
||||
$paginated = $this->logService->search($filters, (int) ($validated['per_page'] ?? 20));
|
||||
|
||||
return $this->success('messages.success', [
|
||||
return $this->success('common.success', [
|
||||
'data' => IdentityLogResource::collection(collect($paginated->items()))->resolve(),
|
||||
'pagination' => [
|
||||
'current_page' => $paginated->currentPage(),
|
||||
@@ -59,7 +60,7 @@ class AdminIdentityLogController extends AdminBaseController
|
||||
'abilities' => [
|
||||
'can_purge' => $request->user()?->hasPermission(
|
||||
'core.admin.identity.logs.purge',
|
||||
\App\Enums\PermissionType::Admin,
|
||||
PermissionType::Admin,
|
||||
) ?? false,
|
||||
],
|
||||
]);
|
||||
@@ -76,7 +77,7 @@ class AdminIdentityLogController extends AdminBaseController
|
||||
$days = (int) ($request->validated()['older_than_days'] ?? 180);
|
||||
$count = $this->logService->purge($days);
|
||||
|
||||
return $this->success('messages.success', [
|
||||
return $this->success('common.success', [
|
||||
'purged_count' => $count,
|
||||
'older_than_days' => $days,
|
||||
]);
|
||||
|
||||
@@ -60,7 +60,7 @@ class AdminIdentityPolicyController extends AdminBaseController
|
||||
$paginated = $this->policyService->search($filters, $perPage);
|
||||
$collection = (new PolicyCollection($paginated))->toArray($request);
|
||||
|
||||
return $this->success('messages.success', [
|
||||
return $this->success('common.success', [
|
||||
'data' => $collection['data'],
|
||||
'abilities' => $collection['abilities'] ?? [],
|
||||
'meta' => [
|
||||
@@ -83,7 +83,7 @@ class AdminIdentityPolicyController extends AdminBaseController
|
||||
$policy = $this->policyService->createAdminPolicy($request->validated());
|
||||
|
||||
return $this->success(
|
||||
'messages.created',
|
||||
'common.created',
|
||||
(new PolicyResource($policy))->toArray($request),
|
||||
201,
|
||||
);
|
||||
@@ -101,7 +101,7 @@ class AdminIdentityPolicyController extends AdminBaseController
|
||||
$policy = $this->policyService->findById($id);
|
||||
|
||||
if (! $policy) {
|
||||
return $this->error('messages.not_found', 404);
|
||||
return $this->error('common.not_found', 404);
|
||||
}
|
||||
|
||||
$validated = $request->validated();
|
||||
@@ -119,13 +119,13 @@ class AdminIdentityPolicyController extends AdminBaseController
|
||||
}
|
||||
|
||||
if (! $this->policyService->updatePolicy($policy, $validated)) {
|
||||
return $this->error('messages.failed', 500);
|
||||
return $this->error('common.failed', 500);
|
||||
}
|
||||
|
||||
$policy->refresh();
|
||||
|
||||
return $this->success(
|
||||
'messages.updated',
|
||||
'common.updated',
|
||||
(new PolicyResource($policy))->toArray($request),
|
||||
);
|
||||
}
|
||||
@@ -142,16 +142,16 @@ class AdminIdentityPolicyController extends AdminBaseController
|
||||
$policy = $this->policyService->findById($id);
|
||||
|
||||
if (! $policy) {
|
||||
return $this->error('messages.not_found', 404);
|
||||
return $this->error('common.not_found', 404);
|
||||
}
|
||||
|
||||
if ($policy->source_type !== IdentityPolicySourceType::Admin) {
|
||||
return $this->forbidden('messages.cannot_delete_system_resource');
|
||||
return $this->forbidden('identity.errors.cannot_delete_system_policy');
|
||||
}
|
||||
|
||||
return $this->policyService->deleteAdminPolicy($policy)
|
||||
? $this->success('messages.deleted')
|
||||
: $this->error('messages.failed', 500);
|
||||
? $this->success('common.deleted')
|
||||
: $this->error('common.failed', 500);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ class AdminIdentityPolicyController extends AdminBaseController
|
||||
$policy = $this->policyService->findById($id);
|
||||
|
||||
if (! $policy) {
|
||||
return $this->error('messages.not_found', 404);
|
||||
return $this->error('common.not_found', 404);
|
||||
}
|
||||
|
||||
if ($policy->source_type === IdentityPolicySourceType::Admin) {
|
||||
@@ -184,6 +184,6 @@ class AdminIdentityPolicyController extends AdminBaseController
|
||||
return $this->error('identity.errors.reset_field_failed', 422);
|
||||
}
|
||||
|
||||
return $this->successWithResource('messages.success', new PolicyResource($policy->fresh()));
|
||||
return $this->successWithResource('common.success', new PolicyResource($policy->fresh()));
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ namespace App\Http\Controllers\Api\Admin\Identity;
|
||||
use App\Extension\HookManager;
|
||||
use App\Extension\IdentityVerification\IdentityVerificationManager;
|
||||
use App\Http\Controllers\Api\Base\AdminBaseController;
|
||||
use App\Http\Requests\Identity\AdminIdentityProviderIndexRequest;
|
||||
use App\Http\Resources\Identity\ProviderResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* 관리자 — IDV 프로바이더 조회 + 설정 스키마 수집 컨트롤러.
|
||||
@@ -28,10 +28,10 @@ class AdminIdentityProviderController extends AdminBaseController
|
||||
/**
|
||||
* 등록된 프로바이더 목록과 각 프로바이더의 설정 스키마를 반환합니다.
|
||||
*
|
||||
* @param Request $request HTTP 요청
|
||||
* @param AdminIdentityProviderIndexRequest $request 검증된 요청 (파라미터 없음)
|
||||
* @return JsonResponse 프로바이더 목록 (settings_schema 포함)
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
public function index(AdminIdentityProviderIndexRequest $request): JsonResponse
|
||||
{
|
||||
$providers = array_values($this->manager->all());
|
||||
|
||||
@@ -48,6 +48,6 @@ class AdminIdentityProviderController extends AdminBaseController
|
||||
return $resource + ['settings_schema' => is_array($schema) ? $schema : []];
|
||||
}, $providers);
|
||||
|
||||
return $this->success('messages.success', $rows);
|
||||
return $this->success('common.success', $rows);
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class PluginSettingsController extends AdminBaseController
|
||||
return $this->notFound('plugins.not_found');
|
||||
}
|
||||
|
||||
return $this->success('messages.success', $this->maskSensitive($identifier, $settings));
|
||||
return $this->success('common.success', $this->maskSensitive($identifier, $settings));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,6 +109,6 @@ class PluginSettingsController extends AdminBaseController
|
||||
return $this->notFound('plugins.not_found');
|
||||
}
|
||||
|
||||
return $this->success('messages.success', $layout);
|
||||
return $this->success('common.success', $layout);
|
||||
}
|
||||
}
|
||||
@@ -48,9 +48,9 @@ class SeoCacheController extends AdminBaseController
|
||||
'by_module' => $this->statsService->getStatsByModule($since),
|
||||
];
|
||||
|
||||
return $this->success('messages.success', $data);
|
||||
return $this->success('common.success', $data);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('messages.error_occurred', 500, $e->getMessage());
|
||||
return $this->error('common.error_occurred', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,14 +70,14 @@ class SeoCacheController extends AdminBaseController
|
||||
if ($layout) {
|
||||
$count = $this->cacheManager->invalidateByLayout($layout);
|
||||
|
||||
return $this->success('messages.success', ['cleared' => $count]);
|
||||
return $this->success('common.success', ['cleared' => $count]);
|
||||
}
|
||||
|
||||
$this->cacheManager->clearAll();
|
||||
|
||||
return $this->success('messages.success', ['cleared' => 'all']);
|
||||
return $this->success('common.success', ['cleared' => 'all']);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('messages.error_occurred', 500, $e->getMessage());
|
||||
return $this->error('common.error_occurred', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,12 +92,12 @@ class SeoCacheController extends AdminBaseController
|
||||
{
|
||||
try {
|
||||
// Phase 5의 SeoDeclarationCollector 구현 후 실제 워밍업 로직 추가 예정
|
||||
return $this->success('messages.success', [
|
||||
return $this->success('common.success', [
|
||||
'status' => 'dispatched',
|
||||
'message' => __('seo.warmup_dispatched'),
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('messages.error_occurred', 500, $e->getMessage());
|
||||
return $this->error('common.error_occurred', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,9 +149,9 @@ class SeoCacheController extends AdminBaseController
|
||||
try {
|
||||
$urls = $this->cacheManager->getCachedUrls();
|
||||
|
||||
return $this->success('messages.success', ['urls' => $urls, 'count' => count($urls)]);
|
||||
return $this->success('common.success', ['urls' => $urls, 'count' => count($urls)]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('messages.error_occurred', 500, $e->getMessage());
|
||||
return $this->error('common.error_occurred', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\Identity;
|
||||
|
||||
use App\Enums\IdentityOriginType;
|
||||
use App\Extension\IdentityVerification\IdentityVerificationManager;
|
||||
use App\Http\Controllers\Api\Base\PublicBaseController;
|
||||
use App\Http\Requests\Identity\CancelChallengeRequest;
|
||||
@@ -15,6 +16,7 @@ use App\Http\Requests\Identity\VerifyChallengeRequest;
|
||||
use App\Http\Resources\Identity\ChallengeResource;
|
||||
use App\Http\Resources\Identity\ProviderResource;
|
||||
use App\Models\IdentityVerificationLog;
|
||||
use App\Models\User;
|
||||
use App\Services\IdentityPolicyService;
|
||||
use App\Services\IdentityVerificationService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -53,7 +55,7 @@ class IdentityVerificationController extends PublicBaseController
|
||||
$user = $request->user();
|
||||
|
||||
$target = $user ?: ($validated['target'] ?? []);
|
||||
if (! ($user instanceof \App\Models\User) && empty($target['email']) && empty($target['phone'])) {
|
||||
if (! ($user instanceof User) && empty($target['email']) && empty($target['phone'])) {
|
||||
return $this->error('identity.errors.missing_target', 422);
|
||||
}
|
||||
|
||||
@@ -68,7 +70,7 @@ class IdentityVerificationController extends PublicBaseController
|
||||
context: [
|
||||
'ip_address' => $request->ip(),
|
||||
'user_agent' => substr((string) $request->userAgent(), 0, 512),
|
||||
'origin_type' => \App\Enums\IdentityOriginType::Api->value,
|
||||
'origin_type' => IdentityOriginType::Api->value,
|
||||
'origin_identifier' => '/api/identity/challenges',
|
||||
],
|
||||
providerId: $providerId,
|
||||
@@ -136,7 +138,7 @@ class IdentityVerificationController extends PublicBaseController
|
||||
*
|
||||
* @param CancelChallengeRequest $request 검증된 요청
|
||||
* @param IdentityVerificationLog $challenge 라우트 모델 바인딩으로 resolve 된 challenge 로그
|
||||
* @return JsonResponse
|
||||
* @return JsonResponse 취소 결과
|
||||
*/
|
||||
public function cancel(CancelChallengeRequest $request, IdentityVerificationLog $challenge): JsonResponse
|
||||
{
|
||||
@@ -159,7 +161,8 @@ class IdentityVerificationController extends PublicBaseController
|
||||
*
|
||||
* @param ShowChallengeRequest $request 검증된 요청
|
||||
* @param IdentityVerificationLog $challenge 라우트 모델 바인딩으로 resolve 된 challenge 로그
|
||||
* @return JsonResponse
|
||||
* @return JsonResponse 공개 안전 상태 필드
|
||||
*
|
||||
* @since engine-v1.46.0
|
||||
*/
|
||||
public function show(ShowChallengeRequest $request, IdentityVerificationLog $challenge): JsonResponse
|
||||
@@ -170,7 +173,7 @@ class IdentityVerificationController extends PublicBaseController
|
||||
return $this->error('identity.errors.challenge_not_found', 404);
|
||||
}
|
||||
|
||||
return $this->success('messages.success', $status);
|
||||
return $this->success('common.success', $status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,6 +191,7 @@ class IdentityVerificationController extends PublicBaseController
|
||||
* @param IdentityCallbackRequest $request 검증된 요청
|
||||
* @param string $providerId 콜백을 보낸 provider 식별자
|
||||
* @return JsonResponse|RedirectResponse
|
||||
*
|
||||
* @since engine-v1.46.0
|
||||
*/
|
||||
public function callback(IdentityCallbackRequest $request, string $providerId)
|
||||
@@ -271,7 +275,7 @@ class IdentityVerificationController extends PublicBaseController
|
||||
$providers,
|
||||
);
|
||||
|
||||
return $this->success('messages.success', $data);
|
||||
return $this->success('common.success', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +304,7 @@ class IdentityVerificationController extends PublicBaseController
|
||||
];
|
||||
}
|
||||
|
||||
return $this->success('messages.success', $data);
|
||||
return $this->success('common.success', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,11 +357,11 @@ class IdentityVerificationController extends PublicBaseController
|
||||
|
||||
$policy = $this->policyService->resolve($scope, $target);
|
||||
if (! $policy || ! $policy->enabled) {
|
||||
return $this->success('messages.success', null);
|
||||
return $this->success('common.success', null);
|
||||
}
|
||||
|
||||
// 민감 필드는 노출하지 않고 UI 힌트에 필요한 최소 필드만 반환
|
||||
return $this->success('messages.success', [
|
||||
return $this->success('common.success', [
|
||||
'policy_key' => $policy->key,
|
||||
'scope' => $policy->scope,
|
||||
'target' => $policy->target,
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Identity;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 관리자 IDV 프로바이더 목록 조회 검증.
|
||||
*
|
||||
* 등록된 프로바이더 전체를 설정 스키마와 함께 반환하는 엔드포인트로, 필터/페이지네이션
|
||||
* 파라미터를 받지 않습니다. 검증 규칙은 비어 있지만, 컨트롤러가 base `Illuminate\Http\Request`
|
||||
* 를 주입받지 않도록 전용 FormRequest 를 둡니다 (규정: docs/backend/validation.md).
|
||||
*
|
||||
* 공개용 `ProvidersIndexRequest`(인증 없는 메타데이터 조회)와 달리 이쪽은 관리자 전용이며,
|
||||
* 인증/권한은 라우트의 permission 미들웨어가 담당합니다.
|
||||
*/
|
||||
class AdminIdentityProviderIndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 요청 권한 — 라우트 permission 미들웨어가 담당하므로 true 고정.
|
||||
*
|
||||
* @return bool 항상 true (권한은 미들웨어 체인에서 처리)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, array<int, mixed>> 검증 규칙 (요청 파라미터 없음)
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -199,6 +199,9 @@ class IdentityVerificationService
|
||||
$publicPayload = $log->properties['public_payload'];
|
||||
}
|
||||
|
||||
// 시도 횟수(attempts / max_attempts) 는 노출하지 않는다.
|
||||
// 이 엔드포인트는 권한 가드 없는 공개 폴링용이라 challenge id 만 알면 누구나 조회할 수 있고,
|
||||
// 두 값을 함께 알면 남은 시도 횟수를 정확히 계산해 무차별 대입 시점을 노릴 수 있다.
|
||||
return [
|
||||
'id' => $log->id,
|
||||
'status' => $log->status->value,
|
||||
|
||||
@@ -69,6 +69,28 @@ class ApiDocScaffolder
|
||||
private readonly ParameterDescriber $paramDescriber = new ParameterDescriber
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 엔드포인트의 `@generated` 블록 키를 만듭니다.
|
||||
*
|
||||
* 기본은 라우트명이다. 다만 `Route::match(['get','post'], ...)->name('x')` 처럼 **하나의
|
||||
* 라우트명이 여러 메서드**를 등록하면(KG이니시스 CBT/모바일 콜백), 한 문서에 같은 키의
|
||||
* 생성 블록이 둘 생긴다. 블록 조회는 `strpos` 로 첫 출현을 잡으므로 두 번째 블록의 사람
|
||||
* 서술이 재생성마다 유실된다. 그런 라우트에 한해 메서드를 접미로 붙여 키를 고유화한다.
|
||||
*
|
||||
* 중복이 아닌 절대다수의 라우트는 키를 그대로 둔다 — 전 문서의 키를 바꾸면 기존 블록과
|
||||
* 대조가 어긋나 사람 서술이 통째로 유실되기 때문이다.
|
||||
*
|
||||
* @param array<string, mixed> $route 라우트 메타데이터
|
||||
* @param bool $methodScoped 라우트명이 문서 안에서 중복되는가 (메서드 접미 필요)
|
||||
* @return string 생성 블록 키
|
||||
*/
|
||||
public function generatedKey(array $route, bool $methodScoped = false): string
|
||||
{
|
||||
$name = $route['name'] ?: $route['uri'];
|
||||
|
||||
return $methodScoped ? $name.'::'.strtolower((string) $route['method']) : $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 엔드포인트의 마크다운 섹션을 생성합니다.
|
||||
*
|
||||
@@ -77,13 +99,14 @@ class ApiDocScaffolder
|
||||
* @param array<string, mixed>|null $schema 실측 응답 스키마 (null=실측 안 됨)
|
||||
* @param array<string, mixed> $probeMeta 실측 메타 (status, skipped_reason, base_url, resolved_uri, body)
|
||||
* @param array<string, string> $commentMap 컬럼명 => 주석 (필드 설명 기본값)
|
||||
* @param bool $methodScopedKey 라우트명이 문서 안에서 중복되어 메서드 접미가 필요한가
|
||||
* @return string 마크다운 섹션
|
||||
*/
|
||||
public function endpointSection(array $route, array $request, ?array $schema, array $probeMeta, array $commentMap = []): string
|
||||
public function endpointSection(array $route, array $request, ?array $schema, array $probeMeta, array $commentMap = [], bool $methodScopedKey = false): string
|
||||
{
|
||||
$name = $route['name'] ?: '(unnamed)';
|
||||
$heading = "### {$route['method']} {$route['uri']}";
|
||||
$genKey = $name;
|
||||
$genKey = $this->generatedKey($route, $methodScopedKey);
|
||||
|
||||
$lines = [];
|
||||
$lines[] = $heading;
|
||||
@@ -173,6 +196,9 @@ class ApiDocScaffolder
|
||||
?string $existing = null,
|
||||
?array $extensions = null
|
||||
): string {
|
||||
// 줄 끝 정규화 — mergeDocument 와 같은 이유 (CRLF 체크아웃에서 줄 단위 매칭이 전부 실패).
|
||||
$existing = $existing === null ? null : $this->normalizeEol($existing);
|
||||
|
||||
usort($entries, fn ($a, $b) => strcmp($a['domain'], $b['domain']));
|
||||
$total = array_sum(array_column($entries, 'count'));
|
||||
|
||||
@@ -472,9 +498,11 @@ class ApiDocScaffolder
|
||||
}
|
||||
|
||||
// 403: admin 게이트 또는 permission 요구 → 권한 부족.
|
||||
// permission 은 여러 권한의 OR 조합(`core.modules.read | core.menus.read`)일 수 있으므로
|
||||
// 셀에 박기 전에 파이프를 이스케이프한다 — 안 하면 3열 표가 갈라져 깨진다.
|
||||
if ($this->hasMiddleware($mw, 'AdminMiddleware') || ! empty($route['permission'])) {
|
||||
$cond = ! empty($route['permission'])
|
||||
? "요구 권한(`{$route['permission']}`)이 없는 경우"
|
||||
? '요구 권한(`'.$this->escapeCell((string) $route['permission']).'`)이 없는 경우'
|
||||
: '관리자 권한이 없는 경우';
|
||||
$rows[] = "| 403 | Forbidden | {$cond} |";
|
||||
}
|
||||
@@ -1040,6 +1068,24 @@ class ApiDocScaffolder
|
||||
return str_replace(['|', "\n", "\r"], ['\\|', ' ', ''], $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 기존 문서의 줄 끝을 LF 로 정규화합니다.
|
||||
*
|
||||
* 보존 로직(표 셀·응답 본문·에러 표·사람 서술)은 전부 `explode("\n")` 후 줄 끝 매칭
|
||||
* (`str_ends_with($line, ' |')` 등)으로 동작한다. Windows 체크아웃(core.autocrlf=true)이
|
||||
* 내려준 CRLF 문서에서는 줄 끝에 \r 이 남아 이 매칭이 전부 실패하고, 결과적으로 사람이
|
||||
* 채운 셀·본문이 하나도 보존되지 않은 채 TODO/마커로 퇴행한다.
|
||||
*
|
||||
* 문서는 `.gitattributes` 가 `eol=lf` 로 저장하므로 정규화가 저장 형식을 바꾸지 않는다.
|
||||
*
|
||||
* @param string $content 기존 문서 내용
|
||||
* @return string LF 로 정규화된 내용
|
||||
*/
|
||||
private function normalizeEol(string $content): string
|
||||
{
|
||||
return str_replace(["\r\n", "\r"], "\n", $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 기존 문서에 새 생성 블록을 병합합니다. 사람 서술은 보존합니다.
|
||||
*
|
||||
@@ -1055,6 +1101,12 @@ class ApiDocScaffolder
|
||||
return $header."\n".implode("\n", $sections);
|
||||
}
|
||||
|
||||
// Windows 체크아웃(core.autocrlf=true)은 문서를 CRLF 로 내려준다. 아래 보존 로직은
|
||||
// 전부 `explode("\n")` + 줄 끝 매칭(`str_ends_with($line, ' |')`) 기반이라, 줄 끝에
|
||||
// \r 이 남아 있으면 표 행이 하나도 파싱되지 않아 사람이 채운 셀이 통째로 유실된다.
|
||||
// 파싱 전에 줄 끝을 LF 로 정규화한다 (문서는 .gitattributes 가 eol=lf 로 저장한다).
|
||||
$existing = $this->normalizeEol($existing);
|
||||
|
||||
$merged = $header."\n";
|
||||
|
||||
foreach ($sections as $i => $section) {
|
||||
@@ -1207,17 +1259,30 @@ class ApiDocScaffolder
|
||||
}
|
||||
|
||||
$previousRows = $this->errorTableRows($previous);
|
||||
|
||||
if ($previousRows === []) {
|
||||
return $section;
|
||||
}
|
||||
|
||||
$currentBody = $this->extractErrorTable($section);
|
||||
|
||||
if ($currentBody === null) {
|
||||
return $section;
|
||||
}
|
||||
|
||||
// 기존 본문이 표가 아닌 사람 서술인 경우 (자동 추론이 에러 행을 만들지 못하는 공개 조회
|
||||
// 엔드포인트에서, 사람이 `대표 에러 없음` 초안 자리를 "왜 도메인 에러가 없는지" 로 채운 것).
|
||||
// 표 행이 없다고 보존을 건너뛰면 재생성이 그 서술을 TODO 초안으로 덮는다.
|
||||
if ($previousRows === []) {
|
||||
$previousBody = $this->extractErrorTable($previous);
|
||||
|
||||
$previousIsHumanProse = $previousBody !== null
|
||||
&& trim($previousBody) !== ''
|
||||
&& ! $this->isTodoCell($previousBody)
|
||||
&& ! str_contains($previousBody, '대표 에러 없음');
|
||||
|
||||
if ($previousIsHumanProse) {
|
||||
return str_replace($currentBody, trim($previousBody), $section);
|
||||
}
|
||||
|
||||
return $section;
|
||||
}
|
||||
|
||||
// 상태코드 키로 병합. `+` 는 왼쪽 우선이므로 기존 행을 먼저 둬서, 같은 상태코드면
|
||||
// 사람이 쓴 구체적 조건이 자동 문구를 이긴다. 자동 추론에만 있는 상태코드는 새로 편입된다.
|
||||
$merged = $previousRows + $this->errorTableRows($section);
|
||||
@@ -1708,12 +1773,32 @@ class ApiDocScaffolder
|
||||
private function locateSubsectionBody(string $block, string $label, array $terminators): ?array
|
||||
{
|
||||
$labelPos = strpos($block, $label);
|
||||
$labelLength = strlen($label);
|
||||
|
||||
// 라벨 정확 일치 실패 시 베이스 라벨(굵은 제목)만으로 재시도한다.
|
||||
// 봉투를 쓰지 않는 엔드포인트(레이아웃 JSON 을 root 에 그대로 내리는 미리보기 서빙 등)에서는
|
||||
// `**응답 필드** (`data` 내부)` 라벨이 사실과 달라 사람이 접미를 떼어낸다. 정확 일치만 보면
|
||||
// 기존 본문 구간을 못 찾아, 표가 아닌 **서술**로 채운 내용이 마커로 퇴행한다
|
||||
// (표는 applyPreservedTableCells 가 행 키로 따로 지키지만, 서술은 이 경로가 유일하다).
|
||||
// 라벨 줄 전체를 라벨 길이로 삼아야 본문 시작 위치가 어긋나지 않는다.
|
||||
if ($labelPos === false) {
|
||||
return null;
|
||||
$base = Str::before($label, ' (');
|
||||
|
||||
if ($base === $label) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$labelPos = strpos($block, $base);
|
||||
|
||||
if ($labelPos === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$lineEnd = strpos($block, "\n", $labelPos);
|
||||
$labelLength = ($lineEnd === false ? strlen($block) : $lineEnd) - $labelPos;
|
||||
}
|
||||
|
||||
$bodyStart = $labelPos + strlen($label);
|
||||
$bodyStart = $labelPos + $labelLength;
|
||||
|
||||
$candidates = [];
|
||||
foreach ($terminators as $terminator) {
|
||||
@@ -2033,6 +2118,9 @@ class ApiDocScaffolder
|
||||
*/
|
||||
public function insertExampleBlocks(string $content, array $exampleBlocks): array
|
||||
{
|
||||
// 줄 끝 정규화 — mergeDocument 와 같은 이유 (CRLF 체크아웃에서 줄 단위 매칭이 전부 실패).
|
||||
$content = $this->normalizeEol($content);
|
||||
|
||||
$inserted = 0;
|
||||
|
||||
foreach ($exampleBlocks as $key => $blocks) {
|
||||
|
||||
@@ -193,6 +193,91 @@ class ParameterDescriber
|
||||
'websocket_port' => 'WebSocket 포트 번호',
|
||||
'websocket_scheme' => 'WebSocket 스킴 (http/https)',
|
||||
'websocket_app_key' => 'WebSocket 앱 키',
|
||||
'websocket_app_secret' => 'WebSocket 앱 시크릿',
|
||||
'websocket_server_host' => 'WebSocket 서버 호스트 주소 (서버측 발행 대상)',
|
||||
'websocket_server_port' => 'WebSocket 서버 포트 번호 (서버측 발행 대상)',
|
||||
'websocket_server_scheme' => 'WebSocket 서버 스킴 (http/https — 서버측 발행 대상)',
|
||||
'websocket_verify_ssl' => 'WebSocket 서버 SSL 인증서 검증 여부',
|
||||
'log_driver' => '로그 드라이버 (single/daily/stack)',
|
||||
'log_level' => '로그 레벨 (debug/info/warning/error 등)',
|
||||
'log_days' => '로그 파일 보관 일수',
|
||||
'search_engine_driver' => '검색 엔진 드라이버 (Scout 엔진 선택)',
|
||||
'session_lifetime' => '세션 유효 시간 (분)',
|
||||
|
||||
// 레이아웃 JSON 스키마 최상위 키 (근거: docs/frontend/layout-json.md 필수/선택 필드 표,
|
||||
// UpdateLayoutContentRequest 검증 규칙. 템플릿/레이아웃 저장 API 의 content.* 키.)
|
||||
'layout_name' => '레이아웃 이름 (식별자 — 파일 경로 기반, 예: board/popular)',
|
||||
'components' => '컴포넌트 트리 배열 (레이아웃이 렌더할 컴포넌트 정의)',
|
||||
'data_sources' => 'API 데이터 소스 정의 배열 (id/endpoint/method)',
|
||||
'init_actions' => '레이아웃 로드 시 실행할 초기화 액션 배열',
|
||||
'named_actions' => '이름으로 호출 가능한 재사용 액션 정의 맵',
|
||||
'defines' => '재사용 컴포넌트 정의 맵 (컴포넌트 트리에서 참조)',
|
||||
'computed' => '계산된 값 정의 맵 (키 → 표현식)',
|
||||
'modals' => '모달 컴포넌트 정의 배열',
|
||||
'scripts' => '동적 로드할 외부 스크립트 배열',
|
||||
'errorHandling' => '레이아웃 레벨 에러 핸들링 설정 (에러 코드별 핸들러 매핑)',
|
||||
'globalHeaders' => '전역 HTTP 헤더 규칙 배열 (pattern + headers)',
|
||||
'init_state' => '초기 상태 값 맵',
|
||||
'initLocal' => 'API 응답을 `_local` 상태에 자동 복사할 키/경로',
|
||||
'initGlobal' => 'API 응답을 `_global` 상태에 자동 복사할 키/경로',
|
||||
'initIsolated' => 'API 응답을 `_isolated` 상태에 자동 복사할 키/경로',
|
||||
'global_state' => '전역 상태 초기값 맵',
|
||||
'slots' => '슬롯별 삽입 콘텐츠 맵 (베이스 레이아웃의 slot 위치에 주입)',
|
||||
'extends' => '상속할 베이스 레이아웃 이름',
|
||||
'transition_overlay' => '페이지 전환 오버레이 설정 (스켈레톤/스피너)',
|
||||
'pageConfig' => '페이지 단위 설정 객체',
|
||||
'error_config' => '에러 표시 설정 객체',
|
||||
|
||||
// SEO 페이지 생성기 (근거: docs/frontend/layout-json.md meta.seo 표,
|
||||
// docs/backend/seo-system.md, Settings SEO 카탈로그)
|
||||
'changefreq' => 'sitemap changefreq 값 (daily/weekly/monthly 등)',
|
||||
'structured_data' => 'JSON-LD 구조화 데이터 정의',
|
||||
'og' => 'Open Graph 메타태그 정의 맵',
|
||||
'page_type' => 'SEO 템플릿 키를 결정하는 페이지 유형',
|
||||
'toggle_setting' => 'SEO 활성화 여부를 결정하는 설정 경로',
|
||||
'vars' => 'SEO 변수 선언 맵 (데이터 소스 값의 표현식 매핑)',
|
||||
'meta_keywords' => 'SEO 메타 키워드 (검색엔진 노출 키워드, 쉼표 구분)',
|
||||
'meta_title_suffix' => '모든 페이지 SEO 제목 뒤에 붙는 접미 문구',
|
||||
'google_site_verification' => 'Google Search Console 사이트 소유 확인 코드',
|
||||
'naver_site_verification' => '네이버 서치어드바이저 사이트 소유 확인 코드',
|
||||
'twitter_default_card' => '기본 트위터 카드 유형 (summary 등)',
|
||||
'twitter_default_site' => '기본 트위터 사이트 계정 (@handle)',
|
||||
'og_image_default_width' => '기본 Open Graph 이미지 너비 (px)',
|
||||
'og_image_default_height' => '기본 Open Graph 이미지 높이 (px)',
|
||||
'sitemap_enabled' => 'sitemap.xml 생성 사용 여부',
|
||||
'sitemap_schedule' => 'sitemap 자동 생성 주기',
|
||||
'sitemap_schedule_time' => 'sitemap 자동 생성 시각',
|
||||
'sitemap_cache_ttl' => 'sitemap 캐시 유효 시간 (초)',
|
||||
'bot_detection_enabled' => '검색엔진 봇 감지 사용 여부 (봇 요청에 SEO 렌더링 적용)',
|
||||
'bot_detection_library_enabled' => '봇 감지 라이브러리 사용 여부 (User-Agent 목록 대신 라이브러리 판정)',
|
||||
'bot_user_agents' => '봇으로 판정할 User-Agent 목록',
|
||||
'generator_enabled' => 'SEO 페이지 생성기 사용 여부',
|
||||
'generator_content' => 'SEO 렌더링 본문 생성 방식',
|
||||
|
||||
// 캐시/보안/업로드 공통 (근거: Settings 카탈로그 advanced/security/upload 그룹)
|
||||
'cache_enabled' => '캐시 사용 여부',
|
||||
'cache_ttl' => '캐시 유효 시간 (초)',
|
||||
'debug_mode' => '디버그 모드 사용 여부 (상세 오류 노출)',
|
||||
'sql_query_log' => 'SQL 쿼리 로그 기록 여부',
|
||||
'maintenance_mode' => '점검 모드 사용 여부 (사이트 접근 차단)',
|
||||
'force_https' => 'HTTPS 강제 리다이렉트 여부',
|
||||
'max_login_attempts' => '로그인 실패 허용 횟수 (초과 시 잠금)',
|
||||
'login_lockout_time' => '로그인 잠금 지속 시간 (분)',
|
||||
'login_attempt_enabled' => '로그인 시도 제한 사용 여부',
|
||||
'auth_token_lifetime' => '인증 토큰 유효 시간 (분)',
|
||||
'max_file_size' => '업로드 허용 최대 파일 크기',
|
||||
'max_file_count' => '업로드 허용 최대 파일 개수',
|
||||
'allowed_extensions' => '업로드 허용 확장자 목록',
|
||||
'image_quality' => '이미지 리사이즈 시 압축 품질 (1~100)',
|
||||
'image_max_width' => '이미지 리사이즈 최대 너비 (px)',
|
||||
'image_max_height' => '이미지 리사이즈 최대 높이 (px)',
|
||||
|
||||
// 사이트 기본 정보 (근거: Settings general 그룹)
|
||||
'site_url' => '사이트 기본 URL',
|
||||
'site_description' => '사이트 설명',
|
||||
'site_logo' => '사이트 로고 이미지',
|
||||
'admin_email' => '관리자 이메일 주소',
|
||||
'currency' => '통화 코드 (ISO 4217 — 예: KRW)',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -204,6 +289,94 @@ class ParameterDescriber
|
||||
* @return string|null 설명 (없으면 null)
|
||||
*/
|
||||
public function describe(string $name, string $location = '', string $type = ''): ?string
|
||||
{
|
||||
// 중첩 필드(general.site_name, shipping.zipcode 등)는 전체명으로는 어떤 규칙에도
|
||||
// 걸리지 않는다. 전체명 매칭을 먼저 시도하고, 실패하면 마지막 세그먼트(leaf)로
|
||||
// 재시도한다 — 중첩 경로의 의미는 leaf 가 결정하고 부모는 그룹 라벨일 뿐이다.
|
||||
// 다국어 로케일 접미(name.ko / alt_text.en)는 부모 필드의 로케일별 값이다.
|
||||
if (str_contains($name, '.')) {
|
||||
return $this->describeNested($name, $location, $type);
|
||||
}
|
||||
|
||||
return $this->describeFlat($name, $location, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 중첩 필드(`.` 포함)의 설명을 leaf 세그먼트로 유추합니다.
|
||||
*
|
||||
* @param string $name 중첩 파라미터명 (예: general.site_name)
|
||||
* @param string $location 위치
|
||||
* @param string $type 타입
|
||||
* @return string|null 설명 (미매칭 시 null)
|
||||
*/
|
||||
private function describeNested(string $name, string $location, string $type): ?string
|
||||
{
|
||||
$leaf = Str::afterLast($name, '.');
|
||||
$parent = Str::beforeLast($name, '.');
|
||||
|
||||
// 배열 원소 인덱스(items.*.name / ids.0) — leaf 가 인덱스면 그 앞을 leaf 로 본다.
|
||||
if ($leaf === '*' || ctype_digit($leaf)) {
|
||||
return $this->describe($parent, $location, $type);
|
||||
}
|
||||
|
||||
// 로케일 접미(name.ko / alt_text.en): 부모 필드의 로케일별 값.
|
||||
if (in_array($leaf, config('app.supported_locales', ['ko', 'en']), true)) {
|
||||
$parentDesc = $this->describe($parent, $location, $type);
|
||||
|
||||
return $parentDesc === null
|
||||
? null
|
||||
: "{$parentDesc} — `{$leaf}` 로케일 값";
|
||||
}
|
||||
|
||||
// 부모가 의미를 한정하는 그룹인 경우: leaf 만으로는 오설명이 된다.
|
||||
// 예) seo_meta.title 은 "제목" 이 아니라 "SEO 메타 제목" 이다.
|
||||
$scoped = $this->describeScopedLeaf($parent, $leaf);
|
||||
if ($scoped !== null) {
|
||||
return $scoped;
|
||||
}
|
||||
|
||||
// leaf 로 재시도 (부모 그룹 라벨은 의미를 바꾸지 않는다).
|
||||
return $this->describeFlat($leaf, $location, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 부모 그룹이 의미를 한정하는 중첩 키의 설명을 반환합니다.
|
||||
*
|
||||
* 대부분의 설정 그룹(general/mail/upload 등)은 라벨일 뿐이라 leaf 가 의미를 결정하지만,
|
||||
* SEO 메타 그룹의 `title`/`description`/`keywords` 는 일반 제목/설명이 아니라 검색엔진
|
||||
* 노출용 메타 값이다. leaf 폴백만 태우면 "제목"/"설명" 으로 축소되어 오설명이 된다.
|
||||
*
|
||||
* @param string $parent 부모 경로 (예: seo_meta, content.meta.seo)
|
||||
* @param string $leaf 마지막 세그먼트
|
||||
* @return string|null 설명 (해당 없으면 null → 일반 leaf 폴백)
|
||||
*/
|
||||
private function describeScopedLeaf(string $parent, string $leaf): ?string
|
||||
{
|
||||
$parentLeaf = Str::afterLast($parent, '.');
|
||||
|
||||
// SEO 메타 그룹 (근거: Page\*Request 의 seo_meta.{title,description,keywords},
|
||||
// 레이아웃 meta.seo — 검색엔진/소셜 공유 노출 값)
|
||||
if (in_array($parentLeaf, ['seo', 'seo_meta'], true)) {
|
||||
return match ($leaf) {
|
||||
'title' => 'SEO 메타 제목 (검색엔진/소셜 공유 표시 제목)',
|
||||
'description' => 'SEO 메타 설명 (검색엔진/소셜 공유 표시 요약)',
|
||||
'keywords' => 'SEO 메타 키워드 (검색엔진 노출 키워드, 쉼표 구분)',
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 세그먼트 파라미터의 설명을 반환합니다.
|
||||
*
|
||||
* @param string $name 파라미터명 (`.` 없음)
|
||||
* @param string $location 위치 (path/query/body)
|
||||
* @param string $type 타입
|
||||
* @return string|null 설명 (미매칭 시 null)
|
||||
*/
|
||||
private function describeFlat(string $name, string $location, string $type): ?string
|
||||
{
|
||||
// path 파라미터는 언제나 리소스 식별자다(라우트 모델 바인딩). 이름이 무엇이든
|
||||
// 정렬·필터 같은 조회 파라미터 의미를 가질 수 없으므로 이름 기반 규칙보다 앞서 처리한다.
|
||||
|
||||
@@ -105,6 +105,8 @@ class ResourceFieldDescriber
|
||||
'install_blocked_reason' => '설치가 차단된 사유 (차단 없으면 null)',
|
||||
|
||||
// 감사/관계 공통 (도메인 무관하게 역할 고정 — 쓰기 응답에서 흔히 등장)
|
||||
// creator/permissions 는 위 "관계/연관 객체" 블록에 이미 있으므로 여기서 재정의하지 않는다
|
||||
// (PHP 배열은 뒤 키가 앞을 덮어 같은 값이 두 번 선언되는 상태였다).
|
||||
'updated_by' => '최종 수정한 사용자 정보 (uuid/name — updated_by 관계 파생, 없으면 null)',
|
||||
'user' => '대상 사용자 정보 객체 (uuid/name/email 등 — user 관계 파생)',
|
||||
'roles' => '보유 역할 목록 (각 원소 id/name/permissions — roles 관계 파생)',
|
||||
@@ -133,6 +135,47 @@ class ResourceFieldDescriber
|
||||
'spec' => '스펙 정의 객체 (편집기/컴포넌트 선언 스키마 등)',
|
||||
'source_meta' => '원천 메타데이터 객체 (출처·경로·해석 정보)',
|
||||
'validation_summary' => '검증 결과 요약 객체 (통과/실패 건수 등)',
|
||||
|
||||
// 레이아웃 JSON 스키마 키 (근거: docs/frontend/layout-json.md 필수/선택 필드 표.
|
||||
// 레이아웃 서빙/저장 응답의 content 하위 키 — 엔진 스키마 계약으로 의미 고정)
|
||||
'$schema' => 'JSON 스키마 선언 URL (편집기/검증 도구용)',
|
||||
'layout_name' => '레이아웃 이름 (식별자 — 파일 경로 기반, 예: board/popular)',
|
||||
'components' => '컴포넌트 트리 (레이아웃이 렌더할 컴포넌트 정의)',
|
||||
'data_sources' => 'API 데이터 소스 정의 배열 (id/endpoint/method)',
|
||||
'modals' => '모달 컴포넌트 정의 배열',
|
||||
'slots' => '슬롯별 삽입 콘텐츠 맵 (베이스 레이아웃의 slot 위치에 주입)',
|
||||
'extends' => '상속하는 베이스 레이아웃 이름 (미상속 시 null)',
|
||||
'schema' => '스키마 정의 객체',
|
||||
'meta' => '메타 정보 객체 (title/description/seo 등)',
|
||||
'pageConfig' => '페이지 단위 설정 객체',
|
||||
'error_config' => '에러 표시 설정 객체',
|
||||
'base_layouts' => '상속 가능한 베이스 레이아웃 목록',
|
||||
'layout_versions' => '레이아웃 버전 이력 목록',
|
||||
'preview' => '미리보기 정보 객체',
|
||||
'vars' => 'SEO 변수 선언 맵 (데이터 소스 값의 표현식 매핑)',
|
||||
'events' => '이벤트 정의 목록',
|
||||
'toggle_settings' => '토글 가능한 설정 항목 목록',
|
||||
'page_types' => 'SEO 템플릿 키로 사용 가능한 페이지 유형 목록',
|
||||
'display_mode' => '표시 방식 (렌더/노출 모드 구분 값)',
|
||||
'templateId' => '대상 템플릿의 식별자',
|
||||
|
||||
// 확장 manifest / 에셋 계약 (근거: module.json/plugin.json/template.json manifest,
|
||||
// ExtensionBundleService 에셋 매니페스트)
|
||||
'g7_version' => '요구하는 코어 최소 버전 (manifest requires.g7_version)',
|
||||
'required_version' => '요구되는 최소 버전',
|
||||
'manifest_source' => 'manifest 를 읽어온 출처 경로 (활성/_bundled 구분)',
|
||||
'manifest_present' => 'manifest 파일 존재 여부',
|
||||
'license' => '라이선스 식별자 (manifest license)',
|
||||
'release_date' => '배포일',
|
||||
'cache_version' => '에셋 캐시 무효화 버전 (번들 URL 파일명에 포함)',
|
||||
'js' => '프론트엔드 JS 에셋 목록 (manifest assets 파생)',
|
||||
'css' => '프론트엔드 CSS 에셋 목록 (manifest assets 파생)',
|
||||
'externals' => '외부 의존 라이브러리 목록 (번들에서 제외되고 전역에서 해석)',
|
||||
'routes' => '라우트 정의 목록',
|
||||
'components_count' => '컴포넌트 개수 (집계)',
|
||||
'theme_color' => '테마 대표 색상',
|
||||
'popup_width' => '팝업 창 너비 (px)',
|
||||
'popup_height' => '팝업 창 높이 (px)',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -143,6 +186,70 @@ class ResourceFieldDescriber
|
||||
* @return string|null 설명 (없으면 null)
|
||||
*/
|
||||
public function describe(string $field, string $type = ''): ?string
|
||||
{
|
||||
// 중첩 필드(settings.general.site_name, meta.total 등)는 전체명으로 어떤 규칙에도
|
||||
// 걸리지 않는다. 마지막 세그먼트(leaf)로 폴백한다 — 중첩 경로의 의미는 leaf 가
|
||||
// 결정하고 상위 세그먼트는 그룹 라벨일 뿐이다. (ParameterDescriber 와 동일 계약)
|
||||
if (str_contains($field, '.')) {
|
||||
return $this->describeNested($field, $type);
|
||||
}
|
||||
|
||||
return $this->describeFlat($field, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 중첩 필드(`.` 포함)의 설명을 leaf 세그먼트로 유추합니다.
|
||||
*
|
||||
* @param string $field 중첩 필드명 (예: settings.general.site_name)
|
||||
* @param string $type 실측 타입
|
||||
* @return string|null 설명 (미매칭 시 null)
|
||||
*/
|
||||
private function describeNested(string $field, string $type): ?string
|
||||
{
|
||||
$leaf = Str::afterLast($field, '.');
|
||||
$parent = Str::beforeLast($field, '.');
|
||||
|
||||
// 배열 원소 인덱스(items.*.name / items.0.name) — 그 앞을 leaf 로 본다.
|
||||
if ($leaf === '*' || ctype_digit($leaf)) {
|
||||
return $this->describe($parent, $type);
|
||||
}
|
||||
|
||||
// 로케일 접미(name.ko): 부모 필드의 로케일별 값.
|
||||
if (in_array($leaf, config('app.supported_locales', ['ko', 'en']), true)) {
|
||||
$parentDesc = $this->describe($parent, $type);
|
||||
|
||||
return $parentDesc === null
|
||||
? null
|
||||
: "{$parentDesc} — `{$leaf}` 로케일 값";
|
||||
}
|
||||
|
||||
// 부모가 의미를 한정하는 그룹(seo/seo_meta)의 title/description/keywords 는
|
||||
// 일반 제목/설명이 아니라 검색엔진 노출용 메타 값이다 (ParameterDescriber 와 동일 계약).
|
||||
$parentLeaf = Str::afterLast($parent, '.');
|
||||
if (in_array($parentLeaf, ['seo', 'seo_meta'], true)) {
|
||||
$scoped = match ($leaf) {
|
||||
'title' => 'SEO 메타 제목 (검색엔진/소셜 공유 표시 제목)',
|
||||
'description' => 'SEO 메타 설명 (검색엔진/소셜 공유 표시 요약)',
|
||||
'keywords' => 'SEO 메타 키워드 (검색엔진 노출 키워드, 쉼표 구분)',
|
||||
default => null,
|
||||
};
|
||||
|
||||
if ($scoped !== null) {
|
||||
return $scoped;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->describeFlat($leaf, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 세그먼트 필드의 설명을 반환합니다.
|
||||
*
|
||||
* @param string $field 필드명 (`.` 없음)
|
||||
* @param string $type 실측 타입
|
||||
* @return string|null 설명 (미매칭 시 null)
|
||||
*/
|
||||
private function describeFlat(string $field, string $type): ?string
|
||||
{
|
||||
// sort_order 는 응답에서 표시 정렬 순서 값(정수 컬럼)으로 고정된다.
|
||||
// 문자열이면 정렬 방향일 수 있어 도메인 특이 → TODO 유지.
|
||||
|
||||
Reference in new issue
Block a user