@sitecore-content-sdk/search 0.2.2-canary.21 → 0.2.2-canary.23
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.
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SearchService = void 0;
|
|
4
4
|
const core_1 = require("@sitecore-content-sdk/core");
|
|
5
5
|
const tools_1 = require("@sitecore-content-sdk/core/tools");
|
|
6
|
+
const analytics_core_1 = require("@sitecore-content-sdk/analytics-core");
|
|
6
7
|
const debug_1 = require("./debug");
|
|
7
8
|
/**
|
|
8
9
|
* Service that fetches search results from Sitecore.
|
|
@@ -39,6 +40,14 @@ class SearchService {
|
|
|
39
40
|
offset,
|
|
40
41
|
});
|
|
41
42
|
const url = new URL('/v1/search', this.config.edgeUrl);
|
|
43
|
+
let sessionId = '';
|
|
44
|
+
try {
|
|
45
|
+
sessionId = (0, analytics_core_1.getClientId)();
|
|
46
|
+
// eslint-disable-next-line no-unused-vars
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
// We don't have to treat errors in a special way since we use an empty string as the fallback value
|
|
50
|
+
}
|
|
42
51
|
const sortFields = sort ? (Array.isArray(sort) ? sort : [sort]) : [];
|
|
43
52
|
const options = Object.assign(Object.assign({}, fetchOptions), { headers: Object.assign(Object.assign({}, fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.headers), { 'x-sitecore-contextid': this.config.contextId }) });
|
|
44
53
|
const { data } = await this.fetcher.post(url.toString(), {
|
|
@@ -50,6 +59,7 @@ class SearchService {
|
|
|
50
59
|
query: {
|
|
51
60
|
keyphrase,
|
|
52
61
|
},
|
|
62
|
+
sessionId,
|
|
53
63
|
sort: {
|
|
54
64
|
fields: sortFields,
|
|
55
65
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NativeDataFetcher } from '@sitecore-content-sdk/core';
|
|
2
2
|
import { resolveEdgeUrl } from '@sitecore-content-sdk/core/tools';
|
|
3
|
+
import { getClientId } from '@sitecore-content-sdk/analytics-core';
|
|
3
4
|
import { debug } from './debug';
|
|
4
5
|
/**
|
|
5
6
|
* Service that fetches search results from Sitecore.
|
|
@@ -36,6 +37,14 @@ export class SearchService {
|
|
|
36
37
|
offset,
|
|
37
38
|
});
|
|
38
39
|
const url = new URL('/v1/search', this.config.edgeUrl);
|
|
40
|
+
let sessionId = '';
|
|
41
|
+
try {
|
|
42
|
+
sessionId = getClientId();
|
|
43
|
+
// eslint-disable-next-line no-unused-vars
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
// We don't have to treat errors in a special way since we use an empty string as the fallback value
|
|
47
|
+
}
|
|
39
48
|
const sortFields = sort ? (Array.isArray(sort) ? sort : [sort]) : [];
|
|
40
49
|
const options = Object.assign(Object.assign({}, fetchOptions), { headers: Object.assign(Object.assign({}, fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.headers), { 'x-sitecore-contextid': this.config.contextId }) });
|
|
41
50
|
const { data } = await this.fetcher.post(url.toString(), {
|
|
@@ -47,6 +56,7 @@ export class SearchService {
|
|
|
47
56
|
query: {
|
|
48
57
|
keyphrase,
|
|
49
58
|
},
|
|
59
|
+
sessionId,
|
|
50
60
|
sort: {
|
|
51
61
|
fields: sortFields,
|
|
52
62
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/search",
|
|
3
|
-
"version": "0.2.2-canary.
|
|
3
|
+
"version": "0.2.2-canary.23",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,11 +36,13 @@
|
|
|
36
36
|
"url": "https://github.com/sitecore/content-sdk/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@sitecore-content-sdk/core": "2.1.0-canary.
|
|
39
|
+
"@sitecore-content-sdk/analytics-core": "2.1.0-canary.14",
|
|
40
|
+
"@sitecore-content-sdk/core": "2.1.0-canary.14"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@types/chai": "^5.2.3",
|
|
43
44
|
"@types/mocha": "^10.0.10",
|
|
45
|
+
"@types/proxyquire": "^1.3.31",
|
|
44
46
|
"chai": "^6.2.1",
|
|
45
47
|
"del-cli": "^7.0.0",
|
|
46
48
|
"eslint": "^9.39.1",
|
|
@@ -50,12 +52,13 @@
|
|
|
50
52
|
"mocha": "^11.7.5",
|
|
51
53
|
"nock": "^14.0.10",
|
|
52
54
|
"nyc": "^17.1.0",
|
|
55
|
+
"proxyquire": "^2.1.3",
|
|
53
56
|
"tsx": "^4.20.6",
|
|
54
57
|
"typescript": "~5.8.3"
|
|
55
58
|
},
|
|
56
59
|
"description": "",
|
|
57
60
|
"types": "types/index.d.ts",
|
|
58
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "bf2ca49692a43da54fce8388d61d45c15a001131",
|
|
59
62
|
"files": [
|
|
60
63
|
"dist",
|
|
61
64
|
"types",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-service.d.ts","sourceRoot":"","sources":["../src/search-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search-service.d.ts","sourceRoot":"","sources":["../src/search-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9D;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI;IACnE,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC5B,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,S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