@yoonion/mimi-seed-mcp 0.23.1 → 0.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,6 @@
1
1
  import type { OAuth2Client } from 'google-auth-library';
2
+ import type { androidpublisher_v3 } from '@googleapis/androidpublisher';
3
+ import { type AppStoreBuildReadiness, type AppStoreVersionCandidate } from '../appstore/release-target.js';
2
4
  export type RiskLevel = 'blocker' | 'warning' | 'info';
3
5
  export interface SubmissionRisk {
4
6
  level: RiskLevel;
@@ -8,14 +10,22 @@ export interface SubmissionRisk {
8
10
  fixUrl?: string;
9
11
  }
10
12
  export declare function isRiskCheckIncomplete(risk: SubmissionRisk): boolean;
11
- export declare const APPSTORE_EDITABLE_STATES = "PREPARE_FOR_SUBMISSION,DEVELOPER_REJECTED,METADATA_REJECTED,REJECTED";
12
13
  export declare function checkPlayStoreRisks(auth: OAuth2Client, packageName: string, language?: string, target?: {
13
14
  track: string;
14
15
  versionCode: string;
15
16
  }): Promise<SubmissionRisk[]>;
16
- export declare function checkAppStoreRisks(appId: string, expected?: {
17
- versionId?: string;
17
+ export declare function checkPlayStoreRisksInEdit(auth: OAuth2Client, packageName: string, editId: string, language: string, target?: {
18
+ track: string;
19
+ versionCode: string;
20
+ }, tracksSnapshot?: readonly androidpublisher_v3.Schema$Track[]): Promise<SubmissionRisk[]>;
21
+ type AppStorePolicy = {
18
22
  socialMedia?: boolean;
19
23
  socialMediaAgeRestricted?: boolean;
24
+ };
25
+ export declare function appStoreBuildRisk(build: AppStoreBuildReadiness): SubmissionRisk | undefined;
26
+ export declare function checkAppStoreRisks(appId: string, expected?: AppStorePolicy & {
27
+ versionId?: string;
20
28
  }): Promise<SubmissionRisk[]>;
29
+ export declare function checkAppStoreVersionRisks(appId: string, { id: selectedVersionId, platform }: Pick<AppStoreVersionCandidate, 'id' | 'platform'>, expected?: AppStorePolicy): Promise<SubmissionRisk[]>;
21
30
  export declare function formatRisks(risks: SubmissionRisk[], platform: string): string;
31
+ export {};
@@ -1,84 +1,87 @@
1
+ import { z } from 'zod';
1
2
  import { publisher, withEdit } from '../playstore/tools.js';
2
- import { apiGet } from '../appstore/tools.js';
3
- import { isNotFound } from '../appstore/http.js';
3
+ import { appStorePagination as pagination, getAppStoreResponse, pageIsIncomplete } from '../appstore/read-response.js';
4
+ import { selectAppInfo } from '../appstore/app-info.js';
5
+ import { selectEditableAppStoreVersion, resolveAppStoreVersionBuild } from '../appstore/release-target.js';
6
+ import { includedScreenshotReadiness, indexIncludedPlacements, listMediaPlacements, screenshotPlacementReadiness } from '../appstore/asset-library.js';
7
+ import { checkLegacyScreenshotReadiness } from '../appstore/screenshots.js';
8
+ import { readAppInfoAgeRatingForRelease, readAppInfoPrivacy } from '../appstore/app-info-policy.js';
4
9
  import { encodePathSegment } from '../lib/url-path.js';
5
10
  import { extractHttpStatus } from '../lib/google-errors.js';
6
11
  export function isRiskCheckIncomplete(risk) {
7
12
  return risk.code.startsWith('API_ERROR_');
8
13
  }
9
- export const APPSTORE_EDITABLE_STATES = 'PREPARE_FOR_SUBMISSION,DEVELOPER_REJECTED,METADATA_REJECTED,REJECTED';
10
14
  export async function checkPlayStoreRisks(auth, packageName, language = 'ko-KR', target) {
15
+ return withEdit(auth, packageName, (editId) => checkPlayStoreRisksInEdit(auth, packageName, editId, language, target));
16
+ }
17
+ export async function checkPlayStoreRisksInEdit(auth, packageName, editId, language, target, tracksSnapshot) {
11
18
  const risks = [];
12
- await withEdit(auth, packageName, async (editId) => {
13
- const [listing, phoneScreenshots, icons, details, tracks] = await Promise.all([
14
- safeGet(async () => {
15
- try {
16
- return await publisher().edits.listings.get({ auth, packageName, editId, language });
17
- }
18
- catch (error) {
19
- if (extractHttpStatus(error) === 404)
20
- return { data: null };
21
- throw error;
22
- }
23
- }, risks, 'LISTING', `${language} 리스팅`),
24
- safeGet(() => publisher().edits.images.list({ auth, packageName, editId, language, imageType: 'phoneScreenshots' }), risks, 'SCREENSHOTS', '전화 스크린샷'),
25
- safeGet(() => publisher().edits.images.list({ auth, packageName, editId, language, imageType: 'icon' }), risks, 'ICON', '앱 아이콘'),
26
- safeGet(() => publisher().edits.details.get({ auth, packageName, editId }), risks, 'DETAILS', '앱 연락처'),
27
- safeGet(() => publisher().edits.tracks.list({ auth, packageName, editId }), risks, 'TRACKS', '릴리스 트랙'),
28
- ]);
29
- if (listing && !listing.data) {
30
- risks.push({ level: 'blocker', code: 'NO_LISTING', title: `${language} 리스팅 없음`, detail: 'Play Console에서 스토어 정보를 입력하세요.', fixUrl: 'https://play.google.com/console/developers' });
31
- }
32
- else if (listing?.data) {
33
- const { title, shortDescription, fullDescription } = listing.data;
34
- if (!title || title.length < 2) {
35
- risks.push({ level: 'blocker', code: 'NO_TITLE', title: '앱 이름 없음', detail: '제목은 필수 항목입니다.' });
36
- }
37
- else if (title.length > 50) {
38
- risks.push({ level: 'warning', code: 'TITLE_TOO_LONG', title: '앱 이름 50자 초과', detail: `현재 ${title.length}자. Google 가이드라인: 50자 이내.` });
19
+ const [listing, phoneScreenshots, icons, details, tracks] = await Promise.all([
20
+ safeGet(async () => {
21
+ try {
22
+ return await publisher().edits.listings.get({ auth, packageName, editId, language });
39
23
  }
40
- if (!shortDescription || shortDescription.length < 10) {
41
- risks.push({ level: 'warning', code: 'NO_SHORT_DESC', title: '짧은 설명 없음', detail: '짧은 설명은 검색 노출에 영향을 줍니다.' });
42
- }
43
- if (!fullDescription || fullDescription.length < 50) {
44
- risks.push({ level: 'blocker', code: 'NO_FULL_DESC', title: '전체 설명 없음', detail: '전체 설명은 필수 항목입니다.' });
45
- }
46
- else if (fullDescription.length > 4000) {
47
- risks.push({ level: 'warning', code: 'DESC_TOO_LONG', title: '설명 4000자 초과', detail: `현재 ${fullDescription.length}자. 4000자 이내로 줄이세요.` });
24
+ catch (error) {
25
+ if (extractHttpStatus(error) === 404)
26
+ return { data: null };
27
+ throw error;
48
28
  }
29
+ }, risks, 'LISTING', `${language} 리스팅`),
30
+ safeGet(() => publisher().edits.images.list({ auth, packageName, editId, language, imageType: 'phoneScreenshots' }), risks, 'SCREENSHOTS', '전화 스크린샷'),
31
+ safeGet(() => publisher().edits.images.list({ auth, packageName, editId, language, imageType: 'icon' }), risks, 'ICON', '앱 아이콘'),
32
+ safeGet(() => publisher().edits.details.get({ auth, packageName, editId }), risks, 'DETAILS', '앱 연락처'),
33
+ tracksSnapshot ?? safeGet(async () => (await publisher().edits.tracks.list({ auth, packageName, editId })).data.tracks ?? [], risks, 'TRACKS', '릴리스 트랙'),
34
+ ]);
35
+ if (listing && !listing.data) {
36
+ risks.push({ level: 'blocker', code: 'NO_LISTING', title: `${language} 리스팅 없음`, detail: 'Play Console에서 스토어 정보를 입력하세요.', fixUrl: 'https://play.google.com/console/developers' });
37
+ }
38
+ else if (listing?.data) {
39
+ const { title, shortDescription, fullDescription } = listing.data;
40
+ if (!title || title.length < 2) {
41
+ risks.push({ level: 'blocker', code: 'NO_TITLE', title: '앱 이름 없음', detail: '제목은 필수 항목입니다.' });
49
42
  }
50
- const screenCount = phoneScreenshots?.data?.images?.length ?? 0;
51
- if (phoneScreenshots && screenCount === 0) {
52
- risks.push({ level: 'blocker', code: 'NO_SCREENSHOTS', title: '전화 스크린샷 없음', detail: '최소 2장 이상의 스크린샷이 필요합니다.' });
43
+ else if (title.length > 50) {
44
+ risks.push({ level: 'warning', code: 'TITLE_TOO_LONG', title: '앱 이름 50자 초과', detail: `현재 ${title.length}자. Google 가이드라인: 50자 이내.` });
53
45
  }
54
- else if (phoneScreenshots && screenCount < 2) {
55
- risks.push({ level: 'warning', code: 'FEW_SCREENSHOTS', title: `스크린샷 ${screenCount}장 (권장: 4~8장)`, detail: '더 많은 스크린샷이 전환율을 높입니다.' });
46
+ if (!shortDescription || shortDescription.length < 10) {
47
+ risks.push({ level: 'warning', code: 'NO_SHORT_DESC', title: '짧은 설명 없음', detail: '짧은 설명은 검색 노출에 영향을 줍니다.' });
56
48
  }
57
- if (icons && !icons.data?.images?.length) {
58
- risks.push({ level: 'blocker', code: 'NO_ICON', title: '앱 아이콘 없음', detail: '512×512px PNG 아이콘이 필요합니다.' });
49
+ if (!fullDescription || fullDescription.length < 50) {
50
+ risks.push({ level: 'blocker', code: 'NO_FULL_DESC', title: '전체 설명 없음', detail: '전체 설명은 필수 항목입니다.' });
59
51
  }
60
- if (details && !details.data?.contactEmail) {
61
- risks.push({ level: 'warning', code: 'NO_CONTACT_EMAIL', title: '개발자 이메일 없음', detail: 'Play Console에서 개발자 연락처를 설정하세요.' });
52
+ else if (fullDescription.length > 4000) {
53
+ risks.push({ level: 'warning', code: 'DESC_TOO_LONG', title: '설명 4000자 초과', detail: `현재 ${fullDescription.length}자. 4000자 이내로 줄이세요.` });
62
54
  }
63
- if (tracks) {
64
- const releaseTracks = tracks.data.tracks ?? [];
65
- if (target) {
66
- const targetTrack = releaseTracks.find((track) => track.track === target.track);
67
- if (!targetTrack?.releases?.some((release) => release.versionCodes?.includes(target.versionCode))) {
68
- risks.push({
69
- level: 'blocker',
70
- code: 'TARGET_BUILD_NOT_FOUND',
71
- title: '대상 트랙에서 빌드를 찾을 수 없음',
72
- detail: `${target.track} 트랙에 versionCode ${target.versionCode}가 있는지 확인하세요.`,
73
- });
74
- }
75
- }
76
- else if (!releaseTracks.some((track) => track.releases?.some((release) => release.versionCodes?.length))) {
77
- risks.push({ level: 'blocker', code: 'NO_BUILD', title: '업로드된 빌드 없음', detail: '내부 테스트 트랙에 APK/AAB를 먼저 업로드하세요.' });
55
+ }
56
+ const screenCount = phoneScreenshots?.data?.images?.length ?? 0;
57
+ if (phoneScreenshots && screenCount === 0) {
58
+ risks.push({ level: 'blocker', code: 'NO_SCREENSHOTS', title: '전화 스크린샷 없음', detail: '최소 2장 이상의 스크린샷이 필요합니다.' });
59
+ }
60
+ else if (phoneScreenshots && screenCount < 2) {
61
+ risks.push({ level: 'warning', code: 'FEW_SCREENSHOTS', title: `스크린샷 ${screenCount}장 (권장: 4~8장)`, detail: '더 많은 스크린샷이 전환율을 높입니다.' });
62
+ }
63
+ if (icons && !icons.data?.images?.length) {
64
+ risks.push({ level: 'blocker', code: 'NO_ICON', title: '앱 아이콘 없음', detail: '512×512px PNG 아이콘이 필요합니다.' });
65
+ }
66
+ if (details && !details.data?.contactEmail) {
67
+ risks.push({ level: 'warning', code: 'NO_CONTACT_EMAIL', title: '개발자 이메일 없음', detail: 'Play Console에서 개발자 연락처를 설정하세요.' });
68
+ }
69
+ if (tracks) {
70
+ if (target) {
71
+ const targetTrack = tracks.find((track) => track.track === target.track);
72
+ if (!targetTrack?.releases?.some((release) => release.versionCodes?.includes(target.versionCode))) {
73
+ risks.push({
74
+ level: 'blocker',
75
+ code: 'TARGET_BUILD_NOT_FOUND',
76
+ title: '대상 트랙에서 빌드를 찾을 수 없음',
77
+ detail: `${target.track} 트랙에 versionCode ${target.versionCode}가 있는지 확인하세요.`,
78
+ });
78
79
  }
79
80
  }
80
- return null;
81
- });
81
+ else if (!tracks.some((track) => track.releases?.some((release) => release.versionCodes?.length))) {
82
+ risks.push({ level: 'blocker', code: 'NO_BUILD', title: '업로드된 빌드 없음', detail: '내부 테스트 트랙에 APK/AAB를 먼저 업로드하세요.' });
83
+ }
84
+ }
82
85
  return risks;
83
86
  }
84
87
  // 조회 실패는 리소스가 없다는 응답과 구분한다. 결과를 표시할 때 API_ERROR_ 항목은 점검 미완료로 취급한다.
@@ -96,44 +99,112 @@ async function safeGet(call, risks, code, title) {
96
99
  return null;
97
100
  }
98
101
  }
99
- const APP_INFO_LIVE_STATE = 'READY_FOR_DISTRIBUTION';
102
+ const idResource = z.object({ id: z.string().min(1) });
103
+ const screenshotPage = pagination.extend({ data: z.array(z.unknown()) });
104
+ const versionLocalizationPage = pagination.extend({
105
+ data: z.array(idResource.extend({
106
+ attributes: z.object({
107
+ locale: z.string().nullish(),
108
+ description: z.string().trim().nullish(),
109
+ whatsNew: z.string().trim().nullish(),
110
+ keywords: z.string().trim().nullish(),
111
+ }).nullish(),
112
+ relationships: z.object({ placements: z.unknown().optional(), appScreenshotSets: z.unknown().optional() }).nullish(),
113
+ })),
114
+ included: z.array(z.unknown()).nullish(),
115
+ });
116
+ function screenshotSetPresence(response) {
117
+ const parsed = screenshotPage.safeParse(response);
118
+ if (!parsed.success)
119
+ return undefined;
120
+ const page = parsed.data;
121
+ if (page.data.some((set) => idResource.safeParse(set).success))
122
+ return true;
123
+ if (page.data.length === 0 && !pageIsIncomplete(page, 0))
124
+ return false;
125
+ return undefined;
126
+ }
127
+ export function appStoreBuildRisk(build) {
128
+ switch (build.status) {
129
+ case 'ready':
130
+ return undefined;
131
+ case 'missing':
132
+ return { level: 'blocker', code: 'NO_BUILD', title: '버전에 연결된 빌드 없음', detail: '대상 버전에 사용할 빌드를 업로드하고 연결하세요.' };
133
+ case 'not-ready':
134
+ return {
135
+ level: 'blocker',
136
+ code: 'BUILD_NOT_READY',
137
+ title: '연결된 빌드 처리 미완료',
138
+ detail: `빌드 ${build.id}의 처리 상태는 ${build.processingState}입니다. App Store Connect에서 처리 결과를 확인하세요.`,
139
+ };
140
+ case 'unknown':
141
+ return { level: 'warning', code: 'API_ERROR_BUILD', title: '연결된 빌드 점검 미완료', detail: build.detail };
142
+ }
143
+ }
100
144
  export async function checkAppStoreRisks(appId, expected = {}) {
101
145
  const risks = [];
102
- const appPath = `/apps/${encodePathSegment(appId)}`;
103
- const versions = await safeGet(() => apiGet(`${appPath}/appStoreVersions`, {
104
- 'filter[appStoreState]': APPSTORE_EDITABLE_STATES,
105
- ...(expected.versionId ? { 'filter[id]': expected.versionId, limit: '1' } : { limit: '5' }),
106
- }), risks, 'VERSIONS', '편집 가능한 버전 목록');
107
- if (!versions)
146
+ const selection = await safeGet(() => selectEditableAppStoreVersion(appId, { versionId: expected.versionId }), risks, 'VERSIONS', '편집 가능한 버전 목록');
147
+ if (!selection)
108
148
  return risks;
109
- const version = expected.versionId
110
- ? versions.data?.find(({ id }) => id === expected.versionId)
111
- : versions.data?.[0];
112
- if (!version && expected.versionId) {
149
+ if (selection.status === 'incomplete' || selection.status === 'ambiguous') {
113
150
  risks.push({
114
- level: 'blocker',
115
- code: 'TARGET_VERSION_UNVERIFIED',
116
- title: '대상 버전을 점검할 수 없음',
117
- detail: '대상 앱의 편집 가능한 버전 목록에서 요청한 버전을 확인하세요.',
151
+ level: 'warning',
152
+ code: selection.status === 'incomplete' ? 'API_ERROR_VERSIONS_INCOMPLETE' : 'API_ERROR_VERSIONS_AMBIGUOUS',
153
+ title: '편집 가능한 버전을 하나로 확인할 수 없음',
154
+ detail: 'App Store Connect에서 대상 플랫폼과 편집 상태를 확인한 뒤 해당 versionId로 다시 점검하세요.',
118
155
  });
119
156
  return risks;
120
157
  }
121
- if (!version) {
122
- risks.push({ level: 'blocker', code: 'NO_EDITABLE_VERSION', title: '편집 가능한 버전 없음', detail: 'App Store Connect에서 새 버전을 만드세요.', fixUrl: 'https://appstoreconnect.apple.com' });
158
+ if (selection.status === 'missing') {
159
+ if (expected.versionId) {
160
+ risks.push({
161
+ level: 'blocker',
162
+ code: 'TARGET_VERSION_UNVERIFIED',
163
+ title: '대상 버전을 점검할 수 없음',
164
+ detail: '대상 앱의 편집 가능한 버전 목록에서 요청한 버전을 확인하세요.',
165
+ });
166
+ }
167
+ else {
168
+ risks.push({ level: 'blocker', code: 'NO_EDITABLE_VERSION', title: '편집 가능한 버전 없음', detail: 'App Store Connect에서 새 버전을 만드세요.', fixUrl: 'https://appstoreconnect.apple.com' });
169
+ }
123
170
  return risks;
124
171
  }
125
- const versionId = encodePathSegment(version.id);
126
- // 1) 메타데이터·스크린샷·버전 첨부 빌드는 versionId 기반으로 조회.
127
- // 2) 개인정보 URL은 appInfoLocalization 단위(앱 단위)로 조회.
128
- const [locs, attachedBuildRel, appInfos] = await Promise.all([
129
- safeGet(() => apiGet(`/appStoreVersions/${versionId}/appStoreVersionLocalizations`), risks, 'LOCALIZATIONS', '버전 로컬라이제이션'),
130
- safeGet(() => apiGet(`/appStoreVersions/${versionId}/relationships/build`), risks, 'BUILD', '버전 첨부 빌드'),
131
- safeGet(() => apiGet(`${appPath}/appInfos`, { 'fields[appInfos]': 'state', 'limit': '10' }), risks, 'APP_INFO', '앱 정보'),
172
+ const { version } = selection;
173
+ const [build, otherRisks] = await Promise.all([
174
+ resolveAppStoreVersionBuild(version),
175
+ checkAppStoreVersionRisks(appId, version, expected),
176
+ ]);
177
+ const buildRisk = appStoreBuildRisk(build);
178
+ return buildRisk ? [buildRisk, ...otherRisks] : otherRisks;
179
+ }
180
+ export async function checkAppStoreVersionRisks(appId, { id: selectedVersionId, platform }, expected = {}) {
181
+ const risks = [];
182
+ const versionId = encodePathSegment(selectedVersionId);
183
+ // 버전 메타데이터·스크린샷과 앱 단위 개인정보처리방침을 병행 조회한다.
184
+ const [locs, appInfo] = await Promise.all([
185
+ safeGet(() => getAppStoreResponse(versionLocalizationPage, `/appStoreVersions/${versionId}/appStoreVersionLocalizations`, {
186
+ limit: '200',
187
+ include: 'placements,appScreenshotSets',
188
+ 'limit[placements]': '50',
189
+ 'limit[appScreenshotSets]': '1',
190
+ 'fields[appStoreVersionLocalizations]': 'locale,description,whatsNew,keywords,placements,appScreenshotSets',
191
+ 'fields[appAssetLibraryPlacements]': 'placementType,state,image',
192
+ }), risks, 'LOCALIZATIONS', '버전 로컬라이제이션'),
193
+ safeGet(() => selectAppInfo(appId, { privacyPlatform: platform }), risks, 'APP_INFO', '앱 정보'),
132
194
  ]);
133
- if (locs && !locs.data?.length) {
195
+ if (locs && pageIsIncomplete(locs, locs.data.length)) {
196
+ risks.push({
197
+ level: 'warning',
198
+ code: 'API_ERROR_LOCALIZATIONS_INCOMPLETE',
199
+ title: '버전 로컬라이제이션 목록이 불완전함',
200
+ detail: 'App Store Connect에서 대상 버전의 전체 로컬라이제이션을 확인하세요.',
201
+ });
202
+ }
203
+ else if (locs?.data.length === 0) {
134
204
  risks.push({ level: 'blocker', code: 'NO_LOCALIZATIONS', title: '로컬라이제이션 없음', detail: '메타데이터를 입력하세요.' });
135
205
  }
136
- else if (locs?.data) {
206
+ if (locs) {
207
+ const placementsById = indexIncludedPlacements(locs.included ?? []);
137
208
  for (const loc of locs.data) {
138
209
  const { locale: rawLocale, description, whatsNew, keywords } = loc.attributes ?? {};
139
210
  const locale = rawLocale ?? loc.id;
@@ -143,143 +214,115 @@ export async function checkAppStoreRisks(appId, expected = {}) {
143
214
  risks.push({ level: 'warning', code: `NO_WHATS_NEW_${locale}`, title: `${locale} 새로운 기능 없음`, detail: '릴리즈 노트를 입력하면 다운로드 전환율이 높아집니다.' });
144
215
  if (!keywords)
145
216
  risks.push({ level: 'warning', code: `NO_KEYWORDS_${locale}`, title: `${locale} 키워드 없음`, detail: '키워드는 검색 노출에 직접 영향을 줍니다.' });
146
- const screenshots = await safeGet(() => apiGet(`/appStoreVersionLocalizations/${loc.id}/appScreenshotSets`), risks, `SCREENSHOTS_${locale}`, `${locale} 스크린샷 셋`);
147
- if (screenshots && !screenshots.data?.length) {
217
+ const screenshots = await safeGet(async () => {
218
+ let readiness = includedScreenshotReadiness(loc.relationships?.placements, placementsById);
219
+ if (readiness === 'unknown') {
220
+ const placements = await listMediaPlacements(loc.id, 'screenshots');
221
+ readiness = placements ? screenshotPlacementReadiness(placements) : 'missing';
222
+ }
223
+ if (readiness === 'missing' && screenshotSetPresence(loc.relationships?.appScreenshotSets) !== false) {
224
+ readiness = await checkLegacyScreenshotReadiness(loc.id);
225
+ }
226
+ if (readiness === 'unknown')
227
+ throw new Error('App Store Connect의 스크린샷 상태를 확인할 수 없습니다.');
228
+ return readiness;
229
+ }, risks, `SCREENSHOTS_${locale}`, `${locale} 스크린샷`);
230
+ if (screenshots === 'missing') {
148
231
  risks.push({
149
232
  level: 'blocker',
150
233
  code: `NO_SCREENSHOTS_${locale}`,
151
234
  title: `${locale} 스크린샷 없음`,
152
- detail: 'iPhone 6.5" 또는 6.9" 스크린샷이 필요합니다.',
235
+ detail: '대상 플랫폼에서 허용하는 스크린샷을 로케일에 배치하세요.',
236
+ });
237
+ }
238
+ else if (screenshots === 'not-ready') {
239
+ risks.push({
240
+ level: 'blocker',
241
+ code: `SCREENSHOTS_NOT_READY_${locale}`,
242
+ title: `${locale} 스크린샷 준비 미완료`,
243
+ detail: '배치된 스크린샷이 처리 중이거나 처리에 실패했습니다. App Store Connect에서 상태를 확인하세요.',
153
244
  });
154
245
  }
155
246
  }
156
247
  }
157
- // 명시한 버전의 첨부 상태는 다른 버전의 빌드로 확인할 수 없다.
158
- let buildVerdict = 'unknown';
159
- if (attachedBuildRel?.data?.id) {
160
- buildVerdict = 'present';
161
- }
162
- else if (attachedBuildRel?.data === null) {
163
- buildVerdict = 'missing';
164
- }
165
- else if (attachedBuildRel) {
248
+ if (!appInfo)
249
+ return risks;
250
+ if ('reason' in appInfo) {
166
251
  risks.push({
167
252
  level: 'warning',
168
- code: 'API_ERROR_BUILD_LINKAGE',
169
- title: '버전 첨부 빌드 확인 실패',
170
- detail: 'App Store Connect의 빌드 관계 응답에 데이터가 없습니다.',
253
+ code: 'API_ERROR_APP_INFO_LINKAGE',
254
+ title: '앱 정보 레코드를 확인할 수 없음',
255
+ detail: appInfo.reason,
171
256
  });
257
+ return risks;
172
258
  }
173
- else if (!expected.versionId) {
174
- const fallbackBuilds = await safeGet(() => apiGet(`/builds`, {
175
- 'filter[app]': appId,
176
- 'fields[builds]': 'version,uploadedDate,processingState',
177
- 'sort': '-uploadedDate',
178
- 'limit': '5',
179
- }), risks, 'BUILDS_FALLBACK', '앱 빌드 목록(폴백)');
180
- buildVerdict = fallbackBuilds?.data?.length ? 'present' : fallbackBuilds ? 'missing' : 'unknown';
181
- }
182
- if (buildVerdict === 'missing') {
183
- risks.push({ level: 'blocker', code: 'NO_BUILD', title: '버전에 연결된 빌드 없음', detail: '대상 버전에 사용할 빌드를 업로드하고 연결하세요.' });
259
+ const { target, policy } = appInfo;
260
+ const [hasPrivacy, ageRating] = await Promise.all([
261
+ policy.hasPrivacy ?? safeGet(() => readAppInfoPrivacy(target.id, platform), risks, 'PRIVACY', '개인정보 로컬라이제이션'),
262
+ policy.ageRating ?? safeGet(() => readAppInfoAgeRatingForRelease(target.id), risks, 'AGE_RATING_SOCIAL', '연령등급 소셜 미디어 응답'),
263
+ ]);
264
+ if (hasPrivacy === false) {
265
+ risks.push({ level: 'blocker', code: 'NO_PRIVACY', title: '개인정보처리방침 없음', detail: platform === 'TV_OS' ? '대상 tvOS 앱의 개인정보처리방침 텍스트를 입력하세요.' : '대상 앱의 개인정보처리방침 URL을 입력하세요.' });
184
266
  }
185
- // 개인정보처리방침 — appInfoLocalization 어디 한 곳이라도 URL 또는 in-app 텍스트가 있으면 OK.
186
- // appInfos 조회 자체가 실패하면 unknown으로 두고 blocker 안 띄움 (warning만 기록됨).
187
- if (appInfos) {
188
- const infos = (appInfos.data ?? []);
189
- const stateOf = (i) => i.attributes?.state ?? i.attributes?.appStoreState ?? '';
190
- const editable = infos.find((i) => stateOf(i) !== APP_INFO_LIVE_STATE) ?? infos[0];
191
- if (!editable) {
267
+ if (ageRating) {
268
+ const attributes = ageRating.data?.attributes;
269
+ const socialMedia = attributes?.socialMedia;
270
+ const socialMediaAgeRestricted = attributes?.socialMediaAgeRestricted;
271
+ const ageAssurance = attributes?.ageAssurance;
272
+ const userGeneratedContent = attributes?.userGeneratedContent;
273
+ if (socialMedia === undefined || socialMediaAgeRestricted === undefined) {
192
274
  risks.push({
193
- level: 'warning',
194
- code: 'API_ERROR_APP_INFO_LINKAGE',
195
- title: '앱 정보 레코드를 확인할 수 없음',
196
- detail: '앱 정보 레코드가 없어 개인정보 처리방침과 연령등급 점검을 완료할 수 없습니다.',
275
+ level: 'blocker',
276
+ code: 'SOCIAL_MEDIA_ANSWERS_MISSING',
277
+ title: '연령등급 소셜 미디어 질문 미응답',
278
+ detail: '2026년 9월부터 신규 앱·업데이트 제출에 socialMedia와 socialMediaAgeRestricted 응답이 필요합니다.',
279
+ fixUrl: 'https://developer.apple.com/news/?id=tlur8uvi',
197
280
  });
198
281
  }
199
- else {
200
- const [localizations, ageRating] = await Promise.all([
201
- safeGet(() => apiGet(`/appInfos/${editable.id}/appInfoLocalizations`, {
202
- 'fields[appInfoLocalizations]': 'locale,privacyPolicyUrl,privacyPolicyText',
203
- 'limit': '200',
204
- }), risks, 'PRIVACY', '개인정보 로컬라이제이션'),
205
- safeGet(async () => {
206
- try {
207
- return await apiGet(`/appInfos/${editable.id}/ageRatingDeclaration`, {
208
- 'fields[ageRatingDeclarations]': 'userGeneratedContent,socialMedia,socialMediaAgeRestricted,ageAssurance',
209
- });
210
- }
211
- catch (error) {
212
- // A 404 means the declaration is genuinely absent, not that the check is unknown.
213
- if (isNotFound(error))
214
- return { data: null };
215
- throw error;
216
- }
217
- }, risks, 'AGE_RATING_SOCIAL', '연령등급 소셜 미디어 응답'),
218
- ]);
219
- if (localizations) {
220
- const locs = (localizations.data ?? []);
221
- const hasPrivacy = locs.some((l) => l.attributes?.privacyPolicyUrl || l.attributes?.privacyPolicyText);
222
- if (!hasPrivacy) {
223
- risks.push({ level: 'blocker', code: 'NO_PRIVACY', title: '개인정보처리방침 URL 없음', detail: 'App Store 가이드라인 5.1.1 — 필수 항목입니다. 모든 로컬라이제이션에서 privacyPolicyUrl 또는 privacyPolicyText 중 하나를 입력하세요.' });
224
- }
225
- }
226
- if (ageRating) {
227
- const declaration = ageRating.data?.attributes ?? {};
228
- if (declaration.socialMedia === undefined || declaration.socialMediaAgeRestricted === undefined) {
229
- risks.push({
230
- level: 'blocker',
231
- code: 'SOCIAL_MEDIA_ANSWERS_MISSING',
232
- title: '연령등급 소셜 미디어 질문 미응답',
233
- detail: '2026년 9월부터 신규 앱·업데이트 제출에 socialMedia와 socialMediaAgeRestricted 응답이 필요합니다.',
234
- fixUrl: 'https://developer.apple.com/news/?id=tlur8uvi',
235
- });
236
- }
237
- if (declaration.socialMediaAgeRestricted === true && declaration.socialMedia !== true) {
238
- risks.push({
239
- level: 'blocker',
240
- code: 'SOCIAL_MEDIA_AGE_RESTRICTION_MISMATCH',
241
- title: '13세 미만 제한 응답 불일치',
242
- detail: 'socialMediaAgeRestricted=true는 socialMedia=true인 앱에서만 의미가 있습니다.',
243
- });
244
- }
245
- if (declaration.socialMediaAgeRestricted === true && declaration.ageAssurance !== true) {
246
- risks.push({
247
- level: 'blocker',
248
- code: 'SOCIAL_MEDIA_AGE_ASSURANCE_MISSING',
249
- title: '13세 미만 소셜 기능 제한에 연령 확인이 없음',
250
- detail: 'Apple은 socialMediaAgeRestricted=true인 경우 최소한 Declared Age Range API로 연령 범위를 확인하도록 요구합니다. ageAssurance 응답과 실제 구현을 확인하세요.',
251
- fixUrl: 'https://developer.apple.com/help/app-store-connect/reference/app-information/age-ratings-values-and-definitions',
252
- });
253
- }
254
- if (expected.socialMedia !== undefined
255
- && declaration.socialMedia !== undefined
256
- && declaration.socialMedia !== expected.socialMedia) {
257
- risks.push({
258
- level: 'blocker',
259
- code: 'SOCIAL_MEDIA_CAPABILITY_MISMATCH',
260
- title: '앱 기능과 App Store 소셜 미디어 응답 불일치',
261
- detail: `프로젝트 기능 선언은 socialMedia=${expected.socialMedia}이지만 App Store Connect는 ${String(declaration.socialMedia)}입니다.`,
262
- });
263
- }
264
- if (expected.socialMediaAgeRestricted !== undefined
265
- && declaration.socialMediaAgeRestricted !== undefined
266
- && declaration.socialMediaAgeRestricted !== expected.socialMediaAgeRestricted) {
267
- risks.push({
268
- level: 'blocker',
269
- code: 'SOCIAL_MEDIA_AGE_GATE_MISMATCH',
270
- title: '13세 미만 기능 제한과 App Store 응답 불일치',
271
- detail: `프로젝트 기능 선언은 socialMediaAgeRestricted=${expected.socialMediaAgeRestricted}이지만 App Store Connect는 ${String(declaration.socialMediaAgeRestricted)}입니다.`,
272
- });
273
- }
274
- if (declaration.userGeneratedContent && declaration.socialMedia === false) {
275
- risks.push({
276
- level: 'warning',
277
- code: 'UGC_WITHOUT_SOCIAL_MEDIA',
278
- title: 'UGC는 있으나 소셜 미디어 기능은 없음으로 응답',
279
- detail: '피드·좋아요·댓글·공유·발견 기능이 있다면 socialMedia 응답을 true로 바꿔야 합니다.',
280
- });
281
- }
282
- }
282
+ if (socialMediaAgeRestricted === true && socialMedia !== true) {
283
+ risks.push({
284
+ level: 'blocker',
285
+ code: 'SOCIAL_MEDIA_AGE_RESTRICTION_MISMATCH',
286
+ title: '13세 미만 제한 응답 불일치',
287
+ detail: 'socialMediaAgeRestricted=true는 socialMedia=true인 앱에서만 의미가 있습니다.',
288
+ });
289
+ }
290
+ if (socialMediaAgeRestricted === true && ageAssurance !== true) {
291
+ risks.push({
292
+ level: 'blocker',
293
+ code: 'SOCIAL_MEDIA_AGE_ASSURANCE_MISSING',
294
+ title: '13세 미만 소셜 기능 제한에 연령 확인이 없음',
295
+ detail: 'Apple은 socialMediaAgeRestricted=true인 경우 최소한 Declared Age Range API로 연령 범위를 확인하도록 요구합니다. ageAssurance 응답과 실제 구현을 확인하세요.',
296
+ fixUrl: 'https://developer.apple.com/help/app-store-connect/reference/app-information/age-ratings-values-and-definitions',
297
+ });
298
+ }
299
+ if (expected.socialMedia !== undefined
300
+ && socialMedia !== undefined
301
+ && socialMedia !== expected.socialMedia) {
302
+ risks.push({
303
+ level: 'blocker',
304
+ code: 'SOCIAL_MEDIA_CAPABILITY_MISMATCH',
305
+ title: '앱 기능과 App Store 소셜 미디어 응답 불일치',
306
+ detail: `프로젝트 기능 선언은 socialMedia=${expected.socialMedia}이지만 App Store Connect는 ${String(socialMedia)}입니다.`,
307
+ });
308
+ }
309
+ if (expected.socialMediaAgeRestricted !== undefined
310
+ && socialMediaAgeRestricted !== undefined
311
+ && socialMediaAgeRestricted !== expected.socialMediaAgeRestricted) {
312
+ risks.push({
313
+ level: 'blocker',
314
+ code: 'SOCIAL_MEDIA_AGE_GATE_MISMATCH',
315
+ title: '13세 미만 기능 제한과 App Store 응답 불일치',
316
+ detail: `프로젝트 기능 선언은 socialMediaAgeRestricted=${expected.socialMediaAgeRestricted}이지만 App Store Connect는 ${String(socialMediaAgeRestricted)}입니다.`,
317
+ });
318
+ }
319
+ if (userGeneratedContent && socialMedia === false) {
320
+ risks.push({
321
+ level: 'warning',
322
+ code: 'UGC_WITHOUT_SOCIAL_MEDIA',
323
+ title: 'UGC는 있으나 소셜 미디어 기능은 없음으로 응답',
324
+ detail: '피드·좋아요·댓글·공유·발견 기능이 있다면 socialMedia 응답을 true로 바꿔야 합니다.',
325
+ });
283
326
  }
284
327
  }
285
328
  return risks;