@coveo/headless 3.30.0-pre.8837ba3c8d → 3.30.0-pre.8bfbf841d4

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.
Files changed (29) hide show
  1. package/dist/cjs/case-assist/headless.cjs +1 -1
  2. package/dist/cjs/commerce/headless.cjs +1 -1
  3. package/dist/cjs/headless.cjs +1 -1
  4. package/dist/cjs/insight/headless.cjs +36 -28
  5. package/dist/cjs/insight/node.cjs.stats.json +1 -1
  6. package/dist/cjs/recommendation/headless.cjs +1 -1
  7. package/dist/cjs/ssr/headless.cjs +1 -1
  8. package/dist/cjs/ssr-commerce/headless.cjs +1 -1
  9. package/dist/cjs/ssr-commerce-next/headless.cjs +1 -1
  10. package/dist/cjs/ssr-next/headless.cjs +1 -1
  11. package/dist/definitions/features/attached-results/attached-results-actions-loader.d.ts +14 -1
  12. package/dist/definitions/features/attached-results/attached-results-actions.d.ts +2 -9
  13. package/dist/definitions/features/attached-results/attached-results-analytics-actions-loader.d.ts +35 -0
  14. package/dist/definitions/insight.index.d.ts +1 -0
  15. package/dist/esm/controllers/insight/attach-to-case/headless-attach-to-case.js +2 -6
  16. package/dist/esm/features/attached-results/attached-results-actions-loader.js +4 -2
  17. package/dist/esm/features/attached-results/attached-results-actions.js +17 -18
  18. package/dist/esm/features/attached-results/attached-results-analytics-actions-loader.js +18 -0
  19. package/dist/esm/features/attached-results/attached-results-slice.js +4 -4
  20. package/dist/esm/insight.index.js +1 -0
  21. package/dist/esm/utils/version.js +1 -1
  22. package/dist/quantic/case-assist/headless.js +1 -1
  23. package/dist/quantic/commerce/headless.js +1 -1
  24. package/dist/quantic/headless.js +1 -1
  25. package/dist/quantic/insight/browser.cjs.stats.json +1 -1
  26. package/dist/quantic/insight/headless.js +8 -8
  27. package/dist/quantic/insight/headless.js.map +4 -4
  28. package/dist/quantic/recommendation/headless.js +1 -1
  29. package/package.json +1 -1
@@ -881,7 +881,7 @@ var validateObject = (engine, schema, obj, validationMessage, errorMessage) => {
881
881
  };
882
882
 
883
883
  // src/utils/version.ts
884
- var VERSION = "3.30.0-pre.8837ba3c8d";
884
+ var VERSION = "3.30.0-pre.8bfbf841d4";
885
885
  var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
886
886
 
887
887
  // src/features/configuration/configuration-actions.ts
@@ -1306,7 +1306,7 @@ var import_toolkit2 = require("@reduxjs/toolkit");
1306
1306
  var import_toolkit = require("@reduxjs/toolkit");
1307
1307
 
1308
1308
  // src/utils/version.ts
1309
- var VERSION = "3.30.0-pre.8837ba3c8d";
1309
+ var VERSION = "3.30.0-pre.8bfbf841d4";
1310
1310
  var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
1311
1311
 
1312
1312
  // src/api/analytics/analytics-selectors.ts
@@ -468,7 +468,7 @@ var import_bueno8 = require("@coveo/bueno");
468
468
  var import_toolkit3 = require("@reduxjs/toolkit");
469
469
 
470
470
  // src/utils/version.ts
471
- var VERSION = "3.30.0-pre.8837ba3c8d";
471
+ var VERSION = "3.30.0-pre.8bfbf841d4";
472
472
  var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
473
473
 
474
474
  // src/features/configuration/configuration-actions.ts
@@ -467,7 +467,7 @@ var import_bueno8 = require("@coveo/bueno");
467
467
  var import_toolkit3 = require("@reduxjs/toolkit");
468
468
 
469
469
  // src/utils/version.ts
470
- var VERSION = "3.30.0-pre.8837ba3c8d";
470
+ var VERSION = "3.30.0-pre.8bfbf841d4";
471
471
  var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
472
472
 
473
473
  // src/features/configuration/configuration-actions.ts
@@ -1306,7 +1306,7 @@ var import_toolkit2 = require("@reduxjs/toolkit");
1306
1306
  var import_toolkit = require("@reduxjs/toolkit");
1307
1307
 
1308
1308
  // src/utils/version.ts
1309
- var VERSION = "3.30.0-pre.8837ba3c8d";
1309
+ var VERSION = "3.30.0-pre.8bfbf841d4";
1310
1310
  var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
1311
1311
 
1312
1312
  // src/api/analytics/analytics-selectors.ts
@@ -2,7 +2,6 @@ import type { PayloadAction } from '@reduxjs/toolkit';
2
2
  import type { InsightEngine } from '../../app/insight-engine/insight-engine.js';
3
3
  import { type SetAttachedResultsActionCreatorPayload } from './attached-results-actions.js';
4
4
  import type { AttachedResult } from './attached-results-state.js';
5
- export type { SetAttachedResultsActionCreatorPayload, AttachedResult };
6
5
  /**
7
6
  * The attached results action creators.
8
7
  *
@@ -27,6 +26,20 @@ export interface AttachedResultsActionCreators {
27
26
  * @returns A dispatchable action.
28
27
  */
29
28
  setAttachedResults(payload: SetAttachedResultsActionCreatorPayload): PayloadAction<SetAttachedResultsActionCreatorPayload>;
29
+ /**
30
+ * Creates an action that attaches a result to a case.
31
+ *
32
+ * @param payload - The action creator payload containing the result to attach.
33
+ * @returns A dispatchable action.
34
+ */
35
+ attachResult(payload: AttachedResult): PayloadAction<AttachedResult>;
36
+ /**
37
+ * Creates an action that detaches a result from a case.
38
+ *
39
+ * @param payload - The action creator payload containing the result to detach.
40
+ * @returns A dispatchable action.
41
+ */
42
+ detachResult(payload: AttachedResult): PayloadAction<AttachedResult>;
30
43
  }
31
44
  /**
32
45
  * Loads the `attachedResults` reducer and returns possible action creators.
@@ -9,13 +9,6 @@ export interface SetAttachedResultsActionCreatorPayload {
9
9
  */
10
10
  loading?: boolean;
11
11
  }
12
- interface SetAttachToCaseAttachActionCreatorPayload {
13
- result: AttachedResult;
14
- }
15
- interface SetAttachToCaseDetachActionCreatorPayload {
16
- result: AttachedResult;
17
- }
18
12
  export declare const setAttachedResults: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SetAttachedResultsActionCreatorPayload], SetAttachedResultsActionCreatorPayload, "insight/attachToCase/setAttachedResults", never, never>;
19
- export declare const attachResult: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SetAttachToCaseAttachActionCreatorPayload], SetAttachToCaseAttachActionCreatorPayload | SetAttachToCaseDetachActionCreatorPayload, "insight/attachToCase/attach", never, never>;
20
- export declare const detachResult: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SetAttachToCaseDetachActionCreatorPayload], SetAttachToCaseAttachActionCreatorPayload | SetAttachToCaseDetachActionCreatorPayload, "insight/attachToCase/detach", never, never>;
21
- export {};
13
+ export declare const attachResult: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: AttachedResult], AttachedResult, "insight/attachToCase/attach", never, never>;
14
+ export declare const detachResult: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: AttachedResult], AttachedResult, "insight/attachToCase/detach", never, never>;
@@ -0,0 +1,35 @@
1
+ import type { Result } from '../../api/search/search/result.js';
2
+ import type { InsightEngine } from '../../app/insight-engine/insight-engine.js';
3
+ import type { InsightAction } from '../analytics/analytics-utils.js';
4
+ /**
5
+ * The attached results action creators.
6
+ *
7
+ * @group Actions
8
+ * @category AttachedResults
9
+ */
10
+ export interface AttachedResultsAnalyticsActionCreators {
11
+ /**
12
+ * Creates an analytics action for when a case attach event occurs.
13
+ *
14
+ * @param result - The result to attach.
15
+ * @returns A dispatchable action.
16
+ */
17
+ logCaseAttach(result: Result): InsightAction;
18
+ /**
19
+ * Creates an analytics action for when a case detach event occurs.
20
+ *
21
+ * @param result - The result to detach.
22
+ * @returns A dispatchable action.
23
+ */
24
+ logCaseDetach(result: Result): InsightAction;
25
+ }
26
+ /**
27
+ * Loads the `attachedResults` reducer and returns possible analytics action creators.
28
+ *
29
+ * @param engine - The headless engine.
30
+ * @returns An object holding the analytics action creators.
31
+ *
32
+ * @group Actions
33
+ * @category AttachedResults
34
+ */
35
+ export declare function loadAttachedResultsAnalyticsActions(engine: InsightEngine): AttachedResultsAnalyticsActionCreators;
@@ -92,6 +92,7 @@ export { buildInsightInterface } from './controllers/insight-interface/insight-i
92
92
  export * from './features/analytics/generic-analytics-actions-loader.js';
93
93
  export * from './features/analytics/insight-analytics-actions-loader.js';
94
94
  export * from './features/attached-results/attached-results-actions-loader.js';
95
+ export * from './features/attached-results/attached-results-analytics-actions-loader.js';
95
96
  export * from './features/case-context/case-context-actions-loader.js';
96
97
  export * from './features/context/context-actions-loader.js';
97
98
  export type { CategoryFacetSortCriterion, CategoryFacetValueRequest, } from './features/facets/category-facet-set/interfaces/request.js';
@@ -49,15 +49,11 @@ export function buildAttachToCase(engine, props) {
49
49
  return isResultAttached();
50
50
  },
51
51
  attach() {
52
- dispatch(attachResult({
53
- result: buildAttachedResultFromSearchResult(result, caseId),
54
- }));
52
+ dispatch(attachResult(buildAttachedResultFromSearchResult(result, caseId)));
55
53
  dispatch(logCaseAttach(result));
56
54
  },
57
55
  detach() {
58
- dispatch(detachResult({
59
- result: buildAttachedResultFromSearchResult(result, caseId),
60
- }));
56
+ dispatch(detachResult(buildAttachedResultFromSearchResult(result, caseId)));
61
57
  dispatch(logCaseDetach(result));
62
58
  },
63
59
  };
@@ -1,5 +1,5 @@
1
- import { attachedResultsReducer as attachedResults } from '../../features/attached-results/attached-results-slice.js';
2
- import { setAttachedResults, } from './attached-results-actions.js';
1
+ import { attachResult, detachResult, setAttachedResults, } from './attached-results-actions.js';
2
+ import { attachedResultsReducer as attachedResults } from './attached-results-slice.js';
3
3
  /**
4
4
  * Loads the `attachedResults` reducer and returns possible action creators.
5
5
  *
@@ -13,5 +13,7 @@ export function loadAttachedResultsActions(engine) {
13
13
  engine.addReducers({ attachedResults });
14
14
  return {
15
15
  setAttachedResults,
16
+ detachResult,
17
+ attachResult,
16
18
  };
17
19
  }
@@ -1,23 +1,24 @@
1
1
  import { ArrayValue, BooleanValue, isNullOrUndefined, RecordValue, SchemaValidationError, } from '@coveo/bueno';
2
2
  import { createAction } from '@reduxjs/toolkit';
3
3
  import { nonEmptyString, requiredNonEmptyString, serializeSchemaValidationError, validatePayload, } from '../../utils/validate-payload.js';
4
+ const attachedResultPayloadDefinition = {
5
+ articleLanguage: nonEmptyString,
6
+ articlePublishStatus: nonEmptyString,
7
+ articleVersionNumber: nonEmptyString,
8
+ caseId: requiredNonEmptyString,
9
+ knowledgeArticleId: nonEmptyString,
10
+ name: nonEmptyString,
11
+ permanentId: nonEmptyString,
12
+ resultUrl: nonEmptyString,
13
+ source: nonEmptyString,
14
+ title: requiredNonEmptyString,
15
+ uriHash: nonEmptyString,
16
+ };
4
17
  const RequiredAttachedResultRecord = new RecordValue({
5
18
  options: {
6
19
  required: true,
7
20
  },
8
- values: {
9
- articleLanguage: nonEmptyString,
10
- articlePublishStatus: nonEmptyString,
11
- articleVersionNumber: nonEmptyString,
12
- caseId: requiredNonEmptyString,
13
- knowledgeArticleId: nonEmptyString,
14
- name: nonEmptyString,
15
- permanentId: nonEmptyString,
16
- resultUrl: nonEmptyString,
17
- source: nonEmptyString,
18
- title: requiredNonEmptyString,
19
- uriHash: nonEmptyString,
20
- },
21
+ values: attachedResultPayloadDefinition,
21
22
  });
22
23
  export const setAttachedResults = createAction('insight/attachToCase/setAttachedResults', (payload) => validatePayload(payload, {
23
24
  results: new ArrayValue({
@@ -31,14 +32,12 @@ export const setAttachedResults = createAction('insight/attachToCase/setAttached
31
32
  export const attachResult = createAction('insight/attachToCase/attach', (payload) => validatePayloadAndPermanentIdOrUriHash(payload));
32
33
  export const detachResult = createAction('insight/attachToCase/detach', (payload) => validatePayloadAndPermanentIdOrUriHash(payload));
33
34
  const validatePayloadAndPermanentIdOrUriHash = (payload) => {
34
- if (isNullOrUndefined(payload.result.permanentId) &&
35
- isNullOrUndefined(payload.result.uriHash)) {
35
+ if (isNullOrUndefined(payload.permanentId) &&
36
+ isNullOrUndefined(payload.uriHash)) {
36
37
  return {
37
38
  payload,
38
39
  error: serializeSchemaValidationError(new SchemaValidationError('Either permanentId or uriHash is required')),
39
40
  };
40
41
  }
41
- return validatePayload(payload, {
42
- result: RequiredAttachedResultRecord,
43
- });
42
+ return validatePayload(payload, attachedResultPayloadDefinition);
44
43
  };
@@ -0,0 +1,18 @@
1
+ import { logCaseAttach, logCaseDetach, } from './attached-results-analytics-actions.js';
2
+ import { attachedResultsReducer as attachedResults } from './attached-results-slice.js';
3
+ /**
4
+ * Loads the `attachedResults` reducer and returns possible analytics action creators.
5
+ *
6
+ * @param engine - The headless engine.
7
+ * @returns An object holding the analytics action creators.
8
+ *
9
+ * @group Actions
10
+ * @category AttachedResults
11
+ */
12
+ export function loadAttachedResultsAnalyticsActions(engine) {
13
+ engine.addReducers({ attachedResults });
14
+ return {
15
+ logCaseDetach,
16
+ logCaseAttach,
17
+ };
18
+ }
@@ -15,13 +15,13 @@ export const attachedResultsReducer = createReducer(getAttachedResultsInitialSta
15
15
  }
16
16
  })
17
17
  .addCase(attachResult, (state, action) => {
18
- if (!isNullOrUndefined(action.payload.result.permanentId) ||
19
- !isNullOrUndefined(action.payload.result.uriHash)) {
20
- state.results = [...state.results, action.payload.result];
18
+ if (!isNullOrUndefined(action.payload.permanentId) ||
19
+ !isNullOrUndefined(action.payload.uriHash)) {
20
+ state.results = [...state.results, action.payload];
21
21
  }
22
22
  })
23
23
  .addCase(detachResult, (state, action) => {
24
- state.results = state.results.filter((result) => attachedResultsMatchIds(result, action.payload.result));
24
+ state.results = state.results.filter((result) => attachedResultsMatchIds(result, action.payload));
25
25
  });
26
26
  });
27
27
  const attachedResultsMatchIds = (result1, result2) => {
@@ -50,6 +50,7 @@ export { buildInsightInterface } from './controllers/insight-interface/insight-i
50
50
  export * from './features/analytics/generic-analytics-actions-loader.js';
51
51
  export * from './features/analytics/insight-analytics-actions-loader.js';
52
52
  export * from './features/attached-results/attached-results-actions-loader.js';
53
+ export * from './features/attached-results/attached-results-analytics-actions-loader.js';
53
54
  export * from './features/case-context/case-context-actions-loader.js';
54
55
  export * from './features/context/context-actions-loader.js';
55
56
  export * from './features/facets/range-facets/date-facet-set/date-facet-actions-loader.js';
@@ -1,2 +1,2 @@
1
- export const VERSION = "3.30.0-pre.8837ba3c8d" || 'Test version';
1
+ export const VERSION = "3.30.0-pre.8bfbf841d4" || 'Test version';
2
2
  export const COVEO_FRAMEWORK = ['@coveo/atomic', '@coveo/quantic'];