ingeniuscliq-core 0.5.24 → 0.5.26
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.
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import { CoreBuilder } from './CoreBuilder';
|
|
2
|
+
/**
|
|
3
|
+
* Extension options for configuring builder behavior
|
|
4
|
+
*/
|
|
5
|
+
export interface CoreBuilderExtensions<TStore> {
|
|
6
|
+
/**
|
|
7
|
+
* Additional initial state properties
|
|
8
|
+
*/
|
|
9
|
+
initialState?: Partial<TStore>;
|
|
10
|
+
/**
|
|
11
|
+
* Additional actions/methods for the store
|
|
12
|
+
*/
|
|
13
|
+
actions?: (set: any, get: any) => Partial<TStore>;
|
|
14
|
+
/**
|
|
15
|
+
* Additional properties to persist in storage
|
|
16
|
+
*/
|
|
17
|
+
partialize?: (state: TStore) => Record<string, any>;
|
|
18
|
+
}
|
|
2
19
|
/**
|
|
3
20
|
* Base builder class with extensibility hooks
|
|
4
21
|
* Provides a pattern for extending store state and actions without duplicating code
|
|
5
22
|
* @template TStore - The type of the store state that will be built
|
|
6
23
|
*/
|
|
7
24
|
export declare abstract class CoreBaseBuilder<TStore> implements CoreBuilder {
|
|
25
|
+
protected extensions: CoreBuilderExtensions<TStore>;
|
|
8
26
|
abstract build(): any;
|
|
9
27
|
/**
|
|
10
28
|
* Hook method to get the base store state
|
|
@@ -14,9 +32,15 @@ export declare abstract class CoreBaseBuilder<TStore> implements CoreBuilder {
|
|
|
14
32
|
* @returns Object with base state and actions
|
|
15
33
|
*/
|
|
16
34
|
protected abstract getBaseState(set: any, get: any): TStore;
|
|
35
|
+
/**
|
|
36
|
+
* Set extension options for the builder
|
|
37
|
+
* @param extensions - Extension configuration object
|
|
38
|
+
*/
|
|
39
|
+
setExtensions(extensions: CoreBuilderExtensions<TStore>): this;
|
|
17
40
|
/**
|
|
18
41
|
* Hook method to allow extending initial state
|
|
19
42
|
* Override this in child classes to add custom properties to the store state
|
|
43
|
+
* Combines properties from child class implementation with runtime extensions
|
|
20
44
|
* @returns Object with additional state properties
|
|
21
45
|
* @example
|
|
22
46
|
* protected extendInitialState() {
|
|
@@ -30,6 +54,7 @@ export declare abstract class CoreBaseBuilder<TStore> implements CoreBuilder {
|
|
|
30
54
|
/**
|
|
31
55
|
* Hook method to allow extending store actions
|
|
32
56
|
* Override this in child classes to add custom methods to the store
|
|
57
|
+
* Combines actions from child class implementation with runtime extensions
|
|
33
58
|
* @param set - Zustand set function
|
|
34
59
|
* @param get - Zustand get function
|
|
35
60
|
* @returns Object with additional actions/methods
|
|
@@ -45,6 +70,7 @@ export declare abstract class CoreBaseBuilder<TStore> implements CoreBuilder {
|
|
|
45
70
|
/**
|
|
46
71
|
* Hook method to allow extending partialize storage
|
|
47
72
|
* Override this in child classes to persist custom properties
|
|
73
|
+
* Combines partialize config from child class implementation with runtime extensions
|
|
48
74
|
* @param state - Current store state
|
|
49
75
|
* @returns Object with properties to persist
|
|
50
76
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreBaseBuilder.d.ts","sourceRoot":"","sources":["../../src/classes/CoreBaseBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;GAIG;AACH,8BAAsB,eAAe,CAAC,MAAM,CAAE,YAAW,WAAW;IAChE,QAAQ,CAAC,KAAK,IAAI,GAAG;IAErB;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM;IAE3D
|
|
1
|
+
{"version":3,"file":"CoreBaseBuilder.d.ts","sourceRoot":"","sources":["../../src/classes/CoreBaseBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,MAAM;IACzC;;OAEG;IACH,YAAY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
6
|
+
*/
|
|
7
|
+
setExtensions(extensions) {
|
|
8
|
+
this.extensions = { ...this.extensions, ...extensions };
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
2
11
|
/**
|
|
3
12
|
* Hook method to allow extending initial state
|
|
4
13
|
* Override this in child classes to add custom properties to the store state
|
|
14
|
+
* Combines properties from child class implementation with runtime extensions
|
|
5
15
|
* @returns Object with additional state properties
|
|
6
16
|
* @example
|
|
7
17
|
* protected extendInitialState() {
|
|
@@ -12,11 +22,12 @@ class CoreBaseBuilder {
|
|
|
12
22
|
* }
|
|
13
23
|
*/
|
|
14
24
|
extendInitialState() {
|
|
15
|
-
return {};
|
|
25
|
+
return { ...this.extensions.initialState };
|
|
16
26
|
}
|
|
17
27
|
/**
|
|
18
28
|
* Hook method to allow extending store actions
|
|
19
29
|
* Override this in child classes to add custom methods to the store
|
|
30
|
+
* Combines actions from child class implementation with runtime extensions
|
|
20
31
|
* @param set - Zustand set function
|
|
21
32
|
* @param get - Zustand get function
|
|
22
33
|
* @returns Object with additional actions/methods
|
|
@@ -29,11 +40,12 @@ class CoreBaseBuilder {
|
|
|
29
40
|
* }
|
|
30
41
|
*/
|
|
31
42
|
extendActions(set, get) {
|
|
32
|
-
return {};
|
|
43
|
+
return { ...this.extensions.actions?.(set, get) };
|
|
33
44
|
}
|
|
34
45
|
/**
|
|
35
46
|
* Hook method to allow extending partialize storage
|
|
36
47
|
* Override this in child classes to persist custom properties
|
|
48
|
+
* Combines partialize config from child class implementation with runtime extensions
|
|
37
49
|
* @param state - Current store state
|
|
38
50
|
* @returns Object with properties to persist
|
|
39
51
|
* @example
|
|
@@ -44,7 +56,7 @@ class CoreBaseBuilder {
|
|
|
44
56
|
* }
|
|
45
57
|
*/
|
|
46
58
|
extendPartialize(state) {
|
|
47
|
-
return {};
|
|
59
|
+
return { ...this.extensions.partialize?.(state) };
|
|
48
60
|
}
|
|
49
61
|
/**
|
|
50
62
|
* Combines base state with extended state and actions
|