@@ -40,7 +40,7 @@ import {
4040 * });
4141 * ```
4242 */
43- export class ObjectStackAdapter < T = any > implements DataSource < T > {
43+ export class ObjectStackAdapter < T = unknown > implements DataSource < T > {
4444 private client : ObjectStackClient ;
4545 private connected : boolean = false ;
4646 private metadataCache : MetadataCache ;
@@ -67,9 +67,10 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
6767 try {
6868 await this . client . connect ( ) ;
6969 this . connected = true ;
70- } catch ( error : any ) {
70+ } catch ( error : unknown ) {
71+ const errorMessage = error instanceof Error ? error . message : 'Failed to connect to ObjectStack server' ;
7172 throw new ConnectionError (
72- error ?. message || 'Failed to connect to ObjectStack server' ,
73+ errorMessage ,
7374 undefined ,
7475 { originalError : error }
7576 ) ;
@@ -85,7 +86,7 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
8586 await this . connect ( ) ;
8687
8788 const queryOptions = this . convertQueryParams ( params ) ;
88- const result : any = await this . client . data . find < T > ( resource , queryOptions ) ;
89+ const result : unknown = await this . client . data . find < T > ( resource , queryOptions ) ;
8990
9091 // Handle legacy/raw array response (e.g. from some mock servers or non-OData endpoints)
9192 if ( Array . isArray ( result ) ) {
@@ -98,13 +99,14 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
9899 } ;
99100 }
100101
102+ const resultObj = result as { value ?: T [ ] ; count ?: number } ;
101103 return {
102- data : result . value || [ ] ,
103- total : result . count || ( result . value ? result . value . length : 0 ) ,
104+ data : resultObj . value || [ ] ,
105+ total : resultObj . count || ( resultObj . value ? resultObj . value . length : 0 ) ,
104106 // Calculate page number safely
105107 page : params ?. $skip && params . $top ? Math . floor ( params . $skip / params . $top ) + 1 : 1 ,
106108 pageSize : params ?. $top ,
107- hasMore : params ?. $top ? ( result . value ?. length || 0 ) === params . $top : false ,
109+ hasMore : params ?. $top ? ( resultObj . value ?. length || 0 ) === params . $top : false ,
108110 } ;
109111 }
110112
@@ -117,9 +119,9 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
117119 try {
118120 const record = await this . client . data . get < T > ( resource , String ( id ) ) ;
119121 return record ;
120- } catch ( error ) {
122+ } catch ( error : unknown ) {
121123 // If record not found, return null instead of throwing
122- if ( ( error as any ) ?. status === 404 ) {
124+ if ( ( error as Record < string , unknown > ) ?. status === 404 ) {
123125 return null ;
124126 }
125127 throw error ;
@@ -172,7 +174,7 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
172174 return await this . client . data . createMany < T > ( resource , data ) ;
173175
174176 case 'delete' : {
175- const ids = data . map ( item => ( item as any ) . id ) . filter ( Boolean ) ;
177+ const ids = data . map ( item => ( item as Record < string , unknown > ) . id ) . filter ( Boolean ) ;
176178
177179 if ( ids . length === 0 ) {
178180 // Track which items are missing IDs
@@ -190,23 +192,25 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
190192
191193 case 'update' : {
192194 // Check if client supports updateMany
195+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
193196 if ( typeof ( this . client . data as any ) . updateMany === 'function' ) {
194197 try {
198+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
195199 const updateMany = ( this . client . data as any ) . updateMany ;
196200 return await updateMany ( resource , data ) as T [ ] ;
197- } catch ( error ) {
201+ } catch {
198202 // If updateMany is not supported, fall back to individual updates
199- console . warn ( 'updateMany not supported, falling back to individual updates' ) ;
203+ // Silently fallback without logging
200204 }
201205 }
202206
203207 // Fallback: Process updates individually with detailed error tracking
204208 const results : T [ ] = [ ] ;
205- const errors : Array < { index : number ; error : any } > = [ ] ;
209+ const errors : Array < { index : number ; error : unknown } > = [ ] ;
206210
207211 for ( let i = 0 ; i < data . length ; i ++ ) {
208212 const item = data [ i ] ;
209- const id = ( item as any ) . id ;
213+ const id = ( item as Record < string , unknown > ) . id ;
210214
211215 if ( ! id ) {
212216 errors . push ( { index : i , error : 'Missing ID' } ) ;
@@ -216,8 +220,9 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
216220 try {
217221 const result = await this . client . data . update < T > ( resource , String ( id ) , item ) ;
218222 results . push ( result ) ;
219- } catch ( error : any ) {
220- errors . push ( { index : i , error : error . message || error } ) ;
223+ } catch ( error : unknown ) {
224+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
225+ errors . push ( { index : i , error : errorMessage } ) ;
221226 }
222227 }
223228
@@ -242,7 +247,7 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
242247 400
243248 ) ;
244249 }
245- } catch ( error : any ) {
250+ } catch ( error : unknown ) {
246251 // If it's already a BulkOperationError, re-throw it
247252 if ( error instanceof BulkOperationError ) {
248253 throw error ;
@@ -254,9 +259,10 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
254259 }
255260
256261 // Wrap other errors in BulkOperationError with proper error tracking
262+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
257263 const errors = data . map ( ( _ , index ) => ( {
258264 index,
259- error : error . message || String ( error )
265+ error : errorMessage
260266 } ) ) ;
261267
262268 throw new BulkOperationError (
@@ -315,7 +321,7 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
315321 * @param objectName - Object name
316322 * @returns Promise resolving to the object schema
317323 */
318- async getObjectSchema ( objectName : string ) : Promise < any > {
324+ async getObjectSchema ( objectName : string ) : Promise < unknown > {
319325 await this . connect ( ) ;
320326
321327 try {
@@ -326,9 +332,10 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
326332 } ) ;
327333
328334 return schema ;
329- } catch ( error : any ) {
335+ } catch ( error : unknown ) {
330336 // Check if it's a 404 error
331- if ( error ?. status === 404 || error ?. statusCode === 404 ) {
337+ const errorObj = error as Record < string , unknown > ;
338+ if ( errorObj ?. status === 404 || errorObj ?. statusCode === 404 ) {
332339 throw new MetadataNotFoundError ( objectName , { originalError : error } ) ;
333340 }
334341
@@ -337,7 +344,7 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
337344 throw error ;
338345 }
339346
340- throw createErrorFromResponse ( error , `getObjectSchema(${ objectName } )` ) ;
347+ throw createErrorFromResponse ( errorObj , `getObjectSchema(${ objectName } )` ) ;
341348 }
342349 }
343350
@@ -384,7 +391,7 @@ export class ObjectStackAdapter<T = any> implements DataSource<T> {
384391 * });
385392 * ```
386393 */
387- export function createObjectStackAdapter < T = any > ( config : {
394+ export function createObjectStackAdapter < T = unknown > ( config : {
388395 baseUrl : string ;
389396 token ?: string ;
390397 fetch ?: ( input : RequestInfo | URL , init ?: RequestInit ) => Promise < Response > ;
0 commit comments