fix(core): Resolve TypeScript strict mode and ES client API compatibility issues for v3.0.0
- Fix ES client v8+ API: use document/doc instead of body for index/update operations - Add type assertions (as any) for ES client ILM, template, and search APIs - Fix strict null checks with proper undefined handling (nullish coalescing) - Fix MetricsCollector interface to match required method signatures - Fix Logger.error signature compatibility in plugins - Resolve TermsQuery type index signature conflict - Remove sourceMap from tsconfig (handled by tsbuild with inlineSourceMap)
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { Client as ElasticClient } from '@elastic/elasticsearch';
|
||||
import {
|
||||
import type {
|
||||
BatchOperation,
|
||||
BatchResult,
|
||||
DocumentOperation,
|
||||
SessionConfig,
|
||||
} from './types.js';
|
||||
import { DocumentOperation } from './types.js';
|
||||
import { Logger } from '../../core/observability/logger.js';
|
||||
import { BulkOperationError } from '../../core/errors/elasticsearch-error.js';
|
||||
|
||||
@@ -237,16 +237,20 @@ export class DocumentSession<T = unknown> {
|
||||
const item = response.items[i];
|
||||
const operation = this.operations[i];
|
||||
|
||||
const action = Object.keys(item)[0];
|
||||
const result = item[action as keyof typeof item] as any;
|
||||
if (!item || !operation) continue;
|
||||
|
||||
if (result.error) {
|
||||
const action = Object.keys(item)[0];
|
||||
if (!action) continue;
|
||||
const result = item[action as keyof typeof item] as Record<string, unknown> | undefined;
|
||||
|
||||
if (result?.error) {
|
||||
failed++;
|
||||
const errorInfo = result.error as { reason?: string } | string;
|
||||
errors.push({
|
||||
documentId: operation.documentId,
|
||||
operation: operation.operation,
|
||||
error: result.error.reason || result.error,
|
||||
statusCode: result.status,
|
||||
error: typeof errorInfo === 'string' ? errorInfo : (errorInfo.reason ?? 'Unknown error'),
|
||||
statusCode: result.status as number,
|
||||
});
|
||||
} else {
|
||||
successful++;
|
||||
@@ -276,7 +280,7 @@ export class DocumentSession<T = unknown> {
|
||||
'All bulk operations failed',
|
||||
successful,
|
||||
failed,
|
||||
errors
|
||||
errors.map(e => ({ documentId: e.documentId, error: e.error, status: e.statusCode }))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -304,13 +308,11 @@ export class DocumentSession<T = unknown> {
|
||||
|
||||
await this.client.deleteByQuery({
|
||||
index: this.index,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
must_not: {
|
||||
ids: {
|
||||
values: seenIds,
|
||||
},
|
||||
query: {
|
||||
bool: {
|
||||
must_not: {
|
||||
ids: {
|
||||
values: seenIds,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -320,7 +322,7 @@ export class DocumentSession<T = unknown> {
|
||||
|
||||
this.logger.debug('Stale documents cleaned up', { index: this.index });
|
||||
} catch (error) {
|
||||
this.logger.warn('Failed to cleanup stale documents', undefined, {
|
||||
this.logger.warn('Failed to cleanup stale documents', {
|
||||
index: this.index,
|
||||
error: (error as Error).message,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user