@viamedici-spc/configurator-react 1.0.2 → 1.0.3-rc0001
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/README.md +26 -33
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +409 -96
- package/dist/index.js +1038 -703
- package/package.json +18 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Atom } from 'jotai';
|
|
2
|
+
import { AtomFamily } from 'jotai/vanilla/utils/atomFamily';
|
|
2
3
|
import { Attribute } from '@viamedici-spc/configurator-ts';
|
|
3
|
-
import { AttributeRelations } from '@viamedici-spc/configurator-ts';
|
|
4
4
|
import { BooleanAttribute } from '@viamedici-spc/configurator-ts';
|
|
5
5
|
import { ChoiceAttribute } from '@viamedici-spc/configurator-ts';
|
|
6
|
+
import { ChoiceValue } from '@viamedici-spc/configurator-ts';
|
|
6
7
|
import { ChoiceValueDecisionState } from '@viamedici-spc/configurator-ts';
|
|
7
8
|
import { ChoiceValueId } from '@viamedici-spc/configurator-ts';
|
|
9
|
+
import { CollectedDecision } from '@viamedici-spc/configurator-ts';
|
|
10
|
+
import { CollectedExplicitDecision } from '@viamedici-spc/configurator-ts';
|
|
11
|
+
import { CollectedImplicitDecision } from '@viamedici-spc/configurator-ts';
|
|
8
12
|
import { ComponentAttribute } from '@viamedici-spc/configurator-ts';
|
|
9
13
|
import { ComponentDecisionState } from '@viamedici-spc/configurator-ts';
|
|
10
14
|
import { Configuration as Configuration_2 } from '@viamedici-spc/configurator-ts';
|
|
11
|
-
import {
|
|
15
|
+
import { ConfiguratorError } from '@viamedici-spc/configurator-ts';
|
|
12
16
|
import { ConstraintsExplainAnswer } from '@viamedici-spc/configurator-ts';
|
|
17
|
+
import { createStore } from 'jotai';
|
|
18
|
+
import { DecisionKind } from '@viamedici-spc/configurator-ts';
|
|
13
19
|
import { DecisionsExplainAnswer } from '@viamedici-spc/configurator-ts';
|
|
14
20
|
import { ExplainQuestion } from '@viamedici-spc/configurator-ts';
|
|
15
21
|
import { ExplainQuestionParam as ExplainQuestionParam_2 } from '@viamedici-spc/configurator-ts';
|
|
16
22
|
import { ExplainSolution } from '@viamedici-spc/configurator-ts';
|
|
17
23
|
import { ExplicitDecision } from '@viamedici-spc/configurator-ts';
|
|
18
|
-
import { FailureResult } from '@viamedici-spc/configurator-ts';
|
|
19
24
|
import { FullExplainAnswer } from '@viamedici-spc/configurator-ts';
|
|
20
25
|
import { GlobalAttributeId } from '@viamedici-spc/configurator-ts';
|
|
21
|
-
import {
|
|
26
|
+
import { GlobalAttributeIdKey } from '@viamedici-spc/configurator-ts';
|
|
27
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
28
|
+
import { MakeManyDecisionsMode } from '@viamedici-spc/configurator-ts';
|
|
29
|
+
import { MakeManyDecisionsResult } from '@viamedici-spc/configurator-ts';
|
|
22
30
|
import { NumericAttribute } from '@viamedici-spc/configurator-ts';
|
|
23
31
|
import { PropsWithChildren } from 'react';
|
|
24
|
-
import {
|
|
32
|
+
import { SessionContext } from '@viamedici-spc/configurator-ts';
|
|
33
|
+
import { StoredConfiguration } from '@viamedici-spc/configurator-ts';
|
|
25
34
|
import { WhyIsAttributeNotSatisfied } from '@viamedici-spc/configurator-ts';
|
|
26
35
|
import { WhyIsBooleanStateNotPossible } from '@viamedici-spc/configurator-ts';
|
|
27
36
|
import { WhyIsChoiceValueStateNotPossible } from '@viamedici-spc/configurator-ts';
|
|
@@ -29,174 +38,478 @@ import { WhyIsComponentStateNotPossible } from '@viamedici-spc/configurator-ts';
|
|
|
29
38
|
import { WhyIsNumericStateNotPossible } from '@viamedici-spc/configurator-ts';
|
|
30
39
|
import { WhyIsStateNotPossible } from '@viamedici-spc/configurator-ts';
|
|
31
40
|
|
|
32
|
-
export declare function Configuration(props: PropsWithChildren<ConfigurationProps>):
|
|
33
|
-
|
|
34
|
-
export declare type ConfigurationError = FailureResult & {
|
|
35
|
-
retry?: () => void;
|
|
36
|
-
};
|
|
41
|
+
export declare function Configuration(props: PropsWithChildren<ConfigurationProps>): JSX_2.Element;
|
|
37
42
|
|
|
38
43
|
export declare type ConfigurationInitialization = {
|
|
39
44
|
/**
|
|
40
|
-
* Gets whether the
|
|
41
|
-
* This information is required for some hooks to be safely used.
|
|
45
|
+
* Gets whether the Configuration is currently initializing.
|
|
42
46
|
*/
|
|
43
|
-
isInitializing: boolean;
|
|
44
|
-
|
|
45
|
-
* Houses a promise when the configuration is in the initializing state.
|
|
46
|
-
* The promise resolves upon completion of the configuration initialization, subsequently becoming null.
|
|
47
|
-
* A new promise is generated each time the configuration re-enters the initializing state.
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* The promise is wrapped in an object to navigate occasional issues where React fails to propagate updates of a React Context to child elements within a React Suspense barrier.
|
|
51
|
-
* Such situations can lead to the initialization promise persistently remaining non-null, and thus, being continuously thrown by the ConfigurationSuspender even after it has been fulfilled.
|
|
52
|
-
* Upon fulfillment of the promise, the encapsulation is imperatively updated to remove the promise for all listeners inside React Suspense barriers.
|
|
53
|
-
*/
|
|
54
|
-
isInitializingPromise: EncapsulatedPromise | null;
|
|
55
|
-
error?: ConfigurationError;
|
|
47
|
+
readonly isInitializing: boolean;
|
|
48
|
+
readonly error?: ConfiguratorErrorWithRetry;
|
|
56
49
|
};
|
|
57
50
|
|
|
58
51
|
export declare type ConfigurationProps = {
|
|
59
52
|
/**
|
|
60
|
-
* The
|
|
61
|
-
*
|
|
53
|
+
* The SessionContext that should be used to create the session. Every time the SessionContext change, a new Session is created and all decisions are tried to restore.
|
|
54
|
+
* @remarks A change to the SessionContext is detected using referentially equality. Consider using {@link useMemo} or {@link useRef} to keep the SessionContext unchanged during rendering.
|
|
62
55
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
sessionContext: SessionContext;
|
|
57
|
+
/**
|
|
58
|
+
* An optional Jotai store where all Atoms will be stored in. Defaults to the result of {@link getDefaultStore()}.
|
|
59
|
+
*/
|
|
60
|
+
jotaiStore?: ReturnType<typeof createStore>;
|
|
68
61
|
};
|
|
69
62
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
* So unsafe hooks like "useAttributes" can safely be used.
|
|
74
|
-
* See the hook documentation whether a hook is safe to use while initialization.
|
|
75
|
-
*/
|
|
76
|
-
export declare function ConfigurationSuspender(props: PropsWithChildren<{}>): JSX.Element;
|
|
63
|
+
export declare type ConfigurationUninitialized = "ConfigurationUninitialized";
|
|
64
|
+
|
|
65
|
+
export declare const ConfigurationUninitialized: ConfigurationUninitialized;
|
|
77
66
|
|
|
78
67
|
export declare type ConfigurationUpdating = {
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Gets whether the Configuration is currently updating.
|
|
70
|
+
*/
|
|
71
|
+
readonly isUpdating: boolean;
|
|
72
|
+
readonly error?: ConfiguratorErrorWithRetry;
|
|
81
73
|
};
|
|
82
74
|
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Represents an error that occurred during initializing or updating a Session.
|
|
77
|
+
*/
|
|
78
|
+
export declare type ConfiguratorErrorWithRetry = ConfiguratorError & {
|
|
79
|
+
/**
|
|
80
|
+
* Retry the failed operation.
|
|
81
|
+
*/
|
|
82
|
+
readonly retry?: () => void;
|
|
85
83
|
};
|
|
86
84
|
|
|
87
85
|
declare type ExplainQuestionParam<T extends WhyIsStateNotPossible> = SimplifiedExplainQuestion<WhyIsAttributeNotSatisfied> | SimplifiedExplainQuestion<T>;
|
|
88
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Represents an Atom which is guarded against access while the Configuration is not fully initialized.
|
|
89
|
+
*/
|
|
90
|
+
export declare type GuardedAtom<Value> = Atom<NonNullable<Value> | ConfigurationUninitialized>;
|
|
91
|
+
|
|
89
92
|
declare type SimplifiedExplainQuestion<T extends ExplainQuestion> = Omit<T, "attributeId" | "subject">;
|
|
90
93
|
|
|
91
94
|
declare type UseAttributeExplainResult<T extends WhyIsStateNotPossible> = {
|
|
92
|
-
explain
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
explain: {
|
|
96
|
+
(question: ExplainQuestionParam<T>, answerType: "decisions"): Promise<DecisionsExplainAnswer>;
|
|
97
|
+
(question: ExplainQuestionParam<T>, answerType: "constraints"): Promise<ConstraintsExplainAnswer>;
|
|
98
|
+
(question: ExplainQuestionParam<T>, answerType: "full"): Promise<FullExplainAnswer>;
|
|
99
|
+
};
|
|
100
|
+
applySolution(solution: ExplainSolution): Promise<MakeManyDecisionsResult>;
|
|
96
101
|
};
|
|
97
102
|
|
|
98
103
|
/**
|
|
99
|
-
* Retrieves
|
|
100
|
-
* @param attributes
|
|
101
|
-
* @
|
|
102
|
-
* Otherwise, they will appear as undefined. Only applicable if @param attributes has items. Defaults to false.
|
|
103
|
-
* @throws If configuration is initializing.
|
|
104
|
+
* Retrieves all existing attributes.
|
|
105
|
+
* @param attributes Set to "all" to retrieve all existing attributes.
|
|
106
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
104
107
|
*/
|
|
105
|
-
export declare function useAttributes(attributes
|
|
108
|
+
export declare function useAttributes(attributes: "all"): ReadonlyArray<Attribute>;
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
|
-
*
|
|
109
|
-
* @param
|
|
110
|
-
* @
|
|
111
|
-
* @returns Undefined if attribute doesn't exist, or it is not a boolean attribute.
|
|
111
|
+
* Retrieves all existing attributes.
|
|
112
|
+
* @param attributes Set to "all" to retrieve all existing attributes.
|
|
113
|
+
* @param suspend Whether to disable the Suspense API.
|
|
112
114
|
*/
|
|
113
|
-
export declare function
|
|
115
|
+
export declare function useAttributes(attributes: "all", suspend: false): ReadonlyArray<Attribute> | ConfigurationUninitialized;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Retrieves the requested attributes.
|
|
119
|
+
* @param attributes The attributes to return.
|
|
120
|
+
* @param filterMissingAttributes Whether to ignore that requested attributes are missing. Missing attributes will be filtered out of the result.
|
|
121
|
+
* @returns The requested attributes in the order of the {@link attributes} parameter.
|
|
122
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
123
|
+
*/
|
|
124
|
+
export declare function useAttributes(attributes: ReadonlyArray<GlobalAttributeId | GlobalAttributeIdKey>, filterMissingAttributes: true): ReadonlyArray<Attribute>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Retrieves the requested attributes.
|
|
128
|
+
* @param attributes The attributes to return.
|
|
129
|
+
* @param filterMissingAttributes Whether to ignore that requested attributes are missing. Missing attributes appear as undefined in the result.
|
|
130
|
+
* @returns The requested attributes in the order of the {@link attributes} parameter.
|
|
131
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
132
|
+
*/
|
|
133
|
+
export declare function useAttributes(attributes: ReadonlyArray<GlobalAttributeId | GlobalAttributeIdKey>, filterMissingAttributes: false): ReadonlyArray<Attribute | undefined>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Retrieves the requested attributes.
|
|
137
|
+
* @param attributes The attributes to return.
|
|
138
|
+
* @param filterMissingAttributes Whether to ignore that requested attributes are missing. Missing attributes will be filtered out of the result.
|
|
139
|
+
* @returns The requested attributes in the order of the {@link attributes} parameter.
|
|
140
|
+
* @param suspend Whether to disable the Suspense API.
|
|
141
|
+
*/
|
|
142
|
+
export declare function useAttributes(attributes: ReadonlyArray<GlobalAttributeId | GlobalAttributeIdKey>, filterMissingAttributes: true, suspend: false): ReadonlyArray<Attribute | undefined> | ConfigurationUninitialized;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves the requested attributes.
|
|
146
|
+
* @param attributes The attributes to return.
|
|
147
|
+
* @param filterMissingAttributes Whether to ignore that requested attributes are missing. Missing attributes appear as undefined in the result.
|
|
148
|
+
* @returns The requested attributes in the order of the {@link attributes} parameter.
|
|
149
|
+
* @param suspend Whether to disable the Suspense API.
|
|
150
|
+
*/
|
|
151
|
+
export declare function useAttributes(attributes: ReadonlyArray<GlobalAttributeId | GlobalAttributeIdKey>, filterMissingAttributes: false, suspend: false): ReadonlyArray<Attribute> | ConfigurationUninitialized;
|
|
152
|
+
|
|
153
|
+
export declare const useBooleanAttribute: {
|
|
154
|
+
/**
|
|
155
|
+
* Gets the requested boolean attribute with specific commands and queries.
|
|
156
|
+
* @param attributeIdOrKey The id of the boolean attribute.
|
|
157
|
+
* @returns Undefined if attribute doesn't exist, or it is not a boolean attribute.
|
|
158
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
159
|
+
*/
|
|
160
|
+
(attributeIdOrKey: GlobalAttributeId | GlobalAttributeIdKey): UseBooleanAttributeResult | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* Gets the requested boolean attribute with specific commands and queries.
|
|
163
|
+
* @param attributeIdOrKey The id of the boolean attribute.
|
|
164
|
+
* @param suspend Whether to disable the Suspense API.
|
|
165
|
+
* @returns Undefined if attribute doesn't exist, or it is not a boolean attribute.
|
|
166
|
+
*/
|
|
167
|
+
(attributeIdOrKey: GlobalAttributeId | GlobalAttributeIdKey, suspend: false): UseBooleanAttributeResult | undefined | ConfigurationUninitialized;
|
|
168
|
+
};
|
|
114
169
|
|
|
115
170
|
export declare type UseBooleanAttributeResult = UseAttributeExplainResult<WhyIsBooleanStateNotPossible> & {
|
|
116
171
|
attribute: BooleanAttribute;
|
|
117
172
|
makeDecision: (state: boolean | null | undefined) => Promise<void>;
|
|
173
|
+
isMandatory: () => boolean;
|
|
118
174
|
};
|
|
119
175
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
176
|
+
export declare const useChoiceAttribute: {
|
|
177
|
+
/**
|
|
178
|
+
* Gets the requested choice attribute with specific commands and queries.
|
|
179
|
+
* @param attributeIdOrKey The id or key of the choice attribute.
|
|
180
|
+
* @returns Undefined if attribute doesn't exist, or it is not a choice attribute.
|
|
181
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
182
|
+
*/
|
|
183
|
+
(attributeIdOrKey: GlobalAttributeId | GlobalAttributeIdKey): UseChoiceAttributeResult | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Gets the requested choice attribute with specific commands and queries.
|
|
186
|
+
* @param attributeIdOrKey The id or key of the choice attribute.
|
|
187
|
+
* @param suspend Whether to disable the Suspense API.
|
|
188
|
+
* @returns Undefined if attribute doesn't exist, or it is not a choice attribute.
|
|
189
|
+
*/
|
|
190
|
+
(attributeIdOrKey: GlobalAttributeId | GlobalAttributeIdKey, suspend: false): UseChoiceAttributeResult | undefined | ConfigurationUninitialized;
|
|
191
|
+
};
|
|
127
192
|
|
|
128
193
|
export declare type UseChoiceAttributeResult = UseAttributeExplainResult<WhyIsChoiceValueStateNotPossible> & {
|
|
129
194
|
attribute: ChoiceAttribute;
|
|
130
195
|
makeDecision: (choiceValueId: ChoiceValueId, state: ChoiceValueDecisionState | null | undefined) => Promise<void>;
|
|
131
196
|
clearDecisions: () => Promise<void>;
|
|
197
|
+
isMultiSelect: () => boolean;
|
|
198
|
+
isMandatory: () => boolean;
|
|
199
|
+
getAllowedChoiceValues: () => ReadonlyArray<ChoiceValue>;
|
|
200
|
+
getBlockedChoiceValues: () => ReadonlyArray<ChoiceValue>;
|
|
201
|
+
getIncludedChoiceValues: () => ReadonlyArray<ChoiceValue>;
|
|
202
|
+
isChoiceValueAllowed: (choiceValue: ChoiceValue) => boolean;
|
|
203
|
+
isChoiceValueBlocked: (choiceValue: ChoiceValue) => boolean;
|
|
132
204
|
};
|
|
133
205
|
|
|
134
|
-
export declare
|
|
206
|
+
export declare const useComponentAttribute: {
|
|
207
|
+
/**
|
|
208
|
+
* Gets the requested component attribute with specific commands and queries.
|
|
209
|
+
* @param attributeIdOrKey The id of the component attribute.
|
|
210
|
+
* @returns Undefined if attribute doesn't exist, or it is not a component attribute.
|
|
211
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
212
|
+
*/
|
|
213
|
+
(attributeIdOrKey: GlobalAttributeId | GlobalAttributeIdKey): UseComponentAttributeResult | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Gets the requested component attribute with specific commands and queries.
|
|
216
|
+
* @param attributeIdOrKey The id of the component attribute.
|
|
217
|
+
* @param suspend Whether to disable the Suspense API.
|
|
218
|
+
* @returns Undefined if attribute doesn't exist, or it is not a component attribute.
|
|
219
|
+
*/
|
|
220
|
+
(attributeIdOrKey: GlobalAttributeId | GlobalAttributeIdKey, suspend: false): UseComponentAttributeResult | undefined | ConfigurationUninitialized;
|
|
221
|
+
};
|
|
135
222
|
|
|
136
223
|
export declare type UseComponentAttributeResult = UseAttributeExplainResult<WhyIsComponentStateNotPossible> & {
|
|
137
224
|
attribute: ComponentAttribute;
|
|
138
225
|
makeDecision: (state: ComponentDecisionState | null | undefined) => Promise<void>;
|
|
139
|
-
|
|
226
|
+
isMandatory: () => boolean;
|
|
140
227
|
};
|
|
141
228
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
229
|
+
export declare const useConfiguration: {
|
|
230
|
+
/**
|
|
231
|
+
* Gets the current Configuration state.
|
|
232
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
233
|
+
*/
|
|
234
|
+
(): Configuration_2;
|
|
235
|
+
/**
|
|
236
|
+
* Gets the current Configuration state.
|
|
237
|
+
* @param suspend Whether to disable the Suspense API.
|
|
238
|
+
*/
|
|
239
|
+
(suspend: false): Configuration_2 | ConfigurationUninitialized;
|
|
240
|
+
};
|
|
147
241
|
|
|
148
242
|
/**
|
|
149
|
-
* Gets the initialization information for the
|
|
150
|
-
* This is safe to use if the configuration is initializing.
|
|
243
|
+
* Gets the initialization information for the Configuration.
|
|
151
244
|
*/
|
|
152
245
|
export declare function useConfigurationInitialization(): ConfigurationInitialization;
|
|
153
246
|
|
|
154
|
-
export declare
|
|
155
|
-
|
|
156
|
-
|
|
247
|
+
export declare const useConfigurationReset: {
|
|
248
|
+
/**
|
|
249
|
+
* Gets whether the Configuration can be reset and a command to actually reset the Configuration to its initial state.
|
|
250
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
251
|
+
*/
|
|
252
|
+
(): UseConfigurationResetResult;
|
|
253
|
+
/**
|
|
254
|
+
* Gets whether the Configuration can be reset and a command to actually reset the Configuration to its initial state.
|
|
255
|
+
* @param suspend Whether to disable the Suspense API.
|
|
256
|
+
*/
|
|
257
|
+
(suspend: false): UseConfigurationResetResult | ConfigurationUninitialized;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export declare type UseConfigurationResetResult = {
|
|
261
|
+
canResetConfiguration: boolean;
|
|
262
|
+
resetConfiguration: () => Promise<void>;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export declare const useConfigurationSatisfaction: {
|
|
266
|
+
/**
|
|
267
|
+
* Gets the Configuration satisfaction state and allows to explain an unsatisfied state.
|
|
268
|
+
* @remarks Will suspend until the configuration is fully initialized.
|
|
269
|
+
*/
|
|
270
|
+
(): UseConfigurationSatisfactionResult;
|
|
271
|
+
/**
|
|
272
|
+
* Gets the Configuration satisfaction state and allows to explain an unsatisfied state.
|
|
273
|
+
* @param suspend Whether to disable the Suspense API.
|
|
274
|
+
*/
|
|
275
|
+
(suspend: false): UseConfigurationSatisfactionResult | ConfigurationUninitialized;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export declare type UseConfigurationSatisfactionResult = {
|
|
279
|
+
isSatisfied: boolean;
|
|
280
|
+
explain: {
|
|
281
|
+
(answerType: "decisions"): Promise<DecisionsExplainAnswer>;
|
|
282
|
+
(answerType: "constraints"): Promise<ConstraintsExplainAnswer>;
|
|
283
|
+
(answerType: "full"): Promise<FullExplainAnswer>;
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
export declare const useConfigurationStoring: {
|
|
288
|
+
/**
|
|
289
|
+
* Gets commands to store and restore a Configuration.
|
|
290
|
+
* @remarks Will suspend until the configuration is fully initialized.
|
|
291
|
+
*/
|
|
292
|
+
(): UseConfigurationStoringResult;
|
|
293
|
+
/**
|
|
294
|
+
* Gets commands to store and restore a Configuration.
|
|
295
|
+
* @param suspend Whether to disable the Suspense API.
|
|
296
|
+
*/
|
|
297
|
+
(suspend: false): UseConfigurationStoringResult | ConfigurationUninitialized;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export declare type UseConfigurationStoringResult = {
|
|
301
|
+
storeConfiguration: () => Promise<StoredConfiguration>;
|
|
302
|
+
restoreConfiguration: (storedConfiguration: StoredConfiguration, mode: MakeManyDecisionsMode) => Promise<MakeManyDecisionsResult>;
|
|
157
303
|
};
|
|
158
304
|
|
|
159
305
|
/**
|
|
160
|
-
* Gets the updating information for the
|
|
161
|
-
* This is safe to use if the configuration is initializing.
|
|
306
|
+
* Gets the updating information for the Configuration.
|
|
162
307
|
*/
|
|
163
308
|
export declare function useConfigurationUpdating(): ConfigurationUpdating;
|
|
164
309
|
|
|
310
|
+
export declare const useConfiguratorStore: () => ReturnType<typeof createStore>;
|
|
311
|
+
|
|
312
|
+
export declare const useDecisionQueries: {
|
|
313
|
+
/**
|
|
314
|
+
* Gets commands to query the decisions of a Configuration.
|
|
315
|
+
* @remarks Will suspend until the configuration is fully initialized.
|
|
316
|
+
*/
|
|
317
|
+
(): UseDecisionQueriesResult;
|
|
318
|
+
/**
|
|
319
|
+
* Gets commands to query the decisions of a Configuration.
|
|
320
|
+
* @param suspend Whether to disable the Suspense API.
|
|
321
|
+
*/
|
|
322
|
+
(suspend: false): UseDecisionQueriesResult | ConfigurationUninitialized;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
export declare type UseDecisionQueriesResult = {
|
|
326
|
+
getDecisions(kind: DecisionKind.Explicit): ReadonlyArray<CollectedExplicitDecision>;
|
|
327
|
+
getDecisions(kind: DecisionKind.Explicit, queue: true): Promise<ReadonlyArray<CollectedExplicitDecision>>;
|
|
328
|
+
getDecisions(kind: DecisionKind.Implicit): ReadonlyArray<CollectedImplicitDecision>;
|
|
329
|
+
getDecisions(kind: DecisionKind.Implicit, queue: true): Promise<ReadonlyArray<CollectedImplicitDecision>>;
|
|
330
|
+
getDecisions(): ReadonlyArray<CollectedDecision>;
|
|
331
|
+
getDecisions(queue: true): Promise<ReadonlyArray<CollectedDecision>>;
|
|
332
|
+
};
|
|
333
|
+
|
|
165
334
|
/**
|
|
166
|
-
* Gets
|
|
167
|
-
* @
|
|
335
|
+
* Gets all implicit and explicit, non-optimistic decisions of the current Configuration.
|
|
336
|
+
* @remarks Will suspend until the configuration is fully initialized.
|
|
168
337
|
*/
|
|
169
|
-
export declare function
|
|
338
|
+
export declare function useDecisions(): ReadonlyArray<CollectedDecision>;
|
|
170
339
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
340
|
+
/**
|
|
341
|
+
* Gets all implicit and explicit, non-optimistic decisions of the current Configuration.
|
|
342
|
+
* @param suspend Whether to disable the Suspense API.
|
|
343
|
+
*/
|
|
344
|
+
export declare function useDecisions(suspend: false): ReadonlyArray<CollectedDecision> | ConfigurationUninitialized;
|
|
175
345
|
|
|
176
346
|
/**
|
|
177
|
-
* Gets
|
|
178
|
-
* @
|
|
347
|
+
* Gets all explicit non-optimistic decisions of the current Configuration.
|
|
348
|
+
* @param kind The kind of decisions that should be returned.
|
|
349
|
+
* @remarks Will suspend until the configuration is fully initialized.
|
|
179
350
|
*/
|
|
180
|
-
export declare function
|
|
351
|
+
export declare function useDecisions(kind: DecisionKind.Explicit): ReadonlyArray<CollectedExplicitDecision>;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Gets all explicit non-optimistic decisions of the current Configuration.
|
|
355
|
+
* @param kind The kind of decisions that should be returned.
|
|
356
|
+
* @param suspend Whether to disable the Suspense API.
|
|
357
|
+
*/
|
|
358
|
+
export declare function useDecisions(kind: DecisionKind.Explicit, suspend: false): ReadonlyArray<CollectedExplicitDecision> | ConfigurationUninitialized;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Gets all implicit non-optimistic decisions of the current Configuration.
|
|
362
|
+
* @param kind The kind of decisions that should be returned.
|
|
363
|
+
* @remarks Will suspend until the configuration is fully initialized.
|
|
364
|
+
*/
|
|
365
|
+
export declare function useDecisions(kind: DecisionKind.Implicit): ReadonlyArray<CollectedImplicitDecision>;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Gets all implicit non-optimistic decisions of the current Configuration.
|
|
369
|
+
* @param kind The kind of decisions that should be returned.
|
|
370
|
+
* @param suspend Whether to disable the Suspense API.
|
|
371
|
+
*/
|
|
372
|
+
export declare function useDecisions(kind: DecisionKind.Implicit, suspend: false): ReadonlyArray<CollectedImplicitDecision> | ConfigurationUninitialized;
|
|
373
|
+
|
|
374
|
+
export declare const useExplain: {
|
|
375
|
+
/**
|
|
376
|
+
* Gets commands for explaining circumstances.
|
|
377
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
378
|
+
*/
|
|
379
|
+
(): UseExplainResult;
|
|
380
|
+
/**
|
|
381
|
+
* Gets commands for explaining circumstances.
|
|
382
|
+
* @param suspend Whether to disable the Suspense API.
|
|
383
|
+
*/
|
|
384
|
+
(suspend: false): UseExplainResult | ConfigurationUninitialized;
|
|
385
|
+
};
|
|
181
386
|
|
|
182
387
|
export declare type UseExplainResult = {
|
|
183
388
|
explain(question: ExplainQuestionParam_2, answerType: "decisions"): Promise<DecisionsExplainAnswer>;
|
|
184
389
|
explain(question: ExplainQuestionParam_2, answerType: "constraints"): Promise<ConstraintsExplainAnswer>;
|
|
185
390
|
explain(question: ExplainQuestionParam_2, answerType: "full"): Promise<FullExplainAnswer>;
|
|
186
|
-
applySolution(solution: ExplainSolution): Promise<
|
|
391
|
+
applySolution(solution: ExplainSolution): Promise<MakeManyDecisionsResult>;
|
|
187
392
|
};
|
|
188
393
|
|
|
189
394
|
/**
|
|
190
|
-
* Gets
|
|
191
|
-
*
|
|
192
|
-
* @throws If configuration is initializing.
|
|
193
|
-
* @returns Undefined if attribute doesn't exist, or it is not a numeric attribute.
|
|
395
|
+
* Gets all Jotai based atoms and atom families of the Configuration session.
|
|
396
|
+
* They can be used to build more advanced reactive pipelines with Jotai.
|
|
194
397
|
*/
|
|
195
|
-
export declare function
|
|
398
|
+
export declare function useJotaiAtoms(): UseJotaiAtomsResult;
|
|
399
|
+
|
|
400
|
+
declare type UseJotaiAtomsResult = {
|
|
401
|
+
createAttributesAtom: {
|
|
402
|
+
(attributes: "all"): GuardedAtom<ReadonlyArray<Attribute>>;
|
|
403
|
+
(attributes: ReadonlyArray<GlobalAttributeId | GlobalAttributeIdKey>, filterMissingAttributes: true): GuardedAtom<ReadonlyArray<Attribute>>;
|
|
404
|
+
(attributes: ReadonlyArray<GlobalAttributeId | GlobalAttributeIdKey>, filterMissingAttributes: false): GuardedAtom<ReadonlyArray<Attribute | undefined>>;
|
|
405
|
+
};
|
|
406
|
+
getConfigurationInitializationAtom: Atom<ConfigurationInitialization>;
|
|
407
|
+
getConfigurationUpdatingAtom: Atom<ConfigurationUpdating>;
|
|
408
|
+
getChoiceAttributeAtomFamily: AtomFamily<GlobalAttributeIdKey, GuardedAtom<UseChoiceAttributeResult | undefined>>;
|
|
409
|
+
getNumericAttributeAtomFamily: AtomFamily<GlobalAttributeIdKey, GuardedAtom<UseNumericAttributeResult | undefined>>;
|
|
410
|
+
getBooleanAttributeAtomFamily: AtomFamily<GlobalAttributeIdKey, GuardedAtom<UseBooleanAttributeResult | undefined>>;
|
|
411
|
+
getComponentAttributeAtomFamily: AtomFamily<GlobalAttributeIdKey, GuardedAtom<UseComponentAttributeResult | undefined>>;
|
|
412
|
+
getConfigurationAtom: GuardedAtom<Configuration_2>;
|
|
413
|
+
getConfigurationStoringAtom: GuardedAtom<UseConfigurationStoringResult>;
|
|
414
|
+
getConfigurationSatisfactionAtom: GuardedAtom<UseConfigurationSatisfactionResult>;
|
|
415
|
+
getMakeDecisionAtom: GuardedAtom<UseMakeDecisionResult>;
|
|
416
|
+
getDecisionQueriesAtom: GuardedAtom<UseDecisionQueriesResult>;
|
|
417
|
+
getConfigurationResetAtom: GuardedAtom<UseConfigurationResetResult>;
|
|
418
|
+
getSessionReinitializationAtom: GuardedAtom<UseSessionReinitializationResult>;
|
|
419
|
+
getExplainAtom: GuardedAtom<UseExplainResult>;
|
|
420
|
+
getTaskSchedulingAtom: GuardedAtom<UseTaskSchedulingResult>;
|
|
421
|
+
getStoredConfigurationAtom: GuardedAtom<StoredConfiguration>;
|
|
422
|
+
getDecisionsAtom: GuardedAtom<ReadonlyArray<CollectedDecision>>;
|
|
423
|
+
getExplicitDecisionsAtom: GuardedAtom<ReadonlyArray<CollectedExplicitDecision>>;
|
|
424
|
+
getImplicitDecisionsAtom: GuardedAtom<NonNullable<ReadonlyArray<CollectedImplicitDecision>>>;
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
export declare const useMakeDecision: {
|
|
428
|
+
/**
|
|
429
|
+
* Gets commands for making one or many decisions.
|
|
430
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
431
|
+
*/
|
|
432
|
+
(): UseMakeDecisionResult;
|
|
433
|
+
/**
|
|
434
|
+
* Gets commands for making one or many decisions.
|
|
435
|
+
* @param suspend Whether to disable the Suspense API.
|
|
436
|
+
*/
|
|
437
|
+
(suspend: false): UseMakeDecisionResult | ConfigurationUninitialized;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
export declare type UseMakeDecisionResult = {
|
|
441
|
+
makeDecision: (decision: ExplicitDecision) => Promise<void>;
|
|
442
|
+
makeManyDecisions: (decisions: ReadonlyArray<ExplicitDecision>, mode: MakeManyDecisionsMode) => Promise<MakeManyDecisionsResult>;
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
export declare const useNumericAttribute: {
|
|
446
|
+
/**
|
|
447
|
+
* Gets the requested numeric attribute with specific commands and queries.
|
|
448
|
+
* @param attributeIdOrKey The id or key of the numeric attribute.
|
|
449
|
+
* @returns Undefined if attribute doesn't exist, or it is not a numeric attribute.
|
|
450
|
+
* @remarks Will suspend until the Configuration is fully initialized.
|
|
451
|
+
*/
|
|
452
|
+
(attributeIdOrKey: GlobalAttributeId | GlobalAttributeIdKey): UseNumericAttributeResult | undefined;
|
|
453
|
+
/**
|
|
454
|
+
* Gets the requested numeric attribute with specific commands and queries.
|
|
455
|
+
* @param attributeIdOrKey The id or key of the numeric attribute.
|
|
456
|
+
* @param suspend Whether to disable the Suspense API.
|
|
457
|
+
* @returns Undefined if attribute doesn't exist, or it is not a numeric attribute.
|
|
458
|
+
*/
|
|
459
|
+
(attributeIdOrKey: GlobalAttributeId | GlobalAttributeIdKey, suspend: false): UseNumericAttributeResult | undefined | ConfigurationUninitialized;
|
|
460
|
+
};
|
|
196
461
|
|
|
197
462
|
export declare type UseNumericAttributeResult = UseAttributeExplainResult<WhyIsNumericStateNotPossible> & {
|
|
198
463
|
attribute: NumericAttribute;
|
|
199
464
|
makeDecision: (state: number | null | undefined) => Promise<void>;
|
|
465
|
+
isMandatory: () => boolean;
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
export declare const useSessionReinitialization: {
|
|
469
|
+
/**
|
|
470
|
+
* Gets a command to reinitialize the session by creating a new session and attempts to migrate all existing decisions.
|
|
471
|
+
* @remarks Will suspend until the configuration is fully initialized.
|
|
472
|
+
*/
|
|
473
|
+
(): UseSessionReinitializationResult;
|
|
474
|
+
/**
|
|
475
|
+
* Gets a command to reinitialize the session by creating a new session and attempts to migrate all existing decisions.
|
|
476
|
+
* @param suspend Whether to disable the Suspense API.
|
|
477
|
+
*/
|
|
478
|
+
(suspend: false): UseSessionReinitializationResult | ConfigurationUninitialized;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
export declare type UseSessionReinitializationResult = {
|
|
482
|
+
reinitializeSession: () => Promise<void>;
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
export declare const useStoredConfiguration: {
|
|
486
|
+
/**
|
|
487
|
+
* Gets the current non-optimistic Configuration state.
|
|
488
|
+
* @remarks Will suspend until the configuration is fully initialized.
|
|
489
|
+
*/
|
|
490
|
+
(): StoredConfiguration;
|
|
491
|
+
/**
|
|
492
|
+
* Gets the current non-optimistic Configuration state.
|
|
493
|
+
* @param suspend Whether to disable the Suspense API.
|
|
494
|
+
*/
|
|
495
|
+
(suspend: false): StoredConfiguration | ConfigurationUninitialized;
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
export declare const useTaskScheduling: {
|
|
499
|
+
/**
|
|
500
|
+
* Gets a command to schedule tasks.
|
|
501
|
+
* @remarks Will suspend until the configuration is fully initialized.
|
|
502
|
+
*/
|
|
503
|
+
(): UseTaskSchedulingResult;
|
|
504
|
+
/**
|
|
505
|
+
* Gets a command to schedule tasks.
|
|
506
|
+
* @param suspend Whether to disable the Suspense API.
|
|
507
|
+
*/
|
|
508
|
+
(suspend: false): UseTaskSchedulingResult | ConfigurationUninitialized;
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
export declare type UseTaskSchedulingResult = {
|
|
512
|
+
scheduleTask: (signal?: AbortSignal | null) => Promise<void>;
|
|
200
513
|
};
|
|
201
514
|
|
|
202
515
|
export { }
|