Skip to content

Commit

Permalink
fixed types
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakprabhakara committed Jan 9, 2025
1 parent f2d272c commit 51787cf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
14 changes: 4 additions & 10 deletions src/_db/commands/reindex/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,8 @@ export const handler = async (argv) => {
if (!aliasesBlob) {
logger.error({ msg: "no aliasesBlob for index " + esTargetIndex });
} else {
aliasesBlob.body.split("\n").forEach((aliasDesc) => {
const parts = aliasDesc.split(" ");
if (parts.length >= 2) {
currentIndices.push(parts[1]);
}
aliasesBlob.body.forEach((aliasRec) => {
currentIndicesWrite.push(aliasRec.alias!);

Check warning on line 98 in src/_db/commands/reindex/postgres.ts

View workflow job for this annotation

GitHub Actions / ci (20)

Forbidden non-null assertion
});
logger.info({ msg: "found current read indices", count: currentIndices.length });
}
Expand All @@ -108,11 +105,8 @@ export const handler = async (argv) => {
if (!aliasesBlobWrite.body) {
logger.error({ msg: "no aliasesBlobWrite" });
} else {
aliasesBlobWrite.body.split("\n").forEach((aliasDesc) => {
const parts = aliasDesc.split(" ");
if (parts.length >= 2) {
currentIndicesWrite.push(parts[1]);
}
aliasesBlobWrite.body.forEach((aliasRec) => {
currentIndicesWrite.push(aliasRec.alias!);

Check warning on line 109 in src/_db/commands/reindex/postgres.ts

View workflow job for this annotation

GitHub Actions / ci (20)

Forbidden non-null assertion
});
}

Expand Down
5 changes: 1 addition & 4 deletions src/_processor/test/workers/ElasticsearchSaverTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ class ElasticsearchSaverTest {
})
)
)
.returns(
() =>
Promise.resolve({ body: {} }) as TransportRequestPromise<ApiResponse<Record<string, any>, unknown>>
)
.returns(() => Promise.resolve({ body: {} }) as TransportRequestPromise<ApiResponse>)
.verifiable(TypeMoq.Times.once());

clock
Expand Down
4 changes: 2 additions & 2 deletions src/models/environment/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ export default async function (opts: Options) {
const indexName = resp.body[0].index;

// Delete all aliases attached to the soon-to-be-deleted index
es.indices.deleteAlias({ index: indexName, name: "_all" }, (err2) => {
es.indices.deleteAlias({ index: indexName!, name: "_all" }, (err2) => {
if (err2) {
reject(err2);
return;
}

// Finally, delete the index itself
es.indices.delete({ index: indexName }, (err3) => {
es.indices.delete({ index: indexName! }, (err3) => {
if (err3) {
reject(err3);
return;
Expand Down
6 changes: 3 additions & 3 deletions src/models/event/query.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from "lodash";
import searchQueryParser from "search-query-parser";
import moment from "moment";
import { ApiResponse, RequestParams } from "@opensearch-project/opensearch";
import { ApiResponse, type API } from "@opensearch-project/opensearch";

import { Scope } from "../../security/scope";
import { scope, getESWithRetry, ClientWithRetry } from "../../persistence/elasticsearch";
Expand Down Expand Up @@ -294,7 +294,7 @@ export function parse(searchQuery: string): any {
return q;
}

export function searchParams(opts: Options): RequestParams.Search {
export function searchParams(opts: Options): API.Search_Request {
const searchQuery = parse(opts.query);
const [index, securityFilters] = scope(opts.scope);

Expand Down Expand Up @@ -366,7 +366,7 @@ export function searchParams(opts: Options): RequestParams.Search {
// };
}

export function searchParamsPaginated(opts: OptionsPaginated): RequestParams.Search {
export function searchParamsPaginated(opts: OptionsPaginated): API.Search_Request {
const searchQuery = parse(opts.query);
const [index, securityFilters] = scope(opts.scope);

Expand Down
2 changes: 1 addition & 1 deletion src/test/models/event/countBy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class EventsCountByTest {
},
},
},
} as ApiResponse<any>;
} as ApiResponse;

es.setup((x) => x.search(TypeMoq.It.isAny())).returns((params): any => {
assert.deepEqual(params.body.query.bool.filter, [
Expand Down
4 changes: 2 additions & 2 deletions src/test/models/event/query.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { suite, test } from "@testdeck/mocha";

import { parse, searchParams, Options } from "../../../models/event/query";
import { RequestParams } from "@opensearch-project/opensearch";
import { type API } from "@opensearch-project/opensearch";
import assert from "assert";

@suite
Expand Down Expand Up @@ -164,7 +164,7 @@ class QueryEventsTest {
cursor: [1492060162148, "abc123"],
};
const output = searchParams(input);
const answer: RequestParams.Search = {
const answer: API.Search_Request = {
index: "retraced.p1.e1.current",
_source: "true",
size: 10,
Expand Down

0 comments on commit 51787cf

Please sign in to comment.