@coveo/headless 3.28.3 → 3.28.4-pre.7521bcce93
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/case-assist/node.cjs.stats.json +1 -1
- package/dist/cjs/commerce/headless.cjs +1 -1
- package/dist/cjs/commerce/node.cjs.stats.json +1 -1
- package/dist/cjs/headless.cjs +1 -1
- package/dist/cjs/insight/headless.cjs +1 -1
- package/dist/cjs/insight/node.cjs.stats.json +1 -1
- package/dist/cjs/node.cjs.stats.json +1 -1
- package/dist/cjs/recommendation/headless.cjs +1 -1
- package/dist/cjs/recommendation/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr/headless.cjs +1 -1
- package/dist/cjs/ssr/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr-commerce/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr-commerce-next/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce-next/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr-next/headless.cjs +1 -1
- package/dist/cjs/ssr-next/node.cjs.stats.json +1 -1
- package/dist/definitions/ssr-next/common/builders/controller-builder.d.ts +18 -0
- package/dist/definitions/ssr-next/common/builders/static-controller-builder.d.ts +24 -0
- package/dist/definitions/ssr-next/common/types/controllers.d.ts +6 -0
- package/dist/esm/ssr-next/common/builders/controller-builder.js +38 -0
- package/dist/esm/ssr-next/common/builders/static-controller-builder.js +46 -0
- 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 +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CoreEngine, CoreEngineNext } from '../../../app/engine.js';
|
|
2
|
+
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
|
+
import type { SSRCommerceEngine } from '../../commerce/factories/build-factory.js';
|
|
4
|
+
import type { BaseControllerDefinitionWithoutProps, BaseControllerDefinitionWithProps } from '../types/controllers.js';
|
|
5
|
+
/**
|
|
6
|
+
* Builder class for creating controllers from definitions
|
|
7
|
+
*/
|
|
8
|
+
export declare class ControllerBuilder<TDefinition extends Partial<BaseControllerDefinitionWithoutProps<TEngine, TController>> & Partial<BaseControllerDefinitionWithProps<TEngine, TController, TProps>>, TEngine extends CoreEngine | CoreEngineNext | SSRCommerceEngine, TProps, TController extends Controller = Controller> {
|
|
9
|
+
private _definition;
|
|
10
|
+
private _engine;
|
|
11
|
+
private _props?;
|
|
12
|
+
private _additionalArgs;
|
|
13
|
+
constructor(definition: TDefinition, engine: TEngine, props?: TProps);
|
|
14
|
+
withAdditionalArgs(additionalArgs?: unknown[]): this;
|
|
15
|
+
build(): TController;
|
|
16
|
+
private buildWithoutProps;
|
|
17
|
+
private buildWithProps;
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
|
+
import type { ControllerWithKind } from '../../commerce/types/controller-definitions.js';
|
|
3
|
+
import type { Kind } from '../../commerce/types/kind.js';
|
|
4
|
+
export type StaticControllerState = {
|
|
5
|
+
initialState?: Controller['state'];
|
|
6
|
+
_kind?: Kind;
|
|
7
|
+
} & Pick<ControllerWithKind, 'state'>;
|
|
8
|
+
/**
|
|
9
|
+
* Builder class for creating static controller
|
|
10
|
+
*/
|
|
11
|
+
declare class StaticControllerBuilder {
|
|
12
|
+
private _state?;
|
|
13
|
+
private _kind?;
|
|
14
|
+
private _initialState?;
|
|
15
|
+
withState(state: StaticControllerState['state']): this;
|
|
16
|
+
withKind(kind: Kind): this;
|
|
17
|
+
withInitialState(initialState: StaticControllerState['initialState']): this;
|
|
18
|
+
/**
|
|
19
|
+
* Builds and returns the static controller state object
|
|
20
|
+
*/
|
|
21
|
+
build(): StaticControllerState;
|
|
22
|
+
}
|
|
23
|
+
export declare function createStaticControllerBuilder<TController extends Controller>(controller: TController): StaticControllerBuilder;
|
|
24
|
+
export {};
|
|
@@ -9,6 +9,12 @@ export interface ControllerStaticState<TState> {
|
|
|
9
9
|
export interface ControllerStaticStateMap {
|
|
10
10
|
[customName: string]: ControllerStaticState<unknown>;
|
|
11
11
|
}
|
|
12
|
+
export interface BaseControllerDefinitionWithoutProps<TEngine, TController extends Controller> {
|
|
13
|
+
build(engine: TEngine, ...args: unknown[]): TController;
|
|
14
|
+
}
|
|
15
|
+
export interface BaseControllerDefinitionWithProps<TEngine, TController extends Controller, TProps> {
|
|
16
|
+
buildWithProps(engine: TEngine, props?: TProps, ...args: unknown[]): TController;
|
|
17
|
+
}
|
|
12
18
|
export interface ControllerDefinitionWithoutProps<TEngine extends CoreEngine | CoreEngineNext, TController extends Controller> {
|
|
13
19
|
/**
|
|
14
20
|
* Creates an instance of the given controller.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder class for creating controllers from definitions
|
|
3
|
+
*/
|
|
4
|
+
export class ControllerBuilder {
|
|
5
|
+
_definition;
|
|
6
|
+
_engine;
|
|
7
|
+
_props;
|
|
8
|
+
_additionalArgs = [];
|
|
9
|
+
constructor(definition, engine, props) {
|
|
10
|
+
this._definition = definition;
|
|
11
|
+
this._engine = engine;
|
|
12
|
+
this._props = props;
|
|
13
|
+
}
|
|
14
|
+
withAdditionalArgs(additionalArgs = []) {
|
|
15
|
+
this._additionalArgs = additionalArgs;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
build() {
|
|
19
|
+
if ('build' in this._definition &&
|
|
20
|
+
typeof this._definition.build === 'function') {
|
|
21
|
+
return this.buildWithoutProps();
|
|
22
|
+
}
|
|
23
|
+
if ('buildWithProps' in this._definition &&
|
|
24
|
+
typeof this._definition.buildWithProps === 'function') {
|
|
25
|
+
return this.buildWithProps();
|
|
26
|
+
}
|
|
27
|
+
throw new Error('Controller definition must have a build or buildWithProps method.');
|
|
28
|
+
}
|
|
29
|
+
buildWithoutProps() {
|
|
30
|
+
const buildFn = this._definition.build;
|
|
31
|
+
return buildFn(this._engine, ...this._additionalArgs);
|
|
32
|
+
}
|
|
33
|
+
buildWithProps() {
|
|
34
|
+
const buildWithPropsFn = this._definition.buildWithProps;
|
|
35
|
+
const controller = buildWithPropsFn(this._engine, this._props, ...this._additionalArgs);
|
|
36
|
+
return { ...controller, initialState: controller.state };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { clone } from '../../../utils/utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Builder class for creating static controller
|
|
4
|
+
*/
|
|
5
|
+
class StaticControllerBuilder {
|
|
6
|
+
_state;
|
|
7
|
+
_kind;
|
|
8
|
+
_initialState;
|
|
9
|
+
withState(state) {
|
|
10
|
+
this._state = clone(state);
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
withKind(kind) {
|
|
14
|
+
this._kind = kind;
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
withInitialState(initialState) {
|
|
18
|
+
this._initialState = clone(initialState);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Builds and returns the static controller state object
|
|
23
|
+
*/
|
|
24
|
+
build() {
|
|
25
|
+
const result = {
|
|
26
|
+
state: this._state,
|
|
27
|
+
};
|
|
28
|
+
if (this._kind) {
|
|
29
|
+
result._kind = this._kind;
|
|
30
|
+
}
|
|
31
|
+
if (this._initialState) {
|
|
32
|
+
result.initialState = this._initialState;
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function createStaticControllerBuilder(controller) {
|
|
38
|
+
const builder = new StaticControllerBuilder().withState(controller.state);
|
|
39
|
+
if ('_kind' in controller) {
|
|
40
|
+
builder.withKind(controller._kind);
|
|
41
|
+
}
|
|
42
|
+
if ('initialState' in controller) {
|
|
43
|
+
builder.withInitialState(controller.initialState);
|
|
44
|
+
}
|
|
45
|
+
return builder;
|
|
46
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "3.28.
|
|
1
|
+
export const VERSION = "3.28.4-pre.7521bcce93" || 'Test version';
|
|
2
2
|
export const COVEO_FRAMEWORK = ['@coveo/atomic', '@coveo/quantic'];
|