55
66import { HttpClient } from '../../core/network/httpClient.js' ;
77import { readAppCache , saveAppCache , AppCacheInfo } from '../../core/utils/cache.js' ;
8- import { resolveAppContext } from '../../core/utils/contextResolver.js' ;
8+ import type { RequestContext } from '../../core/types/context.js' ;
9+ import { ResolvedContext } from '../../core/types/context.js' ;
910
1011/**
1112 * Craft/App item in developer list
@@ -59,9 +60,10 @@ export class SelectionRequiredError extends Error {
5960export async function getAppInfo (
6061 projectPath ?: string ,
6162 autoSelect : boolean = true ,
62- context ?: import ( '../../core/types/index.js' ) . HandlerContext
63+ context ?: RequestContext
6364) : Promise < AppCacheInfo > {
64- const client = new HttpClient ( context ) ;
65+ const ctx = context ? new ResolvedContext ( { } , context ) : undefined ;
66+ const client = new HttpClient ( ctx ) ;
6567
6668 try {
6769 const response = await client . get < LevelListResponse > ( '/level/v1/list' ) ;
@@ -137,7 +139,7 @@ export async function getAppInfo(
137139export async function ensureAppInfo (
138140 projectPath ?: string ,
139141 autoSelect : boolean = true ,
140- context ?: import ( '../../core/types/index.js' ) . HandlerContext
142+ context ?: RequestContext
141143) : Promise < AppCacheInfo > {
142144 // Check cache first
143145 const cached = readAppCache ( projectPath ) ;
@@ -161,9 +163,10 @@ export async function selectApp(
161163 developerId : number ,
162164 appId : number ,
163165 projectPath ?: string ,
164- context ?: import ( '../../core/types/index.js' ) . HandlerContext
166+ context ?: RequestContext
165167) : Promise < AppCacheInfo > {
166- const client = new HttpClient ( context ) ;
168+ const ctx = context ? new ResolvedContext ( { } , context ) : undefined ;
169+ const client = new HttpClient ( ctx ) ;
167170
168171 try {
169172 // Fetch full list to validate selection
@@ -212,9 +215,10 @@ export async function selectApp(
212215 * @returns List of all developers and their apps
213216 */
214217export async function getAllDevelopersAndApps (
215- context ?: import ( '../../core/types/index.js' ) . HandlerContext
218+ context ?: RequestContext
216219) : Promise < LevelListResponse > {
217- const client = new HttpClient ( context ) ;
220+ const ctx = context ? new ResolvedContext ( { } , context ) : undefined ;
221+ const client = new HttpClient ( ctx ) ;
218222
219223 try {
220224 const response = await client . get < LevelListResponse > ( '/level/v1/list' ) ;
@@ -239,7 +243,8 @@ export interface CreateDeveloperResponse {
239243 * Create unverified developer
240244 */
241245export async function createDeveloper ( context ?: import ( '../../core/types/index.js' ) . HandlerContext ) : Promise < CreateDeveloperResponse > {
242- const client = new HttpClient ( context ) ;
246+ const ctx = context ? new ResolvedContext ( { } , context ) : undefined ;
247+ const client = new HttpClient ( ctx ) ;
243248 return await client . post < CreateDeveloperResponse > ( '/v1/developer/create-register' ) ;
244249}
245250
@@ -259,9 +264,10 @@ export async function createAppForDeveloper(
259264 developer_id : number ,
260265 title ?: string ,
261266 genre ?: string ,
262- context ?: import ( '../../core/types/index.js' ) . HandlerContext
267+ context ?: RequestContext
263268) : Promise < CreateAppResponse > {
264- const client = new HttpClient ( context ) ;
269+ const ctx = context ? new ResolvedContext ( { } , context ) : undefined ;
270+ const client = new HttpClient ( ctx ) ;
265271 return await client . post < CreateAppResponse > ( '/level/v1/create' , {
266272 body : {
267273 developer_id,
@@ -292,9 +298,10 @@ export async function editAppInfo(
292298 chatting_label ?: string ,
293299 chatting_number ?: string ,
294300 screen_orientation ?: number ,
295- context ?: import ( '../../core/types/index.js' ) . HandlerContext
301+ context ?: RequestContext
296302) : Promise < EditAppResponse > {
297- const client = new HttpClient ( context ) ;
303+ const ctx = context ? new ResolvedContext ( { } , context ) : undefined ;
304+ const client = new HttpClient ( ctx ) ;
298305 return await client . post < EditAppResponse > ( '/level/v1/submit' , {
299306 body : {
300307 app_id,
@@ -321,7 +328,8 @@ export interface AppStatusResponse {
321328 * Get app review status
322329 */
323330export async function getAppStatus ( app_id : number , context ?: import ( '../../core/types/index.js' ) . HandlerContext ) : Promise < AppStatusResponse > {
324- const client = new HttpClient ( context ) ;
331+ const ctx = context ? new ResolvedContext ( { } , context ) : undefined ;
332+ const client = new HttpClient ( ctx ) ;
325333 return await client . get < AppStatusResponse > ( '/level/v1/status' , {
326334 params : {
327335 app_id : app_id . toString ( ) ,
@@ -364,9 +372,10 @@ export interface AppDetail {
364372 */
365373export async function getAppDetail (
366374 appId : number ,
367- context ?: import ( '../../core/types/index.js' ) . HandlerContext
375+ context ?: RequestContext
368376) : Promise < AppDetail | undefined > {
369- const client = new HttpClient ( context ) ;
377+ const ctx = context ? new ResolvedContext ( { } , context ) : undefined ;
378+ const client = new HttpClient ( ctx ) ;
370379
371380 try {
372381 const response = await client . get < AppDetailAPIResponse > ( '/level/v1/latest' , {
0 commit comments