@zengenti/contensis-react-base 3.0.0-beta.36 → 3.0.0-beta.37

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,3 +1,5 @@
1
+ import { Entry } from 'contensis-delivery-api/lib/models';
2
+ import MappingTemplate from 'jsonpath-mapper/dist/models/Template';
1
3
  import { Context } from './Enums';
2
4
  import { FieldOperators, LogicOperators } from './Queries';
3
5
  import { AppState } from './SearchState';
@@ -32,7 +34,7 @@ export declare type Listing = {
32
34
  /** Display title */
33
35
  title?: string;
34
36
  };
35
- export declare type Facet = {
37
+ export declare type SearchFacet = {
36
38
  /** The first facet to be shown if no facet is supplied via a route parameter [default false] */
37
39
  isDefault?: boolean;
38
40
  /** Set to true to temporarily disable the facet [default false] */
@@ -147,7 +149,7 @@ export declare type WeightedSearchField = {
147
149
  export declare type SearchConfig = {
148
150
  /** An object with a key for each facet that is required for the search */
149
151
  facets: {
150
- [key: string]: Facet;
152
+ [key: string]: SearchFacet;
151
153
  };
152
154
  /** An object with a key for each independent listing that is required for the site */
153
155
  listings?: {
@@ -161,28 +163,55 @@ export declare type SearchConfig = {
161
163
  tabs: Tab[];
162
164
  };
163
165
  export declare type ConfigTypes = {
164
- [key: string]: Facet;
166
+ [key: string]: SearchFacet;
165
167
  } | {
166
168
  [key: string]: Listing;
167
169
  };
168
- export declare type Mappers = {
169
- customApi?: (queryParams: QueryParams) => {
170
- [key: string]: string;
171
- };
172
- results: (entries: any[], facet?: string, context?: Context, state?: AppState) => any[];
173
- filterItems?: (entries: any[]) => any[];
174
- navigate?: ({ state, facet, orderBy, pageIndex, term, }: {
175
- state: AppState;
176
- facet?: string;
177
- orderBy?: string;
178
- pageIndex: number;
179
- term?: string;
180
- }) => NavigateUri;
181
- resultsInfo?: (state: AppState) => any;
182
- };
170
+ /**
171
+ * Type your mapper for mapping API responses (entries) into usable props for your components to render
172
+ */
173
+ export declare type SearchResultsMapper<Target = any, Source = Entry> = (entries: Source[], facet?: string, context?: Context, state?: AppState) => Target[];
174
+ /**
175
+ * Type your custom filter item mapping function with this to ensure correctly typed FilterItems are returned to work with search functions
176
+ */
177
+ export declare type FilterItemsMapper<T = Entry> = (entries: T[]) => FilterItem[];
178
+ /**
179
+ * The uri object type we need to return from the Navigate mapper after any search action has been called
180
+ */
183
181
  export declare type NavigateUri = {
184
182
  path: string;
185
183
  search: string;
186
184
  hash: string;
187
185
  };
186
+ /**
187
+ * Type your jsonpath-mapper mapping template with this to map your next search uri to your custom uri structure after calling any search action
188
+ */
189
+ export declare type SearchUriMapping = MappingTemplate<SearchStateParams>;
190
+ /**
191
+ * Type the argument passed to the Navigate mapper, this provides the relevant keys and data available to manipulate and return the next uri after any search action has been called
192
+ */
193
+ export declare type SearchStateParams = {
194
+ state: AppState;
195
+ facet?: string;
196
+ orderBy?: string;
197
+ pageIndex: number;
198
+ term?: string;
199
+ };
200
+ /** Type your Navigate mapper with this, the Navigate mapper is called after any search action has been called and is required to return the next uri to be parsed by your project's route configuration and provide the right uri parameters to drive the next search query and resulting state */
201
+ export declare type NavigateMapper = ({ state, facet, orderBy, pageIndex, term, }: SearchStateParams) => NavigateUri;
202
+ /** Type your Results Info mapper with this, remember "resultsInfo" prop is a custom object you define yourself - you can provide any keys you wish, conveying detailed messaging or UX tweaks to cover all kinds of scenarios based on data in the search state at that time */
203
+ export declare type ResultsInfoMapper<T = any> = (state: AppState) => T;
204
+ /** Experimental**: If you are trying to use the custom API feature you can add specific keys to the resultant querystring that for the custom API GET request */
205
+ export declare type CustomApiParamsMapper = (queryParams: QueryParams) => {
206
+ [key: string]: string;
207
+ };
208
+ /** Type your Mappers object with this type to provide a accurate, type-safe "mapper" argument to your search implementation */
209
+ export declare type Mappers = {
210
+ customApi?: CustomApiParamsMapper;
211
+ results: SearchResultsMapper;
212
+ filterItems?: FilterItemsMapper;
213
+ navigate?: NavigateMapper;
214
+ resultsInfo?: ResultsInfoMapper;
215
+ };
216
+ /** SearchTransformations is just an alias for Mappers object / argument */
188
217
  export declare type SearchTransformations = Mappers;
@@ -1,7 +1,7 @@
1
1
  import { PagedList } from 'contensis-core-api';
2
2
  import { Entry, TaxonomyNode } from 'contensis-delivery-api/lib/models';
3
3
  import { Context } from '../models/Enums';
4
- import { Facet, Listing, Mappers } from '../models/Search';
4
+ import { SearchFacet, Listing, Mappers } from '../models/Search';
5
5
  import { AppState } from './SearchState';
6
6
  import { QueryParams } from './Queries';
7
7
  import { TimedSearchResponse } from './SearchUtil';
@@ -16,7 +16,7 @@ export declare type DebugFlags = boolean | {
16
16
  preloadOtherFacets?: boolean;
17
17
  };
18
18
  export declare type TriggerSearchParams = {
19
- config?: Facet | Listing;
19
+ config?: SearchFacet | Listing;
20
20
  context: Context;
21
21
  debug?: DebugFlags;
22
22
  defaultLang?: string;
@@ -87,7 +87,7 @@ export declare type SetSearchEntriesParams = {
87
87
  defaultLang: string;
88
88
  facet: string;
89
89
  mappers: Mappers;
90
- nextFacet: Facet;
90
+ nextFacet: SearchFacet;
91
91
  preload: boolean;
92
92
  ogState: AppState;
93
93
  debug: DebugFlags;
@@ -1,5 +1,5 @@
1
1
  import { clearFilters, updateCurrentFacet, updateCurrentTab, updatePageIndex, updateSearchTerm, updateSelectedFilters, updateSortOrder } from '../redux/actions';
2
- import { Facet, Mappers } from '../models/Search';
2
+ import { SearchFacet, Mappers } from '../models/Search';
3
3
  import { DebugFlags } from '../models/SearchActions';
4
4
  import { Facet as StateFacet, Facets, Filters, Paging } from '../models/SearchState';
5
5
  export interface ListingProps<SearchResults = any> {
@@ -47,7 +47,7 @@ export interface SearchProps<SearchResults = any> {
47
47
  }
48
48
  export interface UseMinilistProps {
49
49
  id: string;
50
- config?: Facet;
50
+ config?: SearchFacet;
51
51
  debug?: DebugFlags;
52
52
  defaultLang?: string;
53
53
  excludeIds?: string[];
@@ -1,4 +1,4 @@
1
- export type { CustomApi, CustomWhereClause, Facet as SearchFacet, FeaturedResults, FilterItem, Listing, NavigateUri, QueryParams, SearchConfig, SearchFilter, SearchFilters, SearchTransformations, Tab, WeightedSearchField, } from './Search';
1
+ export * from './Search';
2
2
  export type { SetRouteFiltersOptions } from './SearchActions';
3
3
  export * from './SearchProps';
4
4
  export type { Facet, Filter, Filters, SearchState } from './SearchState';
@@ -1,5 +1,6 @@
1
1
  import { SearchConfig } from '../models/Search';
2
2
  import { Context } from '../models/Enums';
3
+ import { SearchState } from '../models/SearchState';
3
4
  declare const _default: (config: SearchConfig) => <Base extends {
4
5
  readonly context: "facets" | "listings" | "minilist";
5
6
  readonly currentFacet: string;
@@ -256,5 +257,5 @@ declare const _default: (config: SearchConfig) => <Base extends {
256
257
  params: {
257
258
  [key: string]: string;
258
259
  };
259
- }) => Base;
260
+ }) => import("immer/dist/internal").WritableDraft<SearchState> | Base;
260
261
  export default _default;
@@ -1,4 +1,4 @@
1
- import { AppState } from '../models/SearchState';
1
+ import { Entry } from 'contensis-delivery-api/lib/models';
2
2
  import { InitListingAction, SetRouteFiltersOptions, TriggerSearchAction } from '../models/SearchActions';
3
3
  import { Mappers } from '../models/Search';
4
4
  import { Context } from '../models/Enums';
@@ -6,13 +6,13 @@ export declare const searchSagas: import("redux-saga/effects").ForkEffect<never>
6
6
  export declare function setRouteFilters(action: InitListingAction | SetRouteFiltersOptions): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<InitListingAction> | import("redux-saga/effects").CallEffect<void>, void, any>;
7
7
  export declare function doSearch(action: TriggerSearchAction): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<{
8
8
  type: string;
9
- config?: import("../models/Search").Listing | import("../models/Search").Facet | undefined;
9
+ config?: import("../models/Search").Listing | import("../models/Search").SearchFacet | undefined;
10
10
  context: Context;
11
11
  debug?: import("../models/SearchActions").DebugFlags | undefined;
12
12
  defaultLang?: string | undefined;
13
13
  excludeIds?: string[] | undefined;
14
14
  facet: string;
15
- mapper?: ((entries: any[], facet?: string | undefined, context?: Context | undefined, state?: AppState | undefined) => any[]) | undefined;
15
+ mapper?: import("../models/Search").SearchResultsMapper<any, Entry> | undefined;
16
16
  mappers?: Mappers | undefined;
17
17
  params?: {
18
18
  [key: string]: string;
@@ -1,2 +1,3 @@
1
+ import { FilterItemsMapper } from '../models/Search';
2
+ declare const mapEntriesToFilterItems: FilterItemsMapper;
1
3
  export default mapEntriesToFilterItems;
2
- declare function mapEntriesToFilterItems(entries: any): any;
@@ -1,14 +1,3 @@
1
- import { AppState } from '../models/SearchState';
2
- declare type SearchStateParams = {
3
- state: AppState;
4
- facet?: string;
5
- orderBy?: string;
6
- pageIndex: number;
7
- term?: string;
8
- };
9
- declare const mapStateToSearchUri: (params: SearchStateParams) => {
10
- path: Location['pathname'];
11
- search: Location['search'];
12
- hash: Location['hash'];
13
- };
1
+ import { NavigateMapper } from '../models/Search';
2
+ declare const mapStateToSearchUri: NavigateMapper;
14
3
  export default mapStateToSearchUri;
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zengenti/contensis-react-base",
3
- "version": "3.0.0-beta.36",
3
+ "version": "3.0.0-beta.37",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -14006,7 +14006,7 @@
14006
14006
  }
14007
14007
  },
14008
14008
  "zengenti-search-package": {
14009
- "version": "git+https://gitlab+deploy-token-5:XKRGRE1p2PrFAxnWwLNz@gitlab.zengenti.com/zengenti-packages/search.git#a8e1089b388e9e3f84673adf283c45178f6b354f",
14009
+ "version": "git+https://gitlab+deploy-token-5:XKRGRE1p2PrFAxnWwLNz@gitlab.zengenti.com/zengenti-packages/search.git#6e058fca27cde2a766df1cc359b8d99754d731a5",
14010
14010
  "from": "git+https://gitlab+deploy-token-5:XKRGRE1p2PrFAxnWwLNz@gitlab.zengenti.com/zengenti-packages/search.git#immer",
14011
14011
  "dev": true,
14012
14012
  "requires": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zengenti/contensis-react-base",
3
- "version": "3.0.0-beta.36",
3
+ "version": "3.0.0-beta.37",
4
4
  "repository": "https://github.com/zengenti/contensis-react-base",
5
5
  "license": "None",
6
6
  "description": "Turbocharge your React web apps with Contensis. This package handles all dependencies for creating full featured web apps in React with Contensis and Site View. Routing is driven by Site View, Redux is used for global state management and server-side rendering (SSR) is handled for you. Also taking care of intricate hosting issues such as cache invalidation and supporting authenticated content where required.",