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:
2025-11-29 21:19:28 +00:00
parent ec8dfbcfe6
commit 820f84ee61
30 changed files with 344 additions and 220 deletions

View File

@@ -179,8 +179,6 @@ export class TransactionManager {
context.state = 'committing';
const client = ElasticsearchConnectionManager.getInstance().getClient();
// Execute and commit all operations
let committed = 0;
for (const operation of context.operations) {
@@ -285,14 +283,12 @@ export class TransactionManager {
context.state = 'rolling_back';
const client = ElasticsearchConnectionManager.getInstance().getClient();
// Execute compensation operations in reverse order
let rolledBack = 0;
for (let i = context.operations.length - 1; i >= 0; i--) {
const operation = context.operations[i];
if (!operation.executed || !operation.compensation) {
if (!operation || !operation.executed || !operation.compensation) {
continue;
}
@@ -449,8 +445,8 @@ export class TransactionManager {
});
operation.version = {
seqNo: result._seq_no!,
primaryTerm: result._primary_term!,
seqNo: result._seq_no ?? 0,
primaryTerm: result._primary_term ?? 0,
};
operation.originalDocument = result._source;
@@ -466,8 +462,8 @@ export class TransactionManager {
});
operation.version = {
seqNo: result._seq_no,
primaryTerm: result._primary_term,
seqNo: result._seq_no ?? 0,
primaryTerm: result._primary_term ?? 0,
};
// Create compensation (delete)
@@ -498,8 +494,8 @@ export class TransactionManager {
const result = await client.index(updateRequest);
operation.version = {
seqNo: result._seq_no,
primaryTerm: result._primary_term,
seqNo: result._seq_no ?? 0,
primaryTerm: result._primary_term ?? 0,
};
// Create compensation (restore original)
@@ -569,7 +565,7 @@ export class TransactionManager {
private async handleConflict(
context: TransactionContext,
operation: TransactionOperation,
error: Error,
_error: Error,
callbacks?: TransactionCallbacks
): Promise<void> {
this.stats.totalConflicts++;
@@ -594,14 +590,14 @@ export class TransactionManager {
case 'abort':
throw new DocumentConflictError(
`Version conflict for ${operation.index}/${operation.id}`,
{ index: operation.index, id: operation.id }
`${operation.index}/${operation.id}`
);
case 'retry':
if (context.retryAttempts >= context.config.maxRetries) {
throw new DocumentConflictError(
`Max retries exceeded for ${operation.index}/${operation.id}`,
{ index: operation.index, id: operation.id }
`${operation.index}/${operation.id}`
);
}