@coveo/headless 3.28.0-pre.d2189ecd55 → 3.28.0-pre.d3cda60f5f
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/cjs/case-assist/headless.cjs +1 -1
- package/dist/cjs/commerce/headless.cjs +1 -1
- package/dist/cjs/headless.cjs +1 -1
- package/dist/cjs/insight/headless.cjs +1 -1
- package/dist/cjs/recommendation/headless.cjs +1 -1
- package/dist/cjs/ssr/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce-next/headless.cjs +1 -1
- package/dist/cjs/ssr-next/headless.cjs +1 -1
- package/dist/definitions/ssr/commerce/types/build.d.ts +8 -0
- package/dist/definitions/ssr/commerce/types/controller-inference.d.ts +4 -0
- package/dist/definitions/ssr/commerce/types/engine.d.ts +3 -0
- package/dist/definitions/ssr/common/types/engine.d.ts +4 -0
- package/dist/definitions/ssr/common/types/from-build-result.d.ts +8 -0
- package/dist/definitions/ssr-commerce-next.index.d.ts +2 -3
- package/dist/definitions/ssr-next/commerce/engine/commerce-engine.ssr.d.ts +2 -5
- package/dist/definitions/ssr-next/commerce/factories/hydrated-state-factory.d.ts +1 -1
- package/dist/definitions/ssr-next/commerce/factories/static-state-factory.d.ts +1 -1
- package/dist/definitions/ssr-next/commerce/types/build.d.ts +5 -1
- package/dist/definitions/ssr-next/commerce/types/controller-inference.d.ts +0 -3
- package/dist/definitions/ssr-next/commerce/types/engine.d.ts +6 -17
- package/dist/definitions/ssr-next/commerce/types/fetch-static-state.d.ts +7 -11
- package/dist/definitions/ssr-next/commerce/types/hydrate-static-state.d.ts +6 -10
- package/dist/definitions/ssr-next/common/controller-utils.d.ts +0 -1
- package/dist/definitions/ssr-next/common/types/build.d.ts +3 -0
- package/dist/definitions/ssr-next/common/types/engine.d.ts +3 -9
- package/dist/definitions/ssr-next/common/types/fetch-static-state.d.ts +7 -12
- package/dist/definitions/ssr-next/common/types/hydrate-static-state.d.ts +6 -10
- package/dist/definitions/ssr-next/search/engine/search-engine.ssr.d.ts +8 -3
- package/dist/definitions/ssr-next.index.d.ts +1 -2
- package/dist/esm/ssr-next/commerce/engine/commerce-engine.ssr.js +9 -18
- package/dist/esm/ssr-next/commerce/factories/hydrated-state-factory.js +9 -18
- package/dist/esm/ssr-next/commerce/factories/recommendation-hydrated-state-factory.js +7 -17
- package/dist/esm/ssr-next/commerce/factories/recommendation-static-state-factory.js +8 -18
- package/dist/esm/ssr-next/commerce/factories/static-state-factory.js +16 -23
- package/dist/esm/ssr-next/common/controller-utils.js +0 -8
- package/dist/esm/ssr-next/search/engine/search-engine.ssr.js +14 -31
- package/dist/esm/utils/version.js +1 -1
- package/dist/quantic/browser.cjs.stats.json +1 -1
- package/dist/quantic/case-assist/browser.cjs.stats.json +1 -1
- package/dist/quantic/case-assist/headless.js +1 -1
- package/dist/quantic/case-assist/headless.js.map +1 -1
- package/dist/quantic/commerce/browser.cjs.stats.json +1 -1
- package/dist/quantic/commerce/headless.js +1 -1
- package/dist/quantic/commerce/headless.js.map +1 -1
- package/dist/quantic/headless.js +1 -1
- package/dist/quantic/headless.js.map +1 -1
- package/dist/quantic/insight/browser.cjs.stats.json +1 -1
- package/dist/quantic/insight/headless.js +1 -1
- package/dist/quantic/insight/headless.js.map +1 -1
- package/dist/quantic/recommendation/browser.cjs.stats.json +1 -1
- package/dist/quantic/recommendation/headless.js +1 -1
- package/dist/quantic/recommendation/headless.js.map +1 -1
- package/package.json +2 -2
- package/dist/definitions/ssr-next/commerce/types/from-build-result.d.ts +0 -19
- package/dist/definitions/ssr-next/common/types/from-build-result.d.ts +0 -8
- package/dist/esm/ssr-next/commerce/types/from-build-result.js +0 -1
- package/dist/esm/ssr-next/common/types/from-build-result.js +0 -1
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import { composeFunction } from '../../common/controller-utils.js';
|
|
2
1
|
import { buildFactory, } from './build-factory.js';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
buildResult,
|
|
11
|
-
searchActions: params[0].searchActions,
|
|
12
|
-
});
|
|
13
|
-
return staticState;
|
|
14
|
-
}, {
|
|
15
|
-
fromBuildResult: async (...params) => {
|
|
16
|
-
const [{ buildResult: { engine, controllers }, searchActions, },] = params;
|
|
17
|
-
searchActions.forEach((action) => {
|
|
2
|
+
export function hydratedStaticStateFactory(controllerDefinitions, options) {
|
|
3
|
+
return (solutionType) => async (...params) => {
|
|
4
|
+
const solutionTypeBuild = await buildFactory(controllerDefinitions, {
|
|
5
|
+
...options,
|
|
6
|
+
})(solutionType);
|
|
7
|
+
const { engine, controllers } = await solutionTypeBuild(...params);
|
|
8
|
+
params[0].searchActions.forEach((action) => {
|
|
18
9
|
engine.dispatch(action);
|
|
19
10
|
});
|
|
20
11
|
await engine.waitForRequestCompletedAction();
|
|
21
12
|
return { engine, controllers };
|
|
22
|
-
}
|
|
23
|
-
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import { composeFunction } from '../../common/controller-utils.js';
|
|
2
1
|
import { SolutionType } from '../types/controller-constants.js';
|
|
3
2
|
import { buildFactory, } from './build-factory.js';
|
|
4
3
|
export function hydratedRecommendationStaticStateFactory(controllerDefinitions, options) {
|
|
5
|
-
return
|
|
4
|
+
return async (...params) => {
|
|
6
5
|
const solutionTypeBuild = await buildFactory(controllerDefinitions, options)(SolutionType.recommendation);
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
searchActions: params[0].searchActions,
|
|
6
|
+
const { engine, controllers } = (await solutionTypeBuild(...params));
|
|
7
|
+
params[0].searchActions.forEach((action) => {
|
|
8
|
+
engine.dispatch(action);
|
|
11
9
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const [{ buildResult: { engine, controllers }, searchActions, },] = params;
|
|
16
|
-
searchActions.forEach((action) => {
|
|
17
|
-
engine.dispatch(action);
|
|
18
|
-
});
|
|
19
|
-
await engine.waitForRequestCompletedAction();
|
|
20
|
-
return { engine, controllers };
|
|
21
|
-
},
|
|
22
|
-
});
|
|
10
|
+
await engine.waitForRequestCompletedAction();
|
|
11
|
+
return { engine, controllers };
|
|
12
|
+
};
|
|
23
13
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { filterObject } from '../../../utils/utils.js';
|
|
2
|
-
import { composeFunction } from '../../common/controller-utils.js';
|
|
3
2
|
import { createStaticState } from '../controller-utils.js';
|
|
4
3
|
import { SolutionType } from '../types/controller-constants.js';
|
|
5
4
|
import { filterRecommendationControllers } from '../utils/recommendation-filter.js';
|
|
@@ -12,25 +11,16 @@ export function fetchRecommendationStaticStateFactory(controllerDefinitions, opt
|
|
|
12
11
|
}
|
|
13
12
|
return [];
|
|
14
13
|
};
|
|
15
|
-
return
|
|
14
|
+
return async (...params) => {
|
|
16
15
|
const [props] = params;
|
|
17
16
|
const allowedRecommendationKeys = getAllowedRecommendationKeys(props);
|
|
18
17
|
const solutionTypeBuild = await buildFactory(controllerDefinitions, options)(SolutionType.recommendation);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const { engine, controllers } = (await solutionTypeBuild(...params));
|
|
19
|
+
filterRecommendationControllers(controllers, controllerDefinitions ?? {}).refresh(allowedRecommendationKeys);
|
|
20
|
+
const searchActions = await Promise.all(engine.waitForRequestCompletedAction());
|
|
21
|
+
return createStaticState({
|
|
22
|
+
searchActions,
|
|
23
|
+
controllers,
|
|
23
24
|
});
|
|
24
|
-
|
|
25
|
-
}, {
|
|
26
|
-
fromBuildResult: async (...params) => {
|
|
27
|
-
const [{ buildResult: { engine, controllers }, allowedRecommendationKeys, },] = params;
|
|
28
|
-
filterRecommendationControllers(controllers, controllerDefinitions ?? {}).refresh(allowedRecommendationKeys);
|
|
29
|
-
const searchActions = await Promise.all(engine.waitForRequestCompletedAction());
|
|
30
|
-
return createStaticState({
|
|
31
|
-
searchActions,
|
|
32
|
-
controllers,
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
});
|
|
25
|
+
};
|
|
36
26
|
}
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
import { buildProductListing } from '../../../controllers/commerce/product-listing/headless-product-listing.js';
|
|
2
2
|
import { buildSearch } from '../../../controllers/commerce/search/headless-search.js';
|
|
3
3
|
import { augmentPreprocessRequestWithForwardedFor } from '../../common/augment-preprocess-request.js';
|
|
4
|
-
import { composeFunction } from '../../common/controller-utils.js';
|
|
5
4
|
import { createStaticState } from '../controller-utils.js';
|
|
6
5
|
import { SolutionType } from '../types/controller-constants.js';
|
|
7
6
|
import { buildFactory, } from './build-factory.js';
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const staticState = await staticStateBuild.fromBuildResult({
|
|
21
|
-
buildResult,
|
|
22
|
-
});
|
|
23
|
-
return staticState;
|
|
24
|
-
}, {
|
|
25
|
-
fromBuildResult: async (...params) => {
|
|
26
|
-
const [{ buildResult: { engine, controllers }, },] = params;
|
|
7
|
+
export function fetchStaticStateFactory(controllerDefinitions, options) {
|
|
8
|
+
return (solutionType) => async (...params) => {
|
|
9
|
+
const solutionTypeBuild = await buildFactory(controllerDefinitions, {
|
|
10
|
+
...options,
|
|
11
|
+
})(solutionType);
|
|
12
|
+
const { engine, controllers } = await solutionTypeBuild(...params);
|
|
13
|
+
options.configuration.preprocessRequest =
|
|
14
|
+
augmentPreprocessRequestWithForwardedFor({
|
|
15
|
+
preprocessRequest: options.configuration.preprocessRequest,
|
|
16
|
+
navigatorContextProvider: options.navigatorContextProvider,
|
|
17
|
+
loggerOptions: options.loggerOptions,
|
|
18
|
+
});
|
|
27
19
|
switch (solutionType) {
|
|
28
20
|
case SolutionType.listing:
|
|
29
21
|
buildProductListing(engine).executeFirstRequest();
|
|
@@ -33,9 +25,10 @@ export const fetchStaticStateFactory = (controllerDefinitions, options) => (solu
|
|
|
33
25
|
break;
|
|
34
26
|
}
|
|
35
27
|
const searchActions = await Promise.all(engine.waitForRequestCompletedAction());
|
|
36
|
-
|
|
28
|
+
const staticState = createStaticState({
|
|
37
29
|
searchActions,
|
|
38
30
|
controllers,
|
|
39
31
|
});
|
|
40
|
-
|
|
41
|
-
}
|
|
32
|
+
return staticState;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -19,11 +19,3 @@ export function createStaticState({ searchAction, controllers, }) {
|
|
|
19
19
|
searchAction: clone(searchAction),
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
// TODO: KIT-4610: no longer needed along with build()
|
|
23
|
-
export function composeFunction(parentFunction, children) {
|
|
24
|
-
const newFunction = ((...params) => parentFunction(...params));
|
|
25
|
-
for (const [key, value] of Object.entries(children)) {
|
|
26
|
-
newFunction[key] = value;
|
|
27
|
-
}
|
|
28
|
-
return newFunction;
|
|
29
|
-
}
|
|
@@ -2,7 +2,7 @@ import { buildLogger } from '../../../app/logger.js';
|
|
|
2
2
|
import { buildSearchEngine, } from '../../../app/search-engine/search-engine.js';
|
|
3
3
|
import { createWaitForActionMiddleware } from '../../../utils/utils.js';
|
|
4
4
|
import { augmentPreprocessRequestWithForwardedFor } from '../../common/augment-preprocess-request.js';
|
|
5
|
-
import { buildControllerDefinitions,
|
|
5
|
+
import { buildControllerDefinitions, createStaticState, } from '../../common/controller-utils.js';
|
|
6
6
|
function isSearchCompletedAction(action) {
|
|
7
7
|
return /^search\/executeSearch\/(fulfilled|rejected)$/.test(action.type);
|
|
8
8
|
}
|
|
@@ -59,45 +59,28 @@ export function defineSearchEngine(options) {
|
|
|
59
59
|
controllers,
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
const fetchStaticState =
|
|
63
|
-
const
|
|
64
|
-
const staticState = await fetchStaticState.fromBuildResult({
|
|
65
|
-
buildResult,
|
|
66
|
-
});
|
|
62
|
+
const fetchStaticState = async (...params) => {
|
|
63
|
+
const { engine, controllers } = await build(...params);
|
|
67
64
|
options.configuration.preprocessRequest =
|
|
68
65
|
augmentPreprocessRequestWithForwardedFor({
|
|
69
66
|
preprocessRequest: options.configuration.preprocessRequest,
|
|
70
67
|
navigatorContextProvider: options.navigatorContextProvider,
|
|
71
68
|
loggerOptions: options.loggerOptions,
|
|
72
69
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
engine.executeFirstSearch();
|
|
78
|
-
return createStaticState({
|
|
79
|
-
searchAction: await engine.waitForSearchCompletedAction(),
|
|
80
|
-
controllers,
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
const hydrateStaticState = composeFunction(async (...params) => {
|
|
85
|
-
const buildResult = await build(...params);
|
|
86
|
-
const staticState = await hydrateStaticState.fromBuildResult({
|
|
87
|
-
buildResult,
|
|
88
|
-
searchAction: params[0].searchAction,
|
|
70
|
+
engine.executeFirstSearch();
|
|
71
|
+
const staticState = createStaticState({
|
|
72
|
+
searchAction: await engine.waitForSearchCompletedAction(),
|
|
73
|
+
controllers: controllers,
|
|
89
74
|
});
|
|
90
75
|
return staticState;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
76
|
+
};
|
|
77
|
+
const hydrateStaticState = async (...params) => {
|
|
78
|
+
const { engine, controllers } = await build(...params);
|
|
79
|
+
engine.dispatch(params[0].searchAction);
|
|
80
|
+
await engine.waitForSearchCompletedAction();
|
|
81
|
+
return { engine, controllers };
|
|
82
|
+
};
|
|
99
83
|
return {
|
|
100
|
-
build,
|
|
101
84
|
fetchStaticState,
|
|
102
85
|
hydrateStaticState,
|
|
103
86
|
setNavigatorContextProvider,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "3.28.0-pre.
|
|
1
|
+
export const VERSION = "3.28.0-pre.d3cda60f5f" || 'Test version';
|
|
2
2
|
export const COVEO_FRAMEWORK = ['@coveo/atomic', '@coveo/quantic'];
|