import { TokenManager } from '../../auth/token-manager.js'; import { InternalApiClient } from '../../client/internal-api.js'; import { CoreApiClient } from '../../client/core-api.js'; import type { CommercePreflightStep, PaymentOptions, PreflightResult } from './types.js'; export interface EnsureWidgetsResult { normalKey: string; subKey: string; created: boolean; errors: string[]; } export declare function ensureWidgets(coreApi: CoreApiClient): Promise; /** * admin_session — 관리자 로그인 세션으로 현재 프로젝트의 키·결제·몰 설정을 읽는다. * provided — 사용자가 이미 Commerce key 를 갖고 있다. 관리자 키 조회·발급·설정 변경을 하지 않는다. */ export type CredentialSource = 'admin_session' | 'provided'; export type ConfigurationChangeId = 'create_commerce_keychain' | 'select_payment_method' | 'activate_payment_method' | 'set_payment_sandbox' | 'update_mall_profile' | 'setup_payment_widgets' | 'register_checkout_return_domain'; /** 읽기 점검이 찾아낸 설정 차이. auto_setup=false 에서는 제안으로만 돌아간다. */ export interface ConfigurationChange { id: ConfigurationChangeId; target: string; reason: string; current?: unknown; proposed?: unknown; /** 이 변경 없이는 생성된 쇼핑몰의 주문·결제가 동작하지 않는다 */ required: boolean; /** auto_setup=true 로 다시 호출하면 이 도구가 적용할 수 있는지. false 면 사용자 입력·선택이 필요하다 */ auto_applicable: boolean; apply_with: string; apply_error?: string; } export interface AppliedChange { id: ConfigurationChangeId; method: 'POST' | 'PUT' | 'DELETE'; path: string; detail: string; } export interface NewCommerceKey { client_key: string; secret_key: string; keychain_name: string; } export interface CommercePreflightOptions { /** true 일 때만 명시 입력과 누락된 필수 리소스를 실제로 적용한다. credential_source=provided 에서는 무시된다 */ autoSetup: boolean; envMode?: string; credentialSource?: CredentialSource; /** provided 경로에서 사용자가 준 공개 client_key. secret_key 는 받지 않는다 */ providedClientKey?: string; payment?: PaymentOptions; /** 생성 앱이 브라우저에 열릴 origin(APP_ORIGIN). 결제 복귀 도메인 등록 여부를 판정하고 .env.example 에 채운다 */ appOrigin?: string; } export interface CommercePreflightReport extends PreflightResult { mode: string; credential_source: CredentialSource; /** 설정을 적용했거나 적용할 대상 — 사용자가 확인할 수 있게 프로젝트와 환경을 묶어 보여 준다 */ apply_target: { project_name: string | null; app_id: string | null; mode: string; }; ready: boolean; next_action: 'generate_server_sdk_code' | 'review_configuration_changes' | 'resolve_blocker'; warnings: string[]; /** 실제로 보낸 쓰기 요청 수(POST/PUT/DELETE). auto_setup=false 또는 provided 경로에서는 항상 0 */ performed_writes: number; applied_changes: AppliedChange[]; configuration_changes: ConfigurationChange[]; /** auto_setup=true 로 이번 호출에서 새로 발급한 키. 기존 키의 secret_key 는 어떤 경우에도 싣지 않는다 */ new_commerce_key: NewCommerceKey | null; } /** * generate_commerce_code 응답의 preflight 부분. * 기존 키의 secret_key 는 싣지 않는다. 이번 호출(auto_setup=true)에서 새로 발급한 키만 * 서버가 원문을 다시 보여 주지 않으므로 secret_key_once 로 1회 돌려준다. 생성 코드는 env placeholder 를 쓴다. */ export declare function preflightResponse(report: CommercePreflightReport): { api_url: string; commerce_key: { secret_key_once?: string | undefined; warning?: string | undefined; client_key: string | null; newly_created: boolean; env: { APP_ORIGIN?: string | undefined; BOOTPAY_CLIENT_KEY: string; BOOTPAY_SECRET_KEY: string; BOOTPAY_MODE: string; }; auth_header: string; usage: string; } | null; available_pgs?: any[] | undefined; error?: string | undefined; mode: string; credential_source: CredentialSource; ready: boolean; next_action: "generate_server_sdk_code" | "review_configuration_changes" | "resolve_blocker"; warnings: string[]; performed_writes: number; applied_changes: AppliedChange[]; configuration_changes: ConfigurationChange[]; apply_target: { project_name: string | null; app_id: string | null; mode: string; }; steps: CommercePreflightStep[]; }; /** * app_origin 을 생성 앱 .env 의 APP_ORIGIN 값(origin 만)으로 바꾼다. 스킴이 없으면 https 로 본다. * http://localhost:3000 처럼 결제 복귀에 못 쓰는 값도 사용자가 준 origin 이면 그대로 쓴다(로그인·Origin 검사용). */ export declare function appOriginEnvValue(raw?: string): string | null; /** * 커머스 코드 생성 전 점검. * * 1) 읽기 점검 — GET 만 사용한다. 필요한 설정 차이는 configuration_changes 로 모은다. * 2) 명시적 적용 — autoSetup=true 이고 credential_source=admin_session 일 때만 1) 에서 모은 변경 중 * 도구가 적용할 수 있는 것을 실행한다. 사용자가 지정하지 않은 값(예: sandbox 생략)은 애초에 변경 목록에 들어가지 않는다. * * autoSetup=false 는 어떤 분기에서도 네트워크 쓰기 0회다 — 쓰기는 2) 단계의 applier 안에만 있다. */ export declare function runCommercePreflight(tokenManager: TokenManager, internalApi: InternalApiClient, coreApi: CoreApiClient, options: CommercePreflightOptions): Promise; //# sourceMappingURL=preflight.d.ts.map