@secmia/openui-flow 4.1.0 → 4.2.0
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/AGENTS.md +19 -0
- package/README.md +89 -0
- package/dist/index.d.mts +86 -4
- package/dist/index.d.ts +86 -4
- package/dist/index.js +344 -111
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +344 -111
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/AGENTS.md
CHANGED
|
@@ -30,6 +30,12 @@ Core evaluation APIs:
|
|
|
30
30
|
- createRequirementGraph(...)
|
|
31
31
|
- createDefaultRequirementGraph(...)
|
|
32
32
|
|
|
33
|
+
Graph safety guarantees:
|
|
34
|
+
|
|
35
|
+
- Dependency-aware topological ordering
|
|
36
|
+
- Deterministic tie-breaking for equal priority nodes
|
|
37
|
+
- Cycle and invalid dependency detection at graph creation
|
|
38
|
+
|
|
33
39
|
## Public API Surface (Current)
|
|
34
40
|
|
|
35
41
|
Primary component and types:
|
|
@@ -70,6 +76,7 @@ Level 1: style/class slot overrides
|
|
|
70
76
|
|
|
71
77
|
- Use styles and classNames
|
|
72
78
|
- Use unstyled to disable built-in inline style defaults
|
|
79
|
+
- Configure default OAuth button list with oauthProviders
|
|
73
80
|
|
|
74
81
|
Level 2: per-step custom rendering
|
|
75
82
|
|
|
@@ -114,6 +121,18 @@ Persistence:
|
|
|
114
121
|
- Configure via persistence prop
|
|
115
122
|
- Supports session, local, or custom storage driver
|
|
116
123
|
- Use versioned keys (example: flow-state:v1)
|
|
124
|
+
- Use persistence.onError to capture read/write/clear failures
|
|
125
|
+
|
|
126
|
+
Retry policy:
|
|
127
|
+
|
|
128
|
+
- Configure via retryPolicy prop
|
|
129
|
+
- Supports maxAttempts, initialDelayMs, factor, maxDelayMs, jitter, delay, and shouldRetry
|
|
130
|
+
- Adapter calls use retryPolicy backoff; validation errors are not retried unless explicitly allowed
|
|
131
|
+
|
|
132
|
+
Context patching:
|
|
133
|
+
|
|
134
|
+
- mergeContext now recursively merges plain nested objects
|
|
135
|
+
- Arrays are replaced, not merged
|
|
117
136
|
|
|
118
137
|
Validation:
|
|
119
138
|
|
package/README.md
CHANGED
|
@@ -422,6 +422,18 @@ Keep built-in UI structure, but override styles/classes for all slots.
|
|
|
422
422
|
/>
|
|
423
423
|
```
|
|
424
424
|
|
|
425
|
+
Configure OAuth button list in default footer:
|
|
426
|
+
|
|
427
|
+
```tsx
|
|
428
|
+
<AdaptiveFlow
|
|
429
|
+
oauthProviders={[
|
|
430
|
+
{ id: 'google', label: 'Continue with Google' },
|
|
431
|
+
{ id: 'github', label: 'Continue with GitHub' },
|
|
432
|
+
{ id: 'microsoft', label: 'Continue with Microsoft' },
|
|
433
|
+
]}
|
|
434
|
+
/>
|
|
435
|
+
```
|
|
436
|
+
|
|
425
437
|
Use `unstyled` to disable built-in inline defaults.
|
|
426
438
|
|
|
427
439
|
```tsx
|
|
@@ -462,6 +474,14 @@ Use `stepRegistry` to replace selected steps with your own components while leav
|
|
|
462
474
|
/>
|
|
463
475
|
```
|
|
464
476
|
|
|
477
|
+
`run(job)` semantics in custom renderers:
|
|
478
|
+
- sets `busy=true` during the async job
|
|
479
|
+
- clears previous global/field errors before execution
|
|
480
|
+
- catches and normalizes thrown errors into flow error state
|
|
481
|
+
- reverts `busy=false` on completion
|
|
482
|
+
|
|
483
|
+
Use it for custom step actions to keep consistent loading/error behavior.
|
|
484
|
+
|
|
465
485
|
### Level 3: custom renderer for all steps
|
|
466
486
|
|
|
467
487
|
Use `renderStep` for full step-body ownership. You can still reuse `defaultView` when useful.
|
|
@@ -825,6 +845,11 @@ const missing = await getMissingRequirements(context, graph);
|
|
|
825
845
|
- Step: current UI state for unmet requirement.
|
|
826
846
|
- RequirementGraph: graph nodes with optional priority, condition, and dependency metadata.
|
|
827
847
|
|
|
848
|
+
Graph behavior:
|
|
849
|
+
- Dependency-aware ordering uses topological sorting.
|
|
850
|
+
- Priority is used as tie-breaker among currently available nodes.
|
|
851
|
+
- Circular dependencies and unknown dependencies are rejected during graph creation.
|
|
852
|
+
|
|
828
853
|
Evaluation loop:
|
|
829
854
|
1. Build graph.
|
|
830
855
|
2. Evaluate active nodes.
|
|
@@ -862,6 +887,7 @@ Important types:
|
|
|
862
887
|
- `AdaptiveFlowSchemas`
|
|
863
888
|
- `AdaptiveFlowSchema`
|
|
864
889
|
- `AdaptiveFlowPersistence`
|
|
890
|
+
- `AdaptiveFlowOAuthProvider`
|
|
865
891
|
- `AdaptiveStepRegistry`
|
|
866
892
|
- `AdaptiveStepRendererArgs`
|
|
867
893
|
- `AdaptiveStepRenderArgs`
|
|
@@ -874,6 +900,49 @@ Important types:
|
|
|
874
900
|
|
|
875
901
|
---
|
|
876
902
|
|
|
903
|
+
## SSR and hydration notes
|
|
904
|
+
|
|
905
|
+
- Storage persistence only runs in the browser (`window` guard).
|
|
906
|
+
- On SSR, the flow starts from `initialValue`/defaults and then hydrates persisted browser state on mount.
|
|
907
|
+
- For App Router and other SSR setups, pass server-known session hints in `initialValue` to minimize client-side step flash.
|
|
908
|
+
|
|
909
|
+
Example:
|
|
910
|
+
|
|
911
|
+
```tsx
|
|
912
|
+
<AdaptiveFlow
|
|
913
|
+
initialValue={{
|
|
914
|
+
email: user.email ?? null,
|
|
915
|
+
isVerified: Boolean(user.emailVerifiedAt),
|
|
916
|
+
hasPassword: Boolean(user.hasPassword),
|
|
917
|
+
}}
|
|
918
|
+
persistence={{ key: 'flow-state:v1', storage: 'session' }}
|
|
919
|
+
/>
|
|
920
|
+
```
|
|
921
|
+
|
|
922
|
+
### Retry policy
|
|
923
|
+
|
|
924
|
+
Use `retryPolicy` to retry transient adapter failures with configurable backoff.
|
|
925
|
+
|
|
926
|
+
```tsx
|
|
927
|
+
<AdaptiveFlow
|
|
928
|
+
retryPolicy={{
|
|
929
|
+
maxAttempts: 4,
|
|
930
|
+
initialDelayMs: 200,
|
|
931
|
+
factor: 2,
|
|
932
|
+
maxDelayMs: 2000,
|
|
933
|
+
jitter: true,
|
|
934
|
+
shouldRetry: (error) => error.name !== 'FlowValidationError',
|
|
935
|
+
}}
|
|
936
|
+
/>
|
|
937
|
+
```
|
|
938
|
+
|
|
939
|
+
Default behavior:
|
|
940
|
+
- adapter calls are retried with exponential backoff
|
|
941
|
+
- non-adapter validation errors are not retried unless `shouldRetry` allows them
|
|
942
|
+
- retries use the browser/Node timer API, so no extra dependency is required
|
|
943
|
+
|
|
944
|
+
---
|
|
945
|
+
|
|
877
946
|
## Release checklist
|
|
878
947
|
|
|
879
948
|
- Ensure adapter methods return clear, user-safe errors.
|
|
@@ -899,6 +968,26 @@ OAuth return does not resume:
|
|
|
899
968
|
- Cause: missing `completeOAuth` or persistence disabled.
|
|
900
969
|
- Fix: implement `completeOAuth` and enable persistence.
|
|
901
970
|
|
|
971
|
+
Persistence write/read failures:
|
|
972
|
+
- Cause: storage quota, blocked storage, malformed persisted payload.
|
|
973
|
+
- Fix: pass `persistence.onError` to capture and report storage failures.
|
|
974
|
+
|
|
975
|
+
Custom nested context fields collapsing after patch:
|
|
976
|
+
- Cause: patching with a shallow object update.
|
|
977
|
+
- Fix: the flow now performs a recursive object merge for plain nested objects. Arrays are replaced, not merged.
|
|
978
|
+
|
|
979
|
+
```tsx
|
|
980
|
+
<AdaptiveFlow
|
|
981
|
+
persistence={{
|
|
982
|
+
key: 'flow-state:v1',
|
|
983
|
+
storage: 'local',
|
|
984
|
+
onError: (error, phase) => {
|
|
985
|
+
console.error('persistence failure', phase, error);
|
|
986
|
+
},
|
|
987
|
+
}}
|
|
988
|
+
/>
|
|
989
|
+
```
|
|
990
|
+
|
|
902
991
|
---
|
|
903
992
|
|
|
904
993
|
## License
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Built-in requirement keys that cover the default flow states supported by the package.
|
|
6
|
+
*/
|
|
4
7
|
declare const DefaultAppRequirements: {
|
|
5
8
|
readonly HAS_EMAIL: "has_email";
|
|
6
9
|
readonly EMAIL_VERIFIED: "email_verified";
|
|
@@ -10,6 +13,9 @@ declare const DefaultAppRequirements: {
|
|
|
10
13
|
readonly ACCEPTED_TOS: "accepted_tos";
|
|
11
14
|
readonly HAS_JOB_TITLE: "has_job_title";
|
|
12
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Built-in step keys used by the default flow UI and default requirement resolvers.
|
|
18
|
+
*/
|
|
13
19
|
declare const DefaultAdaptiveSteps: {
|
|
14
20
|
readonly COLLECT_EMAIL: "COLLECT_EMAIL";
|
|
15
21
|
readonly VERIFY_OTP: "VERIFY_OTP";
|
|
@@ -18,10 +24,15 @@ declare const DefaultAdaptiveSteps: {
|
|
|
18
24
|
readonly COLLECT_TOS: "COLLECT_TOS";
|
|
19
25
|
readonly COMPLETE: "COMPLETE";
|
|
20
26
|
};
|
|
27
|
+
/** Requirement key from the built-in default requirement set. */
|
|
21
28
|
type DefaultAppRequirement = (typeof DefaultAppRequirements)[keyof typeof DefaultAppRequirements];
|
|
29
|
+
/** Step key from the built-in default step set. */
|
|
22
30
|
type DefaultAdaptiveStep = (typeof DefaultAdaptiveSteps)[keyof typeof DefaultAdaptiveSteps];
|
|
31
|
+
/** Requirement key used by the engine, including custom app-specific requirements. */
|
|
23
32
|
type AppRequirement = DefaultAppRequirement | (string & {});
|
|
33
|
+
/** Step key used by the engine, including custom app-specific steps. */
|
|
24
34
|
type AdaptiveStep = DefaultAdaptiveStep | (string & {});
|
|
35
|
+
/** Base context shape managed by the default flow helpers and UI. */
|
|
25
36
|
type AdaptiveContextBase = {
|
|
26
37
|
email: string | null;
|
|
27
38
|
isVerified: boolean;
|
|
@@ -33,14 +44,23 @@ type AdaptiveContextBase = {
|
|
|
33
44
|
};
|
|
34
45
|
agreedToTos: boolean;
|
|
35
46
|
};
|
|
47
|
+
/** Alias for the default context shape used by the built-in component and hook. */
|
|
36
48
|
type AdaptiveContext = AdaptiveContextBase;
|
|
49
|
+
/** Default set of requirements used when a flow does not provide its own list. */
|
|
37
50
|
declare const defaultRequirements: DefaultAppRequirement[];
|
|
51
|
+
/** Default initial context used by the component and hook when no initialValue is provided. */
|
|
38
52
|
declare const initialContext: AdaptiveContextBase;
|
|
53
|
+
/** Utility type for APIs that may return either a synchronous or asynchronous value. */
|
|
39
54
|
type MaybePromise<T> = T | Promise<T>;
|
|
55
|
+
/** Resolver contract that maps one requirement to the step shown when it is unmet. */
|
|
40
56
|
type RequirementResolver<TContext = AdaptiveContextBase, TStep extends string = AdaptiveStep> = {
|
|
41
57
|
isMet: (context: TContext) => MaybePromise<boolean>;
|
|
42
58
|
step: TStep;
|
|
43
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Single requirement node in the requirement graph.
|
|
62
|
+
* The engine evaluates nodes by priority, dependency readiness, and custom conditions.
|
|
63
|
+
*/
|
|
44
64
|
type RequirementGraphNode<TContext, TRequirement extends string, TStep extends string> = {
|
|
45
65
|
requirement: TRequirement;
|
|
46
66
|
step: TStep;
|
|
@@ -49,13 +69,24 @@ type RequirementGraphNode<TContext, TRequirement extends string, TStep extends s
|
|
|
49
69
|
priority?: number;
|
|
50
70
|
dependsOn?: readonly TRequirement[];
|
|
51
71
|
};
|
|
72
|
+
/** Ordered requirement graph consumed by the engine evaluation helpers. */
|
|
52
73
|
type RequirementGraph<TContext, TRequirement extends string, TStep extends string> = readonly RequirementGraphNode<TContext, TRequirement, TStep>[];
|
|
74
|
+
/** Default requirement-to-step resolvers used by the built-in flow UI. */
|
|
53
75
|
declare const defaultRequirementResolvers: Record<DefaultAppRequirement, RequirementResolver<AdaptiveContextBase, AdaptiveStep>>;
|
|
76
|
+
/**
|
|
77
|
+
* Build a requirement graph from a requirement list, resolver map, and optional graph metadata.
|
|
78
|
+
*
|
|
79
|
+
* The function validates that dependencies refer to known resolver-backed requirements and
|
|
80
|
+
* rejects circular dependency chains at graph creation time.
|
|
81
|
+
*/
|
|
54
82
|
declare function createRequirementGraph<TContext, TRequirement extends string, TStep extends string>(requirements: readonly TRequirement[], resolvers: Partial<Record<TRequirement, RequirementResolver<TContext, TStep>>>, options?: {
|
|
55
83
|
priorities?: Partial<Record<TRequirement, number>>;
|
|
56
84
|
conditions?: Partial<Record<TRequirement, (context: TContext) => MaybePromise<boolean>>>;
|
|
57
85
|
dependencies?: Partial<Record<TRequirement, readonly TRequirement[]>>;
|
|
58
86
|
}): RequirementGraph<TContext, TRequirement, TStep>;
|
|
87
|
+
/**
|
|
88
|
+
* Build a requirement graph using the built-in default resolvers plus any app-specific overrides.
|
|
89
|
+
*/
|
|
59
90
|
declare function createDefaultRequirementGraph<TContext extends AdaptiveContextBase = AdaptiveContextBase, TRequirement extends string = DefaultAppRequirement, TStep extends string = AdaptiveStep>(options?: {
|
|
60
91
|
requirements?: readonly TRequirement[];
|
|
61
92
|
resolvers?: Partial<Record<TRequirement, RequirementResolver<TContext, TStep>>>;
|
|
@@ -63,10 +94,25 @@ declare function createDefaultRequirementGraph<TContext extends AdaptiveContextB
|
|
|
63
94
|
conditions?: Partial<Record<TRequirement, (context: TContext) => MaybePromise<boolean>>>;
|
|
64
95
|
dependencies?: Partial<Record<TRequirement, readonly TRequirement[]>>;
|
|
65
96
|
}): RequirementGraph<TContext, TRequirement, TStep>;
|
|
97
|
+
/**
|
|
98
|
+
* Evaluate the graph against the current context and return the next unmet step.
|
|
99
|
+
*
|
|
100
|
+
* Nodes are evaluated in dependency-aware order with deterministic tie-breaking.
|
|
101
|
+
*/
|
|
66
102
|
declare function evaluateNextStep<TContext, TRequirement extends string, TStep extends string>(context: TContext, graph: RequirementGraph<TContext, TRequirement, TStep>, completeStep: TStep): Promise<TStep>;
|
|
103
|
+
/**
|
|
104
|
+
* Return every unmet requirement for the current context in graph evaluation order.
|
|
105
|
+
*/
|
|
67
106
|
declare function getMissingRequirements<TContext, TRequirement extends string, TStep extends string>(context: TContext, graph: RequirementGraph<TContext, TRequirement, TStep>): Promise<TRequirement[]>;
|
|
68
107
|
|
|
69
|
-
|
|
108
|
+
/** Supported OAuth provider identifiers accepted by the adapter and default UI. */
|
|
109
|
+
type OAuthProvider = "google" | "apple" | (string & {});
|
|
110
|
+
/** Configurable OAuth provider label/id pair used by the default footer buttons. */
|
|
111
|
+
type AdaptiveFlowOAuthProvider = {
|
|
112
|
+
id: OAuthProvider | (string & {});
|
|
113
|
+
label: string;
|
|
114
|
+
};
|
|
115
|
+
/** Result returned by lookupByEmail to seed the flow with backend identity state. */
|
|
70
116
|
type IdentityResolution = {
|
|
71
117
|
accountExists: boolean;
|
|
72
118
|
hasPassword?: boolean;
|
|
@@ -74,6 +120,7 @@ type IdentityResolution = {
|
|
|
74
120
|
agreedToTos?: boolean;
|
|
75
121
|
profile?: Partial<AdaptiveContextBase["profile"]>;
|
|
76
122
|
};
|
|
123
|
+
/** Backend adapter contract used by the flow to delegate all side effects. */
|
|
77
124
|
type AdaptiveFlowAdapter<TContext extends AdaptiveContextBase = AdaptiveContextBase> = {
|
|
78
125
|
lookupByEmail?: (email: string) => Promise<IdentityResolution | null>;
|
|
79
126
|
requestOtp?: (email: string) => Promise<void>;
|
|
@@ -85,29 +132,40 @@ type AdaptiveFlowAdapter<TContext extends AdaptiveContextBase = AdaptiveContextB
|
|
|
85
132
|
startOAuth?: (provider: OAuthProvider, context: TContext) => Promise<void>;
|
|
86
133
|
completeOAuth?: (provider: OAuthProvider | null, context: TContext) => Promise<Partial<TContext> | void>;
|
|
87
134
|
};
|
|
135
|
+
/** Named style slots used by the built-in component shell and step renderers. */
|
|
88
136
|
type AdaptiveFlowStyleSlot = "shell" | "headerRow" | "eyebrow" | "title" | "badge" | "success" | "error" | "info" | "caption" | "formRow" | "formColumn" | "input" | "button" | "checkboxRow" | "complete" | "footer" | "oauthButton";
|
|
137
|
+
/** Inline style overrides keyed by the built-in style slots. */
|
|
89
138
|
type AdaptiveFlowStyles = Partial<Record<AdaptiveFlowStyleSlot, React.CSSProperties>>;
|
|
139
|
+
/** CSS class overrides keyed by the built-in style slots. */
|
|
90
140
|
type AdaptiveFlowClassNames = Partial<Record<AdaptiveFlowStyleSlot, string>>;
|
|
141
|
+
/** Minimal storage interface used by persistence drivers. */
|
|
91
142
|
type AdaptiveFlowStorageDriver = Pick<Storage, "getItem" | "setItem" | "removeItem">;
|
|
143
|
+
/** Persistence settings for storing and restoring flow state across reloads. */
|
|
92
144
|
type AdaptiveFlowPersistence<TContext extends AdaptiveContextBase = AdaptiveContextBase> = {
|
|
93
145
|
key: string;
|
|
94
146
|
storage?: "session" | "local" | AdaptiveFlowStorageDriver;
|
|
95
147
|
serialize?: (state: PersistedAdaptiveFlowState<TContext>) => string;
|
|
96
148
|
deserialize?: (value: string) => PersistedAdaptiveFlowState<TContext>;
|
|
97
149
|
clearOnComplete?: boolean;
|
|
150
|
+
onError?: (error: Error, phase: "read" | "write" | "clear") => void;
|
|
98
151
|
};
|
|
152
|
+
/** Persisted flow payload written to session/local/custom storage. */
|
|
99
153
|
type PersistedAdaptiveFlowState<TContext extends AdaptiveContextBase = AdaptiveContextBase> = {
|
|
100
154
|
context: TContext;
|
|
101
155
|
oauthPendingProvider: OAuthProvider | null;
|
|
102
156
|
};
|
|
157
|
+
/** Context wrapper passed into validators so they can inspect the current flow state. */
|
|
103
158
|
type AdaptiveFlowValidationContext<TContext extends AdaptiveContextBase = AdaptiveContextBase> = {
|
|
104
159
|
context: TContext;
|
|
105
160
|
};
|
|
161
|
+
/** Validator failure payload that can target a specific field or the whole form. */
|
|
106
162
|
type AdaptiveFlowValidationIssue = {
|
|
107
163
|
message: string;
|
|
108
164
|
field?: string;
|
|
109
165
|
};
|
|
166
|
+
/** Validator return type supported by the component and hook. */
|
|
110
167
|
type AdaptiveFlowValidationResult = string | AdaptiveFlowValidationIssue | void | Promise<string | AdaptiveFlowValidationIssue | void>;
|
|
168
|
+
/** Schema adapter contract used for optional Zod-friendly validation. */
|
|
111
169
|
type AdaptiveFlowSchema<TValue> = {
|
|
112
170
|
safeParse?: (value: TValue) => {
|
|
113
171
|
success: boolean;
|
|
@@ -121,6 +179,7 @@ type AdaptiveFlowSchema<TValue> = {
|
|
|
121
179
|
};
|
|
122
180
|
parse?: (value: TValue) => unknown;
|
|
123
181
|
};
|
|
182
|
+
/** Optional schema map for built-in step fields. */
|
|
124
183
|
type AdaptiveFlowSchemas = {
|
|
125
184
|
email?: AdaptiveFlowSchema<string>;
|
|
126
185
|
otp?: AdaptiveFlowSchema<string>;
|
|
@@ -128,7 +187,19 @@ type AdaptiveFlowSchemas = {
|
|
|
128
187
|
profile?: AdaptiveFlowSchema<AdaptiveContextBase["profile"]>;
|
|
129
188
|
tos?: AdaptiveFlowSchema<boolean>;
|
|
130
189
|
};
|
|
190
|
+
/** Backoff settings used to retry transient adapter calls and OAuth completion. */
|
|
191
|
+
type AdaptiveFlowRetryPolicy = {
|
|
192
|
+
maxAttempts?: number;
|
|
193
|
+
initialDelayMs?: number;
|
|
194
|
+
factor?: number;
|
|
195
|
+
maxDelayMs?: number;
|
|
196
|
+
jitter?: boolean;
|
|
197
|
+
shouldRetry?: (error: Error, attempt: number) => boolean;
|
|
198
|
+
delay?: (attempt: number) => number;
|
|
199
|
+
};
|
|
200
|
+
/** Field error bag keyed by field path or logical field name. */
|
|
131
201
|
type AdaptiveFlowFieldErrors = Partial<Record<string, string>>;
|
|
202
|
+
/** Validator map for the built-in flow fields. */
|
|
132
203
|
type AdaptiveFlowValidators<TContext extends AdaptiveContextBase = AdaptiveContextBase> = {
|
|
133
204
|
email?: (input: string, payload: AdaptiveFlowValidationContext<TContext>) => AdaptiveFlowValidationResult;
|
|
134
205
|
otp?: (input: string, payload: AdaptiveFlowValidationContext<TContext> & {
|
|
@@ -140,12 +211,14 @@ type AdaptiveFlowValidators<TContext extends AdaptiveContextBase = AdaptiveConte
|
|
|
140
211
|
profile?: (input: AdaptiveContextBase["profile"], payload: AdaptiveFlowValidationContext<TContext>) => AdaptiveFlowValidationResult;
|
|
141
212
|
tos?: (accepted: boolean, payload: AdaptiveFlowValidationContext<TContext>) => AdaptiveFlowValidationResult;
|
|
142
213
|
};
|
|
214
|
+
/** Transition record emitted whenever the evaluated step changes. */
|
|
143
215
|
type AdaptiveStepTransition<TStep extends string = AdaptiveStep> = {
|
|
144
216
|
from: TStep | null;
|
|
145
217
|
to: TStep;
|
|
146
218
|
at: number;
|
|
147
219
|
attempt: number;
|
|
148
220
|
};
|
|
221
|
+
/** Arguments supplied to a stepRegistry renderer for a specific step. */
|
|
149
222
|
type AdaptiveStepRendererArgs<TContext extends AdaptiveContextBase, TRequirement extends string, TStep extends string> = {
|
|
150
223
|
step: TStep;
|
|
151
224
|
context: TContext;
|
|
@@ -160,7 +233,9 @@ type AdaptiveStepRendererArgs<TContext extends AdaptiveContextBase, TRequirement
|
|
|
160
233
|
adapter?: AdaptiveFlowAdapter<TContext>;
|
|
161
234
|
transitions: AdaptiveStepTransition<TStep>[];
|
|
162
235
|
};
|
|
236
|
+
/** Registry that overrides the UI for selected steps. */
|
|
163
237
|
type AdaptiveStepRegistry<TContext extends AdaptiveContextBase, TRequirement extends string, TStep extends string> = Partial<Record<TStep, (args: AdaptiveStepRendererArgs<TContext, TRequirement, TStep>) => React.ReactNode>>;
|
|
238
|
+
/** Arguments supplied to renderStep for full step-body customization. */
|
|
164
239
|
type AdaptiveStepRenderArgs<TContext extends AdaptiveContextBase = AdaptiveContextBase, TRequirement extends string = AppRequirement, TStep extends string = AdaptiveStep> = {
|
|
165
240
|
step: TStep;
|
|
166
241
|
context: TContext;
|
|
@@ -176,6 +251,7 @@ type AdaptiveStepRenderArgs<TContext extends AdaptiveContextBase = AdaptiveConte
|
|
|
176
251
|
adapter?: AdaptiveFlowAdapter<TContext>;
|
|
177
252
|
transitions: AdaptiveStepTransition<TStep>[];
|
|
178
253
|
};
|
|
254
|
+
/** Props accepted by the AdaptiveFlow component. */
|
|
179
255
|
type AdaptiveFlowProps<TContext extends AdaptiveContextBase = AdaptiveContext, TRequirement extends string = AppRequirement, TStep extends string = AdaptiveStep> = {
|
|
180
256
|
adapter?: AdaptiveFlowAdapter<TContext>;
|
|
181
257
|
requirements?: readonly TRequirement[];
|
|
@@ -201,8 +277,12 @@ type AdaptiveFlowProps<TContext extends AdaptiveContextBase = AdaptiveContext, T
|
|
|
201
277
|
persistence?: AdaptiveFlowPersistence<TContext>;
|
|
202
278
|
validators?: AdaptiveFlowValidators<TContext>;
|
|
203
279
|
schemas?: AdaptiveFlowSchemas;
|
|
280
|
+
oauthProviders?: readonly AdaptiveFlowOAuthProvider[];
|
|
281
|
+
retryPolicy?: AdaptiveFlowRetryPolicy;
|
|
204
282
|
};
|
|
283
|
+
/** Options accepted by the headless useAdaptiveFlow hook. */
|
|
205
284
|
type UseAdaptiveFlowOptions<TContext extends AdaptiveContextBase = AdaptiveContext, TRequirement extends string = AppRequirement, TStep extends string = AdaptiveStep> = Omit<AdaptiveFlowProps<TContext, TRequirement, TStep>, "stepTitles" | "renderStep" | "stepRegistry" | "className" | "classNames" | "styles" | "unstyled">;
|
|
285
|
+
/** Result object returned by useAdaptiveFlow. */
|
|
206
286
|
type UseAdaptiveFlowResult<TContext extends AdaptiveContextBase, TRequirement extends string, TStep extends string> = {
|
|
207
287
|
context: TContext;
|
|
208
288
|
step: TStep;
|
|
@@ -223,7 +303,9 @@ type UseAdaptiveFlowResult<TContext extends AdaptiveContextBase, TRequirement ex
|
|
|
223
303
|
handleTos: () => void;
|
|
224
304
|
handleOAuth: (provider: OAuthProvider) => void;
|
|
225
305
|
};
|
|
226
|
-
|
|
227
|
-
declare function
|
|
306
|
+
/** Headless flow hook that owns state, evaluation, persistence, retries, and adapter wiring. */
|
|
307
|
+
declare function useAdaptiveFlow<TContext extends AdaptiveContextBase = AdaptiveContext, TRequirement extends string = AppRequirement, TStep extends string = AdaptiveStep>({ adapter, requirements, requirementGraph, requirementGraphConfig, requirementResolvers, completeStep, initialValue, onComplete, onError, onStepTransition, persistence, validators, schemas, oauthProviders, retryPolicy, }: UseAdaptiveFlowOptions<TContext, TRequirement, TStep>): UseAdaptiveFlowResult<TContext, TRequirement, TStep>;
|
|
308
|
+
/** Default UI wrapper around useAdaptiveFlow that renders the built-in flow shell and step UI. */
|
|
309
|
+
declare function AdaptiveFlow<TContext extends AdaptiveContextBase = AdaptiveContext, TRequirement extends string = AppRequirement, TStep extends string = AdaptiveStep>({ adapter, requirements, requirementGraph, requirementGraphConfig, requirementResolvers, completeStep, stepTitles, renderStep, stepRegistry, initialValue, onComplete, onError, onStepTransition, className, classNames, styles, unstyled, persistence, validators, schemas, oauthProviders, retryPolicy, }: AdaptiveFlowProps<TContext, TRequirement, TStep>): react_jsx_runtime.JSX.Element;
|
|
228
310
|
|
|
229
|
-
export { type AdaptiveContext, type AdaptiveContextBase, AdaptiveFlow, type AdaptiveFlowAdapter, type AdaptiveFlowClassNames, type AdaptiveFlowFieldErrors, type AdaptiveFlowPersistence, type AdaptiveFlowProps, type AdaptiveFlowSchema, type AdaptiveFlowSchemas, type AdaptiveFlowStorageDriver, type AdaptiveFlowStyleSlot, type AdaptiveFlowStyles, type AdaptiveFlowValidationContext, type AdaptiveFlowValidationIssue, type AdaptiveFlowValidationResult, type AdaptiveFlowValidators, type AdaptiveStep, type AdaptiveStepRegistry, type AdaptiveStepRenderArgs, type AdaptiveStepRendererArgs, type AdaptiveStepTransition, type AppRequirement, type DefaultAdaptiveStep, DefaultAdaptiveSteps, type DefaultAppRequirement, DefaultAppRequirements, type IdentityResolution, type MaybePromise, type OAuthProvider, type PersistedAdaptiveFlowState, type RequirementGraph, type RequirementGraphNode, type RequirementResolver, type UseAdaptiveFlowOptions, type UseAdaptiveFlowResult, createDefaultRequirementGraph, createRequirementGraph, defaultRequirementResolvers, defaultRequirements, evaluateNextStep, getMissingRequirements, initialContext, useAdaptiveFlow };
|
|
311
|
+
export { type AdaptiveContext, type AdaptiveContextBase, AdaptiveFlow, type AdaptiveFlowAdapter, type AdaptiveFlowClassNames, type AdaptiveFlowFieldErrors, type AdaptiveFlowOAuthProvider, type AdaptiveFlowPersistence, type AdaptiveFlowProps, type AdaptiveFlowRetryPolicy, type AdaptiveFlowSchema, type AdaptiveFlowSchemas, type AdaptiveFlowStorageDriver, type AdaptiveFlowStyleSlot, type AdaptiveFlowStyles, type AdaptiveFlowValidationContext, type AdaptiveFlowValidationIssue, type AdaptiveFlowValidationResult, type AdaptiveFlowValidators, type AdaptiveStep, type AdaptiveStepRegistry, type AdaptiveStepRenderArgs, type AdaptiveStepRendererArgs, type AdaptiveStepTransition, type AppRequirement, type DefaultAdaptiveStep, DefaultAdaptiveSteps, type DefaultAppRequirement, DefaultAppRequirements, type IdentityResolution, type MaybePromise, type OAuthProvider, type PersistedAdaptiveFlowState, type RequirementGraph, type RequirementGraphNode, type RequirementResolver, type UseAdaptiveFlowOptions, type UseAdaptiveFlowResult, createDefaultRequirementGraph, createRequirementGraph, defaultRequirementResolvers, defaultRequirements, evaluateNextStep, getMissingRequirements, initialContext, useAdaptiveFlow };
|