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,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schedule types for business-calendar-aware scheduling.
|
|
3
|
+
*
|
|
4
|
+
* Schedule functions in `flow.next()` can return either:
|
|
5
|
+
* - A raw `DateTime.DateTime` (backward compatible, wall-clock time)
|
|
6
|
+
* - A marker type from this module that gets resolved at execution time
|
|
7
|
+
*
|
|
8
|
+
* Business-time markers are resolved in the job-handler using the
|
|
9
|
+
* BusinessCalendarService from `processfocus/calendar`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { Schedule } from "processfocus"
|
|
14
|
+
*
|
|
15
|
+
* flow.next(reviewStep, {
|
|
16
|
+
* schedule: {
|
|
17
|
+
* fn: (_state, ctx) => Schedule.businessHours(
|
|
18
|
+
* ctx.step.submitRequest.completedAt,
|
|
19
|
+
* 1 // 1 business hour
|
|
20
|
+
* ),
|
|
21
|
+
* text: "1 business hour after submission",
|
|
22
|
+
* },
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* // Also available:
|
|
26
|
+
* // Schedule.businessDays(from, days) - business days
|
|
27
|
+
* // Schedule.clockTime(from, duration) - explicit wall-clock time
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
import { type DateTime, Duration } from "effect";
|
|
31
|
+
/**
|
|
32
|
+
* Marker type for scheduling based on business minutes.
|
|
33
|
+
* Resolved at execution time using BusinessCalendarService.addBusinessMinutes().
|
|
34
|
+
*/
|
|
35
|
+
export interface BusinessMinutesSchedule {
|
|
36
|
+
readonly _tag: "BusinessMinutes";
|
|
37
|
+
/** Starting point for the calculation */
|
|
38
|
+
readonly from: DateTime.DateTime;
|
|
39
|
+
/** Number of business minutes to add */
|
|
40
|
+
readonly minutes: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Marker type for scheduling based on business hours.
|
|
44
|
+
* Resolved at execution time using BusinessCalendarService.addBusinessHours().
|
|
45
|
+
*/
|
|
46
|
+
export interface BusinessHoursSchedule {
|
|
47
|
+
readonly _tag: "BusinessHours";
|
|
48
|
+
/** Starting point for the calculation */
|
|
49
|
+
readonly from: DateTime.DateTime;
|
|
50
|
+
/** Number of business hours to add (can be fractional) */
|
|
51
|
+
readonly hours: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Marker type for scheduling based on business days.
|
|
55
|
+
* Resolved at execution time using BusinessCalendarService.addBusinessDays().
|
|
56
|
+
*/
|
|
57
|
+
export interface BusinessDaysSchedule {
|
|
58
|
+
readonly _tag: "BusinessDays";
|
|
59
|
+
/** Starting point for the calculation */
|
|
60
|
+
readonly from: DateTime.DateTime;
|
|
61
|
+
/** Number of business days to add */
|
|
62
|
+
readonly days: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Marker type for explicit wall-clock time scheduling.
|
|
66
|
+
* Provides a way to explicitly opt-in to clock time (instead of relying on
|
|
67
|
+
* raw DateTime return type which is also clock time but less explicit).
|
|
68
|
+
*/
|
|
69
|
+
export interface ClockTimeSchedule {
|
|
70
|
+
readonly _tag: "ClockTime";
|
|
71
|
+
/** Starting point for the calculation */
|
|
72
|
+
readonly from: DateTime.DateTime;
|
|
73
|
+
/** Duration to add */
|
|
74
|
+
readonly duration: Duration.Duration;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Marker type for scheduling based on a reference point with calendar offset.
|
|
78
|
+
* Computes a calendar offset from a reference date and snaps the result to the
|
|
79
|
+
* nearest business day/hours. The snap direction matches the offset sign:
|
|
80
|
+
* negative offsets snap backward, positive snap forward.
|
|
81
|
+
*
|
|
82
|
+
* Edge case: Zero offset ({ days: 0 }) on a non-business day snaps forward
|
|
83
|
+
* to the next business day (same as positive offsets). This ensures scheduling
|
|
84
|
+
* always occurs on a valid business day.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* // Schedule 1 week before start date, snapping to previous business day
|
|
89
|
+
* Schedule.fromPoint(state.start_date, { days: -7 })
|
|
90
|
+
* // If result lands on a weekend/holiday, snaps backward to the previous business day
|
|
91
|
+
*
|
|
92
|
+
* // Schedule on the reference date itself (snaps to next business day if weekend)
|
|
93
|
+
* Schedule.fromPoint(state.start_date, { days: 0 })
|
|
94
|
+
* // Saturday Feb 14 → snaps forward to Monday Feb 16
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export interface FromPointSchedule {
|
|
98
|
+
readonly _tag: "FromPoint";
|
|
99
|
+
/** Starting point for the calculation */
|
|
100
|
+
readonly from: DateTime.DateTime;
|
|
101
|
+
/** Calendar offset to apply (can be negative). Zero offset on non-business days snaps forward. */
|
|
102
|
+
readonly offset: {
|
|
103
|
+
days?: number;
|
|
104
|
+
hours?: number;
|
|
105
|
+
minutes?: number;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Union type of all schedule marker types.
|
|
110
|
+
* Used internally to identify business-time schedules.
|
|
111
|
+
*/
|
|
112
|
+
export type ScheduleMarker = BusinessMinutesSchedule | BusinessHoursSchedule | BusinessDaysSchedule | ClockTimeSchedule | FromPointSchedule;
|
|
113
|
+
/**
|
|
114
|
+
* All possible return types from a schedule function.
|
|
115
|
+
* - Raw `DateTime.DateTime` for backward compatibility (wall-clock time)
|
|
116
|
+
* - Marker types for business-calendar-aware scheduling
|
|
117
|
+
*/
|
|
118
|
+
export type ScheduledTime = DateTime.DateTime | ScheduleMarker;
|
|
119
|
+
/**
|
|
120
|
+
* Schedule helper functions for creating schedule marker types.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* import { Schedule } from "processfocus"
|
|
125
|
+
* import { Duration } from "effect"
|
|
126
|
+
*
|
|
127
|
+
* // Schedule 2 business hours after step completion
|
|
128
|
+
* Schedule.businessHours(ctx.step.submitRequest.completedAt, 2)
|
|
129
|
+
*
|
|
130
|
+
* // Schedule 3 business days after step completion
|
|
131
|
+
* Schedule.businessDays(ctx.step.submitRequest.completedAt, 3)
|
|
132
|
+
*
|
|
133
|
+
* // Explicit clock time (for when you want wall-clock, not business time)
|
|
134
|
+
* Schedule.clockTime(ctx.step.submitRequest.completedAt, "1 hour")
|
|
135
|
+
* Schedule.clockTime(ctx.step.submitRequest.completedAt, Duration.hours(1))
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare const Schedule: {
|
|
139
|
+
/**
|
|
140
|
+
* Create a business minutes schedule marker.
|
|
141
|
+
*
|
|
142
|
+
* @param from - Starting datetime
|
|
143
|
+
* @param minutes - Number of business minutes to add
|
|
144
|
+
* @returns A BusinessMinutesSchedule marker resolved at execution time
|
|
145
|
+
*/
|
|
146
|
+
businessMinutes(from: DateTime.DateTime, minutes: number): BusinessMinutesSchedule;
|
|
147
|
+
/**
|
|
148
|
+
* Create a business hours schedule marker.
|
|
149
|
+
*
|
|
150
|
+
* @param from - Starting datetime
|
|
151
|
+
* @param hours - Number of business hours to add (can be fractional, e.g., 1.5)
|
|
152
|
+
* @returns A BusinessHoursSchedule marker resolved at execution time
|
|
153
|
+
*/
|
|
154
|
+
businessHours(from: DateTime.DateTime, hours: number): BusinessHoursSchedule;
|
|
155
|
+
/**
|
|
156
|
+
* Create a business days schedule marker.
|
|
157
|
+
*
|
|
158
|
+
* @param from - Starting datetime
|
|
159
|
+
* @param days - Number of business days to add
|
|
160
|
+
* @returns A BusinessDaysSchedule marker resolved at execution time
|
|
161
|
+
*/
|
|
162
|
+
businessDays(from: DateTime.DateTime, days: number): BusinessDaysSchedule;
|
|
163
|
+
/**
|
|
164
|
+
* Create a clock time schedule marker.
|
|
165
|
+
*
|
|
166
|
+
* Unlike returning a raw DateTime (which bypasses resolution entirely),
|
|
167
|
+
* this returns a marker that explicitly signals clock-time semantics
|
|
168
|
+
* during resolution. Use this when you want to clearly indicate that
|
|
169
|
+
* a schedule should use wall-clock time, not business time.
|
|
170
|
+
*
|
|
171
|
+
* @param from - Starting datetime
|
|
172
|
+
* @param duration - Duration to add (DurationInput accepts string like "1 hour")
|
|
173
|
+
* @returns A ClockTimeSchedule marker resolved at execution time
|
|
174
|
+
*/
|
|
175
|
+
clockTime(from: DateTime.DateTime, duration: Duration.DurationInput): ClockTimeSchedule;
|
|
176
|
+
/**
|
|
177
|
+
* Create a from-point schedule marker.
|
|
178
|
+
*
|
|
179
|
+
* Computes a calendar offset from a reference date and snaps the result to
|
|
180
|
+
* the nearest business day/hours. The snap direction matches the offset sign:
|
|
181
|
+
* negative offsets snap backward, positive snap forward.
|
|
182
|
+
*
|
|
183
|
+
* Edge case: Zero offset on a non-business day (weekend/holiday) snaps forward
|
|
184
|
+
* to the next business day, ensuring the schedule always lands on a valid
|
|
185
|
+
* business day.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* // Schedule 1 week before start date
|
|
190
|
+
* Schedule.fromPoint(state.start_date, { days: -7 })
|
|
191
|
+
* // If Feb 17 - 7 days = Feb 10 (closed), snaps backward to Feb 9
|
|
192
|
+
*
|
|
193
|
+
* // Schedule on the reference date itself
|
|
194
|
+
* Schedule.fromPoint(state.start_date, { days: 0 })
|
|
195
|
+
* // If start_date is Saturday, snaps to following Monday
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* @param from - Starting datetime (reference point)
|
|
199
|
+
* @param offset - Calendar offset to apply (can have negative values). Zero on non-business days snaps forward.
|
|
200
|
+
* @returns A FromPointSchedule marker resolved at execution time
|
|
201
|
+
*/
|
|
202
|
+
fromPoint(from: DateTime.DateTime, offset: {
|
|
203
|
+
days?: number;
|
|
204
|
+
hours?: number;
|
|
205
|
+
minutes?: number;
|
|
206
|
+
}): FromPointSchedule;
|
|
207
|
+
/**
|
|
208
|
+
* Type guard to check if a value is a schedule marker (not a raw DateTime).
|
|
209
|
+
*
|
|
210
|
+
* @param value - Value to check
|
|
211
|
+
* @returns True if value is a ScheduleMarker
|
|
212
|
+
*/
|
|
213
|
+
isScheduleMarker(value: unknown): value is ScheduleMarker;
|
|
214
|
+
/**
|
|
215
|
+
* Pattern match on a ScheduleMarker, similar to Effect's Option.match/Either.match.
|
|
216
|
+
*
|
|
217
|
+
* @param marker - The schedule marker to match on
|
|
218
|
+
* @param handlers - Object with handler functions for each marker type
|
|
219
|
+
* @returns The result of the matching handler
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* Schedule.match(marker, {
|
|
224
|
+
* onBusinessMinutes: (m) => `${m.minutes} business minutes`,
|
|
225
|
+
* onBusinessHours: (m) => `${m.hours} business hours`,
|
|
226
|
+
* onBusinessDays: (m) => `${m.days} business days`,
|
|
227
|
+
* onClockTime: (m) => `clock time duration`,
|
|
228
|
+
* onFromPoint: (m) => `from ${m.from} with offset`,
|
|
229
|
+
* })
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
match<A, B, C, D, E>(marker: ScheduleMarker, handlers: {
|
|
233
|
+
onBusinessMinutes: (marker: BusinessMinutesSchedule) => A;
|
|
234
|
+
onBusinessHours: (marker: BusinessHoursSchedule) => B;
|
|
235
|
+
onBusinessDays: (marker: BusinessDaysSchedule) => C;
|
|
236
|
+
onClockTime: (marker: ClockTimeSchedule) => D;
|
|
237
|
+
onFromPoint: (marker: FromPointSchedule) => E;
|
|
238
|
+
}): A | B | C | D | E;
|
|
239
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SLA (Service Level Agreement) configuration for Processes and Steps.
|
|
3
|
+
*
|
|
4
|
+
* Durations are expressed in business calendar time (business days/hours/weeks).
|
|
5
|
+
* The actual deadline calculation takes business calendars into account at runtime.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Unit of time for SLA durations.
|
|
9
|
+
* All units are based on business calendar time.
|
|
10
|
+
*/
|
|
11
|
+
export type SlaUnit = "minutes" | "businessHours" | "businessDays" | "businessWeeks";
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for an SLA (Service Level Agreement).
|
|
14
|
+
*/
|
|
15
|
+
export interface SlaConfig {
|
|
16
|
+
/** Duration value (must be a positive integer) */
|
|
17
|
+
readonly value: number;
|
|
18
|
+
/** Unit of time */
|
|
19
|
+
readonly unit: SlaUnit;
|
|
20
|
+
/**
|
|
21
|
+
* Warning threshold as a percentage (0-100).
|
|
22
|
+
* When this percentage of time has elapsed, status changes to "warning".
|
|
23
|
+
* Default: 80 (warn at 80% elapsed, i.e., 20% remaining)
|
|
24
|
+
*/
|
|
25
|
+
readonly warningAt: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for creating an SLA configuration.
|
|
29
|
+
*/
|
|
30
|
+
export interface SlaOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Warning threshold as a decimal (0-1).
|
|
33
|
+
* Default: 0.8 (warn at 80% elapsed)
|
|
34
|
+
*/
|
|
35
|
+
readonly warningAt?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* SLA helper functions for creating SLA configurations.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { Sla } from "processfocus"
|
|
43
|
+
*
|
|
44
|
+
* // Duration units (integer values only)
|
|
45
|
+
* sla: Sla.businessHours(4) // 4 business hours
|
|
46
|
+
* sla: Sla.businessDays(5) // 5 business days
|
|
47
|
+
* sla: Sla.businessWeeks(2) // 2 business weeks (10 days)
|
|
48
|
+
*
|
|
49
|
+
* // With warning threshold (optional)
|
|
50
|
+
* sla: Sla.businessDays(5, { warningAt: 0.8 }) // warn at 80% (4 days elapsed)
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const Sla: {
|
|
54
|
+
/**
|
|
55
|
+
* Creates an SLA configuration with a duration in minutes.
|
|
56
|
+
* Note: Minutes are clock time, not business calendar time.
|
|
57
|
+
*
|
|
58
|
+
* @param minutes - Number of minutes (positive integer)
|
|
59
|
+
* @param options - Optional configuration (warningAt)
|
|
60
|
+
*/
|
|
61
|
+
minutes(minutes: number, options?: SlaOptions): SlaConfig;
|
|
62
|
+
/**
|
|
63
|
+
* Creates an SLA configuration with a duration in business hours.
|
|
64
|
+
*
|
|
65
|
+
* @param hours - Number of business hours (positive integer)
|
|
66
|
+
* @param options - Optional configuration (warningAt)
|
|
67
|
+
*/
|
|
68
|
+
businessHours(hours: number, options?: SlaOptions): SlaConfig;
|
|
69
|
+
/**
|
|
70
|
+
* Creates an SLA configuration with a duration in business days.
|
|
71
|
+
*
|
|
72
|
+
* @param days - Number of business days (positive integer)
|
|
73
|
+
* @param options - Optional configuration (warningAt)
|
|
74
|
+
*/
|
|
75
|
+
businessDays(days: number, options?: SlaOptions): SlaConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Creates an SLA configuration with a duration in business weeks.
|
|
78
|
+
* A business week is 5 business days.
|
|
79
|
+
*
|
|
80
|
+
* @param weeks - Number of business weeks (positive integer)
|
|
81
|
+
* @param options - Optional configuration (warningAt)
|
|
82
|
+
*/
|
|
83
|
+
businessWeeks(weeks: number, options?: SlaOptions): SlaConfig;
|
|
84
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import type { OrgUnit } from "./org-unit.js";
|
|
3
|
+
import type { Role } from "./role.js";
|
|
4
|
+
/**
|
|
5
|
+
* Renderer types built into the frontend stats route.
|
|
6
|
+
* Orgs reference these by name; the frontend maps them to React components.
|
|
7
|
+
*/
|
|
8
|
+
export type StatsViewRenderer = "timeline";
|
|
9
|
+
/**
|
|
10
|
+
* Props for creating a StatsView construct.
|
|
11
|
+
*/
|
|
12
|
+
export interface StatsViewProps {
|
|
13
|
+
/** Display name for the stats view */
|
|
14
|
+
readonly name: string;
|
|
15
|
+
/** Optional description of what this stats view shows */
|
|
16
|
+
readonly purpose?: string;
|
|
17
|
+
/** Roles allowed to access this stats view. Must not be empty. */
|
|
18
|
+
readonly roles: readonly [Role, ...Role[]];
|
|
19
|
+
/**
|
|
20
|
+
* The built-in renderer type the frontend should use.
|
|
21
|
+
* The frontend maps this to a React component (e.g. "timeline" → JourneyTimeline).
|
|
22
|
+
*/
|
|
23
|
+
readonly renderer: StatsViewRenderer;
|
|
24
|
+
/**
|
|
25
|
+
* The GraphQL query name that returns the stats data.
|
|
26
|
+
* This query must be provided by the org's CustomGraphqlSchema.
|
|
27
|
+
*/
|
|
28
|
+
readonly queryName: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Stats view construct for defining custom analytics/visualization screens.
|
|
32
|
+
*
|
|
33
|
+
* StatsViews are organizational-level custom data views that provide
|
|
34
|
+
* visualizations beyond the standard list/table model. They are:
|
|
35
|
+
* - Discovered by the frontend via the `availableStatsViews` GraphQL query
|
|
36
|
+
* - Rendered at `/stats/<path>` in the frontend
|
|
37
|
+
* - Backed by a custom GraphQL query from the org's `CustomGraphqlSchema`
|
|
38
|
+
*
|
|
39
|
+
* Unlike `List`, StatsView does not generate its own GraphQL schema —
|
|
40
|
+
* the org is responsible for providing the query via `CustomGraphqlSchema`.
|
|
41
|
+
* StatsView only carries metadata (name, renderer type, query name, roles)
|
|
42
|
+
* that the frontend uses to discover and render the view.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* new StatsView(org, "enrolment-journeys", {
|
|
47
|
+
* name: "Enrolment Journeys",
|
|
48
|
+
* purpose: "See how quickly enrolments move through the pipeline",
|
|
49
|
+
* roles: [officeStaff],
|
|
50
|
+
* renderer: "timeline",
|
|
51
|
+
* queryName: "timelineAllEnrolmentEnquiries",
|
|
52
|
+
* })
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare class StatsView extends Construct {
|
|
56
|
+
readonly isStatsView: true;
|
|
57
|
+
/** Display name for the stats view */
|
|
58
|
+
readonly name: string;
|
|
59
|
+
/** Optional description of what this stats view shows */
|
|
60
|
+
readonly purpose?: string;
|
|
61
|
+
/** Roles allowed to access this stats view */
|
|
62
|
+
readonly roles: readonly [Role, ...Role[]];
|
|
63
|
+
/** Built-in renderer type the frontend should use */
|
|
64
|
+
readonly renderer: StatsViewRenderer;
|
|
65
|
+
/** GraphQL query name that returns the stats data */
|
|
66
|
+
readonly queryName: string;
|
|
67
|
+
constructor(scope: OrgUnit, id: string, props: StatsViewProps);
|
|
68
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import type { ForEachOutput, FormStepMeta, MergeFormStep, MergeSteps, StepMeta } from "./flow-context.js";
|
|
4
|
+
import { type FlowPath, type TransitionOptions } from "./flow-path.js";
|
|
5
|
+
import type { Phase } from "./phase.js";
|
|
6
|
+
import type { IProcessHolder, Process, ResolveStepOutput } from "./process.js";
|
|
7
|
+
import type { Role } from "./role.js";
|
|
8
|
+
import type { SlaConfig } from "./sla.js";
|
|
9
|
+
export interface StepProps<TOutput extends Schema.Struct.Fields | undefined = undefined> {
|
|
10
|
+
readonly name?: string;
|
|
11
|
+
readonly purpose?: string;
|
|
12
|
+
/**
|
|
13
|
+
* A step is executed by a human or a system.
|
|
14
|
+
* This is the primary role for the step.
|
|
15
|
+
*
|
|
16
|
+
* For user-executed steps (Form), this is required.
|
|
17
|
+
* For system-executed steps (SystemStep), this is undefined.
|
|
18
|
+
* In the database, `role_id = NULL` indicates a system step.
|
|
19
|
+
*/
|
|
20
|
+
readonly role?: Role;
|
|
21
|
+
/**
|
|
22
|
+
* The output schema this step contributes to process state.
|
|
23
|
+
* For Forms, this is the form fields. For SystemSteps, the output schema.
|
|
24
|
+
*/
|
|
25
|
+
readonly output?: TOutput;
|
|
26
|
+
/**
|
|
27
|
+
* Optional visual indicator in swimlane.
|
|
28
|
+
* Steps of the same phase are kept together.
|
|
29
|
+
*/
|
|
30
|
+
readonly phase?: Phase;
|
|
31
|
+
/**
|
|
32
|
+
* Optional SLA (Service Level Agreement) for this step.
|
|
33
|
+
* Specifies the maximum duration for this step to complete,
|
|
34
|
+
* measured in business calendar time from when the step becomes active.
|
|
35
|
+
*/
|
|
36
|
+
readonly sla?: SlaConfig;
|
|
37
|
+
/**
|
|
38
|
+
* Always send todo-assignment notifications for this step, even when the
|
|
39
|
+
* recipient has disabled optional todo-assignment emails.
|
|
40
|
+
*/
|
|
41
|
+
readonly alwaysNotify?: boolean;
|
|
42
|
+
}
|
|
43
|
+
type EmptyObject = Record<string, never>;
|
|
44
|
+
type MergeState<TState, TOutput> = [TOutput] extends [EmptyObject] ? TState : TState & TOutput;
|
|
45
|
+
/**
|
|
46
|
+
* Interface for anything that can be a scope for creating Steps.
|
|
47
|
+
* Extends IProcessHolder to access the Process, and adds phantom type
|
|
48
|
+
* fields to carry accumulated state and steps information for type inference.
|
|
49
|
+
*/
|
|
50
|
+
export interface IStepScope<TState = Record<string, never>, TSteps extends Record<string, StepMeta | FormStepMeta> = Record<string, never>> extends IProcessHolder {
|
|
51
|
+
/** Phantom type to carry state information */
|
|
52
|
+
readonly __scopeState?: TState;
|
|
53
|
+
/** Phantom type to carry completed steps information */
|
|
54
|
+
readonly __scopeSteps?: TSteps;
|
|
55
|
+
}
|
|
56
|
+
export declare abstract class Step<TState = Record<string, never>, TOutput extends Schema.Struct.Fields | undefined = undefined, TId extends string = string, TIsForm extends boolean = false, TIsForEach extends boolean = false> extends Construct implements IStepScope<TState> {
|
|
57
|
+
readonly props: StepProps<TOutput>;
|
|
58
|
+
private _output;
|
|
59
|
+
private _outputSchema;
|
|
60
|
+
readonly process: Process;
|
|
61
|
+
readonly __scopeState?: TState;
|
|
62
|
+
/**
|
|
63
|
+
* Phantom type to carry the step ID as a literal type.
|
|
64
|
+
* Used for type-level step key computation.
|
|
65
|
+
*/
|
|
66
|
+
readonly __stepId?: TId;
|
|
67
|
+
/**
|
|
68
|
+
* Phantom type to indicate if this step is a Form (completed by employee).
|
|
69
|
+
* Forms set this to `true` while generic Steps leave it as `false`.
|
|
70
|
+
*/
|
|
71
|
+
readonly __isForm?: TIsForm;
|
|
72
|
+
/**
|
|
73
|
+
* Phantom type to indicate if this step uses forEach semantics.
|
|
74
|
+
* When true, the step contributes an array of outputs to state
|
|
75
|
+
* instead of a flat merge.
|
|
76
|
+
*/
|
|
77
|
+
readonly __isForEach?: TIsForEach;
|
|
78
|
+
/**
|
|
79
|
+
* The step ID converted to a valid camelCase identifier.
|
|
80
|
+
* Used as the key in ctx.step for this step.
|
|
81
|
+
*/
|
|
82
|
+
readonly stepKey: string;
|
|
83
|
+
/** Stable brand for steps loaded from separately bundled organisation code. */
|
|
84
|
+
readonly isStep: true;
|
|
85
|
+
/**
|
|
86
|
+
* Brand property to identify Form instances across bundle boundaries.
|
|
87
|
+
* Overridden to `true` in Form. Check this instead of using instanceof,
|
|
88
|
+
* which fails when org.js is compiled separately from the job worker.
|
|
89
|
+
*/
|
|
90
|
+
readonly isForm: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Brand property to identify SystemStep instances across bundle boundaries.
|
|
93
|
+
* Overridden to `true` in SystemStep. Check this instead of using instanceof,
|
|
94
|
+
* which fails when org.js is compiled separately from the job worker.
|
|
95
|
+
*/
|
|
96
|
+
readonly isSystemStep: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The output validation schema for this step.
|
|
99
|
+
* Lazily builds Schema.Struct from output fields on first access.
|
|
100
|
+
* Form overrides this to include struct-level validation refinements.
|
|
101
|
+
*/
|
|
102
|
+
get outputSchema(): Schema.Schema.Any | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* The flat submission validation schema for this step.
|
|
105
|
+
* Returns `undefined` for non-Form steps. Form overrides this to return
|
|
106
|
+
* the flattened submission schema (wrapper fields removed, read-only/
|
|
107
|
+
* structural-only excluded), optionally with a filterEffect refinement.
|
|
108
|
+
*
|
|
109
|
+
* Used by start/complete resolvers for server-side validation.
|
|
110
|
+
*/
|
|
111
|
+
get submissionEffectSchema(): Schema.Schema.Any | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Brand property to identify forEach steps across bundle boundaries.
|
|
114
|
+
* Overridden to `true` in SystemStep/Form when forEach is configured.
|
|
115
|
+
*/
|
|
116
|
+
readonly hasForEach: boolean;
|
|
117
|
+
constructor(scope: Process | IStepScope<TState, any>, id: TId, props: StepProps<TOutput>);
|
|
118
|
+
/**
|
|
119
|
+
* Get the output schema for this step.
|
|
120
|
+
*/
|
|
121
|
+
get output(): TOutput | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Connect `step` to this step. Optionally provide transition options.
|
|
124
|
+
* @param step - The next step to connect to
|
|
125
|
+
* @param options - Optional transition options with `condition` and/or `schedule`
|
|
126
|
+
*/
|
|
127
|
+
next<TNextState, TNextOutput extends Schema.Struct.Fields | undefined, TNextId extends string, TNextIsForm extends boolean = false, TNextIsForEach extends boolean = false>(step: Step<TNextState, TNextOutput, TNextId, TNextIsForm, TNextIsForEach>, options?: TransitionOptions<TState>): FlowPath<TNextIsForEach extends true ? TState & ForEachOutput<TNextId, TNextOutput, TNextIsForm> : MergeState<TState, ResolveStepOutput<TNextOutput, TNextIsForm>>, TNextOutput, TNextIsForm extends true ? MergeFormStep<Record<string, never>, TNextId> : MergeSteps<Record<string, never>, TNextId>>;
|
|
128
|
+
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>;
|
|
129
|
+
}
|
|
130
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
import type { FlowContext, StepMeta } from "./flow-context.js";
|
|
3
|
+
import type { Organisation } from "./organisation.js";
|
|
4
|
+
import { type AuthorTaggedError, type ForEachStepRequiresItemsError, type StepResult } from "./system-step.js";
|
|
5
|
+
declare const StepNotFoundError_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 & {
|
|
6
|
+
readonly _tag: "StepNotFoundError";
|
|
7
|
+
} & Readonly<A>;
|
|
8
|
+
/**
|
|
9
|
+
* Error thrown when the target step cannot be found in the organisation.
|
|
10
|
+
*/
|
|
11
|
+
export declare class StepNotFoundError extends StepNotFoundError_base<{
|
|
12
|
+
readonly stepPath: string;
|
|
13
|
+
}> {
|
|
14
|
+
}
|
|
15
|
+
declare const NotASystemStepError_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 & {
|
|
16
|
+
readonly _tag: "NotASystemStepError";
|
|
17
|
+
} & Readonly<A>;
|
|
18
|
+
/**
|
|
19
|
+
* Error thrown when the step is not a SystemStep.
|
|
20
|
+
*/
|
|
21
|
+
export declare class NotASystemStepError extends NotASystemStepError_base<{
|
|
22
|
+
readonly stepPath: string;
|
|
23
|
+
}> {
|
|
24
|
+
}
|
|
25
|
+
declare const SystemStepExecutionError_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 & {
|
|
26
|
+
readonly _tag: "SystemStepExecutionError";
|
|
27
|
+
} & Readonly<A>;
|
|
28
|
+
/**
|
|
29
|
+
* Reserved tag for system-step execution envelopes.
|
|
30
|
+
*
|
|
31
|
+
* The executor no longer wraps failures in this type: author execute/input
|
|
32
|
+
* Effects should fail with AuthorTaggedError, which passes through for onError
|
|
33
|
+
* routing. The class remains exported so job-handler formatting can treat
|
|
34
|
+
* `SystemStepExecutionError` as a reserved/internal tag if it appears in a
|
|
35
|
+
* cause (e.g. older payloads or external call sites).
|
|
36
|
+
*/
|
|
37
|
+
export declare class SystemStepExecutionError extends SystemStepExecutionError_base<{
|
|
38
|
+
readonly stepPath: string;
|
|
39
|
+
readonly error: unknown;
|
|
40
|
+
readonly message: string;
|
|
41
|
+
}> {
|
|
42
|
+
}
|
|
43
|
+
declare const OutputValidationError_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 & {
|
|
44
|
+
readonly _tag: "OutputValidationError";
|
|
45
|
+
} & Readonly<A>;
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when the output validation fails.
|
|
48
|
+
*/
|
|
49
|
+
export declare class OutputValidationError extends OutputValidationError_base<{
|
|
50
|
+
readonly stepPath: string;
|
|
51
|
+
readonly error: unknown;
|
|
52
|
+
}> {
|
|
53
|
+
}
|
|
54
|
+
declare const LongDurationDispatchError_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 & {
|
|
55
|
+
readonly _tag: "LongDurationDispatchError";
|
|
56
|
+
} & Readonly<A>;
|
|
57
|
+
/**
|
|
58
|
+
* Error thrown when dispatching a long-duration step fails.
|
|
59
|
+
*/
|
|
60
|
+
export declare class LongDurationDispatchError extends LongDurationDispatchError_base<{
|
|
61
|
+
readonly message: string;
|
|
62
|
+
readonly cause?: unknown;
|
|
63
|
+
}> {
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* All possible errors from system step execution.
|
|
67
|
+
*
|
|
68
|
+
* Author domain errors (AuthorTaggedError) pass through as-is so onError
|
|
69
|
+
* routing can match their `_tag` without unwrapping an envelope.
|
|
70
|
+
* `SystemStepExecutionError` is not produced by the executor; it remains a
|
|
71
|
+
* separate exported class for reserved-tag formatting if it appears in a cause.
|
|
72
|
+
*/
|
|
73
|
+
export type SystemStepExecutorError = StepNotFoundError | NotASystemStepError | OutputValidationError | LongDurationDispatchError | ForEachStepRequiresItemsError | AuthorTaggedError;
|
|
74
|
+
declare const LongDurationDispatcher_base: Context.TagClass<LongDurationDispatcher, "processfocus/LongDurationDispatcher", {
|
|
75
|
+
readonly dispatch: (todoId: string, stepPath: string) => Effect.Effect<void, LongDurationDispatchError>;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Optional service used to dispatch long-duration system steps out-of-process.
|
|
79
|
+
*/
|
|
80
|
+
export declare class LongDurationDispatcher extends LongDurationDispatcher_base {
|
|
81
|
+
}
|
|
82
|
+
declare const StepProcessStateReader_base: Context.TagClass<StepProcessStateReader, "processfocus/StepProcessStateReader", {
|
|
83
|
+
/**
|
|
84
|
+
* Read the current process state for a given todo.
|
|
85
|
+
* Returns the full state object (may be empty).
|
|
86
|
+
*/
|
|
87
|
+
readonly getProcessStateByTodoId: (todoId: string) => Effect.Effect<Record<string, unknown>>;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Optional service that lets system steps read their process state at
|
|
91
|
+
* execution time. Used by deferred steps to check idempotency guards
|
|
92
|
+
* (e.g. has this Resend email already been sent on a previous retry?).
|
|
93
|
+
*/
|
|
94
|
+
export declare class StepProcessStateReader extends StepProcessStateReader_base {
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Service interface for executing system steps.
|
|
98
|
+
*
|
|
99
|
+
* The execute function may return an Effect with requirements (services needed
|
|
100
|
+
* by the system step's execute function). These requirements must be provided
|
|
101
|
+
* by the caller.
|
|
102
|
+
*/
|
|
103
|
+
export interface SystemStepExecutorService {
|
|
104
|
+
/**
|
|
105
|
+
* Execute a system step against the current process state.
|
|
106
|
+
*
|
|
107
|
+
* @param stepPath - Path of the system step to execute
|
|
108
|
+
* @param state - Current process state
|
|
109
|
+
* @param ctx - Flow context with completed step metadata
|
|
110
|
+
* @param todoId - The todo ID for the current job (passed to executeStep for dispatch)
|
|
111
|
+
* @param forEachInput - Optional pre-computed input for forEach steps (bypasses input derivation)
|
|
112
|
+
* @param completedStepPaths - Completed steps whose JSON state values can be schema-rehydrated
|
|
113
|
+
* @returns A StepResult: Completed with output, or Deferred for async dispatch.
|
|
114
|
+
*/
|
|
115
|
+
readonly execute: (stepPath: string, state: Record<string, unknown>, ctx: FlowContext<Record<string, StepMeta>>, todoId: string, forEachInput?: unknown, completedStepPaths?: readonly string[]) => Effect.Effect<StepResult, SystemStepExecutorError, unknown>;
|
|
116
|
+
}
|
|
117
|
+
declare const SystemStepExecutor_base: Context.TagClass<SystemStepExecutor, "processfocus/SystemStepExecutor", SystemStepExecutorService>;
|
|
118
|
+
/**
|
|
119
|
+
* Context tag for the SystemStepExecutor service.
|
|
120
|
+
*/
|
|
121
|
+
export declare class SystemStepExecutor extends SystemStepExecutor_base {
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create a SystemStepExecutor service from an Organisation.
|
|
125
|
+
*
|
|
126
|
+
* @param org - The organisation containing process definitions
|
|
127
|
+
* @returns A SystemStepExecutorService implementation
|
|
128
|
+
*/
|
|
129
|
+
export declare const makeSystemStepExecutor: (org: Organisation) => SystemStepExecutorService;
|
|
130
|
+
export {};
|