@openstax/ts-utils 1.1.42 → 1.1.43

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.
@@ -10,6 +10,10 @@ declare type Field = {
10
10
  key: string;
11
11
  type: 'keyword';
12
12
  };
13
+ export interface IndexOptions<T> {
14
+ body: T;
15
+ id: string;
16
+ }
13
17
  export interface SearchOptions {
14
18
  page?: number;
15
19
  query: string | undefined;
@@ -1,7 +1,8 @@
1
- import { SearchOptions } from '.';
1
+ import { IndexOptions, SearchOptions } from '.';
2
2
  export declare const memorySearchTheBadWay: <T>({ loadAllDocumentsTheBadWay }: {
3
3
  loadAllDocumentsTheBadWay: () => Promise<T[]>;
4
4
  }) => {
5
+ index: (_options: IndexOptions<T>) => Promise<undefined>;
5
6
  search: (options: SearchOptions) => Promise<{
6
7
  items: T[];
7
8
  pageSize: number;
@@ -5,6 +5,7 @@ const MAX_RESULTS = 10;
5
5
  const resolveField = (document, field) => field.key.toString().split('.').reduce((result, key) => result[key], document);
6
6
  export const memorySearchTheBadWay = ({ loadAllDocumentsTheBadWay }) => {
7
7
  return {
8
+ index: async (_options) => undefined,
8
9
  search: async (options) => {
9
10
  const results = (await loadAllDocumentsTheBadWay())
10
11
  .map(document => {