Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ lerna-debug.log
!.env.test
!**/.env.schema

/configs
/configs
/modules/graphql-router/src/admin/**
3 changes: 2 additions & 1 deletion apps/search-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
"test": "tsx --test ./src/**/*.test.ts"
},
"dependencies": {
"@aws-sdk/credential-provider-node": "^3.972.60",
Comment thread
justincorrigible marked this conversation as resolved.
Outdated
"@overture-stack/arranger-graphql-router": "file:../../modules/graphql-router",
"@overture-stack/sqon": "file:../../modules/sqon",
"@overture-stack/arranger-types": "file:../../modules/types",
"@overture-stack/sqon": "file:../../modules/sqon",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
Expand Down
5 changes: 2 additions & 3 deletions modules/graphql-router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import enforceAccessControl, { getDefaultServerSideFilter } from '#accessControl
import fallbackConfigs, { validateConfigs } from '#config/index.js';
import downloadRoutes from '#download/index.js';
import getGraphQLRoutes from '#graphqlRoutes.js';
import { getIndexMapping } from '#searchClient/index.js';
import { buildCatalogueIntrospectionBody } from '#introspection/buildCatalogueIntrospection.js';
import resolveCatalogueFields from '#mapping/resolveCatalogueFields.js';
import buildSearchClient, { type SearchClient } from '#searchClient/index.js';
import buildSearchClient, { getIndexMapping, type SearchClient } from '#searchClient/index.js';
import type { ArrangerBaseContext } from '#types.js';
import { addContext } from '#utils/context.js';
import { warnDeprecatedConfigsSource } from '#utils/noops.js';
Expand Down Expand Up @@ -76,7 +75,7 @@ const arrangerRouter = async <Context extends ArrangerBaseContext>({
}));

const mappingFromIndex = await getIndexMapping({
enableDebug,
enableDebug: !!enableDebug,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this change necessary?

@demariadaniel demariadaniel Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a Type error, enableDebug at line 58 is boolean | undefined, and getIndexMapping expects only a boolean.
We had to leverage enableDebug to troubleshoot in HCMI Dev.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternately we could change the getIndexMapping signature to make enableDebug an optional argument and be false by default.

@justincorrigible justincorrigible Jul 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like a type problem in the function's definition, rather than something to be coerced in this manner 🤔

@joneubank thoughts on this?

searchClient: esClient,
esIndex: configs[configRootProperties.ES_INDEX],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { SearchClient, SearchConfig } from './types.js';

export type OSClientOptions = Prettify<
SearchConfig & {
clientType: 'opensearch';
clientType: 'opensearch' | 'opensearch-aws';
}
>;

Expand Down
31 changes: 30 additions & 1 deletion modules/graphql-router/src/searchClient/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { defaultProvider } from '@aws-sdk/credential-provider-node';
import { AwsSigv4Signer } from '@opensearch-project/opensearch/aws';
Comment thread
justincorrigible marked this conversation as resolved.

import { createElasticSearchClient, type ESClientOptions } from './createElasticSearchClient.js';
import { createOpenSearchClient, type OSClientOptions } from './createOpenSearchClient.js';
import type { SearchClient, SearchConfig, SearchConfigWithClient, SupportedClientTypes } from './types.js';

export const supportedClientValues = ['opensearch', 'elasticsearch'] as const satisfies SupportedClientTypes[];
export const supportedClientValues = [
'opensearch',
'elasticsearch',
'opensearch-aws',
] as const satisfies SupportedClientTypes[];

const buildAuthHeaders = (auth: SearchConfig['auth']): Record<string, string> =>
auth
Expand Down Expand Up @@ -243,6 +250,28 @@ const createSearchClient = (clientConfig: SearchConfigWithClient): SearchClient
return createOpenSearchClient(options);
}

case 'opensearch-aws': {
const options: OSClientOptions = {
...clientConfig,
clientType,
...AwsSigv4Signer({
region: 'us-east-1',
Comment thread
justincorrigible marked this conversation as resolved.
Outdated
service: 'es',
// Must return a Promise that resolve to an AWS.Credentials object.
// This function is used to acquire the credentials when the client start and
// when the credentials are expired.
// The Client will refresh the Credentials only when they are expired.
// With AWS SDK V2, Credentials.refreshPromise is used when available to refresh the credentials.
getCredentials: () => {
// Any other method to acquire a new Credentials object can be used.
const credentialsProvider = defaultProvider();
return credentialsProvider();
},
}),
};
return createOpenSearchClient(options);
}

case 'elasticsearch': {
const options: ESClientOptions = { ...clientConfig, clientType };
return createElasticSearchClient(options);
Expand Down
21 changes: 16 additions & 5 deletions modules/graphql-router/src/searchClient/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { Client as ElasticClient } from '@elastic/elasticsearch';
import type { Client as OpenSearchClient } from '@opensearch-project/opensearch';

export type SupportedClients = { elasticsearch: ElasticClient; opensearch: OpenSearchClient };
export type SupportedClients = {
elasticsearch: ElasticClient;
opensearch: OpenSearchClient;
'opensearch-aws': OpenSearchClient;
};
export type SupportedClientTypes = keyof SupportedClients;
export type SearchConfig = {
node: string;
Expand Down Expand Up @@ -40,8 +44,13 @@ export type SearchClientIndicesOpenParams = { index: string | string[] };
export type SearchClientIndicesPutMappingsParams = { index: string; body: Record<string, any> };
export type SearchClientIndicesPutSettingsParams = { body: Record<string, any> };
export type SearchClientBulkParams = { body: Record<string, any>[] };
export type SearchClientCreateParams = { id: string; index: string; body: Record<string, any> };
export type SearchClientDeleteParams = { index: string; id: string };
export type SearchClientCreateParams = {
id: string;
index: string;
body: Record<string, any>;
refresh?: boolean | 'false' | 'true' | 'wait_for';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list of types is peculiar, is this inherited from some third party library or did we decide these types? If we decided them, lets simplify to a list of string literals and add some documentation for why we chose these. If they are inherited, could we simplify them in a similar way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the problem too. Just to be clear, this is comment points to an outdated change, the latest version does not contain string literals for 'false' or 'true'. These are definitions that reflect the expected types for the OS/ES libraries.

};
export type SearchClientDeleteParams = { index: string; id: string; refresh?: boolean | 'false' | 'true' | 'wait_for' };
Comment thread
demariadaniel marked this conversation as resolved.
Outdated
export type SearchClientDeleteByQueryParams = { index: string; body: Record<string, any> };
export type SearchClientIndexParams = { index: string; body: Record<string, any> };
export type SearchClientUpdateParams = { id: string; index: string; body: Record<string, any> };
Expand Down Expand Up @@ -95,6 +104,8 @@ type SearchClientHitsResponse = SearchClientBaseResponse & {
hits: {
hits: {
_source: any;
_id: string;
_index: string;
}[];
};
};
Expand All @@ -108,8 +119,8 @@ type SearchClientAggregationsResponse = SearchClientBaseResponse & {
export type SearchClientSearchBody = {
_shards: ShardData;
aggregations?: Record<string, any>;
hits?: {
hits: { _id: string; _index: string; _source?: any }[];
hits: {
hits: { _source?: any }[];
};
timed_out: boolean;
took: number;
Expand Down
Loading