@constructor-io/constructorio-client-javascript 2.34.1 → 2.34.3

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,154 @@
1
+ import EventDispatcher from './event-dispatcher';
2
+
3
+ export * from './search';
4
+ export * from './autocomplete';
5
+ export * from './quizzes';
6
+ export * from './recommendations';
7
+ export * from './browse';
8
+ export * from './tracker';
9
+ export * from './event-dispatcher';
10
+
11
+ export interface NetworkParameters extends Record<string, any> {
12
+ timeout?: number;
13
+ }
14
+
15
+ export interface IdOptions extends Record<string, any> {
16
+ base_url?: string;
17
+ ip_address?: string;
18
+ user_agent?: string;
19
+ timeout?: number;
20
+ persist?: boolean;
21
+ cookie_name_client_id?: string;
22
+ cookie_name_session_id?: string;
23
+ cookie_name_session_data?: string;
24
+ local_name_client_id?: string;
25
+ local_name_session_id?: string;
26
+ local_name_session_data?: string;
27
+ cookie_prefix_for_experiment?: string;
28
+ cookie_domain?: string;
29
+ cookie_days_to_live?: number;
30
+ on_node?: boolean;
31
+ session_is_new?: boolean;
32
+ client_id_storage_location?: string;
33
+ session_id_storage_location?: string;
34
+ }
35
+
36
+ export interface ConstructorClientOptions {
37
+ apiKey: string;
38
+ version?: string;
39
+ serviceUrl?: string;
40
+ sessionId?: string;
41
+ clientId?: string;
42
+ userId?: string;
43
+ segments?: string[];
44
+ testCells?: Record<string, string>;
45
+ idOptions?: IdOptions;
46
+ fetch?: any;
47
+ trackingSendDelay?: number;
48
+ sendTrackingEvents?: boolean;
49
+ sendReferrerWithTrackingEvents?: boolean;
50
+ eventDispatcher?: EventDispatcher;
51
+ beaconMode?: boolean;
52
+ networkParameters?: NetworkParameters;
53
+ }
54
+
55
+ export interface RequestFeature extends Record<string, any> {
56
+ query_items: boolean;
57
+ auto_generated_refined_query_rules: boolean;
58
+ manual_searchandizing: boolean;
59
+ personalization: boolean;
60
+ filter_items: boolean;
61
+ }
62
+
63
+ export interface RequestFeatureVariant extends Record<string, any> {
64
+ query_items: string;
65
+ auto_generated_refined_query_rules: string;
66
+ manual_searchandizing: string | null;
67
+ personalization: string;
68
+ filter_items: string;
69
+ }
70
+
71
+ export type ErrorData = {
72
+ message: string;
73
+ [key: string]: any;
74
+ };
75
+
76
+ export interface ResultSources extends Record<string, any> {
77
+ token_match: { count: number; [key: string]: any };
78
+ embeddings_match: { count: number; [key: string]: any };
79
+ }
80
+
81
+ export interface SortOption extends Record<string, any> {
82
+ sort_by: string;
83
+ display_name: string;
84
+ sort_order: string;
85
+ status: string;
86
+ }
87
+
88
+ export interface Feature extends Record<string, any> {
89
+ feature_name: string;
90
+ display_name: string;
91
+ enabled: boolean;
92
+ variant: {
93
+ name: string;
94
+ display_name: string;
95
+ [key: string]: any;
96
+ };
97
+ }
98
+
99
+ export interface FmtOption extends Record<string, any> {
100
+ groups_start: string;
101
+ groups_max_depth: number;
102
+ }
103
+
104
+ export type Facet = RangeFacet | OptionFacet;
105
+
106
+ export interface BaseFacet extends Record<string, any> {
107
+ data: Record<string, any>;
108
+ status: Record<string, any>;
109
+ display_name: string;
110
+ name: string;
111
+ hidden: boolean;
112
+ }
113
+
114
+ export interface RangeFacet extends BaseFacet, Record<string, any> {
115
+ max: number;
116
+ min: number;
117
+ type: 'range';
118
+ }
119
+
120
+ export interface OptionFacet extends BaseFacet, Record<string, any> {
121
+ options: FacetOption[];
122
+ type: 'multiple' | 'single' | 'hierarchical';
123
+ }
124
+
125
+ export interface FacetOption extends Record<string, any> {
126
+ count: number;
127
+ display_name: string;
128
+ value: string;
129
+ options?: FacetOption[];
130
+ range?: ['-inf' | number, 'inf' | number];
131
+ status: string;
132
+ }
133
+
134
+ export interface Group extends BaseGroup, Record<string, any> {
135
+ count: number;
136
+ data: Record<string, any>;
137
+ parents: BaseGroup[];
138
+ children: Group[];
139
+ }
140
+
141
+ export interface Collection extends Record<string, any> {
142
+ collection_id: string;
143
+ display_name: string;
144
+ data: Record<string, any>;
145
+ }
146
+
147
+ export interface BaseGroup extends Record<string, any> {
148
+ display_name: string;
149
+ group_id: string;
150
+ }
151
+
152
+ export interface FmtOptions extends Record<string, any> {}
153
+
154
+ export type Nullable<T> = T | null;
@@ -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,101 @@
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
+ FmtOption,
6
+ Group,
7
+ NetworkParameters,
8
+ RequestFeature,
9
+ RequestFeatureVariant,
10
+ ResultSources,
11
+ SortOption,
12
+ } from '.';
13
+ import EventDispatcher from './event-dispatcher';
14
14
 
15
- /***********
16
- *
17
- * SEARCH
18
- *
19
- ***********/
15
+ export default Search;
20
16
 
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>;
17
+ export interface SearchParameters {
18
+ page?: number;
19
+ offset?: number;
20
+ resultsPerPage?: number;
21
+ filters?: Record<string, any>;
22
+ sortBy?: string;
23
+ sortOrder?: string;
24
+ section?: string;
25
+ fmtOptions?: Record<string, any>;
26
+ hiddenFields?: string[];
27
+ hiddenFacets?: string[];
28
+ variationsMap?: Record<string, any>;
34
29
  }
35
30
  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>;
31
+ constructor(options: ConstructorClientOptions);
32
+
33
+ options: ConstructorClientOptions;
34
+
35
+ eventDispatcher: EventDispatcher;
36
+
37
+ getSearchResults(
38
+ query: string,
39
+ parameters?: SearchParameters,
40
+ networkParameters?: NetworkParameters
41
+ ): Promise<SearchResponse>;
46
42
  }
47
43
 
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>[];
44
+ /** *********
45
+ * search results returned from server
46
+ ********** */
47
+ export interface SearchResponse {
48
+ request: Partial<SearchRequestType>;
49
+ response: Partial<SearchResponseType | Redirect>;
50
+ result_id: string;
62
51
  }
63
52
 
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>;
53
+ export interface SearchResponseType 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>[];
76
62
  }
77
63
 
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>[];
64
+ export interface SearchRequestType 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>;
88
76
  }
89
77
 
90
- declare namespace Search {
91
- export interface SearchResponse {
92
- request: Partial<Request>;
93
- response: Partial<Response | Redirect>;
94
- result_id: string;
95
- }
78
+ export 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>[];
96
88
  }
97
89
 
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
- }
90
+ export interface Redirect extends Record<string, any> {
91
+ redirect: {
92
+ data: {
93
+ match_id: number;
94
+ rule_id: number;
95
+ url: string;
96
+ [key: string]: any;
97
+ };
98
+ matched_terms: string[];
99
+ matched_user_segments: string[];
100
+ };
109
101
  }