@zengenti/contensis-react-base 3.0.0-beta.35 → 3.0.0-beta.39

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] */
@@ -48,6 +50,8 @@ export declare type SearchFilter = {
48
50
  contentTypeId?: string | string[];
49
51
  /** An array of CustomWhereClause to include in the search query when dynamically loading entries via the contentTypeId key */
50
52
  customWhere?: CustomWhereClause;
53
+ /** Use this to set a specific value to render for the initial / unselected option in this filter */
54
+ defaultValue?: string;
51
55
  /** The content type field we will apply the filter key to, to filter the list of returned results. */
52
56
  fieldId: string | string[];
53
57
  /** The Delivery API search operator we will use to filter the list of returned results. */
@@ -147,7 +151,7 @@ export declare type WeightedSearchField = {
147
151
  export declare type SearchConfig = {
148
152
  /** An object with a key for each facet that is required for the search */
149
153
  facets: {
150
- [key: string]: Facet;
154
+ [key: string]: SearchFacet;
151
155
  };
152
156
  /** An object with a key for each independent listing that is required for the site */
153
157
  listings?: {
@@ -161,28 +165,55 @@ export declare type SearchConfig = {
161
165
  tabs: Tab[];
162
166
  };
163
167
  export declare type ConfigTypes = {
164
- [key: string]: Facet;
168
+ [key: string]: SearchFacet;
165
169
  } | {
166
170
  [key: string]: Listing;
167
171
  };
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
- };
172
+ /**
173
+ * Type your mapper for mapping API responses (entries) into usable props for your components to render
174
+ */
175
+ export declare type SearchResultsMapper<Target = any, Source = Entry> = (entries: Source[], facet?: string, context?: Context, state?: AppState) => Target[];
176
+ /**
177
+ * Type your custom filter item mapping function with this to ensure correctly typed FilterItems are returned to work with search functions
178
+ */
179
+ export declare type FilterItemsMapper<T = Entry> = (entries: T[]) => FilterItem[];
180
+ /**
181
+ * The uri object type we need to return from the Navigate mapper after any search action has been called
182
+ */
183
183
  export declare type NavigateUri = {
184
184
  path: string;
185
185
  search: string;
186
186
  hash: string;
187
187
  };
188
+ /**
189
+ * Type your jsonpath-mapper mapping template with this to map your next search uri to your custom uri structure after calling any search action
190
+ */
191
+ export declare type SearchUriMapping = MappingTemplate<SearchStateParams>;
192
+ /**
193
+ * 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
194
+ */
195
+ export declare type SearchStateParams = {
196
+ state: AppState;
197
+ facet?: string;
198
+ orderBy?: string;
199
+ pageIndex: number;
200
+ term?: string;
201
+ };
202
+ /** 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 */
203
+ export declare type NavigateMapper = ({ state, facet, orderBy, pageIndex, term, }: SearchStateParams) => NavigateUri;
204
+ /** 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 */
205
+ export declare type ResultsInfoMapper<T = any> = (state: AppState) => T;
206
+ /** 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 */
207
+ export declare type CustomApiParamsMapper = (queryParams: QueryParams) => {
208
+ [key: string]: string;
209
+ };
210
+ /** Type your Mappers object with this type to provide a accurate, type-safe "mapper" argument to your search implementation */
211
+ export declare type Mappers = {
212
+ customApi?: CustomApiParamsMapper;
213
+ results: SearchResultsMapper;
214
+ filterItems?: FilterItemsMapper;
215
+ navigate?: NavigateMapper;
216
+ resultsInfo?: ResultsInfoMapper;
217
+ };
218
+ /** SearchTransformations is just an alias for Mappers object / argument */
188
219
  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,6 +1,6 @@
1
1
  import { Context } from './Enums';
2
2
  import { CustomWhereClause } from './Search';
3
- export declare type AppState = Record<'search', SearchState>;
3
+ export declare type AppState = Record<'search', SearchState> & Record<string, any>;
4
4
  export declare type SearchState = {
5
5
  context: keyof typeof Context;
6
6
  currentFacet: string;
@@ -58,6 +58,7 @@ export declare type Filters = {
58
58
  export declare type Filter = {
59
59
  contentTypeId?: string;
60
60
  customWhere?: CustomWhereClause;
61
+ defaultValue?: string;
61
62
  fieldId?: string;
62
63
  isGrouped?: boolean;
63
64
  isSingleSelect?: boolean;
@@ -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;
@@ -40,6 +41,7 @@ declare const _default: (config: SearchConfig) => <Base extends {
40
41
  readonly field: string;
41
42
  }[];
42
43
  })[] | undefined;
44
+ readonly defaultValue?: string | undefined;
43
45
  readonly fieldId?: string | undefined;
44
46
  readonly isGrouped?: boolean | undefined;
45
47
  readonly isSingleSelect?: boolean | undefined;
@@ -118,6 +120,7 @@ declare const _default: (config: SearchConfig) => <Base extends {
118
120
  readonly field: string;
119
121
  }[];
120
122
  })[] | undefined;
123
+ readonly defaultValue?: string | undefined;
121
124
  readonly fieldId?: string | undefined;
122
125
  readonly isGrouped?: boolean | undefined;
123
126
  readonly isSingleSelect?: boolean | undefined;
@@ -196,6 +199,7 @@ declare const _default: (config: SearchConfig) => <Base extends {
196
199
  readonly field: string;
197
200
  }[];
198
201
  })[] | undefined;
202
+ readonly defaultValue?: string | undefined;
199
203
  readonly fieldId?: string | undefined;
200
204
  readonly isGrouped?: boolean | undefined;
201
205
  readonly isSingleSelect?: boolean | undefined;
@@ -256,5 +260,5 @@ declare const _default: (config: SearchConfig) => <Base extends {
256
260
  params: {
257
261
  [key: string]: string;
258
262
  };
259
- }) => Base;
263
+ }) => import("immer/dist/internal").WritableDraft<SearchState> | Base;
260
264
  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.35",
3
+ "version": "3.0.0-beta.39",
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#bd4af6a041a2a092d522cb9f79eef147056e6887",
14009
+ "version": "git+https://gitlab+deploy-token-5:XKRGRE1p2PrFAxnWwLNz@gitlab.zengenti.com/zengenti-packages/search.git#906b7d37b112ab4ff462907650c9784ada7af5ff",
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.35",
3
+ "version": "3.0.0-beta.39",
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.",