@yoonion/mimi-seed-mcp 0.23.2 → 0.23.3

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.
@@ -234,6 +234,14 @@ per-domain inventory is [`docs/domain/tool-catalog.md`](domain/tool-catalog.md).
234
234
 
235
235
  ## 4. Workflows (call sequences)
236
236
 
237
+ Use `release_status` to check a known release across both stores. It reports the build linked to the selected
238
+ Apple version. Use the exact Play version code when available.
239
+
240
+ Use the store's `*_plan_release` for a checklist with submission risks already included. The plan and
241
+ `*_check_submission_risks` expose the same MCP structured output. Use `target` for the checked identifiers
242
+ and report `blockingCodes` or an incomplete check before continuing. A passing `canSubmit` result describes
243
+ the checks performed. Keep the preview and approval steps below, and recheck after changes to the target.
244
+
237
245
  ### Play Store release / promote
238
246
  1. `playstore_list_tracks` — see current track/version state.
239
247
  2. Check the selected track and version code with `playstore_check_submission_risks`. Report blockers or incomplete checks and stop the release workflow.
@@ -5,7 +5,7 @@ import { listAppInfoRecords, requireAppInfo } from './app-info.js';
5
5
  import { encodePathSegment } from '../lib/url-path.js';
6
6
  export async function listApps() {
7
7
  const data = await apiGet('/apps', {
8
- 'fields[apps]': 'name,bundleId,sku,primaryLocale,contentRightsDeclaration',
8
+ 'fields[apps]': 'name,bundleId,sku,primaryLocale',
9
9
  'limit': '200',
10
10
  });
11
11
  return (data.data ?? []).map((a) => ({
@@ -19,7 +19,6 @@ export async function listApps() {
19
19
  export async function getApp(appId) {
20
20
  const data = await apiGet(`/apps/${encodePathSegment(appId)}`, {
21
21
  'fields[apps]': 'name,bundleId,sku,primaryLocale,contentRightsDeclaration',
22
- 'include': 'appStoreVersions',
23
22
  });
24
23
  return data.data;
25
24
  }
@@ -1,8 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  import { apiGet } from './client.js';
3
- import { isNotFound, V1_BASE } from './http.js';
3
+ import { isNotFound } from './http.js';
4
4
  import { collectPages } from '../lib/paginate.js';
5
5
  import { encodePathSegment } from '../lib/url-path.js';
6
+ import { appStoreNextPagePath } from './read-response.js';
6
7
  const id = z.string().min(1);
7
8
  const resourceRef = z.object({ type: z.string(), id });
8
9
  const relationship = z.object({ data: resourceRef.nullish() }).nullish();
@@ -156,7 +157,6 @@ async function readPlacements(localizationId, filters) {
156
157
  return null;
157
158
  throw error;
158
159
  }
159
- const base = new URL(V1_BASE);
160
160
  const seen = new Set();
161
161
  let total = 0;
162
162
  return collectPages(async (next) => {
@@ -171,15 +171,8 @@ async function readPlacements(localizationId, filters) {
171
171
  seen.add(row.id);
172
172
  }
173
173
  total = Math.max(total, meta?.paging?.total ?? 0);
174
- let nextPageToken;
175
- if (links?.next) {
176
- const url = new URL(links.next, `${V1_BASE}${path}`);
177
- if (url.origin !== base.origin || url.pathname !== `${base.pathname}${path}` || url.username || url.password) {
178
- throw new Error('App Store Connect의 미디어 배치 페이지 링크가 올바르지 않습니다.');
179
- }
180
- nextPageToken = `${path}${url.search}`;
181
- }
182
- else if (meta?.paging?.nextCursor || total > seen.size) {
174
+ const nextPageToken = links?.next ? appStoreNextPagePath(path, links.next) : undefined;
175
+ if (!nextPageToken && (meta?.paging?.nextCursor || total > seen.size)) {
183
176
  throw new Error('App Store Connect의 미디어 배치 목록이 불완전합니다.');
184
177
  }
185
178
  return {
@@ -39,18 +39,18 @@ export function submitForReviewDryRunText(preview) {
39
39
  lines.push('🛑 심사 제출 dry-run — 아직 실제 제출 안 함.');
40
40
  lines.push('');
41
41
  lines.push(` versionId : ${preview.versionId}`);
42
- lines.push(` versionString: ${preview.versionString ?? '(조회 실패)'}`);
43
- lines.push(` state : ${preview.state ?? '(조회 실패)'}`);
42
+ lines.push(` versionString: ${preview.versionString}`);
43
+ lines.push(` state : ${preview.state}`);
44
44
  lines.push(` appId : ${preview.appId}`);
45
45
  lines.push(` platform : ${preview.platform}`);
46
46
  if (preview.attachedBuild) {
47
- lines.push(` attachedBuild: #${preview.attachedBuild.buildNumber ?? '?'} (id=${preview.attachedBuild.id}, state=${preview.attachedBuild.processingState ?? '?'})`);
47
+ lines.push(` attachedBuild: #${preview.attachedBuild.buildNumber} (id=${preview.attachedBuild.id}, state=${preview.attachedBuild.processingState})`);
48
48
  }
49
49
  else {
50
50
  lines.push(` attachedBuild: ⚠️ 미연결 — appstore_attach_build 필요 (buildId 생략 = 최신 VALID 빌드)`);
51
51
  }
52
52
  if (preview.whatsNewByLocale.length === 0) {
53
- lines.push(` whatsNew : ⚠️ 등록된 로컬라이제이션 없음`);
53
+ lines.push(` whatsNew : ⚠️ 등록된 출시 노트 없음`);
54
54
  }
55
55
  else {
56
56
  lines.push(` whatsNew :`);
@@ -1,4 +1,15 @@
1
1
  import { z } from 'zod';
2
+ export declare const appStoreResourceRef: z.ZodObject<{
3
+ id: z.ZodString;
4
+ type: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export declare const appStoreToOne: z.ZodObject<{
7
+ data: z.ZodNullable<z.ZodObject<{
8
+ id: z.ZodString;
9
+ type: z.ZodString;
10
+ }, z.core.$strip>>;
11
+ }, z.core.$strip>;
12
+ export declare function includedAppStoreResource<T>(included: readonly unknown[] | null | undefined, ref: z.infer<typeof appStoreResourceRef>, schema: z.ZodType<T>): T | undefined;
2
13
  export declare const appStorePagination: z.ZodObject<{
3
14
  links: z.ZodOptional<z.ZodNullable<z.ZodObject<{
4
15
  next: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -6,9 +17,11 @@ export declare const appStorePagination: z.ZodObject<{
6
17
  meta: z.ZodOptional<z.ZodObject<{
7
18
  paging: z.ZodOptional<z.ZodObject<{
8
19
  total: z.ZodOptional<z.ZodNumber>;
20
+ limit: z.ZodOptional<z.ZodNumber>;
9
21
  nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
22
  }, z.core.$strip>>;
11
23
  }, z.core.$strip>>;
12
24
  }, z.core.$strip>;
25
+ export declare function appStoreNextPagePath(path: string, next: string): string;
13
26
  export declare function pageIsIncomplete(page: z.infer<typeof appStorePagination>, count: number): boolean;
14
27
  export declare function getAppStoreResponse<T>(schema: z.ZodType<T>, path: string, params?: Record<string, string>): Promise<T>;
@@ -1,12 +1,30 @@
1
1
  import { z } from 'zod';
2
2
  import { apiGet } from './client.js';
3
+ import { V1_BASE } from './http.js';
4
+ export const appStoreResourceRef = z.object({ id: z.string().min(1), type: z.string().min(1) });
5
+ export const appStoreToOne = z.object({ data: appStoreResourceRef.nullable() });
6
+ export function includedAppStoreResource(included, ref, schema) {
7
+ const matches = included?.filter((resource) => resource !== null && typeof resource === 'object'
8
+ && 'id' in resource && resource.id === ref.id && 'type' in resource && resource.type === ref.type);
9
+ return matches?.length === 1 ? schema.safeParse(matches[0]).data : undefined;
10
+ }
3
11
  export const appStorePagination = z.object({
4
12
  links: z.object({ next: z.string().nullish() }).nullish(),
5
13
  meta: z.object({ paging: z.object({
6
14
  total: z.number().int().nonnegative().optional(),
15
+ limit: z.number().int().nonnegative().optional(),
7
16
  nextCursor: z.string().nullish(),
8
17
  }).optional() }).optional(),
9
18
  });
19
+ export function appStoreNextPagePath(path, next) {
20
+ const endpoint = new URL(`${V1_BASE}${path}`);
21
+ const url = new URL(next, endpoint);
22
+ if (url.origin !== endpoint.origin || url.pathname !== endpoint.pathname
23
+ || url.username || url.password || url.hash || !url.search) {
24
+ throw new Error('App Store Connect의 다음 페이지 링크가 요청한 리소스와 일치하지 않습니다.');
25
+ }
26
+ return `${path}${url.search}`;
27
+ }
10
28
  export function pageIsIncomplete(page, count) {
11
29
  return Boolean(page.links?.next || page.meta?.paging?.nextCursor) || (page.meta?.paging?.total ?? 0) > count;
12
30
  }
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
- declare const platformSchema: z.ZodEnum<{
2
+ export declare const appStorePlatformSchema: z.ZodEnum<{
3
3
  IOS: "IOS";
4
4
  MAC_OS: "MAC_OS";
5
5
  TV_OS: "TV_OS";
6
6
  VISION_OS: "VISION_OS";
7
7
  }>;
8
- export type AppStorePlatform = z.infer<typeof platformSchema>;
8
+ export type AppStorePlatform = z.infer<typeof appStorePlatformSchema>;
9
9
  declare const processingState: z.ZodEnum<{
10
10
  PROCESSING: "PROCESSING";
11
11
  FAILED: "FAILED";
@@ -21,12 +21,16 @@ export type AppStoreBuildReadiness = {
21
21
  status: 'ready' | 'not-ready';
22
22
  id: string;
23
23
  processingState: z.infer<typeof processingState>;
24
+ buildNumber?: string;
24
25
  };
25
26
  export interface AppStoreVersionCandidate {
26
27
  id: string;
27
28
  versionString?: string;
28
29
  state: string;
29
30
  platform: AppStorePlatform;
31
+ appStoreState?: string;
32
+ releaseType?: string;
33
+ createdDate?: string;
30
34
  linkedBuildId?: string;
31
35
  build?: AppStoreBuildReadiness;
32
36
  }
@@ -44,6 +48,7 @@ export declare function selectEditableAppStoreVersion(appId: string, filters?: {
44
48
  versionId?: string;
45
49
  versionString?: string;
46
50
  }): Promise<VersionSelection>;
51
+ export declare function selectAppStoreVersionForStatus(appId: string, versionString: string, platform?: AppStorePlatform): Promise<VersionSelection>;
47
52
  /** Resolve the selected version's build without an API request when included data is complete. */
48
53
  export declare function resolveAppStoreVersionBuild(version: AppStoreVersionCandidate): Promise<AppStoreBuildReadiness>;
49
54
  export {};
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { encodePathSegment } from '../lib/url-path.js';
3
3
  import { isNotFound } from './http.js';
4
- import { appStorePagination, getAppStoreResponse, pageIsIncomplete } from './read-response.js';
4
+ import { appStorePagination, getAppStoreResponse, includedAppStoreResource, pageIsIncomplete } from './read-response.js';
5
5
  const editableStates = ['PREPARE_FOR_SUBMISSION', 'DEVELOPER_REJECTED', 'METADATA_REJECTED', 'REJECTED'];
6
6
  const versionPage = appStorePagination.extend({
7
7
  data: z.array(z.object({
@@ -12,65 +12,82 @@ const versionPage = appStorePagination.extend({
12
12
  appVersionState: z.string().nullish(),
13
13
  appStoreState: z.string().nullish(),
14
14
  platform: z.string().nullish(),
15
+ releaseType: z.string().nullish(),
16
+ createdDate: z.string().nullish(),
15
17
  }).nullish(),
16
18
  relationships: z.object({ build: z.unknown().optional() }).nullish(),
17
19
  })),
18
20
  included: z.array(z.unknown()).nullish(),
19
21
  });
20
- const platformSchema = z.enum(['IOS', 'MAC_OS', 'TV_OS', 'VISION_OS']);
22
+ export const appStorePlatformSchema = z.enum(['IOS', 'MAC_OS', 'TV_OS', 'VISION_OS']);
21
23
  const buildReference = z.object({ id: z.string().min(1), type: z.literal('builds') });
22
24
  const buildRelationship = z.object({ data: buildReference.nullable() });
23
25
  const processingState = z.enum(['PROCESSING', 'FAILED', 'INVALID', 'VALID']);
24
26
  const buildResource = buildReference.extend({
25
- attributes: z.object({ processingState }).nullish(),
27
+ attributes: z.object({ processingState, version: z.string().nullish() }).nullish(),
26
28
  });
27
29
  const buildResponse = z.object({ data: buildResource.nullable() });
28
30
  function buildReadiness(build) {
29
31
  const state = build.attributes?.processingState;
30
32
  if (!state)
31
33
  return undefined;
32
- return { status: state === 'VALID' ? 'ready' : 'not-ready', id: build.id, processingState: state };
34
+ return {
35
+ status: state === 'VALID' ? 'ready' : 'not-ready',
36
+ id: build.id,
37
+ processingState: state,
38
+ buildNumber: build.attributes?.version ?? undefined,
39
+ };
33
40
  }
34
- export async function selectEditableAppStoreVersion(appId, filters = {}) {
35
- const { versionId, versionString } = filters;
41
+ export function selectEditableAppStoreVersion(appId, filters = {}) {
42
+ return selectVersion(appId, filters, true);
43
+ }
44
+ export function selectAppStoreVersionForStatus(appId, versionString, platform) {
45
+ return selectVersion(appId, { versionString, platform }, false);
46
+ }
47
+ async function selectVersion(appId, filters, editableOnly) {
48
+ const { versionId, versionString, platform } = filters;
49
+ const fields = 'versionString,platform,appVersionState,build';
36
50
  const page = await getAppStoreResponse(versionPage, `/apps/${encodePathSegment(appId)}/appStoreVersions`, {
37
- 'filter[appVersionState]': editableStates.join(','),
51
+ ...(editableOnly ? { 'filter[appVersionState]': editableStates.join(',') } : {}),
38
52
  ...(versionId ? { 'filter[id]': versionId } : {}),
39
53
  ...(versionString ? { 'filter[versionString]': versionString } : {}),
40
- 'fields[appStoreVersions]': 'versionString,platform,appVersionState,build',
41
- 'fields[builds]': 'processingState',
54
+ ...(platform ? { 'filter[platform]': platform } : {}),
55
+ 'fields[appStoreVersions]': editableOnly ? fields : `${fields},appStoreState,releaseType,createdDate`,
56
+ 'fields[builds]': 'processingState,version',
42
57
  include: 'build',
43
58
  limit: versionId ? '1' : '5',
44
59
  });
45
60
  const candidates = [];
46
61
  let incomplete = pageIsIncomplete(page, page.data.length);
47
62
  for (const row of page.data) {
48
- const version = row.attributes?.versionString ?? undefined;
49
- const state = row.attributes?.appVersionState ?? row.attributes?.appStoreState ?? undefined;
63
+ const { attributes } = row;
64
+ const version = attributes?.versionString ?? undefined;
65
+ const state = attributes?.appVersionState ?? attributes?.appStoreState ?? undefined;
50
66
  if ((versionId && versionId !== row.id) || (versionString && version && versionString !== version)
51
- || (state && !editableStates.includes(state)))
67
+ || (editableOnly && state && !editableStates.includes(state)))
68
+ continue;
69
+ const rowPlatform = appStorePlatformSchema.safeParse(attributes?.platform);
70
+ if (rowPlatform.success && platform && platform !== rowPlatform.data)
52
71
  continue;
53
- const platform = platformSchema.safeParse(row.attributes?.platform);
54
- if (!state || !platform.success || (versionString && !version)) {
72
+ if (!state || !rowPlatform.success || (versionString && !version)) {
55
73
  incomplete = true;
56
74
  continue;
57
75
  }
58
76
  const linkage = buildRelationship.safeParse(row.relationships?.build);
59
77
  const linkedBuildId = linkage.success ? linkage.data.data?.id : undefined;
60
- const included = linkedBuildId ? (page.included ?? []).filter((item) => {
61
- const ref = buildReference.safeParse(item);
62
- return ref.success && ref.data.id === linkedBuildId;
63
- }) : [];
64
- const embedded = included.length === 1 ? buildResource.safeParse(included[0]) : undefined;
78
+ const embedded = linkage.data?.data && includedAppStoreResource(page.included, linkage.data.data, buildResource);
65
79
  candidates.push({
66
80
  id: row.id,
67
81
  versionString: version,
68
82
  state,
69
- platform: platform.data,
83
+ platform: rowPlatform.data,
84
+ appStoreState: attributes?.appStoreState ?? undefined,
85
+ releaseType: attributes?.releaseType ?? undefined,
86
+ createdDate: attributes?.createdDate ?? undefined,
70
87
  linkedBuildId,
71
88
  build: linkage.success && linkage.data.data === null
72
89
  ? { status: 'missing' }
73
- : embedded?.success ? buildReadiness(embedded.data) : undefined,
90
+ : embedded ? buildReadiness(embedded) : undefined,
74
91
  });
75
92
  }
76
93
  if (candidates.length > 1)
@@ -89,7 +106,7 @@ export async function resolveAppStoreVersionBuild(version) {
89
106
  : { status: 'missing' };
90
107
  try {
91
108
  const { data } = await getAppStoreResponse(buildResponse, `/appStoreVersions/${encodePathSegment(version.id)}/build`, {
92
- 'fields[builds]': 'processingState',
109
+ 'fields[builds]': 'processingState,version',
93
110
  });
94
111
  if (!data)
95
112
  return missing;
@@ -6,7 +6,10 @@
6
6
  // 2. 만들어 둔 버전의 releaseType 을 나중에 바꾸기 (PATCH appStoreVersions)
7
7
  // 3. 단계적 출시 시작·일시중지·재개·즉시완료 (phasedRelease)
8
8
  // Play 는 userFraction/halted 로 3번이 되는데 iOS 만 비어 있었다.
9
+ import { z } from 'zod';
10
+ import { apiPatch, apiPost } from './client.js';
9
11
  import { V1_BASE, apiRequest, authHeadersOrThrow, isNotFound } from './http.js';
12
+ import { appStoreResourceRef, appStoreToOne, getAppStoreResponse, includedAppStoreResource } from './read-response.js';
10
13
  import { encodePathSegment } from '../lib/url-path.js';
11
14
  /** 각 상태가 "지금 출시" 요청을 받을 수 있는지 + 사람이 읽을 설명. */
12
15
  const STATE_NOTE = {
@@ -20,48 +23,79 @@ const STATE_NOTE = {
20
23
  REJECTED: 'Apple 이 거절함 — 수정 후 재제출.',
21
24
  METADATA_REJECTED: '메타데이터 거절 — 수정 후 재제출.',
22
25
  };
23
- async function get(path, params) {
24
- const headers = await authHeadersOrThrow();
25
- const query = params ? `?${new URLSearchParams(params).toString()}` : '';
26
- return apiRequest(V1_BASE, `${path}${query}`, headers, { method: 'GET' });
27
- }
28
- async function send(method, path, body) {
29
- const headers = await authHeadersOrThrow();
30
- return apiRequest(V1_BASE, path, headers, {
31
- method,
32
- ...(body === undefined
33
- ? {}
34
- : { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }),
26
+ const phasedType = 'appStoreVersionPhasedReleases';
27
+ const phasedRelation = 'appStoreVersionPhasedRelease';
28
+ const phasedFields = 'phasedReleaseState,startDate,totalPauseDuration,currentDayNumber';
29
+ const phasedRef = appStoreResourceRef.extend({
30
+ type: z.literal(phasedType),
31
+ });
32
+ const phasedResource = phasedRef.extend({
33
+ attributes: z.object({
34
+ phasedReleaseState: z.enum(['INACTIVE', 'ACTIVE', 'PAUSED', 'COMPLETE']),
35
+ currentDayNumber: z.number().nullish(),
36
+ startDate: z.string().nullish(),
37
+ totalPauseDuration: z.number().nullish(),
38
+ }),
39
+ });
40
+ const phasedResponse = z.object({ data: phasedResource.nullable() });
41
+ const phasedCreateResponse = z.object({ data: phasedRef });
42
+ const releaseDocument = z.object({
43
+ data: appStoreResourceRef.extend({
44
+ type: z.literal('appStoreVersions'),
45
+ attributes: z.object({
46
+ versionString: z.string().nullish(),
47
+ appStoreState: z.string().nullish(),
48
+ appVersionState: z.string().nullish(),
49
+ releaseType: z.string().nullish(),
50
+ earliestReleaseDate: z.string().nullish(),
51
+ }).nullish(),
52
+ relationships: z.object({ [phasedRelation]: z.unknown().optional() }).nullish(),
53
+ }),
54
+ included: z.array(z.unknown()).nullish(),
55
+ });
56
+ async function readVersion(versionId, includePhased = false) {
57
+ const fields = 'versionString,appStoreState,appVersionState,releaseType,earliestReleaseDate';
58
+ const document = await getAppStoreResponse(releaseDocument, `/appStoreVersions/${encodePathSegment(versionId)}`, {
59
+ 'fields[appStoreVersions]': includePhased ? `${fields},${phasedRelation}` : fields,
60
+ ...(includePhased ? { include: phasedRelation, [`fields[${phasedType}]`]: phasedFields } : {}),
35
61
  });
62
+ if (document.data.id !== versionId)
63
+ throw new Error('App Store Connect에서 요청한 버전과 다른 버전을 반환했습니다.');
64
+ return document;
65
+ }
66
+ function versionSummary(row) {
67
+ const a = row.attributes;
68
+ return {
69
+ versionId: row.id,
70
+ versionString: a?.versionString ?? undefined,
71
+ state: a?.appStoreState ?? a?.appVersionState ?? undefined,
72
+ releaseType: a?.releaseType ?? undefined,
73
+ earliestReleaseDate: a?.earliestReleaseDate ?? undefined,
74
+ };
36
75
  }
37
76
  export async function getVersionSummary(versionId) {
38
- const data = await get(`/appStoreVersions/${encodePathSegment(versionId)}`, { 'fields[appStoreVersions]': 'versionString,appStoreState,releaseType,earliestReleaseDate' });
39
- const a = data.data?.attributes ?? {};
77
+ return versionSummary((await readVersion(versionId)).data);
78
+ }
79
+ function phasedSummary(row) {
80
+ const attributes = row.attributes;
40
81
  return {
41
- versionId,
42
- versionString: a.versionString,
43
- state: a.appStoreState,
44
- releaseType: a.releaseType,
45
- earliestReleaseDate: a.earliestReleaseDate,
82
+ id: row.id,
83
+ state: attributes.phasedReleaseState,
84
+ currentDayNumber: attributes.currentDayNumber ?? undefined,
85
+ startDate: attributes.startDate ?? undefined,
86
+ totalPauseDuration: attributes.totalPauseDuration ?? undefined,
46
87
  };
47
88
  }
48
89
  /** to-one 관계는 없을 때 200 + data:null 로 오기도 하고 404 로 오기도 한다. 둘 다 "없음"으로 본다. */
49
- async function getPhasedRelease(versionId) {
90
+ async function getPhasedRelease(versionId, linkedId) {
50
91
  try {
51
- const data = await get(`/appStoreVersions/${encodePathSegment(versionId)}/appStoreVersionPhasedRelease`);
52
- if (!data.data)
53
- return null;
54
- const a = (data.data.attributes ?? {});
55
- return {
56
- id: data.data.id,
57
- state: a.phasedReleaseState,
58
- currentDayNumber: a.currentDayNumber,
59
- startDate: a.startDate,
60
- totalPauseDuration: a.totalPauseDuration,
61
- };
92
+ const { data } = await getAppStoreResponse(phasedResponse, `/appStoreVersions/${encodePathSegment(versionId)}/appStoreVersionPhasedRelease`, { [`fields[${phasedType}]`]: phasedFields });
93
+ if (linkedId && data?.id !== linkedId)
94
+ throw new Error('App Store Connect의 단계적 출시 연결과 상세 조회 결과가 일치하지 않습니다.');
95
+ return data ? phasedSummary(data) : null;
62
96
  }
63
97
  catch (err) {
64
- if (isNotFound(err))
98
+ if (!linkedId && isNotFound(err))
65
99
  return null;
66
100
  throw err;
67
101
  }
@@ -71,8 +105,12 @@ export function stateNote(state) {
71
105
  }
72
106
  /** 버전 상태 + 단계적 출시 상태를 한 번에. 쓰기 전 미리보기용. */
73
107
  export async function getReleaseStatus(versionId) {
74
- const version = await getVersionSummary(versionId);
75
- const phased = await getPhasedRelease(versionId);
108
+ const document = await readVersion(versionId, true);
109
+ const version = versionSummary(document.data);
110
+ const linkage = appStoreToOne.safeParse(document.data.relationships?.[phasedRelation]).data?.data;
111
+ const ref = linkage?.type === phasedType ? linkage : undefined;
112
+ const included = ref && includedAppStoreResource(document.included, ref, phasedResource);
113
+ const phased = linkage === null ? null : included ? phasedSummary(included) : await getPhasedRelease(versionId, ref?.id);
76
114
  return { version, phased, note: stateNote(version.state) };
77
115
  }
78
116
  /**
@@ -91,7 +129,7 @@ export async function requestRelease(versionId) {
91
129
  .filter(Boolean)
92
130
  .join('\n'));
93
131
  }
94
- await send('POST', '/appStoreVersionReleaseRequests', {
132
+ await apiPost('/appStoreVersionReleaseRequests', {
95
133
  data: {
96
134
  type: 'appStoreVersionReleaseRequests',
97
135
  relationships: { appStoreVersion: { data: { type: 'appStoreVersions', id: versionId } } },
@@ -115,7 +153,7 @@ export async function updateReleaseType(args) {
115
153
  attributes.earliestReleaseDate = earliestReleaseDate;
116
154
  else if (earliestReleaseDate === undefined)
117
155
  attributes.earliestReleaseDate = null;
118
- await send('PATCH', `/appStoreVersions/${encodePathSegment(versionId)}`, {
156
+ await apiPatch(`/appStoreVersions/${encodePathSegment(versionId)}`, {
119
157
  data: { type: 'appStoreVersions', id: versionId, attributes },
120
158
  });
121
159
  return getVersionSummary(versionId);
@@ -131,23 +169,23 @@ export async function updateReleaseType(args) {
131
169
  */
132
170
  export async function setPhasedRelease(args) {
133
171
  const { versionId, action } = args;
134
- const version = await getVersionSummary(versionId);
135
- const current = await getPhasedRelease(versionId);
172
+ const { version, phased: current } = await getReleaseStatus(versionId);
136
173
  if (action === 'enable') {
137
174
  if (!current) {
138
- const created = await send('POST', '/appStoreVersionPhasedReleases', {
175
+ const result = await apiPost('/appStoreVersionPhasedReleases', {
139
176
  data: {
140
177
  type: 'appStoreVersionPhasedReleases',
141
178
  attributes: { phasedReleaseState: 'ACTIVE' },
142
179
  relationships: { appStoreVersion: { data: { type: 'appStoreVersions', id: versionId } } },
143
180
  },
144
181
  });
145
- void created;
146
- }
147
- else if (current.state === 'PAUSED') {
148
- await patchState(current.id, 'ACTIVE');
182
+ const createdId = phasedCreateResponse.safeParse(result).data?.data.id;
183
+ return { action, phased: await verifyPhasedChange(versionId, createdId), version };
149
184
  }
150
- return { action, phased: await getPhasedRelease(versionId), version };
185
+ if (current.state !== 'PAUSED')
186
+ return { action, phased: current, version };
187
+ await patchState(current.id, 'ACTIVE');
188
+ return { action, phased: await verifyPhasedChange(versionId, current.id, 'ACTIVE'), version };
151
189
  }
152
190
  if (!current) {
153
191
  throw new Error([
@@ -156,15 +194,30 @@ export async function setPhasedRelease(args) {
156
194
  ].join('\n'));
157
195
  }
158
196
  if (action === 'disable') {
159
- await send('DELETE', `/appStoreVersionPhasedReleases/${encodePathSegment(current.id)}`);
197
+ await apiRequest(V1_BASE, `/appStoreVersionPhasedReleases/${encodePathSegment(current.id)}`, await authHeadersOrThrow(), {
198
+ method: 'DELETE',
199
+ });
160
200
  return { action, phased: null, version };
161
201
  }
162
202
  const next = action === 'pause' ? 'PAUSED' : action === 'resume' ? 'ACTIVE' : 'COMPLETE';
163
203
  await patchState(current.id, next);
164
- return { action, phased: await getPhasedRelease(versionId), version };
204
+ return { action, phased: await verifyPhasedChange(versionId, current.id, next), version };
205
+ }
206
+ async function verifyPhasedChange(versionId, id, expectedState) {
207
+ try {
208
+ const phased = await getPhasedRelease(versionId, id);
209
+ if (!phased || (expectedState && phased.state !== expectedState)) {
210
+ throw new Error('단계적 출시의 변경된 상태가 응답에 없습니다.');
211
+ }
212
+ return phased;
213
+ }
214
+ catch (error) {
215
+ const reason = error instanceof Error ? error.message : String(error);
216
+ throw new Error(`단계적 출시 변경 요청이 접수됐지만 결과를 확인할 수 없습니다. 상태를 먼저 조회하세요. 원인: ${reason}`, { cause: error });
217
+ }
165
218
  }
166
219
  async function patchState(phasedReleaseId, state) {
167
- await send('PATCH', `/appStoreVersionPhasedReleases/${encodePathSegment(phasedReleaseId)}`, {
220
+ await apiPatch(`/appStoreVersionPhasedReleases/${encodePathSegment(phasedReleaseId)}`, {
168
221
  data: {
169
222
  type: 'appStoreVersionPhasedReleases',
170
223
  id: phasedReleaseId,
@@ -0,0 +1,19 @@
1
+ /** Read the review target and preview together. Resolve missing included resources against that same version. */
2
+ export declare function buildSubmitForReviewPreview(versionId: string): Promise<{
3
+ versionId: string;
4
+ appId: string;
5
+ platform: string;
6
+ versionString: string;
7
+ state: string;
8
+ attachedBuild: {
9
+ id: string;
10
+ buildNumber: string;
11
+ uploadedDate: string | undefined;
12
+ processingState: string;
13
+ } | undefined;
14
+ whatsNewByLocale: {
15
+ locale: string;
16
+ length: number;
17
+ excerpt: string;
18
+ }[];
19
+ }>;