@constructor-io/constructorio-client-javascript 2.34.2 → 2.34.4

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.
@@ -0,0 +1,85 @@
1
+ import { Nullable } from './index.d';
2
+ import { ConstructorClientOptions, NetworkParameters } from '.';
3
+
4
+ export default Quizzes;
5
+
6
+ export interface QuizzesParameters {
7
+ section?: string;
8
+ answers?: any[];
9
+ versionId?: string;
10
+ }
11
+
12
+ declare class Quizzes {
13
+ constructor(options: ConstructorClientOptions);
14
+
15
+ options: ConstructorClientOptions;
16
+
17
+ getQuizNextQuestion(
18
+ id: string,
19
+ parameters?: QuizzesParameters,
20
+ networkParameters?: NetworkParameters
21
+ ): Promise<NextQuestionResponse>;
22
+
23
+ getQuizResults(
24
+ id: string,
25
+ parameters?: QuizzesParameters,
26
+ networkParameters?: NetworkParameters
27
+ ): Promise<QuizResultsResponse>;
28
+ }
29
+
30
+ /* quizzes results returned from server */
31
+ export interface NextQuestionResponse extends Record<string, any> {
32
+ next_question: Question;
33
+ is_last_question?: boolean;
34
+ version_id?: string;
35
+ }
36
+ export interface QuizResultsResponse extends Record<string, any> {
37
+ result: Partial<QuizResult>;
38
+ version_id?: string;
39
+ }
40
+
41
+ export type Question = SelectQuestion | OpenQuestion | CoverQuestion
42
+
43
+ export interface BaseQuestion extends Record<string, any> {
44
+ id: number;
45
+ title: string;
46
+ description: string;
47
+ cta_text: Nullable<string>;
48
+ images?: Nullable<QuestionImages>;
49
+ }
50
+
51
+ export interface SelectQuestion extends BaseQuestion {
52
+ type: 'single' | 'multiple'
53
+ options: QuestionOption[];
54
+ }
55
+
56
+ export interface OpenQuestion extends BaseQuestion {
57
+ type: 'open'
58
+ inputPlaceholder?: Nullable<string>;
59
+ }
60
+
61
+ export interface CoverQuestion extends BaseQuestion {
62
+ type: 'cover'
63
+ }
64
+
65
+ export interface QuizResult extends Record<string, any> {
66
+ filter_expression: Record<string, any>;
67
+ results_url: string;
68
+ }
69
+
70
+ export interface QuestionOption extends Record<string, any> {
71
+ id: number;
72
+ value: string;
73
+ attribute: Nullable<{
74
+ name: string;
75
+ value: string;
76
+ }>;
77
+ images?: Nullable<QuestionImages>;
78
+ }
79
+
80
+ export interface QuestionImages extends Record<string, any> {
81
+ primary_url?: Nullable<string>;
82
+ primary_alt?: Nullable<string>;
83
+ secondary_url?: Nullable<string>;
84
+ secondary_alt?: Nullable<string>;
85
+ }
@@ -1,77 +1,68 @@
1
- import { ConstructorClientOptions, ErrorData } from "./types";
2
- import EventDispatcher from "./event-dispatcher";
1
+ import { ConstructorClientOptions, NetworkParameters } from '.';
2
+ import EventDispatcher from './event-dispatcher';
3
3
 
4
- /******************
5
- *
6
- * Recommendations
7
- *
8
- *****************/
9
- export = Recommendations;
4
+ export default Recommendations;
10
5
 
11
- interface RecommendationsParameters {
12
- itemIds?: string | string[];
13
- numResults?: number;
14
- section?: string;
15
- term?: string;
16
- filters?: Record<string, any>;
17
- variationsMap?: Record<string, any>;
6
+ export interface RecommendationsParameters {
7
+ itemIds?: string | string[];
8
+ numResults?: number;
9
+ section?: string;
10
+ term?: string;
11
+ filters?: Record<string, any>;
12
+ variationsMap?: Record<string, any>;
18
13
  }
19
14
 
20
15
  declare class Recommendations {
21
- constructor(options: ConstructorClientOptions);
22
- options: ConstructorClientOptions;
23
- eventDispatcher: EventDispatcher;
16
+ constructor(options: ConstructorClientOptions);
24
17
 
25
- getRecommendations(
26
- podId: string,
27
- parameters?: RecommendationsParameters,
28
- networkParameters?: {
29
- timeout?: number;
30
- }
31
- ): Promise<Recommendations.RecommendationsResponse>;
18
+ options: ConstructorClientOptions;
19
+
20
+ eventDispatcher: EventDispatcher;
21
+
22
+ getRecommendations(
23
+ podId: string,
24
+ parameters?: RecommendationsParameters,
25
+ networkParameters?: NetworkParameters
26
+ ): Promise<RecommendationsResponse>;
32
27
  }
33
28
 
34
- /***********
35
- *
36
- * Recommendations results returned from server
37
- *
38
- ***********/
39
- declare namespace Recommendations {
40
- export interface RecommendationsResponse extends Record<string, any> {
41
- request: Partial<Request>;
42
- response: Partial<Response>;
43
- result_id: string;
44
- }
29
+ /** *********
30
+ * Recommendations results returned from server
31
+ ********** */
32
+ export interface RecommendationsResponse extends Record<string, any> {
33
+ request: Partial<RecommendationsRequestType>;
34
+ response: Partial<RecommendationsResponseType>;
35
+ result_id: string;
45
36
  }
46
37
 
47
- interface Request extends Record<string, any> {
48
- num_results: number;
49
- item_id: string;
50
- filters: {
51
- group_id: string;
52
- [key: string]: any;
53
- };
54
- pod_id: string;
38
+ export interface RecommendationsRequestType extends Record<string, any> {
39
+ num_results: number;
40
+ item_id: string;
41
+ filters: {
42
+ group_id: string;
43
+ [key: string]: any;
44
+ };
45
+ pod_id: string;
55
46
  }
56
47
 
57
- interface Response extends Record<string, any> {
58
- results: Partial<Result>;
59
- total_num_results: number;
60
- pod: {
61
- id:string;
62
- display_name: string;
63
- [key: string]: any;
64
- };
48
+ export interface RecommendationsResponseType extends Record<string, any> {
49
+ results: Partial<RecommendationsResultType>;
50
+ total_num_results: number;
51
+ pod: {
52
+ id: string;
53
+ display_name: string;
54
+ [key: string]: any;
55
+ };
65
56
  }
66
57
 
67
- interface Result extends Record<string, any> {
68
- matched_terms: string[];
69
- data: Record<string, any>;
70
- value: string;
71
- is_slotted: boolean;
72
- labels: Record<string, any>;
73
- strategy: {
74
- id: string;
75
- [key: string]: any;
76
- };
77
- }
58
+ export interface RecommendationsResultType extends Record<string, any> {
59
+ matched_terms: string[];
60
+ data: Record<string, any>;
61
+ value: string;
62
+ is_slotted: boolean;
63
+ labels: Record<string, any>;
64
+ strategy: {
65
+ id: string;
66
+ [key: string]: any;
67
+ };
68
+ }
@@ -1,109 +1,103 @@
1
1
  import {
2
- ConstructorClientOptions,
3
- ErrorData,
4
- Facet,
5
- Feature,
6
- FmtOption,
7
- Group,
8
- RequestFeature,
9
- RequestFeatureVariant,
10
- ResultSources,
11
- SortOption,
12
- } from "./types";
13
- import EventDispatcher from "./event-dispatcher";
2
+ ConstructorClientOptions,
3
+ Facet,
4
+ Feature,
5
+ FilterExpression,
6
+ FmtOption,
7
+ Group,
8
+ NetworkParameters,
9
+ RequestFeature,
10
+ RequestFeatureVariant,
11
+ ResultSources,
12
+ SortOption,
13
+ } from '.';
14
+ import EventDispatcher from './event-dispatcher';
14
15
 
15
- /***********
16
- *
17
- * SEARCH
18
- *
19
- ***********/
16
+ export default Search;
20
17
 
21
- export = Search;
22
-
23
- interface SearchParameters {
24
- page?: number;
25
- resultsPerPage?: number;
26
- filters?: Record<string, any>;
27
- sortBy?: string;
28
- sortOrder?: string;
29
- section?: string;
30
- fmtOptions?: Record<string, any>;
31
- hiddenFields?: string[];
32
- hiddenFacets?: string[];
33
- variationsMap?: Record<string, any>;
18
+ export interface SearchParameters {
19
+ page?: number;
20
+ offset?: number;
21
+ resultsPerPage?: number;
22
+ filters?: Record<string, any>;
23
+ sortBy?: string;
24
+ sortOrder?: string;
25
+ section?: string;
26
+ fmtOptions?: Record<string, any>;
27
+ preFilterExpression: FilterExpression;
28
+ hiddenFields?: string[];
29
+ hiddenFacets?: string[];
30
+ variationsMap?: Record<string, any>;
34
31
  }
35
32
  declare class Search {
36
- constructor(options: ConstructorClientOptions);
37
- options: ConstructorClientOptions;
38
- eventDispatcher: EventDispatcher;
39
- getSearchResults(
40
- query: string,
41
- parameters?: SearchParameters,
42
- networkParameters?: {
43
- timeout?: number;
44
- }
45
- ): Promise<Search.SearchResponse>;
33
+ constructor(options: ConstructorClientOptions);
34
+
35
+ options: ConstructorClientOptions;
36
+
37
+ eventDispatcher: EventDispatcher;
38
+
39
+ getSearchResults(
40
+ query: string,
41
+ parameters?: SearchParameters,
42
+ networkParameters?: NetworkParameters
43
+ ): Promise<SearchResponse>;
46
44
  }
47
45
 
48
- /***********
49
- *
50
- * search results returned from server
51
- *
52
- ***********/
53
- interface Response extends Record<string, any> {
54
- result_sources: Partial<ResultSources>;
55
- facets: Partial<Facet>[];
56
- groups: Partial<Group>[];
57
- results: Partial<Result>[];
58
- sort_options: Partial<SortOption>[];
59
- refined_content: Record<string, any>[];
60
- total_num_results: number;
61
- features: Partial<Feature>[];
46
+ /** *********
47
+ * search results returned from server
48
+ ********** */
49
+ export interface SearchResponse {
50
+ request: Partial<SearchRequestType>;
51
+ response: Partial<SearchResponseType | Redirect>;
52
+ result_id: string;
62
53
  }
63
54
 
64
- interface Request extends Record<string, any> {
65
- page: number;
66
- num_results_per_page: number;
67
- section: string;
68
- blacklist_rules: boolean;
69
- term: string;
70
- fmt_options: Partial<FmtOption>;
71
- sort_by: string;
72
- sort_order: string;
73
- features: Partial<RequestFeature>;
74
- feature_variants: Partial<RequestFeatureVariant>;
75
- searchandized_items: Record<string, any>;
55
+ export interface SearchResponseType extends Record<string, any> {
56
+ result_sources: Partial<ResultSources>;
57
+ facets: Partial<Facet>[];
58
+ groups: Partial<Group>[];
59
+ results: Partial<Result>[];
60
+ sort_options: Partial<SortOption>[];
61
+ refined_content: Record<string, any>[];
62
+ total_num_results: number;
63
+ features: Partial<Feature>[];
76
64
  }
77
65
 
78
- interface Result extends Record<string, any> {
79
- matched_terms: string[];
80
- data: {
81
- id: string;
82
- [key: string]: any;
83
- };
84
- value: string;
85
- is_slotted: false;
86
- labels: Record<string, any>;
87
- variations: Record<string, any>[];
66
+ export interface SearchRequestType extends Record<string, any> {
67
+ page: number;
68
+ num_results_per_page: number;
69
+ section: string;
70
+ blacklist_rules: boolean;
71
+ term: string;
72
+ fmt_options: Partial<FmtOption>;
73
+ sort_by: string;
74
+ sort_order: string;
75
+ features: Partial<RequestFeature>;
76
+ feature_variants: Partial<RequestFeatureVariant>;
77
+ searchandized_items: Record<string, any>;
88
78
  }
89
79
 
90
- declare namespace Search {
91
- export interface SearchResponse {
92
- request: Partial<Request>;
93
- response: Partial<Response | Redirect>;
94
- result_id: string;
95
- }
80
+ export interface Result extends Record<string, any> {
81
+ matched_terms: string[];
82
+ data: {
83
+ id: string;
84
+ [key: string]: any;
85
+ };
86
+ value: string;
87
+ is_slotted: false;
88
+ labels: Record<string, any>;
89
+ variations: Record<string, any>[];
96
90
  }
97
91
 
98
- interface Redirect extends Record<string, any> {
99
- redirect: {
100
- data: {
101
- match_id: number;
102
- rule_id: number;
103
- url: string;
104
- [key: string]: any;
105
- };
106
- matched_terms: string[];
107
- matched_user_segments: string[];
108
- }
92
+ export interface Redirect extends Record<string, any> {
93
+ redirect: {
94
+ data: {
95
+ match_id: number;
96
+ rule_id: number;
97
+ url: string;
98
+ [key: string]: any;
99
+ };
100
+ matched_terms: string[];
101
+ matched_user_segments: string[];
102
+ };
109
103
  }