@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.
@@ -119,7 +119,7 @@ var Quizzes = /*#__PURE__*/function () {
119
119
 
120
120
  (0, _createClass2["default"])(Quizzes, [{
121
121
  key: "getQuizNextQuestion",
122
- value: function getQuizNextQuestion(quizId, parameters) {
122
+ value: function getQuizNextQuestion(id, parameters) {
123
123
  var _this = this;
124
124
 
125
125
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -129,7 +129,7 @@ var Quizzes = /*#__PURE__*/function () {
129
129
  var signal = controller.signal;
130
130
 
131
131
  try {
132
- requestUrl = createQuizUrl(quizId, parameters, this.options, 'next');
132
+ requestUrl = createQuizUrl(id, parameters, this.options, 'next');
133
133
  } catch (e) {
134
134
  return Promise.reject(e);
135
135
  } // Handle network timeout if specified
@@ -178,7 +178,7 @@ var Quizzes = /*#__PURE__*/function () {
178
178
 
179
179
  }, {
180
180
  key: "getQuizResults",
181
- value: function getQuizResults(quizId, parameters) {
181
+ value: function getQuizResults(id, parameters) {
182
182
  var _this2 = this;
183
183
 
184
184
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -188,7 +188,7 @@ var Quizzes = /*#__PURE__*/function () {
188
188
  var signal = controller.signal;
189
189
 
190
190
  try {
191
- requestUrl = createQuizUrl(quizId, parameters, this.options, 'finalize');
191
+ requestUrl = createQuizUrl(id, parameters, this.options, 'finalize');
192
192
  } catch (e) {
193
193
  return Promise.reject(e);
194
194
  } // Handle network timeout if specified
@@ -1,67 +1,59 @@
1
1
  import {
2
- ConstructorClientOptions,
3
- RequestFeature,
4
- RequestFeatureVariant,
5
- } from "./types";
6
- import EventDispatcher from "./event-dispatcher";
7
-
8
- /***************
9
- *
10
- * Autocomplete
11
- *
12
- ***************/
13
- export = Autocomplete;
14
-
15
- interface IAutocompleteParameters {
16
- numResults: number;
17
- filters: Record<string, any>;
18
- resultsPerSection: Record<string, number>;
19
- hiddenFields: string[];
20
- variationsMap: Record<string, any>;
2
+ ConstructorClientOptions,
3
+ NetworkParameters,
4
+ RequestFeature,
5
+ RequestFeatureVariant,
6
+ } from '.';
7
+ import EventDispatcher from './event-dispatcher';
8
+
9
+ export default Autocomplete;
10
+
11
+ export interface IAutocompleteParameters {
12
+ numResults?: number;
13
+ filters?: Record<string, any>;
14
+ resultsPerSection?: Record<string, number>;
15
+ hiddenFields?: string[];
16
+ variationsMap?: Record<string, any>;
21
17
  }
22
18
 
23
19
  declare class Autocomplete {
24
- constructor(options: ConstructorClientOptions);
25
- options: ConstructorClientOptions;
26
- eventDispatcher: EventDispatcher;
20
+ constructor(options: ConstructorClientOptions);
21
+
22
+ options: ConstructorClientOptions;
23
+
24
+ eventDispatcher: EventDispatcher;
27
25
 
28
- getAutocompleteResults(
29
- query: string,
30
- parameters?: IAutocompleteParameters,
31
- networkParameters?: {
32
- timeout?: number;
33
- }
34
- ): Promise<Autocomplete.AutocompleteResponse>;
26
+ getAutocompleteResults(
27
+ query: string,
28
+ parameters?: IAutocompleteParameters,
29
+ networkParameters?: NetworkParameters
30
+ ): Promise<AutocompleteResponse>;
35
31
  }
36
32
 
37
- /***********
38
- *
39
- * Autocomplete results returned from server
40
- *
41
- ***********/
42
- declare namespace Autocomplete {
43
- export interface AutocompleteResponse extends Record<string, any> {
44
- request: Partial<Request>;
45
- sections: Record<string, Section>;
46
- result_id: string;
47
- }
33
+ /** *********
34
+ * Autocomplete results returned from server
35
+ ********** */
36
+ export interface AutocompleteResponse extends Record<string, any> {
37
+ request: Partial<AutocompleteRequestType>;
38
+ sections: Record<string, Section>;
39
+ result_id: string;
48
40
  }
49
41
 
50
- interface Request extends Record<string, any> {
51
- num_results: number;
52
- term: string;
53
- query: string;
54
- features: Partial<RequestFeature>;
55
- feature_variants: Partial<RequestFeatureVariant>;
56
- searchandized_items: Record<string, any>;
42
+ export interface AutocompleteRequestType extends Record<string, any> {
43
+ num_results: number;
44
+ term: string;
45
+ query: string;
46
+ features: Partial<RequestFeature>;
47
+ feature_variants: Partial<RequestFeatureVariant>;
48
+ searchandized_items: Record<string, any>;
57
49
  }
58
50
 
59
- type Section = Partial<SectionItem>[]
51
+ export type Section = Partial<SectionItem>[];
60
52
 
61
- interface SectionItem extends Record<string, any> {
62
- data: Record<string, any>;
63
- is_slotted: boolean;
64
- labels: Record<string, any>;
65
- matched_terms: string[];
66
- value: string;
53
+ export interface SectionItem extends Record<string, any> {
54
+ data: Record<string, any>;
55
+ is_slotted: boolean;
56
+ labels: Record<string, any>;
57
+ matched_terms: string[];
58
+ value: string;
67
59
  }
@@ -1,133 +1,141 @@
1
- import { Collection, ConstructorClientOptions, ErrorData, Facet, Feature, Group, RequestFeature, RequestFeatureVariant, ResultSources, SortOption } from "./types";
2
- import EventDispatcher from "./event-dispatcher";
1
+ import {
2
+ Collection,
3
+ ConstructorClientOptions,
4
+ Facet,
5
+ Feature,
6
+ FilterExpression,
7
+ Group,
8
+ NetworkParameters,
9
+ RequestFeature,
10
+ RequestFeatureVariant,
11
+ ResultSources,
12
+ SortOption,
13
+ } from '.';
14
+ import EventDispatcher from './event-dispatcher';
3
15
 
4
- /*********
5
- *
6
- * Browse
7
- *
8
- *********/
9
- export = Browse;
16
+ export default Browse;
10
17
 
11
- interface IBrowseParameters {
12
- page?: number;
13
- offset?: number;
14
- resultsPerPage?: number;
15
- filters?: Record<string, any>;
16
- sortBy?: string;
17
- sortOrder?: string;
18
- section?: string;
19
- fmtOptions?: object;
20
- preFilterExpression: Record<string, any>;
21
- hiddenFields?: string[];
22
- hiddenFacets?: string[];
23
- variationsMap?: Record<string, any>;
24
- qs?: Record<string, any>;
18
+ export interface IBrowseParameters {
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>;
31
+ qs?: Record<string, any>;
25
32
  }
26
33
 
27
34
  declare class Browse {
28
- constructor(options: ConstructorClientOptions);
29
- options: ConstructorClientOptions;
30
- eventDispatcher: EventDispatcher;
35
+ constructor(options: ConstructorClientOptions);
31
36
 
32
- getBrowseResults(
33
- filterName: string,
34
- filterValue: string,
35
- parameters?: IBrowseParameters,
36
- networkParameters?: {
37
- timeout?: number;
38
- }
39
- ): Promise<Browse.GetBrowseResultsResponse>;
37
+ options: ConstructorClientOptions;
40
38
 
41
- getBrowseResultsForItemIds(
42
- itemIds: string[],
43
- parameters?: Omit<IBrowseParameters, "preFilterExpression" | "preFilterExpression">,
44
- networkParameters?: {
45
- timeout?: number;
46
- }
47
- ): Promise<Browse.GetBrowseResultsForItemIdsResponse>;
39
+ eventDispatcher: EventDispatcher;
48
40
 
49
- getBrowseGroups(
50
- parameters: Pick<IBrowseParameters, "filters" | "section" | "fmtOptions">,
51
- networkParameters?: {
52
- timeout?: number;
53
- }
54
- ): Promise<Browse.GetBrowseGroupsResponse>;
41
+ getBrowseResults(
42
+ filterName: string,
43
+ filterValue: string,
44
+ parameters?: IBrowseParameters,
45
+ networkParameters?: NetworkParameters
46
+ ): Promise<GetBrowseResultsResponse>;
55
47
 
56
- getBrowseFacets(
57
- parameters?: Pick<IBrowseParameters, "page" | "offset" | "section" | "fmtOptions"| "resultsPerPage">,
58
- networkParameters?: {
59
- timeout?: number;
60
- }
61
- ): Promise<Browse.GetBrowseFacetsResponse>;
48
+ getBrowseResultsForItemIds(
49
+ itemIds: string[],
50
+ parameters?: Omit<IBrowseParameters, 'preFilterExpression' | 'qs'>,
51
+ networkParameters?: NetworkParameters
52
+ ): Promise<GetBrowseResultsForItemIdsResponse>;
62
53
 
63
- getBrowseFacetOptions(
64
- facetName: string,
65
- parameters?: Pick<IBrowseParameters, "section" | "fmtOptions">,
66
- networkParameters?: {
67
- timeout?: number;
68
- }
69
- ): Promise<Browse.GetBrowseFacetOptionsResponse>;
54
+ getBrowseGroups(
55
+ parameters?: Pick<IBrowseParameters, 'filters' | 'section' | 'fmtOptions'>,
56
+ networkParameters?: NetworkParameters
57
+ ): Promise<GetBrowseGroupsResponse>;
58
+
59
+ getBrowseFacets(
60
+ parameters?: Pick<
61
+ IBrowseParameters,
62
+ 'page' | 'offset' | 'section' | 'fmtOptions' | 'resultsPerPage'
63
+ >,
64
+ networkParameters?: NetworkParameters
65
+ ): Promise<GetBrowseFacetsResponse>;
66
+
67
+ getBrowseFacetOptions(
68
+ facetName: string,
69
+ parameters?: Pick<IBrowseParameters, 'section' | 'fmtOptions'>,
70
+ networkParameters?: NetworkParameters
71
+ ): Promise<GetBrowseFacetOptionsResponse>;
70
72
  }
71
73
 
72
- /***********
73
- *
74
- * Browse results returned from server
75
- *
76
- ***********/
77
- declare namespace Browse {
78
- export type GetBrowseResultsResponse = BrowseResponse<GetBrowseResultsResponseData>;
79
- export type GetBrowseResultsForItemIdsResponse = BrowseResponse<GetBrowseResultsResponseData>;
80
- export type GetBrowseGroupsResponse = BrowseResponse<Pick<GetBrowseResultsResponseData, "result_sources" | "groups" | "refined_content">>;
81
- export type GetBrowseFacetsResponse = BrowseResponse<Pick<GetBrowseResultsResponseData, "facets" | "total_num_results">>;
82
- export type GetBrowseFacetOptionsResponse = BrowseResponse<Pick<GetBrowseResultsResponseData, "facets">>;
74
+ /** *********
75
+ * Browse results returned from server
76
+ ********** */
77
+ export interface BrowseResponse<ResponseType> extends Record<string, any> {
78
+ request?: Partial<BrowseRequestType>;
79
+ response?: Partial<ResponseType>;
80
+ result_id?: string;
81
+ ad_based?: boolean;
83
82
  }
84
83
 
85
- interface BrowseResponse<ResponseType> extends Record<string, any> {
86
- request?: Partial<Request>;
87
- response?: Partial<ResponseType>;
88
- result_id?: string;
89
- ad_based?: boolean;
84
+ export type GetBrowseResultsResponse =
85
+ BrowseResponse<GetBrowseResultsResponseData>;
86
+ export type GetBrowseResultsForItemIdsResponse =
87
+ BrowseResponse<GetBrowseResultsResponseData>;
88
+ export type GetBrowseGroupsResponse = BrowseResponse<
89
+ Pick<
90
+ GetBrowseResultsResponseData,
91
+ 'result_sources' | 'groups' | 'refined_content'
92
+ >
93
+ >;
94
+ export type GetBrowseFacetsResponse = BrowseResponse<
95
+ Pick<GetBrowseResultsResponseData, 'facets' | 'total_num_results'>
96
+ >;
97
+ export type GetBrowseFacetOptionsResponse = BrowseResponse<
98
+ Pick<GetBrowseResultsResponseData, 'facets'>
99
+ >;
90
100
 
101
+ export interface GetBrowseResultsResponseData extends Record<string, any> {
102
+ result_sources: Partial<ResultSources>;
103
+ facets: Partial<Facet>[];
104
+ groups: Partial<Group>[];
105
+ results: Partial<BrowseResultData>[];
106
+ sort_options: Partial<SortOption>[];
107
+ refined_content: Record<string, any>[];
108
+ total_num_results: number;
109
+ features: Partial<Feature>[];
110
+ collection: Partial<Collection>;
91
111
  }
92
112
 
93
- interface GetBrowseResultsResponseData extends Record<string, any> {
94
- result_sources: Partial<ResultSources>;
95
- facets: Partial<Facet>[];
96
- groups: Partial<Group>[];
97
- results: Partial<BrowseResultData>[];
98
- sort_options: Partial<SortOption>[];
99
- refined_content: Record<string, any>[];
100
- total_num_results: number;
101
- features: Partial<Feature>[];
102
- collection: Partial<Collection>
113
+ export interface BrowseResultData extends Record<string, any> {
114
+ matched_terms: string[];
115
+ data: {
116
+ id: string;
117
+ [key: string]: any;
118
+ };
119
+ value: string;
120
+ is_slotted: false;
121
+ labels: Record<string, any>;
122
+ variations: Record<string, any>[];
103
123
  }
104
124
 
105
- interface BrowseResultData extends Record<string, any> {
106
- matched_terms: string[];
107
- data: {
108
- id: string;
109
- [key: string]: any;
110
- };
111
- value: string;
112
- is_slotted: false;
113
- labels: Record<string, any>;
114
- variations: Record<string, any>[];
125
+ export interface BrowseRequestType extends Record<string, any> {
126
+ browse_filter_name: string;
127
+ browse_filter_value: string;
128
+ filter_match_types: Record<string, any>;
129
+ filters: Record<string, any>;
130
+ fmt_options: Record<string, any>;
131
+ num_results_per_page: number;
132
+ page: number;
133
+ section: string;
134
+ sort_by: string;
135
+ sort_order: string;
136
+ term: string;
137
+ query: string;
138
+ features: Partial<RequestFeature>;
139
+ feature_variants: Partial<RequestFeatureVariant>;
140
+ searchandized_items: Record<string, any>;
115
141
  }
116
-
117
- interface Request extends Record<string, any> {
118
- browse_filter_name: string;
119
- browse_filter_value: string;
120
- filter_match_types: Record<string, any>,
121
- filters: Record<string, any>,
122
- fmt_options: Record<string, any>,
123
- num_results_per_page: number;
124
- page: number,
125
- section: string,
126
- sort_by: string,
127
- sort_order: string,
128
- term: string;
129
- query: string;
130
- features: Partial<RequestFeature>;
131
- feature_variants: Partial<RequestFeatureVariant>;
132
- searchandized_items: Record<string, any>;
133
- }
@@ -1,29 +1,30 @@
1
- import Search from "./search";
2
- import Browse from "./browse";
3
- import Autocomplete from "./autocomplete";
4
- import Recommendations from "./recommendations";
5
- import Tracker from "./tracker";
6
- import { ConstructorClientOptions } from "./types";
1
+ import Search from './search';
2
+ import Browse from './browse';
3
+ import Autocomplete from './autocomplete';
4
+ import Recommendations from './recommendations';
5
+ import Tracker from './tracker';
6
+ import { ConstructorClientOptions } from '.';
7
7
 
8
8
  export = ConstructorIO;
9
9
 
10
- /*********************
11
- *
12
- * Constructor client
13
- *
14
- *********************/
15
10
  declare class ConstructorIO {
16
- constructor(options: ConstructorClientOptions);
17
- private options: ConstructorClientOptions;
18
- search: Search;
19
- browse: Browse;
20
- autocomplete: Autocomplete;
21
- recommendations: Recommendations;
22
- tracker: Tracker;
23
-
24
- setClientOptions(options: ConstructorClientOptions): void;
11
+ constructor(options: ConstructorClientOptions);
12
+
13
+ private options: ConstructorClientOptions;
14
+
15
+ search: Search;
16
+
17
+ browse: Browse;
18
+
19
+ autocomplete: Autocomplete;
20
+
21
+ recommendations: Recommendations;
22
+
23
+ tracker: Tracker;
24
+
25
+ setClientOptions(options: ConstructorClientOptions): void;
25
26
  }
26
27
 
27
28
  declare namespace ConstructorIO {
28
- export { Tracker }
29
- }
29
+ export { Search, Browse, Autocomplete, Recommendations, Tracker };
30
+ }
@@ -1,13 +1,19 @@
1
- import { ConstructorClientOptions } from "./types";
1
+ import { ConstructorClientOptions } from '.';
2
2
 
3
- export = EventDispatcher;
3
+ export default EventDispatcher;
4
4
 
5
5
  declare class EventDispatcher {
6
- constructor(options: ConstructorClientOptions);
7
- events: { name: string; data: Record<string, any> }[];
8
- enabled: boolean;
9
- waitForBeacon: boolean;
10
- active: boolean;
11
- queue(name: string, data: Record<string, any>): void;
12
- dispatchEvents(): void;
6
+ constructor(options: ConstructorClientOptions);
7
+
8
+ events: { name: string; data: Record<string, any> }[];
9
+
10
+ enabled: boolean;
11
+
12
+ waitForBeacon: boolean;
13
+
14
+ active: boolean;
15
+
16
+ queue(name: string, data: Record<string, any>): void;
17
+
18
+ dispatchEvents(): void;
13
19
  }
@@ -0,0 +1,182 @@
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;
155
+
156
+ export type FilterExpression =
157
+ | FilterExpressionGroup
158
+ | FilterExpressionNot
159
+ | FilterExpressionValue
160
+ | FilterExpressionRange;
161
+
162
+ export type FilterExpressionGroup =
163
+ | FilterExpressionGroupOr
164
+ | FilterExpressionGroupAnd;
165
+
166
+ export type FilterExpressionGroupOr = { or: FilterExpression[] };
167
+ export type FilterExpressionGroupAnd = { and: FilterExpression[] };
168
+ export type FilterExpressionCondition = 'or' | 'and';
169
+
170
+ export type FilterExpressionNot = { not: FilterExpression };
171
+
172
+ export type FilterExpressionValue = {
173
+ name: string;
174
+ value: string;
175
+ };
176
+
177
+ export type FilterExpressionRange = {
178
+ name: string;
179
+ range: FilterExpressionRangeValue;
180
+ };
181
+
182
+ export type FilterExpressionRangeValue = ['-inf' | number, 'inf' | number];