@openstax/ts-utils 1.24.1 → 1.24.2-pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  import { IndexOptions, SearchOptions } from '.';
2
- export declare const memorySearchTheBadWay: <T>({ loadAllDocumentsTheBadWay }: {
3
- loadAllDocumentsTheBadWay: () => Promise<T[]>;
2
+ export declare const memorySearchTheBadWay: <T>({ store }: {
3
+ store: {
4
+ loadAllDocumentsTheBadWay: () => Promise<T[]>;
5
+ };
4
6
  }) => {
5
7
  ensureIndexCreated: () => Promise<undefined>;
6
8
  index: (_options: IndexOptions<T>) => Promise<undefined>;
@@ -13,13 +13,13 @@ var MatchType;
13
13
  MatchType[MatchType["Should"] = 2] = "Should";
14
14
  })(MatchType || (MatchType = {}));
15
15
  const resolveField = (document, field) => field.key.toString().split('.').reduce((result, key) => result[key], document);
16
- const memorySearchTheBadWay = ({ loadAllDocumentsTheBadWay }) => {
16
+ const memorySearchTheBadWay = ({ store }) => {
17
17
  return {
18
18
  ensureIndexCreated: async () => undefined,
19
19
  index: async (_options) => undefined,
20
20
  search: async (options) => {
21
21
  const getFieldType = (field) => { var _a; return (_a = options.fields.find(f => f.key == field.key)) === null || _a === void 0 ? void 0 : _a.type; };
22
- const results = (await loadAllDocumentsTheBadWay())
22
+ const results = (await store.loadAllDocumentsTheBadWay())
23
23
  .map(document => {
24
24
  let weight = 0;
25
25
  const matchFilters = (filters, matchType) => {
@@ -1,6 +1,6 @@
1
1
  import { RequestBody } from '@opensearch-project/opensearch/lib/Transport';
2
- import { ConfigProviderForConfig } from '../config';
3
- import { IndexOptions, SearchOptions } from './searchProvider';
2
+ import { ConfigProviderForConfig } from '../../config';
3
+ import { IndexOptions, SearchOptions } from '.';
4
4
  export declare type Config = {
5
5
  node: string;
6
6
  region: string;
@@ -14,8 +14,8 @@ export declare type IndexConfig = {
14
14
  pageSize?: number;
15
15
  };
16
16
  export declare const openSearchService: <T extends RequestBody<Record<string, any>>, C extends string = "deployed">(initializer?: Initializer<C>) => (indexConfig: IndexConfig, configProvider: { [key in C]: {
17
- node: import("../config").ConfigValueProvider<string>;
18
- region: import("../config").ConfigValueProvider<string>;
17
+ node: import("../../config").ConfigValueProvider<string>;
18
+ region: import("../../config").ConfigValueProvider<string>;
19
19
  }; }) => {
20
20
  ensureIndexCreated: () => Promise<void>;
21
21
  index: (params: IndexOptions<T>) => Promise<void>;
@@ -5,9 +5,9 @@ exports.openSearchService = void 0;
5
5
  const credential_provider_node_1 = require("@aws-sdk/credential-provider-node");
6
6
  const opensearch_1 = require("@opensearch-project/opensearch");
7
7
  const aws_1 = require("@opensearch-project/opensearch/aws");
8
- const config_1 = require("../config");
9
- const guards_1 = require("../guards");
10
- const helpers_1 = require("../misc/helpers");
8
+ const config_1 = require("../../config");
9
+ const guards_1 = require("../../guards");
10
+ const helpers_1 = require("../../misc/helpers");
11
11
  const openSearchService = (initializer = {}) => (indexConfig, configProvider) => {
12
12
  const config = configProvider[(0, guards_1.ifDefined)(initializer.configSpace, 'deployed')];
13
13
  const pageSize = indexConfig.pageSize || 10;