@@ -59,8 +59,8 @@ function getTSDiagnostics(code: string): string[] {
5959 const codeWithImport = [
6060 'import { ImageKit } from "@imagekit/nodejs";' ,
6161 functionSource . type === 'declaration' ?
62- `async function run(${ functionSource . client } : ImageKit)` :
63- `const run: (${ functionSource . client } : ImageKit) => Promise<unknown> =` ,
62+ `async function run(${ functionSource . client } : ImageKit)`
63+ : `const run: (${ functionSource . client } : ImageKit) => Promise<unknown> =` ,
6464 functionSource . code ,
6565 ] . join ( '\n' ) ;
6666 const sourcePath = path . resolve ( 'code.ts' ) ;
@@ -108,55 +108,55 @@ function getTSDiagnostics(code: string): string[] {
108108
109109const fuse = new Fuse (
110110 [
111- " client.customMetadataFields.create" ,
112- " client.customMetadataFields.delete" ,
113- " client.customMetadataFields.list" ,
114- " client.customMetadataFields.update" ,
115- " client.files.copy" ,
116- " client.files.delete" ,
117- " client.files.get" ,
118- " client.files.move" ,
119- " client.files.rename" ,
120- " client.files.update" ,
121- " client.files.upload" ,
122- " client.files.bulk.addTags" ,
123- " client.files.bulk.delete" ,
124- " client.files.bulk.removeAITags" ,
125- " client.files.bulk.removeTags" ,
126- " client.files.versions.delete" ,
127- " client.files.versions.get" ,
128- " client.files.versions.list" ,
129- " client.files.versions.restore" ,
130- " client.files.metadata.get" ,
131- " client.files.metadata.getFromURL" ,
132- " client.savedExtensions.create" ,
133- " client.savedExtensions.delete" ,
134- " client.savedExtensions.get" ,
135- " client.savedExtensions.list" ,
136- " client.savedExtensions.update" ,
137- " client.assets.list" ,
138- " client.cache.invalidation.create" ,
139- " client.cache.invalidation.get" ,
140- " client.folders.copy" ,
141- " client.folders.create" ,
142- " client.folders.delete" ,
143- " client.folders.move" ,
144- " client.folders.rename" ,
145- " client.folders.job.get" ,
146- " client.accounts.usage.get" ,
147- " client.accounts.origins.create" ,
148- " client.accounts.origins.delete" ,
149- " client.accounts.origins.get" ,
150- " client.accounts.origins.list" ,
151- " client.accounts.origins.update" ,
152- " client.accounts.urlEndpoints.create" ,
153- " client.accounts.urlEndpoints.delete" ,
154- " client.accounts.urlEndpoints.get" ,
155- " client.accounts.urlEndpoints.list" ,
156- " client.accounts.urlEndpoints.update" ,
157- " client.beta.v2.files.upload" ,
158- " client.webhooks.unsafeUnwrap" ,
159- " client.webhooks.unwrap"
111+ ' client.customMetadataFields.create' ,
112+ ' client.customMetadataFields.delete' ,
113+ ' client.customMetadataFields.list' ,
114+ ' client.customMetadataFields.update' ,
115+ ' client.files.copy' ,
116+ ' client.files.delete' ,
117+ ' client.files.get' ,
118+ ' client.files.move' ,
119+ ' client.files.rename' ,
120+ ' client.files.update' ,
121+ ' client.files.upload' ,
122+ ' client.files.bulk.addTags' ,
123+ ' client.files.bulk.delete' ,
124+ ' client.files.bulk.removeAITags' ,
125+ ' client.files.bulk.removeTags' ,
126+ ' client.files.versions.delete' ,
127+ ' client.files.versions.get' ,
128+ ' client.files.versions.list' ,
129+ ' client.files.versions.restore' ,
130+ ' client.files.metadata.get' ,
131+ ' client.files.metadata.getFromURL' ,
132+ ' client.savedExtensions.create' ,
133+ ' client.savedExtensions.delete' ,
134+ ' client.savedExtensions.get' ,
135+ ' client.savedExtensions.list' ,
136+ ' client.savedExtensions.update' ,
137+ ' client.assets.list' ,
138+ ' client.cache.invalidation.create' ,
139+ ' client.cache.invalidation.get' ,
140+ ' client.folders.copy' ,
141+ ' client.folders.create' ,
142+ ' client.folders.delete' ,
143+ ' client.folders.move' ,
144+ ' client.folders.rename' ,
145+ ' client.folders.job.get' ,
146+ ' client.accounts.usage.get' ,
147+ ' client.accounts.origins.create' ,
148+ ' client.accounts.origins.delete' ,
149+ ' client.accounts.origins.get' ,
150+ ' client.accounts.origins.list' ,
151+ ' client.accounts.origins.update' ,
152+ ' client.accounts.urlEndpoints.create' ,
153+ ' client.accounts.urlEndpoints.delete' ,
154+ ' client.accounts.urlEndpoints.get' ,
155+ ' client.accounts.urlEndpoints.list' ,
156+ ' client.accounts.urlEndpoints.update' ,
157+ ' client.beta.v2.files.upload' ,
158+ ' client.webhooks.unsafeUnwrap' ,
159+ ' client.webhooks.unwrap' ,
160160 ] ,
161161 { threshold : 1 , shouldSort : true } ,
162162) ;
@@ -239,7 +239,12 @@ function parseError(code: string, error: unknown): string | undefined {
239239 // Deno uses V8; the first "<anonymous>:LINE:COLUMN" is the top of stack.
240240 const lineNumber = error . stack ?. match ( / < a n o n y m o u s > : ( [ 0 - 9 ] + ) : [ 0 - 9 ] + / ) ?. [ 1 ] ;
241241 // -1 for the zero-based indexing
242- const line = lineNumber && code . split ( '\n' ) . at ( parseInt ( lineNumber , 10 ) - 1 ) ?. trim ( ) ;
242+ const line =
243+ lineNumber &&
244+ code
245+ . split ( '\n' )
246+ . at ( parseInt ( lineNumber , 10 ) - 1 )
247+ ?. trim ( ) ;
243248 return line ? `${ message } \n at line ${ lineNumber } \n ${ line } ` : message ;
244249 } catch {
245250 return message ;
@@ -251,8 +256,9 @@ const fetch = async (req: Request): Promise<Response> => {
251256
252257 const runFunctionSource = code ? getRunFunctionSource ( code ) : null ;
253258 if ( ! runFunctionSource ) {
254- const message = code
255- ? 'The code is missing a top-level `run` function.'
259+ const message =
260+ code ?
261+ 'The code is missing a top-level `run` function.'
256262 : 'The code argument is missing. Provide one containing a top-level `run` function.' ;
257263 return Response . json (
258264 {
@@ -297,7 +303,7 @@ const fetch = async (req: Request): Promise<Response> => {
297303 try {
298304 let run_ = async ( client : any ) => { } ;
299305 run_ = ( await tseval ( `${ code } \nexport default run;` ) ) . default ;
300- const result = await run_ ( makeSdkProxy ( client , { path : [ " client" ] } ) ) ;
306+ const result = await run_ ( makeSdkProxy ( client , { path : [ ' client' ] } ) ) ;
301307 return Response . json ( {
302308 is_error : false ,
303309 result,
0 commit comments