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,31 @@
|
|
|
1
|
+
import type { Effect, Schema } from "effect";
|
|
2
|
+
import type { ClientRepresentation } from "./types.js";
|
|
3
|
+
import { type WalkError } from "./walker.js";
|
|
4
|
+
/**
|
|
5
|
+
* Convert an Effect Schema.Struct to its client-side form representation
|
|
6
|
+
*
|
|
7
|
+
* This function walks the schema's AST and generates a typed structure
|
|
8
|
+
* that mirrors the schema's type shape, with each field mapped to its
|
|
9
|
+
* corresponding form component (TextField, NumberField, etc.).
|
|
10
|
+
*
|
|
11
|
+
* **IMPORTANT**: Only Schema.Struct is supported. The type system prevents
|
|
12
|
+
* passing any other schema type at compile time.
|
|
13
|
+
*
|
|
14
|
+
* @param schema - The Effect Schema.Struct to convert
|
|
15
|
+
* @returns An Effect that produces the client representation
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const schema = Schema.Struct({
|
|
20
|
+
* username: Schema.String,
|
|
21
|
+
* age: Schema.NumberFromString,
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* const representation = await Effect.runPromise(asClientRepresentation(schema))
|
|
25
|
+
* // {
|
|
26
|
+
* // username: { field: "username", type: "text", label: "Username", ... },
|
|
27
|
+
* // age: { field: "age", _tag: "number", label: "Age", ... }
|
|
28
|
+
* // }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const asClientRepresentation: <const Fields extends Schema.Struct.Fields>(schema: Schema.Struct<Fields>) => Effect.Effect<ClientRepresentation<Schema.Struct<Fields>>, WalkError>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type FormRule } from "../../../form-rule/src/index.js";
|
|
2
|
+
import { type FormComponent } from "./types.js";
|
|
3
|
+
export interface ClientFormDefinition {
|
|
4
|
+
readonly components: Readonly<Record<string, FormComponent>>;
|
|
5
|
+
readonly rules: readonly FormRule[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Projects a definition through an already-authorized field set. A rule is
|
|
9
|
+
* removed as a unit when any condition, effect, or otherwise path references
|
|
10
|
+
* an omitted field.
|
|
11
|
+
*/
|
|
12
|
+
export declare const omitClientFormDefinitionFields: (definition: ClientFormDefinition, omittedFieldNames: ReadonlySet<string>) => ClientFormDefinition;
|
|
13
|
+
/** Browser-safe structural validation for form component JSON. */
|
|
14
|
+
export declare const isFormComponent: (value: unknown) => value is FormComponent;
|
|
15
|
+
export declare const isClientFormDefinition: (value: unknown) => value is ClientFormDefinition;
|
|
16
|
+
export declare const parseClientFormDefinition: (value: unknown, path?: string) => ClientFormDefinition;
|
|
17
|
+
export declare const parseNullableClientFormDefinition: (value: unknown, path?: string) => ClientFormDefinition | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type * as AST from "effect/SchemaAST";
|
|
2
|
+
import type { ClientFieldPermissionMetadata } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Metadata extracted from Effect Schema annotations.
|
|
5
|
+
* Property names match BaseFormComponent for spreading.
|
|
6
|
+
*/
|
|
7
|
+
export interface FieldMetadata {
|
|
8
|
+
label: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
autoComplete?: string;
|
|
11
|
+
readonly?: boolean;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
content?: string;
|
|
14
|
+
permission?: ClientFieldPermissionMetadata;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Extract FormLabel, FormDescription, and FormReadOnly annotations from AST.
|
|
18
|
+
* Note: FormDefault is handled separately at runtime when process state is available.
|
|
19
|
+
*/
|
|
20
|
+
export declare const extractAnnotations: (annotations: AST.Annotations, fieldName: string) => FieldMetadata;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility surface for the shared public runtime registry. Keeping the
|
|
3
|
+
* state in one published module prevents private runtimes and internal form
|
|
4
|
+
* walkers from registering against different singleton instances.
|
|
5
|
+
*/
|
|
6
|
+
export { type PluginScript, type WalkerPlugin, cleanupAllPlugins, getMatchingPlugin, registerWalkerPlugin, unregisterWalkerPlugin, } from "@processfocus/runtime";
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import type { Schema } from "effect";
|
|
2
|
+
import type { CalendarSlotCalendarMetadata, LinkButtonColor, MetricBreakdownBucket, MetricBreakdownControl, MetricBreakdownField, RadioFieldMarker, RadioFieldOption } from "../../../form-schema/src/index.js";
|
|
3
|
+
export type { CalendarSlotCalendarMetadata, CalendarSlotItem, CalendarSlotWeekday, FieldPermissionMetadata, LinkButtonColor, MetricBreakdownBucket, MetricBreakdownColor, MetricBreakdownControl, MetricBreakdownField, MetricBreakdownSelectorControl, MetricBreakdownSelectorOption, RadioFieldOption, } from "../../../form-schema/src/index.js";
|
|
4
|
+
export interface ClientFieldPermissionMetadata {
|
|
5
|
+
readonly modify: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Enum of supported form component types
|
|
9
|
+
*/
|
|
10
|
+
export declare enum FormComponentType {
|
|
11
|
+
Text = "text",
|
|
12
|
+
TextArea = "textarea",
|
|
13
|
+
Number = "number",
|
|
14
|
+
Date = "date",
|
|
15
|
+
Email = "email",
|
|
16
|
+
Phone = "phone",
|
|
17
|
+
ProviderUser = "provider-user",
|
|
18
|
+
Boolean = "boolean",
|
|
19
|
+
Radio = "radio",
|
|
20
|
+
Select = "select",
|
|
21
|
+
File = "file",
|
|
22
|
+
FieldSet = "fieldset",
|
|
23
|
+
List = "list",
|
|
24
|
+
Table = "table",
|
|
25
|
+
Lookup = "lookup",
|
|
26
|
+
CalendarSlot = "calendar-slot",
|
|
27
|
+
MetricBreakdown = "metric-breakdown",
|
|
28
|
+
Plugin = "plugin",
|
|
29
|
+
Static = "static",
|
|
30
|
+
Link = "link"
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Base metadata which all form components share
|
|
34
|
+
*/
|
|
35
|
+
export interface BaseFormComponent {
|
|
36
|
+
readonly _tag: FormComponentType;
|
|
37
|
+
readonly label: string;
|
|
38
|
+
readonly description?: string;
|
|
39
|
+
readonly readonly?: boolean;
|
|
40
|
+
readonly disabled?: boolean;
|
|
41
|
+
readonly hidden?: boolean;
|
|
42
|
+
readonly required?: boolean;
|
|
43
|
+
readonly permission?: ClientFieldPermissionMetadata;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Form components that represents an actual input field
|
|
47
|
+
*/
|
|
48
|
+
export interface FormField extends BaseFormComponent {
|
|
49
|
+
readonly field: string;
|
|
50
|
+
readonly autoComplete?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Text input field
|
|
54
|
+
*/
|
|
55
|
+
export interface TextField extends FormField {
|
|
56
|
+
readonly _tag: FormComponentType.Text;
|
|
57
|
+
}
|
|
58
|
+
export interface SelectField extends FormField {
|
|
59
|
+
readonly _tag: FormComponentType.Select;
|
|
60
|
+
readonly options: readonly string[];
|
|
61
|
+
/** Encoded value to restore when clearing an optional/nullable choice. */
|
|
62
|
+
readonly emptyValue?: "null" | "undefined";
|
|
63
|
+
}
|
|
64
|
+
export interface TextAreaField extends FormField {
|
|
65
|
+
readonly _tag: FormComponentType.TextArea;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Number input field
|
|
69
|
+
*/
|
|
70
|
+
export interface NumberField extends FormField {
|
|
71
|
+
readonly _tag: FormComponentType.Number;
|
|
72
|
+
}
|
|
73
|
+
export interface DateField extends FormField {
|
|
74
|
+
readonly _tag: FormComponentType.Date;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Email input field
|
|
78
|
+
*/
|
|
79
|
+
export interface EmailField extends FormField {
|
|
80
|
+
readonly _tag: FormComponentType.Email;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Phone input field
|
|
84
|
+
*/
|
|
85
|
+
export interface PhoneField extends FormField {
|
|
86
|
+
readonly _tag: FormComponentType.Phone;
|
|
87
|
+
}
|
|
88
|
+
export interface ProviderUserField extends FormField {
|
|
89
|
+
readonly _tag: FormComponentType.ProviderUser;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Boolean/checkbox field
|
|
93
|
+
*/
|
|
94
|
+
export interface BooleanField extends FormField {
|
|
95
|
+
readonly _tag: FormComponentType.Boolean;
|
|
96
|
+
}
|
|
97
|
+
export interface RadioField extends FormField {
|
|
98
|
+
readonly _tag: FormComponentType.Radio;
|
|
99
|
+
readonly options: readonly [RadioFieldOption, ...RadioFieldOption[]];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* File upload field.
|
|
103
|
+
* The stored value is a fileId string; the UI handles upload via FileUploadContext.
|
|
104
|
+
*/
|
|
105
|
+
export interface FileField extends FormField {
|
|
106
|
+
readonly _tag: FormComponentType.File;
|
|
107
|
+
readonly documentStore: string;
|
|
108
|
+
readonly accept?: string;
|
|
109
|
+
readonly maxSize?: number;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Recursive type for form component children
|
|
113
|
+
*/
|
|
114
|
+
export type FormComponentChildren = Record<string, FormComponent>;
|
|
115
|
+
/**
|
|
116
|
+
* Regular FieldSet that contributes to path hierarchy
|
|
117
|
+
* Children paths include this FieldSet's name
|
|
118
|
+
*/
|
|
119
|
+
export interface FieldSet<T extends FormComponentChildren = FormComponentChildren> extends BaseFormComponent {
|
|
120
|
+
readonly _tag: FormComponentType.FieldSet;
|
|
121
|
+
readonly children: T;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Searchable lookup/select field.
|
|
125
|
+
* The frontend uses stepPath + fieldName to call the GraphQL query for suggestions.
|
|
126
|
+
*
|
|
127
|
+
* For dependent lookups, `dependencies` lists the field names this lookup
|
|
128
|
+
* depends on and `queryName` is the generated GraphQL query to call.
|
|
129
|
+
*/
|
|
130
|
+
export interface LookupField extends FormField {
|
|
131
|
+
readonly _tag: FormComponentType.Lookup;
|
|
132
|
+
readonly dependencies?: ReadonlyArray<string>;
|
|
133
|
+
readonly queryName?: string;
|
|
134
|
+
readonly allowFreeText?: boolean;
|
|
135
|
+
}
|
|
136
|
+
export interface CalendarSlotField extends FormField {
|
|
137
|
+
readonly _tag: FormComponentType.CalendarSlot;
|
|
138
|
+
readonly timeZone: string;
|
|
139
|
+
readonly locale: string;
|
|
140
|
+
readonly calendar?: CalendarSlotCalendarMetadata;
|
|
141
|
+
readonly emptyMessageHtml?: string;
|
|
142
|
+
readonly loadErrorMessageHtml?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Plugin-provided field carried through the generic PluginField variant.
|
|
146
|
+
* Keeps the discriminated union closed while supporting unlimited plugin types via pluginType.
|
|
147
|
+
*/
|
|
148
|
+
export interface PluginField extends FormField {
|
|
149
|
+
readonly _tag: FormComponentType.Plugin;
|
|
150
|
+
readonly pluginType: string;
|
|
151
|
+
readonly pluginData?: unknown;
|
|
152
|
+
readonly scripts?: import("./plugin-registry.js").PluginScript[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* List/array field whose items are structs.
|
|
156
|
+
* Each item is rendered as a group of child form components.
|
|
157
|
+
*/
|
|
158
|
+
export interface ListField extends BaseFormComponent {
|
|
159
|
+
readonly _tag: FormComponentType.List;
|
|
160
|
+
readonly field: string;
|
|
161
|
+
readonly addButtonLabel?: string;
|
|
162
|
+
readonly itemChildren: Record<string, FormComponent>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Read-only tabular display field whose rows are structs.
|
|
166
|
+
*/
|
|
167
|
+
export interface TableField extends BaseFormComponent {
|
|
168
|
+
readonly _tag: FormComponentType.Table;
|
|
169
|
+
readonly field: string;
|
|
170
|
+
readonly itemChildren: Record<string, FormComponent>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Static text display (no input field).
|
|
174
|
+
* Renders as read-only text content without any form input.
|
|
175
|
+
*/
|
|
176
|
+
export interface StaticText extends BaseFormComponent {
|
|
177
|
+
readonly _tag: FormComponentType.Static;
|
|
178
|
+
readonly field: string;
|
|
179
|
+
readonly content?: string;
|
|
180
|
+
}
|
|
181
|
+
export interface StaticLink extends Omit<BaseFormComponent, "label"> {
|
|
182
|
+
readonly _tag: FormComponentType.Link;
|
|
183
|
+
readonly field: string;
|
|
184
|
+
readonly label?: string;
|
|
185
|
+
readonly url: string;
|
|
186
|
+
readonly text: string;
|
|
187
|
+
readonly display?: "button";
|
|
188
|
+
readonly color?: LinkButtonColor;
|
|
189
|
+
}
|
|
190
|
+
export interface MetricBreakdown extends BaseFormComponent {
|
|
191
|
+
readonly _tag: FormComponentType.MetricBreakdown;
|
|
192
|
+
readonly field: string;
|
|
193
|
+
readonly title: string;
|
|
194
|
+
readonly buckets: readonly MetricBreakdownBucket[];
|
|
195
|
+
readonly badge?: string;
|
|
196
|
+
readonly currency?: string;
|
|
197
|
+
readonly fields?: readonly MetricBreakdownField[];
|
|
198
|
+
readonly controls?: readonly MetricBreakdownControl[];
|
|
199
|
+
readonly contextFields?: readonly string[];
|
|
200
|
+
readonly dataSource?: "item";
|
|
201
|
+
readonly rendererPluginType?: string;
|
|
202
|
+
readonly rendererPluginData?: Record<string, unknown>;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Union of all form component types
|
|
206
|
+
*/
|
|
207
|
+
export type FormComponent = TextField | TextAreaField | NumberField | DateField | EmailField | PhoneField | ProviderUserField | BooleanField | RadioField | SelectField | FileField | LookupField | CalendarSlotField | FieldSet | ListField | TableField | PluginField | StaticText | StaticLink | MetricBreakdown;
|
|
208
|
+
/**
|
|
209
|
+
* Helper type that forces TypeScript to evaluate and display the full type
|
|
210
|
+
* instead of showing the mapped type structure
|
|
211
|
+
*/
|
|
212
|
+
type Prettify<T> = {
|
|
213
|
+
[K in keyof T]: T[K];
|
|
214
|
+
} & {};
|
|
215
|
+
/**
|
|
216
|
+
* Type-level mapping from Effect Schema.Struct to client form representation
|
|
217
|
+
*
|
|
218
|
+
* Maps each field in the schema to its corresponding form component,
|
|
219
|
+
* preserving exact property names and structure.
|
|
220
|
+
*
|
|
221
|
+
* Only accepts Schema.Struct types.
|
|
222
|
+
*/
|
|
223
|
+
export type ClientRepresentation<S> = S extends Schema.Struct<infer Fields> ? Prettify<MapFieldsToComponents<Fields>> : never;
|
|
224
|
+
/**
|
|
225
|
+
* Maps Schema.Struct.Fields to form components
|
|
226
|
+
*
|
|
227
|
+
* Iterates over each field and maps the schema type to the appropriate component
|
|
228
|
+
*/
|
|
229
|
+
type MapFieldsToComponents<Fields extends Schema.Struct.Fields> = {
|
|
230
|
+
[K in keyof Fields]: MapSchemaToComponent<Fields[K]>;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Maps a single Schema to its form component type
|
|
234
|
+
*
|
|
235
|
+
* Determines the component type based on the schema's decoded (Type) type.
|
|
236
|
+
* All nested structs are treated as regular FieldSets (flattening is
|
|
237
|
+
* only relevant for submission schema).
|
|
238
|
+
*/
|
|
239
|
+
type MapSchemaToComponent<S> = S extends RadioFieldMarker ? RadioField : S extends Schema.Literal<infer Values> ? Values[number] extends string ? SelectField : FormComponent : S extends Schema.Struct<infer NestedFields> ? FieldSet<Prettify<MapFieldsToComponents<NestedFields>>> : S extends Schema.Schema<infer A, infer I> ? I extends string | null | undefined ? TextField | SelectField : I extends number | null | undefined ? NumberField : I extends boolean | null | undefined ? BooleanField : A extends ReadonlyArray<unknown> ? ListField | TableField : A extends object ? FieldSet : FormComponent : FormComponent;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import * as AST from "effect/SchemaAST";
|
|
3
|
+
import type { FormComponent } from "./types.js";
|
|
4
|
+
declare const UnknownSchemaFieldTypeError_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 & {
|
|
5
|
+
readonly _tag: "UnknownSchemaFieldTypeError";
|
|
6
|
+
} & Readonly<A>;
|
|
7
|
+
/**
|
|
8
|
+
* Error types for walker failures
|
|
9
|
+
*/
|
|
10
|
+
export declare class UnknownSchemaFieldTypeError extends UnknownSchemaFieldTypeError_base<{
|
|
11
|
+
readonly fieldName: string;
|
|
12
|
+
readonly schemaType: string;
|
|
13
|
+
}> {
|
|
14
|
+
get message(): string;
|
|
15
|
+
}
|
|
16
|
+
declare const IndexSignaturesNotSupportedError_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 & {
|
|
17
|
+
readonly _tag: "IndexSignaturesNotSupportedError";
|
|
18
|
+
} & Readonly<A>;
|
|
19
|
+
export declare class IndexSignaturesNotSupportedError extends IndexSignaturesNotSupportedError_base<{}> {
|
|
20
|
+
get message(): string;
|
|
21
|
+
}
|
|
22
|
+
declare const UnrecognizedASTNodeError_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 & {
|
|
23
|
+
readonly _tag: "UnrecognizedASTNodeError";
|
|
24
|
+
} & Readonly<A>;
|
|
25
|
+
export declare class UnrecognizedASTNodeError extends UnrecognizedASTNodeError_base<{
|
|
26
|
+
readonly nodeTag: string;
|
|
27
|
+
}> {
|
|
28
|
+
get message(): string;
|
|
29
|
+
}
|
|
30
|
+
declare const InvalidPropertyKeyError_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 & {
|
|
31
|
+
readonly _tag: "InvalidPropertyKeyError";
|
|
32
|
+
} & Readonly<A>;
|
|
33
|
+
export declare class InvalidPropertyKeyError extends InvalidPropertyKeyError_base<{
|
|
34
|
+
readonly propertyKey: PropertyKey;
|
|
35
|
+
}> {
|
|
36
|
+
get message(): string;
|
|
37
|
+
}
|
|
38
|
+
declare const InvalidFieldPermissionError_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 & {
|
|
39
|
+
readonly _tag: "InvalidFieldPermissionError";
|
|
40
|
+
} & Readonly<A>;
|
|
41
|
+
export declare class InvalidFieldPermissionError extends InvalidFieldPermissionError_base<{
|
|
42
|
+
readonly fieldName: string;
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
}> {
|
|
45
|
+
get message(): string;
|
|
46
|
+
}
|
|
47
|
+
declare const InvalidStaticLinkError_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 & {
|
|
48
|
+
readonly _tag: "InvalidStaticLinkError";
|
|
49
|
+
} & Readonly<A>;
|
|
50
|
+
export declare class InvalidStaticLinkError extends InvalidStaticLinkError_base<{
|
|
51
|
+
readonly fieldName: string;
|
|
52
|
+
readonly url: unknown;
|
|
53
|
+
readonly text: unknown;
|
|
54
|
+
}> {
|
|
55
|
+
get message(): string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Union of all walker error types
|
|
59
|
+
*/
|
|
60
|
+
export type WalkError = UnknownSchemaFieldTypeError | IndexSignaturesNotSupportedError | UnrecognizedASTNodeError | InvalidPropertyKeyError | InvalidFieldPermissionError | InvalidStaticLinkError;
|
|
61
|
+
/**
|
|
62
|
+
* Main walker function that processes Effect Schema AST and emits form structure
|
|
63
|
+
*
|
|
64
|
+
* @param ast - The Effect Schema AST to walk
|
|
65
|
+
* @param parentPath - Current path prefix for building field paths
|
|
66
|
+
*/
|
|
67
|
+
export declare const walkAST: (ast: AST.AST, parentPath?: string, nestingDepth?: number) => Effect.Effect<Record<string, FormComponent>, WalkError>;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { evaluateFormRules } from "./lib/evaluator.js";
|
|
2
|
+
export { formRuleConditionPaths, formRuleReferencesFieldNames, } from "./lib/paths.js";
|
|
3
|
+
export type { FormRule, FormRuleEffect, FormRuleEvaluationInput, FormRuleEvaluationResult, FormRuleExpression, FormRuleLiteral, FormRulePath, FormRulePathSegment, FormRuleTargetState, FormRuleTargetStateEntry, FormRuleValueSource, FormRuleValues, OrderingOperator, RuleValue, } from "./lib/types.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormRule, FormRuleExpression, FormRulePath } from "./types.js";
|
|
2
|
+
export declare const formRuleConditionPaths: ({ expression, }: {
|
|
3
|
+
readonly expression: FormRuleExpression;
|
|
4
|
+
}) => readonly FormRulePath[];
|
|
5
|
+
/** Whether any condition, effect, or otherwise path references a field name. */
|
|
6
|
+
export declare const formRuleReferencesFieldNames: ({ rule, fieldNames, }: {
|
|
7
|
+
readonly rule: FormRule;
|
|
8
|
+
readonly fieldNames: ReadonlySet<string>;
|
|
9
|
+
}) => boolean;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export type FormRuleLiteral = string | number | boolean | null | readonly FormRuleLiteral[];
|
|
2
|
+
export type FormRuleValues = Readonly<Record<string, unknown>>;
|
|
3
|
+
export type FormRuleValueSource = "current" | "base";
|
|
4
|
+
export type FormRulePathSegment = string | number;
|
|
5
|
+
export type FormRulePath = readonly FormRulePathSegment[];
|
|
6
|
+
export type RuleValue = {
|
|
7
|
+
readonly _tag: "literal";
|
|
8
|
+
readonly value: FormRuleLiteral;
|
|
9
|
+
} | {
|
|
10
|
+
readonly _tag: "field";
|
|
11
|
+
readonly path: FormRulePath;
|
|
12
|
+
readonly source?: FormRuleValueSource;
|
|
13
|
+
};
|
|
14
|
+
export type OrderingOperator = "lt" | "lte" | "gt" | "gte";
|
|
15
|
+
export type FormRuleExpression = {
|
|
16
|
+
readonly _tag: "equals";
|
|
17
|
+
readonly left: RuleValue;
|
|
18
|
+
readonly right: RuleValue;
|
|
19
|
+
} | {
|
|
20
|
+
readonly _tag: "notEquals";
|
|
21
|
+
readonly left: RuleValue;
|
|
22
|
+
readonly right: RuleValue;
|
|
23
|
+
} | {
|
|
24
|
+
readonly _tag: "in";
|
|
25
|
+
readonly value: RuleValue;
|
|
26
|
+
readonly candidates: RuleValue;
|
|
27
|
+
} | {
|
|
28
|
+
readonly _tag: "notIn";
|
|
29
|
+
readonly value: RuleValue;
|
|
30
|
+
readonly candidates: RuleValue;
|
|
31
|
+
} | {
|
|
32
|
+
readonly _tag: "blank";
|
|
33
|
+
readonly value: RuleValue;
|
|
34
|
+
} | {
|
|
35
|
+
readonly _tag: "present";
|
|
36
|
+
readonly value: RuleValue;
|
|
37
|
+
} | {
|
|
38
|
+
readonly _tag: "and";
|
|
39
|
+
readonly expressions: readonly FormRuleExpression[];
|
|
40
|
+
} | {
|
|
41
|
+
readonly _tag: "or";
|
|
42
|
+
readonly expressions: readonly FormRuleExpression[];
|
|
43
|
+
} | {
|
|
44
|
+
readonly _tag: "not";
|
|
45
|
+
readonly expression: FormRuleExpression;
|
|
46
|
+
} | {
|
|
47
|
+
readonly _tag: "numberOrder";
|
|
48
|
+
readonly operator: OrderingOperator;
|
|
49
|
+
readonly left: RuleValue;
|
|
50
|
+
readonly right: RuleValue;
|
|
51
|
+
} | {
|
|
52
|
+
readonly _tag: "stringOrder";
|
|
53
|
+
readonly operator: OrderingOperator;
|
|
54
|
+
readonly left: RuleValue;
|
|
55
|
+
readonly right: RuleValue;
|
|
56
|
+
} | {
|
|
57
|
+
readonly _tag: "dateOrder";
|
|
58
|
+
readonly operator: OrderingOperator;
|
|
59
|
+
readonly left: RuleValue;
|
|
60
|
+
readonly right: RuleValue;
|
|
61
|
+
};
|
|
62
|
+
export interface FormRuleTargetState {
|
|
63
|
+
readonly hidden?: boolean;
|
|
64
|
+
readonly disabled?: boolean;
|
|
65
|
+
readonly required?: boolean;
|
|
66
|
+
readonly label?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface FormRuleEffect {
|
|
69
|
+
readonly target: FormRulePath;
|
|
70
|
+
readonly state: FormRuleTargetState;
|
|
71
|
+
}
|
|
72
|
+
export interface FormRuleTargetStateEntry {
|
|
73
|
+
readonly path: FormRulePath;
|
|
74
|
+
readonly state: FormRuleTargetState;
|
|
75
|
+
}
|
|
76
|
+
export interface FormRule {
|
|
77
|
+
readonly condition: FormRuleExpression;
|
|
78
|
+
readonly effects: readonly FormRuleEffect[];
|
|
79
|
+
readonly otherwise?: readonly FormRuleEffect[];
|
|
80
|
+
}
|
|
81
|
+
export interface FormRuleEvaluationInput {
|
|
82
|
+
readonly rules: readonly FormRule[];
|
|
83
|
+
readonly values: FormRuleValues;
|
|
84
|
+
readonly baseValues?: FormRuleValues;
|
|
85
|
+
readonly baseState?: readonly FormRuleTargetStateEntry[];
|
|
86
|
+
}
|
|
87
|
+
export interface FormRuleEvaluationResult {
|
|
88
|
+
readonly targets: readonly FormRuleTargetStateEntry[];
|
|
89
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./lib/annotation-helpers.js";
|
|
2
|
+
export * from "./lib/deferred-value.js";
|
|
3
|
+
export * from "./lib/email.js";
|
|
4
|
+
export * from "./lib/field-count.js";
|
|
5
|
+
export * from "./lib/form-annotations.js";
|
|
6
|
+
export * from "./lib/form-schema.js";
|
|
7
|
+
export * from "./lib/phone.js";
|
|
8
|
+
export * from "./lib/property-signature.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Schema, SchemaAST } from "effect";
|
|
2
|
+
/** Look through field wrappers on the encoded side, never into container children. */
|
|
3
|
+
export declare const fieldAnnotation: (ast: SchemaAST.AST, key: symbol) => unknown;
|
|
4
|
+
/** Property annotations override the underlying encoded field's annotations. */
|
|
5
|
+
export declare const fieldInputAst: (field: Schema.Struct.Fields[string]) => SchemaAST.AST;
|
|
6
|
+
export declare const hasStructuralOnlyAnnotation: (field: Schema.Struct.Fields[string]) => boolean;
|
|
7
|
+
export declare const hasFlattenAnnotation: (field: Schema.Struct.Fields[string]) => boolean;
|
|
8
|
+
export declare const isReadOnlyField: (field: Schema.Struct.Fields[string]) => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** An opaque authoring-time value. Only the owning Form can resolve it. */
|
|
2
|
+
export declare const DeferredValueTypeId: unique symbol;
|
|
3
|
+
export interface DeferredValue<out Value> {
|
|
4
|
+
readonly [DeferredValueTypeId]: true;
|
|
5
|
+
readonly fallback: Value | undefined;
|
|
6
|
+
}
|
|
7
|
+
export type FormValue<Value> = Value | DeferredValue<Value | undefined>;
|
|
8
|
+
export declare const isDeferredValue: (value: unknown) => value is DeferredValue<unknown>;
|
|
9
|
+
/** Internal annotation for a deferred structural leaf, never a value schema. */
|
|
10
|
+
export declare const FormDeferredContent: unique symbol;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { type FieldOptions } from "./form-schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* Email schema using validator.js for robust email validation.
|
|
5
|
+
*
|
|
6
|
+
* Configured to allow:
|
|
7
|
+
* - UTF-8 local parts (e.g., üñîcödé@example.com)
|
|
8
|
+
* - IDN/punycode domains (e.g., user@日本語.jp)
|
|
9
|
+
* - localhost-style emails for development (e.g., user@localhost)
|
|
10
|
+
*
|
|
11
|
+
* The value is trimmed before validation.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { EmailField } from "../index.js"
|
|
16
|
+
*
|
|
17
|
+
* const form = Schema.Struct({
|
|
18
|
+
* contactEmail: EmailField(),
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const Email: Schema.refine<string, typeof Schema.Trim>;
|
|
23
|
+
export declare const EmailField: (options?: FieldOptions<string>) => Schema.Schema<string, string, never>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Counts the number of top-level fields that have validation errors.
|
|
4
|
+
* Assumes the schema has no Context requirements (all our form schemas are context-free).
|
|
5
|
+
*
|
|
6
|
+
* @param schema - Effect Schema to validate against
|
|
7
|
+
* @param data - Data to validate
|
|
8
|
+
* @returns Number of top-level fields with validation errors
|
|
9
|
+
*/
|
|
10
|
+
export declare const countInvalidFields: (schema: Schema.Schema.Any, data: unknown) => number;
|
|
11
|
+
/**
|
|
12
|
+
* Counts the total number of fields in a schema.
|
|
13
|
+
*
|
|
14
|
+
* @param schema - Effect Schema struct to count fields in
|
|
15
|
+
* @returns Total number of fields
|
|
16
|
+
*/
|
|
17
|
+
export declare const countTotalFields: (schema: {
|
|
18
|
+
fields: Record<PropertyKey, unknown>;
|
|
19
|
+
}) => number;
|
|
20
|
+
/**
|
|
21
|
+
* Calculates how many fields are completed (valid) vs total fields.
|
|
22
|
+
*
|
|
23
|
+
* @param schema - Effect Schema to validate against
|
|
24
|
+
* @param data - Data to validate
|
|
25
|
+
* @returns Object with fieldsCompleted and totalFields
|
|
26
|
+
*/
|
|
27
|
+
export declare const calculateFieldCompletion: (schema: {
|
|
28
|
+
fields: Record<PropertyKey, unknown>;
|
|
29
|
+
} & Schema.Schema.Any, data: unknown) => {
|
|
30
|
+
fieldsCompleted: number;
|
|
31
|
+
totalFields: number;
|
|
32
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OrganisationFrontendManifestFormComponentPluginDeclaration } from "../../../frontend-manifest/src/index.js";
|
|
2
|
+
export type FormComponentPluginTypeDeclaration = OrganisationFrontendManifestFormComponentPluginDeclaration;
|
|
3
|
+
export declare const FormLabel: unique symbol;
|
|
4
|
+
export declare const FormDescription: unique symbol;
|
|
5
|
+
export declare const FormReadOnly: unique symbol;
|
|
6
|
+
export declare const FormDefault: unique symbol;
|
|
7
|
+
export declare const FormPermission: unique symbol;
|
|
8
|
+
export declare const FormRequired: unique symbol;
|
|
9
|
+
export declare const FormMessage: unique symbol;
|
|
10
|
+
export declare const FormAutoComplete: unique symbol;
|
|
11
|
+
export declare const FormNumberInput: unique symbol;
|
|
12
|
+
export declare const FormDateInput: unique symbol;
|
|
13
|
+
export declare const FormEmailInput: unique symbol;
|
|
14
|
+
export declare const FormPhoneInput: unique symbol;
|
|
15
|
+
export declare const FormTextAreaInput: unique symbol;
|
|
16
|
+
export declare const FormTableInput: unique symbol;
|
|
17
|
+
export declare const FormListInput: unique symbol;
|
|
18
|
+
export declare const FormFileInput: unique symbol;
|
|
19
|
+
export declare const FormLookupInput: unique symbol;
|
|
20
|
+
export declare const FormRadioInput: unique symbol;
|
|
21
|
+
export declare const FormSuggestionInput: unique symbol;
|
|
22
|
+
export declare const FormCalendarSlotInput: unique symbol;
|
|
23
|
+
export declare const FormProviderUserInput: unique symbol;
|
|
24
|
+
export declare const FormStaticText: unique symbol;
|
|
25
|
+
export declare const FormComponentPluginType: unique symbol;
|