@@ -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,12 +239,7 @@ 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 =
243- lineNumber &&
244- code
245- . split ( '\n' )
246- . at ( parseInt ( lineNumber , 10 ) - 1 )
247- ?. trim ( ) ;
242+ const line = lineNumber && code . split ( '\n' ) . at ( parseInt ( lineNumber , 10 ) - 1 ) ?. trim ( ) ;
248243 return line ? `${ message } \n at line ${ lineNumber } \n ${ line } ` : message ;
249244 } catch {
250245 return message ;
@@ -256,9 +251,8 @@ const fetch = async (req: Request): Promise<Response> => {
256251
257252 const runFunctionSource = code ? getRunFunctionSource ( code ) : null ;
258253 if ( ! runFunctionSource ) {
259- const message =
260- code ?
261- 'The code is missing a top-level `run` function.'
254+ const message = code
255+ ? 'The code is missing a top-level `run` function.'
262256 : 'The code argument is missing. Provide one containing a top-level `run` function.' ;
263257 return Response . json (
264258 {
@@ -303,7 +297,7 @@ const fetch = async (req: Request): Promise<Response> => {
303297 try {
304298 let run_ = async ( client : any ) => { } ;
305299 run_ = ( await tseval ( `${ code } \nexport default run;` ) ) . default ;
306- const result = await run_ ( makeSdkProxy ( client , { path : [ ' client' ] } ) ) ;
300+ const result = await run_ ( makeSdkProxy ( client , { path : [ " client" ] } ) ) ;
307301 return Response . json ( {
308302 is_error : false ,
309303 result,
0 commit comments