processfocus 0.1.0-next.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/LICENSE.md +28 -0
- package/README.md +14 -0
- package/dist/auth-FmXptohB.mjs +275 -0
- package/dist/auth-config/src/lib/authentication-config.d.ts +146 -0
- package/dist/auth-config/src/lib/custom-entities-config.d.ts +47 -0
- package/dist/auth-config/src/lib/policies-config.d.ts +52 -0
- package/dist/auth-config/src/lib/provider-types.d.ts +194 -0
- package/dist/auth.d.ts +4 -0
- package/dist/auth.mjs +2 -0
- package/dist/business-calendar/src/index.d.ts +10 -0
- package/dist/business-calendar/src/lib/calendar-config.d.ts +163 -0
- package/dist/business-calendar/src/lib/calendar-period.d.ts +88 -0
- package/dist/business-calendar/src/lib/calendar-service-impl.d.ts +19 -0
- package/dist/business-calendar/src/lib/calendar-service.d.ts +215 -0
- package/dist/business-calendar/src/lib/datetime-utils.d.ts +30 -0
- package/dist/business-calendar/src/lib/duration-calculator.d.ts +49 -0
- package/dist/business-calendar/src/lib/errors.d.ts +69 -0
- package/dist/business-calendar/src/lib/holiday-calculator.d.ts +61 -0
- package/dist/business-calendar/src/lib/holidays.d.ts +141 -0
- package/dist/business-calendar/src/lib/types.d.ts +110 -0
- package/dist/calendar.d.ts +1 -0
- package/dist/calendar.mjs +1204 -0
- package/dist/form-client-representation/src/index.d.ts +6 -0
- package/dist/form-client-representation/src/lib/as-client-representation.d.ts +31 -0
- package/dist/form-client-representation/src/lib/client-form-definition.d.ts +17 -0
- package/dist/form-client-representation/src/lib/extract-annotations.d.ts +20 -0
- package/dist/form-client-representation/src/lib/plugin-registry.d.ts +6 -0
- package/dist/form-client-representation/src/lib/types.d.ts +239 -0
- package/dist/form-client-representation/src/lib/walker.d.ts +68 -0
- package/dist/form-rule/src/index.d.ts +3 -0
- package/dist/form-rule/src/lib/evaluator.d.ts +2 -0
- package/dist/form-rule/src/lib/paths.d.ts +9 -0
- package/dist/form-rule/src/lib/types.d.ts +89 -0
- package/dist/form-schema/src/index.d.ts +8 -0
- package/dist/form-schema/src/lib/annotation-helpers.d.ts +8 -0
- package/dist/form-schema/src/lib/deferred-value.d.ts +10 -0
- package/dist/form-schema/src/lib/email.d.ts +23 -0
- package/dist/form-schema/src/lib/field-count.d.ts +32 -0
- package/dist/form-schema/src/lib/form-annotations.d.ts +25 -0
- package/dist/form-schema/src/lib/form-schema.d.ts +459 -0
- package/dist/form-schema/src/lib/phone.d.ts +4 -0
- package/dist/form-schema/src/lib/property-signature.d.ts +3 -0
- package/dist/form-submission-schema/src/index.d.ts +2 -0
- package/dist/form-submission-schema/src/lib/form-submission-schema.d.ts +49 -0
- package/dist/form-submission-schema/src/lib/schema-defaults.d.ts +16 -0
- package/dist/forms.d.ts +1 -0
- package/dist/forms.mjs +2 -0
- package/dist/frontend-manifest/src/index.d.ts +2 -0
- package/dist/frontend-manifest/src/lib/browser-plugin-artifact.d.ts +25 -0
- package/dist/frontend-manifest/src/lib/frontend-manifest.d.ts +83 -0
- package/dist/frontend-plugin-host/src/index.d.ts +2 -0
- package/dist/frontend-plugin-host/src/lib/frontend-plugin-host.d.ts +124 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.mjs +3780 -0
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.mjs +5 -0
- package/dist/paths-BkzLn-rG.mjs +282 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.mjs +84 -0
- package/dist/process/src/lib/app-icons.d.ts +52 -0
- package/dist/process/src/lib/brands.d.ts +20 -0
- package/dist/process/src/lib/document-store.d.ts +30 -0
- package/dist/process/src/lib/execution-failure-notifications.d.ts +14 -0
- package/dist/process/src/lib/flow-context.d.ts +181 -0
- package/dist/process/src/lib/flow-path.d.ts +123 -0
- package/dist/process/src/lib/form-authoring.d.ts +19 -0
- package/dist/process/src/lib/form-decoration.d.ts +13 -0
- package/dist/process/src/lib/form-defaults.d.ts +5 -0
- package/dist/process/src/lib/form.d.ts +557 -0
- package/dist/process/src/lib/invitation.d.ts +35 -0
- package/dist/process/src/lib/list.d.ts +447 -0
- package/dist/process/src/lib/lookup-accessor.d.ts +68 -0
- package/dist/process/src/lib/node_step.d.ts +68 -0
- package/dist/process/src/lib/org-unit.d.ts +53 -0
- package/dist/process/src/lib/org-utils.d.ts +56 -0
- package/dist/process/src/lib/organisation-frontend-plugin-manifest.d.ts +33 -0
- package/dist/process/src/lib/organisation.d.ts +166 -0
- package/dist/process/src/lib/phase.d.ts +16 -0
- package/dist/process/src/lib/process.d.ts +196 -0
- package/dist/process/src/lib/public-form-branding.d.ts +27 -0
- package/dist/process/src/lib/role.d.ts +29 -0
- package/dist/process/src/lib/schedule.d.ts +239 -0
- package/dist/process/src/lib/sla.d.ts +84 -0
- package/dist/process/src/lib/stats-view.d.ts +68 -0
- package/dist/process/src/lib/step.d.ts +130 -0
- package/dist/process/src/lib/system-step-executor.d.ts +130 -0
- package/dist/process/src/lib/system-step.d.ts +248 -0
- package/dist/sdk/src/auth.d.ts +4 -0
- package/dist/sdk/src/calendar.d.ts +1 -0
- package/dist/sdk/src/forms.d.ts +1 -0
- package/dist/sdk/src/index.d.ts +26 -0
- package/dist/sdk/src/manifest.d.ts +2 -0
- package/dist/sdk/src/plugin.d.ts +3 -0
- package/dist/sdk/src/testing.d.ts +9 -0
- package/dist/src-C-909PVQ.mjs +498 -0
- package/dist/testing.d.ts +9 -0
- package/dist/testing.mjs +5 -0
- package/package.json +67 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow context types and utilities for accessing step metadata in callbacks.
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe access to information about who completed previous steps
|
|
5
|
+
* in a process flow.
|
|
6
|
+
*/
|
|
7
|
+
import { DateTime, type Effect, type Schema } from "effect";
|
|
8
|
+
import type { FlattenFields } from "../../../form-submission-schema/src/index.js";
|
|
9
|
+
/**
|
|
10
|
+
* Capitalize the first letter of a string at the type level.
|
|
11
|
+
*/
|
|
12
|
+
type Capitalize<S extends string> = S extends `${infer F}${infer R}` ? `${Uppercase<F>}${R}` : S;
|
|
13
|
+
/**
|
|
14
|
+
* Convert a string to camelCase at the type level.
|
|
15
|
+
* Handles spaces, underscores, and hyphens as word separators.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* type T1 = CamelCase<"Submit time off request"> // "submitTimeOffRequest"
|
|
19
|
+
* type T2 = CamelCase<"approve_request"> // "approveRequest"
|
|
20
|
+
* type T3 = CamelCase<"my-step"> // "myStep"
|
|
21
|
+
* type T4 = CamelCase<"alreadyCamel"> // "alreadycamel" (lowercased)
|
|
22
|
+
*/
|
|
23
|
+
export type CamelCase<S extends string> = S extends `${infer Word} ${infer Rest}` ? `${Lowercase<Word>}${CamelCaseRest<Rest>}` : S extends `${infer Word}_${infer Rest}` ? `${Lowercase<Word>}${CamelCaseRest<Rest>}` : S extends `${infer Word}-${infer Rest}` ? `${Lowercase<Word>}${CamelCaseRest<Rest>}` : Lowercase<S>;
|
|
24
|
+
/**
|
|
25
|
+
* Helper for CamelCase - processes remaining words with capitalization.
|
|
26
|
+
*/
|
|
27
|
+
type CamelCaseRest<S extends string> = S extends `${infer Word} ${infer Rest}` ? `${Capitalize<Lowercase<Word>>}${CamelCaseRest<Rest>}` : S extends `${infer Word}_${infer Rest}` ? `${Capitalize<Lowercase<Word>>}${CamelCaseRest<Rest>}` : S extends `${infer Word}-${infer Rest}` ? `${Capitalize<Lowercase<Word>>}${CamelCaseRest<Rest>}` : Capitalize<Lowercase<S>>;
|
|
28
|
+
/**
|
|
29
|
+
* Convert a string to a valid camelCase JavaScript identifier.
|
|
30
|
+
* Handles spaces, underscores, hyphens, and removes invalid characters.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* toCamelCase("Submit time off request") // "submitTimeOffRequest"
|
|
34
|
+
* toCamelCase("approve_request") // "approveRequest"
|
|
35
|
+
* toCamelCase("my-step") // "myStep"
|
|
36
|
+
* toCamelCase("123 invalid start") // "invalidStart" (removes leading digits)
|
|
37
|
+
*/
|
|
38
|
+
export declare function toCamelCase(str: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Extract the step ID from a step path.
|
|
41
|
+
* Step paths are like "OrgUnit/Process/StepId" or "/OrgUnit/Process/StepId" - we want "StepId".
|
|
42
|
+
*
|
|
43
|
+
* Handles optional leading slash for backward compatibility.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getStepIdFromPath(stepPath: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Basic user info from the user table.
|
|
48
|
+
* This is minimal - just the auth identity.
|
|
49
|
+
*/
|
|
50
|
+
export interface StepUserInfo {
|
|
51
|
+
/** User ID (e.g., "usr-01ABC...") */
|
|
52
|
+
userId: string;
|
|
53
|
+
/** Subject from auth provider (might be email, might be UUID) */
|
|
54
|
+
sub: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Provider user info from the provider user table.
|
|
58
|
+
* Richer identity information for users who are provider users.
|
|
59
|
+
*/
|
|
60
|
+
export interface StepProviderUserInfo {
|
|
61
|
+
/** Provider user ID (e.g., "emp-01ABC...") */
|
|
62
|
+
id: string;
|
|
63
|
+
/** Full name */
|
|
64
|
+
name: string;
|
|
65
|
+
/** First name */
|
|
66
|
+
firstName: string;
|
|
67
|
+
/** Last name */
|
|
68
|
+
lastName: string;
|
|
69
|
+
/** Email address */
|
|
70
|
+
email: string;
|
|
71
|
+
/** Profile picture URL */
|
|
72
|
+
picture: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Metadata about a completed step.
|
|
76
|
+
* Provider user info is always present - for M2M/system users without provider user records,
|
|
77
|
+
* the user's sub is used as fallback for name/email fields.
|
|
78
|
+
*/
|
|
79
|
+
export interface StepMeta {
|
|
80
|
+
/** The user who completed the step */
|
|
81
|
+
user: StepUserInfo;
|
|
82
|
+
/** Provider user info - always present (uses user.sub as fallback for M2M users) */
|
|
83
|
+
providerUser: StepProviderUserInfo;
|
|
84
|
+
/** When the step was completed */
|
|
85
|
+
completedAt: DateTime.DateTime;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Metadata about a completed Form step.
|
|
89
|
+
* Alias for StepMeta - both now guarantee providerUser is present.
|
|
90
|
+
*/
|
|
91
|
+
export type FormStepMeta = StepMeta;
|
|
92
|
+
/**
|
|
93
|
+
* Process-level metadata.
|
|
94
|
+
*/
|
|
95
|
+
export interface ProcessMeta {
|
|
96
|
+
/** Process execution ID */
|
|
97
|
+
executionId: string;
|
|
98
|
+
/** When the process was started */
|
|
99
|
+
startedAt: DateTime.DateTime;
|
|
100
|
+
/** Metadata about the first step (who started the process) */
|
|
101
|
+
startStep: StepMeta;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The context object passed to form(), summary(), and condition callbacks.
|
|
105
|
+
* Provides access to process and step metadata.
|
|
106
|
+
*
|
|
107
|
+
* @typeParam TSteps - Record mapping step keys (camelCase) to StepMeta
|
|
108
|
+
*/
|
|
109
|
+
export interface FlowContext<TSteps extends Record<string, StepMeta>> {
|
|
110
|
+
/** Process-level metadata */
|
|
111
|
+
process: ProcessMeta;
|
|
112
|
+
/** Completed step metadata, keyed by camelCase step ID */
|
|
113
|
+
step: TSteps;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Resolves persisted provider-user identifiers to request-time display values.
|
|
117
|
+
* Process state should keep the submitted id/email; summaries can use this to
|
|
118
|
+
* display the current name or email without denormalizing identity data.
|
|
119
|
+
*/
|
|
120
|
+
export interface ProviderUserDisplayResolver {
|
|
121
|
+
readonly display: (providerUserIdOrEmail: string) => Effect.Effect<string, never>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Context passed to summary callbacks.
|
|
125
|
+
*/
|
|
126
|
+
export interface SummaryContext<TSteps extends Record<string, StepMeta>> extends FlowContext<TSteps> {
|
|
127
|
+
readonly providerUserDisplay: ProviderUserDisplayResolver;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Raw data from database query for a completed step.
|
|
131
|
+
* Note: Provider user fields are always populated via COALESCE in the SQL query,
|
|
132
|
+
* using user.sub as fallback for M2M/system users without provider user records.
|
|
133
|
+
*/
|
|
134
|
+
export interface CompletedStepData {
|
|
135
|
+
stepPath: string;
|
|
136
|
+
userId: string;
|
|
137
|
+
userSub: string;
|
|
138
|
+
providerUserId: string;
|
|
139
|
+
providerUserName: string;
|
|
140
|
+
providerUserFirstName: string;
|
|
141
|
+
providerUserLastName: string;
|
|
142
|
+
providerUserEmail: string;
|
|
143
|
+
providerUserPicture: string;
|
|
144
|
+
completedAt: DateTime.DateTime;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Build a FlowContext from database query results.
|
|
148
|
+
*
|
|
149
|
+
* @param processExecutionId - Current process execution ID
|
|
150
|
+
* @param processStartedAt - When the process was started
|
|
151
|
+
* @param completedSteps - List of completed steps with user/employee info
|
|
152
|
+
* @returns FlowContext object for use in callbacks
|
|
153
|
+
*/
|
|
154
|
+
export declare function buildFlowContext(processExecutionId: string, processStartedAt: DateTime.DateTime, completedSteps: CompletedStepData[]): FlowContext<Record<string, StepMeta>>;
|
|
155
|
+
/**
|
|
156
|
+
* Merge a new step into the accumulated steps record.
|
|
157
|
+
* Used by FlowPath to build up the TSteps type as the flow progresses.
|
|
158
|
+
*
|
|
159
|
+
* @typeParam TSteps - Existing accumulated steps
|
|
160
|
+
* @typeParam TStepId - ID of the step being added
|
|
161
|
+
* @typeParam TMeta - The metadata type (StepMeta for generic, FormStepMeta for Forms)
|
|
162
|
+
*/
|
|
163
|
+
export type MergeSteps<TSteps extends Record<string, StepMeta | FormStepMeta>, TStepId extends string, TMeta extends StepMeta | FormStepMeta = StepMeta> = TSteps & {
|
|
164
|
+
[K in CamelCase<TStepId>]: TMeta;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Merge a Form step - uses FormStepMeta (providerUser is required).
|
|
168
|
+
*/
|
|
169
|
+
export type MergeFormStep<TSteps extends Record<string, StepMeta | FormStepMeta>, TStepId extends string> = MergeSteps<TSteps, TStepId, FormStepMeta>;
|
|
170
|
+
/**
|
|
171
|
+
* State contribution type for forEach steps.
|
|
172
|
+
* Instead of flat-merging TOutput into state, forEach steps contribute
|
|
173
|
+
* an array of outputs keyed by the step's camelCase ID.
|
|
174
|
+
*
|
|
175
|
+
* When TIsForm is true, wrapper fields are flattened in each array element
|
|
176
|
+
* to match the canonical flat submission shape.
|
|
177
|
+
*/
|
|
178
|
+
export type ForEachOutput<TId extends string, TOutput extends Schema.Struct.Fields | undefined, TIsForm extends boolean = false> = {
|
|
179
|
+
[K in CamelCase<TId>]: ReadonlyArray<TOutput extends Schema.Struct.Fields ? TIsForm extends true ? FlattenFields<TOutput> extends infer F extends Schema.Struct.Fields ? Schema.Schema.Type<ReturnType<typeof Schema.Struct<F>>> : Record<string, never> : Schema.Schema.Type<ReturnType<typeof Schema.Struct<TOutput>>> : Record<string, never>>;
|
|
180
|
+
};
|
|
181
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Schema } from "effect";
|
|
2
|
+
import type { ForEachOutput, FormStepMeta, MergeFormStep, MergeSteps, StepMeta } from "./flow-context.js";
|
|
3
|
+
import type { Condition, Process, ResolveStepOutput, ScheduleFn } from "./process.js";
|
|
4
|
+
import type { IStepScope, Step } from "./step.js";
|
|
5
|
+
/**
|
|
6
|
+
* Options for conditional edges in the flow.
|
|
7
|
+
* @deprecated Use TransitionOptions instead for new code
|
|
8
|
+
*/
|
|
9
|
+
export interface ConditionOptions<TState> {
|
|
10
|
+
condition: {
|
|
11
|
+
fn: Condition<TState>;
|
|
12
|
+
text?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Options for scheduled edges in the flow.
|
|
17
|
+
*/
|
|
18
|
+
export interface ScheduleOptions<TState, TSteps extends Record<string, StepMeta | FormStepMeta> = Record<string, never>> {
|
|
19
|
+
schedule: {
|
|
20
|
+
fn: ScheduleFn<TState, TSteps>;
|
|
21
|
+
text?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Combined options for flow transitions.
|
|
26
|
+
* Supports both condition (boolean-based) and schedule (ScheduledTime-based) triggers.
|
|
27
|
+
* They can coexist on the same edge.
|
|
28
|
+
*/
|
|
29
|
+
export interface TransitionOptions<TState, TSteps extends Record<string, StepMeta | FormStepMeta> = Record<string, never>> {
|
|
30
|
+
condition?: {
|
|
31
|
+
fn: Condition<TState>;
|
|
32
|
+
text?: string;
|
|
33
|
+
};
|
|
34
|
+
schedule?: {
|
|
35
|
+
fn: ScheduleFn<TState, TSteps>;
|
|
36
|
+
text?: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface OnErrorOptions {
|
|
40
|
+
taggedErrors?: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
export interface ElseTransitionOptions {
|
|
43
|
+
text?: string;
|
|
44
|
+
}
|
|
45
|
+
export type MergeState<TState, TOutput> = [TOutput] extends [
|
|
46
|
+
Record<string, never>
|
|
47
|
+
] ? TState : TState & TOutput;
|
|
48
|
+
type AnyStep = Step<any, Schema.Struct.Fields | undefined, string, boolean, boolean>;
|
|
49
|
+
export declare function assertSameProcess(step: AnyStep, process: Process): void;
|
|
50
|
+
/**
|
|
51
|
+
* Wraps a step in a FlowPath without adding an edge.
|
|
52
|
+
* Used by Process.start() which handles edge creation separately.
|
|
53
|
+
*/
|
|
54
|
+
export declare function wrapInFlowPath<TState, TOutput extends Schema.Struct.Fields | undefined, TSteps extends Record<string, StepMeta | FormStepMeta> = Record<string, never>, TIsForm extends boolean = false>(step: Step<TState, TOutput, string, TIsForm, boolean>, process: Process): FlowPath<TState, TOutput, TSteps>;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a FlowPath by connecting two steps with an edge.
|
|
57
|
+
* This is the core implementation used by both Step.next() and FlowPath.next().
|
|
58
|
+
*
|
|
59
|
+
* Note: The type assertion on toStep is safe because TState is a phantom type
|
|
60
|
+
* (Step.__scopeState is never populated at runtime). We're reinterpreting the
|
|
61
|
+
* Step's type-level state to include accumulated state from the flow.
|
|
62
|
+
*
|
|
63
|
+
* @typeParam TIsForm - Whether the target step is a Form (determines meta type)
|
|
64
|
+
* @typeParam TIsForEach - Whether the target step is a forEach step (array state)
|
|
65
|
+
*/
|
|
66
|
+
export declare function createFlowPath<TState, TSteps extends Record<string, StepMeta | FormStepMeta>, TNextOutput extends Schema.Struct.Fields | undefined, TNextId extends string, TIsForm extends boolean = false, TIsForEach extends boolean = false>(fromStep: AnyStep, toStep: AnyStep, process: Process, options?: TransitionOptions<TState, TSteps>): FlowPath<TIsForEach extends true ? TState & ForEachOutput<TNextId, TNextOutput, TIsForm> : MergeState<TState, ResolveStepOutput<TNextOutput, TIsForm>>, TNextOutput, TIsForm extends true ? MergeFormStep<TSteps, TNextId> : MergeSteps<TSteps, TNextId>>;
|
|
67
|
+
export declare function createOnErrorFlowPath<TState, TSteps extends Record<string, StepMeta | FormStepMeta>, TNextOutput extends Schema.Struct.Fields | undefined, TNextId extends string, TNextIsForm extends boolean = false, TNextIsForEach extends boolean = false>(fromStep: AnyStep, toStep: AnyStep, process: Process, options?: OnErrorOptions): FlowPath<TNextIsForEach extends true ? TState & ForEachOutput<TNextId, TNextOutput, TNextIsForm> : MergeState<TState, ResolveStepOutput<TNextOutput, TNextIsForm>>, TNextOutput, TNextIsForm extends true ? MergeFormStep<TSteps, TNextId> : MergeSteps<TSteps, TNextId>>;
|
|
68
|
+
/**
|
|
69
|
+
* FlowPath represents a position in a process flow with accumulated state and step metadata.
|
|
70
|
+
*
|
|
71
|
+
* @typeParam TState - Accumulated state type from completed steps
|
|
72
|
+
* @typeParam TOutput - Output schema of the current step
|
|
73
|
+
* @typeParam TSteps - Record of completed step metadata, keyed by camelCase step ID
|
|
74
|
+
*/
|
|
75
|
+
export declare class FlowPath<TState, TOutput extends Schema.Struct.Fields | undefined, TSteps extends Record<string, StepMeta | FormStepMeta> = Record<string, never>> implements IStepScope<TState, TSteps> {
|
|
76
|
+
readonly step: Step<TState, TOutput, string, boolean, boolean>;
|
|
77
|
+
readonly process: Process;
|
|
78
|
+
/** Phantom type field to carry accumulated state for type inference */
|
|
79
|
+
readonly __scopeState?: TState;
|
|
80
|
+
/** Phantom type field to carry completed steps for type inference */
|
|
81
|
+
readonly __scopeSteps?: TSteps;
|
|
82
|
+
constructor(step: Step<TState, TOutput, string, boolean, boolean>, process: Process);
|
|
83
|
+
end(): Step<TState, TOutput, string, boolean, boolean>;
|
|
84
|
+
end<TEndState, TEndOutput extends Schema.Struct.Fields | undefined, TEndIsForm extends boolean = false, TEndIsForEach extends boolean = false>(step: Step<TEndState, TEndOutput, string, TEndIsForm, TEndIsForEach>, options?: TransitionOptions<TState>): Step<TEndIsForEach extends true ? TState & ForEachOutput<string, TEndOutput, TEndIsForm> : MergeState<TState, ResolveStepOutput<TEndOutput, TEndIsForm>>, TEndOutput, string, TEndIsForm>;
|
|
85
|
+
next<TNextState, TNextOutput extends Schema.Struct.Fields | undefined, TNextId extends string, TNextIsForm extends boolean = false, TNextIsForEach extends boolean = false>(target: Step<TNextState, TNextOutput, TNextId, TNextIsForm, TNextIsForEach>, options?: TransitionOptions<TState, TSteps>): FlowPath<TNextIsForEach extends true ? TState & ForEachOutput<TNextId, TNextOutput, TNextIsForm> : MergeState<TState, ResolveStepOutput<TNextOutput, TNextIsForm>>, TNextOutput, TNextIsForm extends true ? MergeFormStep<TSteps, TNextId> : MergeSteps<TSteps, TNextId>>;
|
|
86
|
+
/**
|
|
87
|
+
* Returns an ElseBranch that can be used to define the else edge.
|
|
88
|
+
* The else edge is followed ONLY if NO conditional edges match.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* flow.next(stepApproved, (s) => s.approved)
|
|
92
|
+
* flow.else().next(stepRejected).end()
|
|
93
|
+
*/
|
|
94
|
+
else(): ElseBranch<TState, TOutput, TSteps>;
|
|
95
|
+
/**
|
|
96
|
+
* Shorthand for .else().end() - creates an else edge to __end__.
|
|
97
|
+
*/
|
|
98
|
+
elseEnd(): Step<TState, TOutput, string, boolean, boolean>;
|
|
99
|
+
/**
|
|
100
|
+
* Shorthand for .else().end(step) - creates an else edge to step AND marks as terminal.
|
|
101
|
+
*/
|
|
102
|
+
elseEnd<TEndState, TEndOutput extends Schema.Struct.Fields | undefined, TEndIsForm extends boolean = false>(step: Step<TEndState, TEndOutput, string, TEndIsForm, boolean>, options?: ElseTransitionOptions): Step<MergeState<TState, ResolveStepOutput<TEndOutput, TEndIsForm>>, TEndOutput, string, TEndIsForm>;
|
|
103
|
+
/**
|
|
104
|
+
* Shorthand for .else().next(target) - creates an else edge to target step.
|
|
105
|
+
*/
|
|
106
|
+
elseNext<TNextState, TNextOutput extends Schema.Struct.Fields | undefined, TNextIsForm extends boolean = false>(target: Step<TNextState, TNextOutput, string, TNextIsForm, boolean>, options?: ElseTransitionOptions): FlowPath<MergeState<TState, ResolveStepOutput<TNextOutput, TNextIsForm>>, TNextOutput, TSteps>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Represents an else branch from a flow path.
|
|
110
|
+
* The else edge is followed ONLY if NO conditional edges from the source step match.
|
|
111
|
+
*/
|
|
112
|
+
export declare class ElseBranch<TState, TOutput extends Schema.Struct.Fields | undefined, TSteps extends Record<string, StepMeta | FormStepMeta> = Record<string, never>> {
|
|
113
|
+
readonly step: Step<TState, TOutput, string, boolean, boolean>;
|
|
114
|
+
readonly process: Process;
|
|
115
|
+
constructor(step: Step<TState, TOutput, string, boolean, boolean>, process: Process);
|
|
116
|
+
/**
|
|
117
|
+
* Create an else edge to the next step.
|
|
118
|
+
*/
|
|
119
|
+
next<TNextState, TNextOutput extends Schema.Struct.Fields | undefined, TNextIsForm extends boolean = false>(target: Step<TNextState, TNextOutput, string, TNextIsForm, boolean>, options?: ElseTransitionOptions): FlowPath<MergeState<TState, ResolveStepOutput<TNextOutput, TNextIsForm>>, TNextOutput, TSteps>;
|
|
120
|
+
end(): Step<TState, TOutput, string, boolean, boolean>;
|
|
121
|
+
end<TEndState, TEndOutput extends Schema.Struct.Fields | undefined, TEndIsForm extends boolean = false>(step: Step<TEndState, TEndOutput, string, TEndIsForm, boolean>, options?: ElseTransitionOptions): Step<MergeState<TState, ResolveStepOutput<TEndOutput, TEndIsForm>>, TEndOutput, string, TEndIsForm>;
|
|
122
|
+
}
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { type DeferredValue, type StructuralOnlyMarker } from "../../../form-schema/src/index.js";
|
|
3
|
+
import type { FlowContext, FormStepMeta, StepMeta } from "./flow-context.js";
|
|
4
|
+
type StructuralContent = Schema.Schema.Any & StructuralOnlyMarker;
|
|
5
|
+
type Resolver<State, Steps extends Record<string, StepMeta | FormStepMeta>, Item, A> = (state: State, ctx: FlowContext<Steps>, item: Item) => A;
|
|
6
|
+
export interface FormAuthoring<State, Steps extends Record<string, StepMeta | FormStepMeta>, Item> {
|
|
7
|
+
readonly value: <A>(resolve: Resolver<State, Steps, Item, A>, fallback?: NoInfer<A>) => DeferredValue<A>;
|
|
8
|
+
readonly query: <A>(resolve: Resolver<State, Steps, Item, A>) => DeferredValue<A>;
|
|
9
|
+
readonly content: (resolve: Resolver<State, Steps, Item, StructuralContent | undefined>, fallback?: StructuralContent) => StructuralContent;
|
|
10
|
+
}
|
|
11
|
+
/** Never let deferred descriptors reach schema walkers or serialized metadata. */
|
|
12
|
+
export declare const assertResolvedFormFields: (fields: Schema.Struct.Fields) => void;
|
|
13
|
+
/** Each declaration owns its callbacks; each resolution owns its evaluated values. */
|
|
14
|
+
interface FormDeclarationCompiler<State, Steps extends Record<string, StepMeta | FormStepMeta>, Item> {
|
|
15
|
+
readonly helpers: FormAuthoring<State, Steps, Item>;
|
|
16
|
+
readonly project: <Fields extends Schema.Struct.Fields>(fields: Fields, args?: readonly [State, FlowContext<Steps>, Item]) => Fields;
|
|
17
|
+
}
|
|
18
|
+
export declare const createFormAuthoring: <State, Steps extends Record<string, StepMeta | FormStepMeta>, Item>() => FormDeclarationCompiler<State, Steps, Item>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Schema, SchemaAST } from "effect";
|
|
2
|
+
declare const FormDecorationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
3
|
+
readonly _tag: "FormDecorationError";
|
|
4
|
+
} & Readonly<A>;
|
|
5
|
+
export declare class FormDecorationError extends FormDecorationError_base<{
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
}> {
|
|
9
|
+
}
|
|
10
|
+
export declare const decorateAst: (original: SchemaAST.AST, value: unknown, path: string) => SchemaAST.AST;
|
|
11
|
+
/** Preserve property transformations and exact field types during safe resolution. */
|
|
12
|
+
export declare const mapFormFields: <Fields extends Schema.Struct.Fields>(fields: Fields, map: (ast: SchemaAST.AST, name: string) => SchemaAST.AST, mapAnnotations?: (annotations: SchemaAST.Annotations, ast: SchemaAST.AST, name: string, side: "input" | "output") => SchemaAST.Annotations, mapOutput?: (ast: SchemaAST.AST, name: string) => SchemaAST.AST) => Fields;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
/** Authoritative annotated defaults only: never initialization placeholders. */
|
|
3
|
+
export declare const resolveFormFieldDefaults: (fields: Schema.Struct.Fields, currentProviderUser?: string) => Effect.Effect<Record<string, unknown>, never>;
|
|
4
|
+
/** Submitted edits win while omitted nested values retain authored defaults. */
|
|
5
|
+
export declare const mergeFormDefaults: (defaults: Record<string, unknown>, input: Record<string, unknown>) => Record<string, unknown>;
|