@openstax/ts-utils 1.24.1 → 1.24.2-pre2
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.
- package/dist/cjs/services/searchProvider/memorySearchTheBadWay.d.ts +4 -2
- package/dist/cjs/services/searchProvider/memorySearchTheBadWay.js +2 -2
- package/dist/cjs/services/{openSearch.d.ts → searchProvider/openSearch.d.ts} +5 -5
- package/dist/cjs/services/{openSearch.js → searchProvider/openSearch.js} +3 -3
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/searchProvider/memorySearchTheBadWay.d.ts +4 -2
- package/dist/esm/services/searchProvider/memorySearchTheBadWay.js +2 -2
- package/dist/esm/services/{openSearch.d.ts → searchProvider/openSearch.d.ts} +5 -5
- package/dist/esm/services/{openSearch.js → searchProvider/openSearch.js} +3 -3
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/script/bin/.deploy.bash.swp +0 -0
- package/script/bin/.init-params-script.bash.swp +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { IndexOptions, SearchOptions } from '.';
|
|
2
|
-
export declare const memorySearchTheBadWay: <T>({
|
|
3
|
-
|
|
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>;
|
|
@@ -10,13 +10,13 @@ var MatchType;
|
|
|
10
10
|
MatchType[MatchType["Should"] = 2] = "Should";
|
|
11
11
|
})(MatchType || (MatchType = {}));
|
|
12
12
|
const resolveField = (document, field) => field.key.toString().split('.').reduce((result, key) => result[key], document);
|
|
13
|
-
export const memorySearchTheBadWay = ({
|
|
13
|
+
export const memorySearchTheBadWay = ({ store }) => {
|
|
14
14
|
return {
|
|
15
15
|
ensureIndexCreated: async () => undefined,
|
|
16
16
|
index: async (_options) => undefined,
|
|
17
17
|
search: async (options) => {
|
|
18
18
|
const getFieldType = (field) => { var _a; return (_a = options.fields.find(f => f.key == field.key)) === null || _a === void 0 ? void 0 : _a.type; };
|
|
19
|
-
const results = (await loadAllDocumentsTheBadWay())
|
|
19
|
+
const results = (await store.loadAllDocumentsTheBadWay())
|
|
20
20
|
.map(document => {
|
|
21
21
|
let weight = 0;
|
|
22
22
|
const matchFilters = (filters, matchType) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestBody } from '@opensearch-project/opensearch/lib/Transport';
|
|
2
|
-
import { ConfigProviderForConfig } from '
|
|
3
|
-
import { IndexOptions, SearchOptions } from '
|
|
2
|
+
import { ConfigProviderForConfig } from '../../config';
|
|
3
|
+
import { IndexOptions, SearchOptions } from '.';
|
|
4
4
|
export declare type Config = {
|
|
5
5
|
node: string;
|
|
6
6
|
region: string;
|
|
@@ -13,9 +13,9 @@ export declare type IndexConfig = {
|
|
|
13
13
|
mappings: Record<string, any>;
|
|
14
14
|
pageSize?: number;
|
|
15
15
|
};
|
|
16
|
-
export declare const openSearchService: <
|
|
17
|
-
node: import("
|
|
18
|
-
region: import("
|
|
16
|
+
export declare const openSearchService: <C extends string = "deployed">(initializer?: Initializer<C>) => <T extends RequestBody<Record<string, any>>>(indexConfig: IndexConfig, configProvider: { [key in C]: {
|
|
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>;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { defaultProvider } from '@aws-sdk/credential-provider-node';
|
|
3
3
|
import { Client } from '@opensearch-project/opensearch';
|
|
4
4
|
import { AwsSigv4Signer } from '@opensearch-project/opensearch/aws';
|
|
5
|
-
import { resolveConfigValue } from '
|
|
6
|
-
import { ifDefined, isDefined } from '
|
|
7
|
-
import { once } from '
|
|
5
|
+
import { resolveConfigValue } from '../../config';
|
|
6
|
+
import { ifDefined, isDefined } from '../../guards';
|
|
7
|
+
import { once } from '../../misc/helpers';
|
|
8
8
|
export const openSearchService = (initializer = {}) => (indexConfig, configProvider) => {
|
|
9
9
|
const config = configProvider[ifDefined(initializer.configSpace, 'deployed')];
|
|
10
10
|
const pageSize = indexConfig.pageSize || 10;
|