@searchcraft/javascript-sdk 0.10.7 → 0.11.1
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.
- package/dist/components/defineCustomElements.js +4 -0
- package/dist/components/index.d.ts +530 -217
- package/dist/components/index.js +1661 -8
- package/dist/components/index.js.map +1 -1
- package/dist/components/{p-e99cd628.js → p-0c495408.js} +30 -20
- package/dist/components/p-0c495408.js.map +1 -0
- package/dist/components/{p-b4cac872.js → p-1d5c5536.js} +18 -8
- package/dist/components/p-1d5c5536.js.map +1 -0
- package/dist/components/{p-274c5cc8.js → p-3286bbb3.js} +22 -10
- package/dist/components/p-3286bbb3.js.map +1 -0
- package/dist/components/{p-ea48ccae.js → p-3e41546c.js} +17 -8
- package/dist/components/p-3e41546c.js.map +1 -0
- package/dist/components/{p-adc6236e.js → p-87435aac.js} +31 -20
- package/dist/components/p-87435aac.js.map +1 -0
- package/dist/components/p-919734fe.js +31 -0
- package/dist/components/p-919734fe.js.map +1 -0
- package/dist/components/{p-b01f8216.js → p-b13c7fbb.js} +48 -33
- package/dist/components/p-b13c7fbb.js.map +1 -0
- package/dist/components/{p-810a7850.js → p-b4b67072.js} +2 -2
- package/dist/components/p-b4b67072.js.map +1 -0
- package/dist/components/{p-acab4d41.js → p-b7e99386.js} +22 -22
- package/dist/components/p-b7e99386.js.map +1 -0
- package/dist/components/{p-4dd1995c.js → p-c9b65e8f.js} +4 -4
- package/dist/components/{p-4dd1995c.js.map → p-c9b65e8f.js.map} +1 -1
- package/dist/components/p-d54771ef.js.map +1 -1
- package/dist/components/{p-a64b4cba.js → p-e2a10337.js} +2 -2
- package/dist/components/{p-a64b4cba.js.map → p-e2a10337.js.map} +1 -1
- package/dist/components/p-e30203b1.js +62 -0
- package/dist/components/p-e30203b1.js.map +1 -0
- package/dist/components/{p-320e3895.js → p-fc8ccffa.js} +22 -11
- package/dist/components/p-fc8ccffa.js.map +1 -0
- package/dist/components/searchcraft-ad.js +1 -1
- package/dist/components/searchcraft-facet-list.js +1 -1
- package/dist/components/searchcraft-filter-panel.js +51 -23
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +1 -1
- package/dist/components/searchcraft-loading.d.ts +11 -0
- package/dist/components/searchcraft-loading.js +8 -0
- package/dist/components/searchcraft-loading.js.map +1 -0
- package/dist/components/searchcraft-pagination.js +13 -3
- package/dist/components/searchcraft-pagination.js.map +1 -1
- package/dist/components/searchcraft-popover-button.js +21 -9
- package/dist/components/searchcraft-popover-button.js.map +1 -1
- package/dist/components/searchcraft-popover-footer.js +1 -1
- package/dist/components/searchcraft-popover-form.js +32 -20
- package/dist/components/searchcraft-popover-form.js.map +1 -1
- package/dist/components/searchcraft-popover-list-item.js +1 -1
- package/dist/components/searchcraft-popover-list-view.js +1 -1
- package/dist/components/searchcraft-results-info.js +15 -7
- package/dist/components/searchcraft-results-info.js.map +1 -1
- package/dist/components/searchcraft-search-result.js +1 -1
- package/dist/components/searchcraft-search-results-per-page.js +14 -4
- package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
- package/dist/components/searchcraft-search-results.js +50 -69
- package/dist/components/searchcraft-search-results.js.map +1 -1
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-summary-box.d.ts +11 -0
- package/dist/components/searchcraft-summary-box.js +2287 -0
- package/dist/components/searchcraft-summary-box.js.map +1 -0
- package/dist/components/searchcraft-theme.js +2 -2
- package/dist/components/searchcraft-theme.js.map +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/hydrate/index.js +6072 -4862
- package/dist/hydrate/index.mjs +6072 -4862
- package/dist/themes/hologram.css +1 -1
- package/dist/themes/hologram.css.map +1 -1
- package/dist/types/classes/CoreInstanceRegistry.d.ts +38 -0
- package/dist/types/classes/Logger.d.ts +25 -0
- package/dist/types/classes/SearchcraftCore.d.ts +50 -0
- package/dist/types/classes/index.d.ts +3 -0
- package/dist/types/clients/MeasureClient.d.ts +27 -0
- package/dist/types/clients/SearchClient.d.ts +35 -0
- package/dist/types/clients/SummaryClient.d.ts +10 -0
- package/dist/types/clients/ad-clients/AdClient.d.ts +20 -0
- package/dist/types/clients/ad-clients/AdMarketplaceClient.d.ts +14 -0
- package/dist/types/clients/ad-clients/CustomAdClient.d.ts +6 -0
- package/dist/types/clients/ad-clients/NativoClient.d.ts +14 -0
- package/dist/types/clients/ad-clients/index.d.ts +5 -0
- package/dist/types/clients/index.d.ts +4 -0
- package/dist/types/components/searchcraft-ad/searchcraft-ad.d.ts +10 -3
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +9 -2
- package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +14 -3
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +9 -6
- package/dist/types/components/searchcraft-loading/searchcraft-loading.d.ts +10 -0
- package/dist/types/components/searchcraft-pagination/searchcraft-pagination.d.ts +8 -1
- package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +10 -2
- package/dist/types/components/searchcraft-popover-footer/searchcraft-popover-footer.d.ts +8 -1
- package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +11 -3
- package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +9 -1
- package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +11 -3
- package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +8 -1
- package/dist/types/components/searchcraft-search-result/searchcraft-search-result.d.ts +10 -1
- package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +11 -5
- package/dist/types/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.d.ts +8 -1
- package/dist/types/components/searchcraft-summary-box/searchcraft-summary-box.d.ts +49 -0
- package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +8 -1
- package/dist/types/components.d.ts +256 -6
- package/dist/types/index.d.ts +4 -5
- package/dist/types/store/SearchcraftStore.types.d.ts +14 -15
- package/dist/types/store/SearchcraftStoreFactory.d.ts +13 -0
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/types/core-types/AdClientResponses.types.d.ts +24 -0
- package/dist/types/types/core-types/Facets.types.d.ts +39 -0
- package/dist/types/types/core-types/Measure.types.d.ts +52 -0
- package/dist/types/types/core-types/SearchClient.types.d.ts +67 -0
- package/dist/types/types/core-types/SearchClientResponses.types.d.ts +7 -0
- package/dist/types/types/core-types/SearchcraftAdConfig.types.d.ts +76 -0
- package/dist/types/types/core-types/SearchcraftConfig.types.d.ts +65 -0
- package/dist/types/types/core-types/SearchcraftResponse.types.d.ts +46 -0
- package/dist/types/types/core-types/SubscriptionEvents.types.d.ts +51 -0
- package/dist/types/types/core-types/index.d.ts +10 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/sdk-types/index.d.ts +4 -0
- package/dist/types/types/sdk-types/result-mappings.types.d.ts +58 -0
- package/dist/types/types/sdk-types/searchcraft-filter-panel.types.d.ts +44 -0
- package/dist/types/types/sdk-types/templates.types.d.ts +29 -0
- package/dist/types/utils/core-utils/index.d.ts +3 -0
- package/dist/types/utils/core-utils/sanitize.d.ts +2 -0
- package/dist/types/utils/core-utils/url.d.ts +2 -0
- package/dist/types/utils/facets.d.ts +1 -1
- package/dist/types/utils/html.d.ts +1 -1
- package/dist/types/utils/units.d.ts +1 -1
- package/package.json +5 -3
- package/dist/components/p-062d6b80.js +0 -1940
- package/dist/components/p-062d6b80.js.map +0 -1
- package/dist/components/p-274c5cc8.js.map +0 -1
- package/dist/components/p-320e3895.js.map +0 -1
- package/dist/components/p-810a7850.js.map +0 -1
- package/dist/components/p-acab4d41.js.map +0 -1
- package/dist/components/p-adc6236e.js.map +0 -1
- package/dist/components/p-b01f8216.js.map +0 -1
- package/dist/components/p-b4cac872.js.map +0 -1
- package/dist/components/p-e99cd628.js.map +0 -1
- package/dist/components/p-ea48ccae.js.map +0 -1
- package/dist/types/store/SearchcraftStore.d.ts +0 -4
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ADMResponse {
|
|
2
|
+
partial_qt: string;
|
|
3
|
+
text_ads: ADMAd[];
|
|
4
|
+
product_ads: ADMAd[];
|
|
5
|
+
}
|
|
6
|
+
export interface AdClientResponseItem {
|
|
7
|
+
id: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ADMClientResponseItem extends AdClientResponseItem {
|
|
10
|
+
admAdType: 'adm-text-ad' | 'adm-product-ad';
|
|
11
|
+
admAd?: ADMAd;
|
|
12
|
+
}
|
|
13
|
+
export interface ADMAd {
|
|
14
|
+
adv_id: number;
|
|
15
|
+
adv_name: string;
|
|
16
|
+
click_url?: string;
|
|
17
|
+
image_url?: string;
|
|
18
|
+
impression_url?: string;
|
|
19
|
+
price?: number;
|
|
20
|
+
price_currency?: string;
|
|
21
|
+
sale_price?: number;
|
|
22
|
+
term: string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=AdClientResponses.types.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type Facet = {
|
|
2
|
+
/**
|
|
3
|
+
* The path of the facet. The path represents where in the facet tree structure
|
|
4
|
+
* this facet exists. There is an arbitrary number of levels in a facet tree.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* '/sports/college' - Represents that this is the facet node exists at [root] -> [sports] -> [college] in the facet tree.
|
|
9
|
+
* '/weather' - Represents that this facet exists at [root] -> [weather] in the facet tree
|
|
10
|
+
* '/news/local' - [root] -> [news] -> [local]
|
|
11
|
+
*/
|
|
12
|
+
path: string;
|
|
13
|
+
/**
|
|
14
|
+
* The count value just represents an arbitrary `count` metadata for this facet node.
|
|
15
|
+
*/
|
|
16
|
+
count: number;
|
|
17
|
+
};
|
|
18
|
+
export type FacetWithChildrenArray = Facet & {
|
|
19
|
+
children: FacetWithChildrenArray[] | null | undefined;
|
|
20
|
+
};
|
|
21
|
+
export type FacetWithChildrenObject = Facet & {
|
|
22
|
+
children: Record<string, FacetWithChildrenObject>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A Facet object returned in a search response.
|
|
26
|
+
*/
|
|
27
|
+
export type FacetRoot = {
|
|
28
|
+
[key: string]: FacetWithChildrenArray[];
|
|
29
|
+
};
|
|
30
|
+
export type FacetPrime = FacetRoot[];
|
|
31
|
+
/**
|
|
32
|
+
* A structured Facet tree.
|
|
33
|
+
*
|
|
34
|
+
* A Facet tree is the root node of a "complete view" of the facet node tree.
|
|
35
|
+
* Nodes are structured based on the `path` of each facet
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export type FacetTree = FacetWithChildrenObject;
|
|
39
|
+
//# sourceMappingURL=Facets.types.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of measure requests that can be sent to the /measure/event endpoint.
|
|
3
|
+
*/
|
|
4
|
+
export type MeasureEventName = 'sdk_initialized' | 'search_requested' | 'search_response_received' | 'search_completed' | 'document_clicked';
|
|
5
|
+
/**
|
|
6
|
+
* The type used for sending multiple measure events in a single network request.
|
|
7
|
+
* Uses /measure/batch request.
|
|
8
|
+
*/
|
|
9
|
+
export interface BatchMeasureRequest {
|
|
10
|
+
items: MeasureRequest[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The type representing a measure request.
|
|
14
|
+
*/
|
|
15
|
+
export interface MeasureRequest {
|
|
16
|
+
event_name: MeasureEventName;
|
|
17
|
+
properties: MeasureRequestProperties;
|
|
18
|
+
user: MeasureRequestUser;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Properties attached to a measure request.
|
|
22
|
+
*/
|
|
23
|
+
export interface MeasureRequestProperties {
|
|
24
|
+
searchcraft_organization_id?: string;
|
|
25
|
+
searchcraft_application_id?: string;
|
|
26
|
+
searchcraft_index_names: string[];
|
|
27
|
+
search_term?: string;
|
|
28
|
+
number_of_documents?: number;
|
|
29
|
+
external_document_id?: string;
|
|
30
|
+
document_position?: number;
|
|
31
|
+
session_id?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* User properties attached to a measure request.
|
|
35
|
+
*/
|
|
36
|
+
export interface MeasureRequestUser {
|
|
37
|
+
user_id: string;
|
|
38
|
+
country?: string;
|
|
39
|
+
city?: string;
|
|
40
|
+
device_id?: string;
|
|
41
|
+
client_ip?: string;
|
|
42
|
+
locale?: string;
|
|
43
|
+
os?: string;
|
|
44
|
+
platform?: string;
|
|
45
|
+
region?: string;
|
|
46
|
+
sdk_name?: string;
|
|
47
|
+
sdk_version?: string;
|
|
48
|
+
user_agent?: string;
|
|
49
|
+
latitude?: number;
|
|
50
|
+
longitude?: number;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=Measure.types.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface FacetPathsForIndexField {
|
|
2
|
+
fieldName: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RangeValueForIndexField {
|
|
6
|
+
fieldName: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SearchClientQuery {
|
|
10
|
+
occur?: 'must' | 'should';
|
|
11
|
+
exact?: {
|
|
12
|
+
ctx: string;
|
|
13
|
+
};
|
|
14
|
+
fuzzy?: {
|
|
15
|
+
ctx: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export type SearchClientRequest = {
|
|
19
|
+
limit?: number;
|
|
20
|
+
offset?: number;
|
|
21
|
+
order_by?: string;
|
|
22
|
+
sort?: 'asc' | 'desc';
|
|
23
|
+
query: SearchClientQuery[];
|
|
24
|
+
};
|
|
25
|
+
export interface SearchClientRequestProperties {
|
|
26
|
+
/**
|
|
27
|
+
* The search mode, which can be either 'fuzzy' or 'exact'.
|
|
28
|
+
*/
|
|
29
|
+
mode: 'fuzzy' | 'exact';
|
|
30
|
+
/**
|
|
31
|
+
* The starting point for the results, used for pagination.
|
|
32
|
+
* Optional parameter.
|
|
33
|
+
*/
|
|
34
|
+
offset?: number;
|
|
35
|
+
/**
|
|
36
|
+
* The number of results returned.
|
|
37
|
+
* Optional parameter.
|
|
38
|
+
*/
|
|
39
|
+
limit?: number;
|
|
40
|
+
/**
|
|
41
|
+
* The field to order the results by (e.g., 'date_published', 'title', etc.).
|
|
42
|
+
* Optional parameter.
|
|
43
|
+
*/
|
|
44
|
+
order_by?: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* The search term provided by the user.
|
|
47
|
+
*/
|
|
48
|
+
searchTerm: string;
|
|
49
|
+
/**
|
|
50
|
+
* The sort order, which can be either 'asc' or 'desc'.
|
|
51
|
+
* Optional parameter.
|
|
52
|
+
*/
|
|
53
|
+
sort?: 'asc' | 'desc' | null;
|
|
54
|
+
/**
|
|
55
|
+
* The facet path value(s) specified by the `facets` filter items that the `searchcraft-filter-panel` renders.
|
|
56
|
+
* There may be multiple rendered within a single filter panel.
|
|
57
|
+
* Optional parameter.
|
|
58
|
+
*/
|
|
59
|
+
facetPathsForIndexFields?: Record<string, FacetPathsForIndexField>;
|
|
60
|
+
/**
|
|
61
|
+
* The date range slider value(s) specified by the `dateRange` filter items that the `searchcraft-filter-panel` renders.
|
|
62
|
+
* There may be multiple rendered within a single filter panel.
|
|
63
|
+
* Optional parameter.
|
|
64
|
+
*/
|
|
65
|
+
rangeValueForIndexFields?: Record<string, RangeValueForIndexField>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=SearchClient.types.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ADMAdTemplate, CustomAdTemplate } from '../sdk-types';
|
|
2
|
+
export interface CustomAdConfig {
|
|
3
|
+
/**
|
|
4
|
+
* The amount of debounce delay to add before calling the ad_container_rendered event
|
|
5
|
+
*/
|
|
6
|
+
adContainerRenderedDebounceDelay?: number;
|
|
7
|
+
/**
|
|
8
|
+
* The number of custom ads to render at the start of the search results page.
|
|
9
|
+
*/
|
|
10
|
+
adStartQuantity?: number;
|
|
11
|
+
/**
|
|
12
|
+
* The number of custom ads to render at the end of the search results page.
|
|
13
|
+
*/
|
|
14
|
+
adEndQuantity?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Renders a custom ad in between search results, at the specified interval.
|
|
17
|
+
*/
|
|
18
|
+
adInterstitialInterval?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Specifies the number of ads to be rendered in each interstitial in between search results.
|
|
21
|
+
*/
|
|
22
|
+
adInterstitialQuantity?: number;
|
|
23
|
+
/**
|
|
24
|
+
* A callback function responsible for rendering the custom ad containers.
|
|
25
|
+
*/
|
|
26
|
+
template: CustomAdTemplate;
|
|
27
|
+
}
|
|
28
|
+
export interface NativoAdConfig {
|
|
29
|
+
/**
|
|
30
|
+
* The placement id to use for Nativo ads.
|
|
31
|
+
*/
|
|
32
|
+
placementId?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The class name for nativo ad containers.
|
|
35
|
+
*/
|
|
36
|
+
adClassName?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The number of custom ads to render at the start of the search results page.
|
|
39
|
+
*/
|
|
40
|
+
adStartQuantity?: number;
|
|
41
|
+
/**
|
|
42
|
+
* The number of custom ads to render at the end of the search results page.
|
|
43
|
+
*/
|
|
44
|
+
adEndQuantity?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Renders a custom ad in between search results, at the specified interval.
|
|
47
|
+
*/
|
|
48
|
+
adInterstitialInterval?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Specify how many normal search results to render before rendering the first interstitial ad grouping.
|
|
51
|
+
*/
|
|
52
|
+
adInterstialStartIndex?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Specifies the number of ads to be rendered in each interstitial in between search results.
|
|
55
|
+
*/
|
|
56
|
+
adInterstitialQuantity?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface ADMAdConfig {
|
|
59
|
+
/**
|
|
60
|
+
* The number of product ads to request.
|
|
61
|
+
*/
|
|
62
|
+
productAdQuantity?: number;
|
|
63
|
+
/**
|
|
64
|
+
* The number of text ads to request.
|
|
65
|
+
*/
|
|
66
|
+
textAdQuantity?: number;
|
|
67
|
+
/**
|
|
68
|
+
* The adm sub value.
|
|
69
|
+
*/
|
|
70
|
+
sub?: string;
|
|
71
|
+
/**
|
|
72
|
+
* A callback function responsible for rendering the ADM ad containers.
|
|
73
|
+
*/
|
|
74
|
+
template?: ADMAdTemplate;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=SearchcraftAdConfig.types.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ADMAdConfig, CustomAdConfig, NativoAdConfig } from './SearchcraftAdConfig.types';
|
|
2
|
+
/**
|
|
3
|
+
* The SearchcraftConfig object is used to initialize the Searchcraft JavaScript SDK in your front-end application. See the [getting started page](https://docs.searchcraft.io/sdks/javascript/getting-started/) for a guide on how and where to use this configuration object.
|
|
4
|
+
*/
|
|
5
|
+
export interface SearchcraftConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The read key value to use when sending Searchcraft search requests. This value needs read key-specific permissions. If you are using Searchcraft Cloud, this value can be configured in Vektron.
|
|
8
|
+
*/
|
|
9
|
+
readKey: string;
|
|
10
|
+
/**
|
|
11
|
+
* The endpoint url of your Searchcraft cluster where your specified search index exists. If you are using Searchcraft Cloud, this value can be found within the Vektron dashboard in the Code Snippets section when configuring a search index.
|
|
12
|
+
*/
|
|
13
|
+
endpointURL: string;
|
|
14
|
+
/**
|
|
15
|
+
* Name of the Searchcraft search index to search for results within. If you are using Searchcraft Cloud, this value can be found within the Vektron dashboard in the Code Snippets section when configuring a search index.
|
|
16
|
+
*/
|
|
17
|
+
indexName: string;
|
|
18
|
+
/**
|
|
19
|
+
* The initial search query to call when Searchcraft is first initialized in your front-end application. This parameter can be used when you want to populate a page with an initial set of search results based on a query.
|
|
20
|
+
*
|
|
21
|
+
* This value is a stringified Search query object. For a more in-depth reference on search queries, see the [search endpoint documentation](https://docs.searchcraft.io/api/search/).
|
|
22
|
+
*/
|
|
23
|
+
initialQuery?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The maximum number of documents to return per page of results.
|
|
26
|
+
*/
|
|
27
|
+
searchResultsPerPage?: number;
|
|
28
|
+
/**
|
|
29
|
+
* The URL pointing towards Searchcraft Cloud's semantic search and RAG summary processing layer. When using a `searchcraft-summary-box` component, this value must be specified.
|
|
30
|
+
*/
|
|
31
|
+
cortexURL?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Instructions provided to the LLM when creating search result summaries.
|
|
34
|
+
*/
|
|
35
|
+
summaryInstructionsPrompt?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The amount of delay, in milliseconds, to debounce summary requests. Defaults to `1000`
|
|
38
|
+
*/
|
|
39
|
+
summaryDebounceDelay?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Name of the ad source to use.
|
|
42
|
+
*/
|
|
43
|
+
searchDebounceDelay?: number;
|
|
44
|
+
/**
|
|
45
|
+
* A unique user identifier for end users of your product. This would typically correspond to a user id
|
|
46
|
+
* in your consuming application's database. Used for data analysis and visualizations on Vektron.
|
|
47
|
+
*/
|
|
48
|
+
measureUserIdentifier?: string;
|
|
49
|
+
/**
|
|
50
|
+
* This object allows you to configure the quantity, number, template, and positioning of custom ad containers within your search results.
|
|
51
|
+
*
|
|
52
|
+
* To see more information on how to configure custom ads, see [the custom ads guide](https://docs.searchcraft.io/sdks/javascript/custom-ads/)
|
|
53
|
+
*/
|
|
54
|
+
customAdConfig?: CustomAdConfig;
|
|
55
|
+
nativoConfig?: NativoAdConfig;
|
|
56
|
+
admAdConfig?: ADMAdConfig;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Used internally by consuming packages as part of the core sdk constructor.
|
|
60
|
+
*/
|
|
61
|
+
export interface SearchcraftSDKInfo {
|
|
62
|
+
sdkName: string;
|
|
63
|
+
sdkVersion: string;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=SearchcraftConfig.types.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { FacetPrime } from './Facets.types';
|
|
2
|
+
/**
|
|
3
|
+
* The structure of a response returned from a Searchcraft operation.
|
|
4
|
+
*/
|
|
5
|
+
export interface SearchcraftResponse {
|
|
6
|
+
status: number;
|
|
7
|
+
data: SearchcraftResponseData | SearchcraftResponseError;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error returned when a search is unsuccessful.
|
|
11
|
+
*/
|
|
12
|
+
export type SearchcraftResponseError = {
|
|
13
|
+
status: number;
|
|
14
|
+
message?: string;
|
|
15
|
+
code?: number;
|
|
16
|
+
hits?: [];
|
|
17
|
+
facets?: null;
|
|
18
|
+
count?: number;
|
|
19
|
+
time_taken?: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Top-level result returned when a search is successful.
|
|
23
|
+
*/
|
|
24
|
+
export interface SearchcraftResponseData {
|
|
25
|
+
count?: number;
|
|
26
|
+
facets?: FacetPrime;
|
|
27
|
+
hits?: SearchIndexHit[];
|
|
28
|
+
time_taken?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Represents an entry in the search index returned as part of a search result.
|
|
32
|
+
*/
|
|
33
|
+
export interface SearchIndexHit {
|
|
34
|
+
doc?: SearchDocument;
|
|
35
|
+
document_id?: string;
|
|
36
|
+
score?: number;
|
|
37
|
+
source_index?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Data document returned within a SearchResult.
|
|
41
|
+
*/
|
|
42
|
+
export interface SearchDocument extends Record<string, string | number> {
|
|
43
|
+
id: number;
|
|
44
|
+
[key: string]: string | number;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=SearchcraftResponse.types.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface SubscriptionEventMap {
|
|
2
|
+
ad_container_rendered: AdContainerRenderedSubscriptionEvent;
|
|
3
|
+
ad_container_viewed: AdContainerViewedSubscriptionEvent;
|
|
4
|
+
query_fetched: QueryFetchedEvent;
|
|
5
|
+
query_submitted: QuerySubmittedEvent;
|
|
6
|
+
initialized: InitializedEvent;
|
|
7
|
+
input_cleared: InputClearedEvent;
|
|
8
|
+
no_results_returned: NoResultsReturnedEvent;
|
|
9
|
+
}
|
|
10
|
+
export interface AdContainerRenderedSubscriptionEvent extends SubscriptionEvent {
|
|
11
|
+
name: 'ad_container_rendered';
|
|
12
|
+
data: {
|
|
13
|
+
adContainerId: string;
|
|
14
|
+
searchTerm: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface AdContainerViewedSubscriptionEvent extends SubscriptionEvent {
|
|
18
|
+
name: 'ad_container_viewed';
|
|
19
|
+
data: {
|
|
20
|
+
adContainerId: string;
|
|
21
|
+
searchTerm: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface QuerySubmittedEvent extends SubscriptionEvent {
|
|
25
|
+
name: 'query_submitted';
|
|
26
|
+
data: {
|
|
27
|
+
searchTerm: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface QueryFetchedEvent extends SubscriptionEvent {
|
|
31
|
+
name: 'query_fetched';
|
|
32
|
+
data: {
|
|
33
|
+
searchTerm: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface InputClearedEvent extends SubscriptionEvent {
|
|
37
|
+
name: 'input_cleared';
|
|
38
|
+
}
|
|
39
|
+
export interface NoResultsReturnedEvent extends SubscriptionEvent {
|
|
40
|
+
name: 'no_results_returned';
|
|
41
|
+
}
|
|
42
|
+
export interface InitializedEvent extends SubscriptionEvent {
|
|
43
|
+
name: 'initialized';
|
|
44
|
+
}
|
|
45
|
+
export type SubscriptionEventName = keyof SubscriptionEventMap;
|
|
46
|
+
export type SubscriptionEventCallback<T extends SubscriptionEventName> = (event: SubscriptionEventMap[T]) => void;
|
|
47
|
+
export type UnsubscribeFunction = () => void;
|
|
48
|
+
export interface SubscriptionEvent {
|
|
49
|
+
name: SubscriptionEventName;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=SubscriptionEvents.types.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './AdClientResponses.types';
|
|
2
|
+
export * from './Facets.types';
|
|
3
|
+
export * from './Measure.types';
|
|
4
|
+
export * from './SearchcraftConfig.types';
|
|
5
|
+
export * from './SearchClient.types';
|
|
6
|
+
export * from './SearchClientResponses.types';
|
|
7
|
+
export * from './SearchcraftResponse.types';
|
|
8
|
+
export * from './SubscriptionEvents.types';
|
|
9
|
+
export * from './SearchcraftAdConfig.types';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A data type representing an index field value, along with properties
|
|
3
|
+
* describing how to format and display the index field value.
|
|
4
|
+
*/
|
|
5
|
+
export type SearchResultFieldName = {
|
|
6
|
+
/**
|
|
7
|
+
* The index field name.
|
|
8
|
+
*/
|
|
9
|
+
fieldName: string;
|
|
10
|
+
/**
|
|
11
|
+
* The data type to treat this index field as.
|
|
12
|
+
*/
|
|
13
|
+
dataType: 'text' | 'date' | 'number';
|
|
14
|
+
/**
|
|
15
|
+
* The locale to use when formatting dataType: `number`
|
|
16
|
+
*/
|
|
17
|
+
numberFormatLocale?: string;
|
|
18
|
+
/**
|
|
19
|
+
* If it's a number, the number format to apply.
|
|
20
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
|
|
21
|
+
*/
|
|
22
|
+
numberFormatOptions?: Intl.NumberFormatOptions;
|
|
23
|
+
/**
|
|
24
|
+
* A scale factor to apply to a `number` value.
|
|
25
|
+
*/
|
|
26
|
+
numberScale?: number;
|
|
27
|
+
/**
|
|
28
|
+
* The locale to use when formatting dataType: `date`.
|
|
29
|
+
*/
|
|
30
|
+
dateFormatLocale?: string;
|
|
31
|
+
/**
|
|
32
|
+
* If it's a date, the date format to apply.
|
|
33
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
|
|
34
|
+
*/
|
|
35
|
+
dateFormatOptions?: Intl.DateTimeFormatOptions;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* A data type representing the mapping of index fields, for the purpose of rendering them
|
|
39
|
+
* in search result item.
|
|
40
|
+
*/
|
|
41
|
+
export type SearchResultMapping = {
|
|
42
|
+
/**
|
|
43
|
+
* The fields to map to.
|
|
44
|
+
*/
|
|
45
|
+
fieldNames: SearchResultFieldName[];
|
|
46
|
+
/**
|
|
47
|
+
* The delimiter used to join them.
|
|
48
|
+
*/
|
|
49
|
+
delimiter?: string;
|
|
50
|
+
};
|
|
51
|
+
export type PopoverResultMappings = {
|
|
52
|
+
title?: SearchResultMapping;
|
|
53
|
+
subtitle?: SearchResultMapping;
|
|
54
|
+
imageSource?: SearchResultMapping;
|
|
55
|
+
imageAlt?: SearchResultMapping;
|
|
56
|
+
href?: SearchResultMapping;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=result-mappings.types.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface FilterItem {
|
|
2
|
+
type: 'facets' | 'dateRange' | 'numericRange' | 'exactMatchToggle' | 'mostRecentToggle';
|
|
3
|
+
label: string;
|
|
4
|
+
options: object | null;
|
|
5
|
+
}
|
|
6
|
+
export interface FacetsFilterItem extends FilterItem {
|
|
7
|
+
fieldName: string;
|
|
8
|
+
type: 'facets';
|
|
9
|
+
options: {
|
|
10
|
+
showSublevel: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface NumericFilterItem extends FilterItem {
|
|
14
|
+
fieldName: string;
|
|
15
|
+
type: 'numericRange';
|
|
16
|
+
options: {
|
|
17
|
+
min: number;
|
|
18
|
+
max: number;
|
|
19
|
+
granularity: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface DateRangeFilterItem extends FilterItem {
|
|
23
|
+
fieldName: string;
|
|
24
|
+
type: 'dateRange';
|
|
25
|
+
options: {
|
|
26
|
+
minDate: Date;
|
|
27
|
+
maxDate?: Date;
|
|
28
|
+
granularity: 'year' | 'month' | 'day' | 'hour';
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface ExactMatchToggleFilterItem extends FilterItem {
|
|
32
|
+
type: 'exactMatchToggle';
|
|
33
|
+
options: {
|
|
34
|
+
subLabel?: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface MostRecentToggleFilterItem extends FilterItem {
|
|
38
|
+
fieldName: string;
|
|
39
|
+
type: 'mostRecentToggle';
|
|
40
|
+
options: {
|
|
41
|
+
subLabel?: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=searchcraft-filter-panel.types.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ADMAd } from '..';
|
|
2
|
+
export type TemplateHtml = (strings: TemplateStringsArray, ...values: (string | number | undefined)[]) => string;
|
|
3
|
+
export type SearchResultTemplate<T> = (data: T, index: number, utils: {
|
|
4
|
+
html: TemplateHtml;
|
|
5
|
+
source_index?: string;
|
|
6
|
+
}) => string;
|
|
7
|
+
export type SearchResultTemplateData = any;
|
|
8
|
+
export type ResultsInfoTemplate = (data: {
|
|
9
|
+
range: [number, number];
|
|
10
|
+
count: number;
|
|
11
|
+
responseTime: string;
|
|
12
|
+
}, utils: {
|
|
13
|
+
html: TemplateHtml;
|
|
14
|
+
}) => string;
|
|
15
|
+
export type CustomAdTemplate = (data: {
|
|
16
|
+
adContainerId: string;
|
|
17
|
+
searchTerm: string;
|
|
18
|
+
}, utils: {
|
|
19
|
+
html: TemplateHtml;
|
|
20
|
+
}) => string;
|
|
21
|
+
export type PopoverButtonTemplate = (data: {
|
|
22
|
+
isPopoverVisible: boolean;
|
|
23
|
+
}, utils: {
|
|
24
|
+
html: TemplateHtml;
|
|
25
|
+
}) => string;
|
|
26
|
+
export type ADMAdTemplate = (data: ADMAd, utils: {
|
|
27
|
+
html: TemplateHtml;
|
|
28
|
+
}) => string;
|
|
29
|
+
//# sourceMappingURL=templates.types.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FacetTree, FacetWithChildrenArray, FacetWithChildrenObject } from
|
|
1
|
+
import type { FacetTree, FacetWithChildrenArray, FacetWithChildrenObject } from "../types/index";
|
|
2
2
|
/**
|
|
3
3
|
* Helper function for getting a Node (FacetWithChildrenObject)
|
|
4
4
|
* at a given path. Traverses the node tree to get the node.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SearchResultMapping } from
|
|
1
|
+
import type { SearchResultMapping } from "../types/index";
|
|
2
2
|
/**
|
|
3
3
|
* Given a document and a SearchResultMapping, return a mapped value from the document.
|
|
4
4
|
* Applies formatting based on the values specified in the `SearchResultFieldName` values.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@searchcraft/javascript-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.1",
|
|
5
5
|
"description": "Searchcraft Javascript SDK",
|
|
6
6
|
"author": "Searchcraft Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -41,16 +41,18 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"classnames": "^2.3.2",
|
|
43
43
|
"dompurify": "^3.2.4",
|
|
44
|
+
"marked": "^15.0.12",
|
|
44
45
|
"nanoid": "^5.0.9"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@searchcraft/core": "^0.10.7",
|
|
48
48
|
"@stencil/core": "^4.7.0",
|
|
49
49
|
"@stencil/react-output-target": "^0.8.2",
|
|
50
50
|
"@stencil/sass": "^3.0.12",
|
|
51
51
|
"@stencil/vue-output-target": "^0.9.2",
|
|
52
|
+
"@thumbmarkjs/thumbmarkjs": "^0.16.1",
|
|
52
53
|
"@types/node": "^16.18.11",
|
|
54
|
+
"nanoid": "^5.0.9",
|
|
53
55
|
"zustand": "^5.0.1"
|
|
54
56
|
},
|
|
55
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "a76993be3f9de0f8dd0a1d8326a43435e794ec7d"
|
|
56
58
|
}
|