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.
Files changed (98) hide show
  1. package/LICENSE.md +28 -0
  2. package/README.md +14 -0
  3. package/dist/auth-FmXptohB.mjs +275 -0
  4. package/dist/auth-config/src/lib/authentication-config.d.ts +146 -0
  5. package/dist/auth-config/src/lib/custom-entities-config.d.ts +47 -0
  6. package/dist/auth-config/src/lib/policies-config.d.ts +52 -0
  7. package/dist/auth-config/src/lib/provider-types.d.ts +194 -0
  8. package/dist/auth.d.ts +4 -0
  9. package/dist/auth.mjs +2 -0
  10. package/dist/business-calendar/src/index.d.ts +10 -0
  11. package/dist/business-calendar/src/lib/calendar-config.d.ts +163 -0
  12. package/dist/business-calendar/src/lib/calendar-period.d.ts +88 -0
  13. package/dist/business-calendar/src/lib/calendar-service-impl.d.ts +19 -0
  14. package/dist/business-calendar/src/lib/calendar-service.d.ts +215 -0
  15. package/dist/business-calendar/src/lib/datetime-utils.d.ts +30 -0
  16. package/dist/business-calendar/src/lib/duration-calculator.d.ts +49 -0
  17. package/dist/business-calendar/src/lib/errors.d.ts +69 -0
  18. package/dist/business-calendar/src/lib/holiday-calculator.d.ts +61 -0
  19. package/dist/business-calendar/src/lib/holidays.d.ts +141 -0
  20. package/dist/business-calendar/src/lib/types.d.ts +110 -0
  21. package/dist/calendar.d.ts +1 -0
  22. package/dist/calendar.mjs +1204 -0
  23. package/dist/form-client-representation/src/index.d.ts +6 -0
  24. package/dist/form-client-representation/src/lib/as-client-representation.d.ts +31 -0
  25. package/dist/form-client-representation/src/lib/client-form-definition.d.ts +17 -0
  26. package/dist/form-client-representation/src/lib/extract-annotations.d.ts +20 -0
  27. package/dist/form-client-representation/src/lib/plugin-registry.d.ts +6 -0
  28. package/dist/form-client-representation/src/lib/types.d.ts +239 -0
  29. package/dist/form-client-representation/src/lib/walker.d.ts +68 -0
  30. package/dist/form-rule/src/index.d.ts +3 -0
  31. package/dist/form-rule/src/lib/evaluator.d.ts +2 -0
  32. package/dist/form-rule/src/lib/paths.d.ts +9 -0
  33. package/dist/form-rule/src/lib/types.d.ts +89 -0
  34. package/dist/form-schema/src/index.d.ts +8 -0
  35. package/dist/form-schema/src/lib/annotation-helpers.d.ts +8 -0
  36. package/dist/form-schema/src/lib/deferred-value.d.ts +10 -0
  37. package/dist/form-schema/src/lib/email.d.ts +23 -0
  38. package/dist/form-schema/src/lib/field-count.d.ts +32 -0
  39. package/dist/form-schema/src/lib/form-annotations.d.ts +25 -0
  40. package/dist/form-schema/src/lib/form-schema.d.ts +459 -0
  41. package/dist/form-schema/src/lib/phone.d.ts +4 -0
  42. package/dist/form-schema/src/lib/property-signature.d.ts +3 -0
  43. package/dist/form-submission-schema/src/index.d.ts +2 -0
  44. package/dist/form-submission-schema/src/lib/form-submission-schema.d.ts +49 -0
  45. package/dist/form-submission-schema/src/lib/schema-defaults.d.ts +16 -0
  46. package/dist/forms.d.ts +1 -0
  47. package/dist/forms.mjs +2 -0
  48. package/dist/frontend-manifest/src/index.d.ts +2 -0
  49. package/dist/frontend-manifest/src/lib/browser-plugin-artifact.d.ts +25 -0
  50. package/dist/frontend-manifest/src/lib/frontend-manifest.d.ts +83 -0
  51. package/dist/frontend-plugin-host/src/index.d.ts +2 -0
  52. package/dist/frontend-plugin-host/src/lib/frontend-plugin-host.d.ts +124 -0
  53. package/dist/index.d.ts +26 -0
  54. package/dist/index.mjs +3780 -0
  55. package/dist/manifest.d.ts +2 -0
  56. package/dist/manifest.mjs +5 -0
  57. package/dist/paths-BkzLn-rG.mjs +282 -0
  58. package/dist/plugin.d.ts +3 -0
  59. package/dist/plugin.mjs +84 -0
  60. package/dist/process/src/lib/app-icons.d.ts +52 -0
  61. package/dist/process/src/lib/brands.d.ts +20 -0
  62. package/dist/process/src/lib/document-store.d.ts +30 -0
  63. package/dist/process/src/lib/execution-failure-notifications.d.ts +14 -0
  64. package/dist/process/src/lib/flow-context.d.ts +181 -0
  65. package/dist/process/src/lib/flow-path.d.ts +123 -0
  66. package/dist/process/src/lib/form-authoring.d.ts +19 -0
  67. package/dist/process/src/lib/form-decoration.d.ts +13 -0
  68. package/dist/process/src/lib/form-defaults.d.ts +5 -0
  69. package/dist/process/src/lib/form.d.ts +557 -0
  70. package/dist/process/src/lib/invitation.d.ts +35 -0
  71. package/dist/process/src/lib/list.d.ts +447 -0
  72. package/dist/process/src/lib/lookup-accessor.d.ts +68 -0
  73. package/dist/process/src/lib/node_step.d.ts +68 -0
  74. package/dist/process/src/lib/org-unit.d.ts +53 -0
  75. package/dist/process/src/lib/org-utils.d.ts +56 -0
  76. package/dist/process/src/lib/organisation-frontend-plugin-manifest.d.ts +33 -0
  77. package/dist/process/src/lib/organisation.d.ts +166 -0
  78. package/dist/process/src/lib/phase.d.ts +16 -0
  79. package/dist/process/src/lib/process.d.ts +196 -0
  80. package/dist/process/src/lib/public-form-branding.d.ts +27 -0
  81. package/dist/process/src/lib/role.d.ts +29 -0
  82. package/dist/process/src/lib/schedule.d.ts +239 -0
  83. package/dist/process/src/lib/sla.d.ts +84 -0
  84. package/dist/process/src/lib/stats-view.d.ts +68 -0
  85. package/dist/process/src/lib/step.d.ts +130 -0
  86. package/dist/process/src/lib/system-step-executor.d.ts +130 -0
  87. package/dist/process/src/lib/system-step.d.ts +248 -0
  88. package/dist/sdk/src/auth.d.ts +4 -0
  89. package/dist/sdk/src/calendar.d.ts +1 -0
  90. package/dist/sdk/src/forms.d.ts +1 -0
  91. package/dist/sdk/src/index.d.ts +26 -0
  92. package/dist/sdk/src/manifest.d.ts +2 -0
  93. package/dist/sdk/src/plugin.d.ts +3 -0
  94. package/dist/sdk/src/testing.d.ts +9 -0
  95. package/dist/src-C-909PVQ.mjs +498 -0
  96. package/dist/testing.d.ts +9 -0
  97. package/dist/testing.mjs +5 -0
  98. package/package.json +67 -0
@@ -0,0 +1,498 @@
1
+ import { Either, Schema, SchemaAST } from "effect";
2
+ import isURL from "validator/lib/isURL";
3
+ import isEmail from "validator/lib/isEmail";
4
+ import { ArrayFormatter } from "effect/ParseResult";
5
+ //#region ../form-schema/src/lib/form-annotations.ts
6
+ const FormLabel = Symbol.for("pf/form/annotation/Label");
7
+ const FormDescription = Symbol.for("pf/form/annotation/Description");
8
+ const FormReadOnly = Symbol.for("pf/form/annotation/ReadOnly");
9
+ const FormDefault = Symbol.for("pf/form/annotation/Default");
10
+ const FormPermission = Symbol.for("pf/form/annotation/Permission");
11
+ const FormRequired = Symbol.for("pf/form/annotation/Required");
12
+ const FormMessage = Symbol.for("pf/form/annotation/Message");
13
+ const FormAutoComplete = Symbol.for("pf/form/annotation/AutoComplete");
14
+ const FormNumberInput = Symbol.for("pf/form/annotation/NumberInput");
15
+ const FormDateInput = Symbol.for("pf/form/annotation/DateInput");
16
+ const FormEmailInput = Symbol.for("pf/form/annotation/EmailInput");
17
+ const FormPhoneInput = Symbol.for("pf/form/annotation/PhoneInput");
18
+ const FormTextAreaInput = Symbol.for("pf/form/annotation/TextAreaInput");
19
+ const FormTableInput = Symbol.for("pf/form/annotation/TableInput");
20
+ const FormListInput = Symbol.for("pf/form/annotation/ListInput");
21
+ const FormFileInput = Symbol.for("pf/form/annotation/FileInput");
22
+ const FormLookupInput = Symbol.for("pf/form/annotation/LookupInput");
23
+ const FormRadioInput = Symbol.for("pf/form/annotation/RadioInput");
24
+ const FormSuggestionInput = Symbol.for("pf/form/annotation/SuggestionInput");
25
+ const FormCalendarSlotInput = Symbol.for("pf/form/annotation/CalendarSlotInput");
26
+ const FormProviderUserInput = Symbol.for("pf/form/annotation/ProviderUserInput");
27
+ const FormStaticText = Symbol.for("pf/form/annotation/StaticText");
28
+ const FormComponentPluginType = Symbol.for("pf/form/annotation/ComponentPluginType");
29
+ //#endregion
30
+ //#region ../form-schema/src/lib/form-schema.ts
31
+ const FLATTEN_SYMBOL = Symbol.for("processfocus/form-schema/flatten");
32
+ const STRUCTURAL_ONLY_SYMBOL = Symbol.for("processfocus/form-schema/structural-only");
33
+ const STRUCTURAL_TYPE_SYMBOL = Symbol.for("processfocus/form-schema/structural-type");
34
+ const TEXTBLOCK_CONTENT_SYMBOL = Symbol.for("processfocus/form-schema/textblock-content");
35
+ const TEXTBLOCK_DYNAMIC_CONTENT_SYMBOL = Symbol.for("processfocus/form-schema/textblock-dynamic-content");
36
+ const METRIC_BREAKDOWN_SYMBOL = Symbol.for("processfocus/form-schema/metric-breakdown");
37
+ const LINK_URL_SYMBOL = Symbol.for("processfocus/form-schema/link-url");
38
+ const LINK_TEXT_SYMBOL = Symbol.for("processfocus/form-schema/link-text");
39
+ const LINK_DISPLAY_SYMBOL = Symbol.for("processfocus/form-schema/link-display");
40
+ const LINK_COLOR_SYMBOL = Symbol.for("processfocus/form-schema/link-color");
41
+ const CurrentProviderUser = Symbol.for("processfocus/form-schema/current-provider-user");
42
+ /** Preserve read-only classification in downstream process-state inference. */
43
+ const ReadOnly = (schema) => schema.annotations({ [FormReadOnly]: true });
44
+ const Wrapper = (fields) => Schema.Struct(fields).annotations({ [FLATTEN_SYMBOL]: true });
45
+ const structuralElement = (type, data) => Schema.Undefined.annotations({
46
+ [STRUCTURAL_ONLY_SYMBOL]: true,
47
+ [STRUCTURAL_TYPE_SYMBOL]: type,
48
+ ...data
49
+ });
50
+ const StructuralOnly = structuralElement("structural");
51
+ const Divider = structuralElement("divider");
52
+ const TextBlock = (text) => structuralElement("textblock", { [TEXTBLOCK_CONTENT_SYMBOL]: text });
53
+ const DynamicTextBlock = (options) => structuralElement("textblock", {
54
+ [TEXTBLOCK_CONTENT_SYMBOL]: options.text,
55
+ [TEXTBLOCK_DYNAMIC_CONTENT_SYMBOL]: options.resolve
56
+ });
57
+ const Image = (src, alt) => structuralElement("image", {
58
+ src,
59
+ alt
60
+ });
61
+ const linkElement = (url, text, display, options) => structuralElement("link", {
62
+ [LINK_URL_SYMBOL]: url,
63
+ [LINK_TEXT_SYMBOL]: text,
64
+ ...display ? { [LINK_DISPLAY_SYMBOL]: display } : {},
65
+ ...options?.color ? { [LINK_COLOR_SYMBOL]: options.color } : {}
66
+ });
67
+ const Link = (url, text) => linkElement(url, text);
68
+ const LinkButton = (url, text, options) => linkElement(url, text, "button", options);
69
+ const MetricBreakdown = (options) => structuralElement("metric-breakdown", { [METRIC_BREAKDOWN_SYMBOL]: options });
70
+ const isMetricBreakdownBucket = (value) => {
71
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
72
+ return typeof value["label"] === "string";
73
+ };
74
+ const isMetricBreakdownSelectorOption = (value) => {
75
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
76
+ const record = value;
77
+ return typeof record["label"] === "string" && typeof record["value"] === "string";
78
+ };
79
+ const isMetricBreakdownControl = (value) => {
80
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
81
+ const record = value;
82
+ return record["type"] === "selector" && typeof record["name"] === "string" && (record["urlParameter"] === void 0 || typeof record["urlParameter"] === "string") && typeof record["label"] === "string" && (record["value"] === void 0 || typeof record["value"] === "string") && Array.isArray(record["options"]) && record["options"].length > 0 && record["options"].every(isMetricBreakdownSelectorOption);
83
+ };
84
+ const isMetricBreakdownOptions = (value) => {
85
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
86
+ const record = value;
87
+ const dataSource = record["dataSource"];
88
+ const controls = record["controls"];
89
+ const rendererPluginType = record["rendererPluginType"];
90
+ const rendererPluginData = record["rendererPluginData"];
91
+ return typeof record["title"] === "string" && Array.isArray(record["buckets"]) && record["buckets"].every(isMetricBreakdownBucket) && (controls === void 0 || Array.isArray(controls) && controls.every(isMetricBreakdownControl)) && (dataSource === void 0 || dataSource === "item") && (rendererPluginType === void 0 || typeof rendererPluginType === "string") && (rendererPluginData === void 0 || typeof rendererPluginData === "object" && rendererPluginData !== null && !Array.isArray(rendererPluginData));
92
+ };
93
+ const isListFieldMetadata = (value) => typeof value === "object" && value !== null && (!("addButtonLabel" in value) || typeof value.addButtonLabel === "string");
94
+ const isFieldPermissionMetadata = (value) => typeof value === "object" && value !== null && "modify" in value && typeof value.modify === "object" && value.modify !== null && "node" in value.modify && typeof value.modify.node === "object" && value.modify.node !== null && "path" in value.modify.node && typeof value.modify.node.path === "string";
95
+ const applyFieldAnnotations = (schema, options) => {
96
+ if (!options) return schema;
97
+ const annotations = {};
98
+ if (options.label !== void 0) annotations[FormLabel] = options.label;
99
+ if (options.description !== void 0) annotations[FormDescription] = options.description;
100
+ if (options.autoComplete !== void 0) annotations[FormAutoComplete] = options.autoComplete;
101
+ if (options.readOnly !== void 0) annotations[FormReadOnly] = options.readOnly;
102
+ if (isFieldPermissionMetadata(options.permission)) annotations[FormPermission] = options.permission;
103
+ if (options.default !== void 0) annotations[FormDefault] = options.default;
104
+ return Object.getOwnPropertySymbols(annotations).length > 0 ? schema.annotations(annotations) : schema;
105
+ };
106
+ function TextField(options) {
107
+ return applyFieldAnnotations(Schema.String, options);
108
+ }
109
+ function TextArea(options) {
110
+ return applyFieldAnnotations(Schema.String.annotations({ [FormTextAreaInput]: true }), options);
111
+ }
112
+ /**
113
+ * Create a text field from a transformation schema
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const schema = Schema.Struct({
118
+ * date: TextFieldFrom(Schema.DateFromString, { label: "Birth date" })
119
+ * })
120
+ * ```
121
+ */
122
+ const TextFieldFrom = (schema, options) => applyFieldAnnotations(schema, options);
123
+ /**
124
+ * Validate that a string is a well-formed HTTPS URL.
125
+ *
126
+ * Uses `validator/lib/isURL` with `protocols: ["https"]` and
127
+ * `require_protocol: true` so bare hostnames and non-HTTPS schemes are
128
+ * rejected. TLDs are required to catch typos like `https://x`.
129
+ *
130
+ * Exported so server-side code (e.g. `updateRegion`) can reuse the same
131
+ * check without pulling in the full form-schema field constructor.
132
+ */
133
+ const isHttpsUrl = (value) => isURL(value, {
134
+ protocols: ["https"],
135
+ require_protocol: true,
136
+ require_tld: true
137
+ });
138
+ const httpsUrlSchema = Schema.String.pipe(Schema.filter(isHttpsUrl, { message: () => "Must be a valid HTTPS URL (e.g. https://example.com/path)" }), Schema.annotations({ arbitrary: () => (fc) => fc.webUrl({ validSchemes: ["https"] }) }));
139
+ /**
140
+ * Create an HTTPS URL text field with built-in validation via
141
+ * `validator.js`.
142
+ *
143
+ * The pattern annotation guides Effect's arbitrary generator so that
144
+ * auto-generated test data produces valid HTTPS URLs. The `isHttpsUrl`
145
+ * filter then performs the real validation using `validator/lib/isURL`.
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const schema = Schema.Struct({
150
+ * endpoint: HttpsUrlField({ label: "OTLP Endpoint" })
151
+ * })
152
+ * ```
153
+ */
154
+ const HttpsUrlField = (options) => {
155
+ return applyFieldAnnotations(httpsUrlSchema, options);
156
+ };
157
+ /**
158
+ * Create a number field with optional label and description
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * const schema = Schema.Struct({
163
+ * age: NumberField({ label: "Your age", description: "Age in years" })
164
+ * })
165
+ * ```
166
+ */
167
+ const NumberField = (options) => applyFieldAnnotations(Schema.Number, options);
168
+ /**
169
+ * Create a number field from a transformation schema
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * const schema = Schema.Struct({
174
+ * age: NumberFieldFrom(Schema.NumberFromString, { label: "Your age" })
175
+ * })
176
+ * ```
177
+ */
178
+ const NumberFieldFrom = (schema, options) => {
179
+ const base = options?.required ? schema.annotations({
180
+ jsonSchema: { minLength: 1 },
181
+ [FormRequired]: true,
182
+ [FormNumberInput]: true
183
+ }) : schema.annotations({ [FormNumberInput]: true });
184
+ return applyFieldAnnotations(base, options);
185
+ };
186
+ const DateField = (options) => applyFieldAnnotations(Schema.DateTimeUtc.annotations({ [FormDateInput]: true }), options);
187
+ const requiredBooleanSchema = Schema.Boolean.pipe(Schema.filter((b) => b === true, {
188
+ message: () => "This field is required",
189
+ jsonSchema: {
190
+ type: "boolean",
191
+ enum: [true]
192
+ },
193
+ [FormRequired]: true
194
+ }));
195
+ /**
196
+ * Create a boolean field with optional label and description
197
+ *
198
+ * When `required: true`, the field must be checked (true) to pass validation.
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const schema = Schema.Struct({
203
+ * acceptTerms: BooleanField({ label: "Accept terms and conditions" }),
204
+ * approved: BooleanField({ label: "I approve", required: true })
205
+ * })
206
+ * ```
207
+ */
208
+ const BooleanField = (options) => {
209
+ const base = options?.required ? requiredBooleanSchema : Schema.Boolean;
210
+ return applyFieldAnnotations(base, options);
211
+ };
212
+ /**
213
+ * Create a file upload field with optional accept filter and max size.
214
+ *
215
+ * The underlying value is a `fileId` string (returned by the document store
216
+ * after upload). The frontend renders this as a file picker that handles
217
+ * upload automatically.
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * const schema = Schema.Struct({
222
+ * artifact: FileField({ label: "Deployment artifact", accept: ".zip", maxSize: 100_000_000 })
223
+ * })
224
+ * ```
225
+ */
226
+ const FileField = (options) => {
227
+ const metadata = {
228
+ documentStore: options.documentStore.node.path.startsWith("/") ? options.documentStore.node.path : `/${options.documentStore.node.path}`,
229
+ ...options.accept != null && { accept: options.accept },
230
+ ...options.maxSize != null && { maxSize: options.maxSize }
231
+ };
232
+ const base = Schema.String.annotations({ [FormFileInput]: metadata });
233
+ return applyFieldAnnotations(base, options);
234
+ };
235
+ /**
236
+ * Create a list/array field whose items are structs.
237
+ *
238
+ * Produces `Schema.Array(Schema.Struct(itemFields))` with optional annotations.
239
+ *
240
+ * @example
241
+ * ```typescript
242
+ * const schema = Schema.Struct({
243
+ * students: ListField({
244
+ * first_name: TextField({ label: "First name" }),
245
+ * parent_email: TextField({ label: "Parent email" }),
246
+ * }, { label: "Students" }),
247
+ * })
248
+ * ```
249
+ */
250
+ const ListField = (itemFields, options) => {
251
+ const schema = Schema.Array(Schema.Struct(itemFields));
252
+ const annotatedSchema = options?.addButtonLabel === void 0 ? schema : schema.annotations({ [FormListInput]: { addButtonLabel: options.addButtonLabel } });
253
+ return applyFieldAnnotations(annotatedSchema, options);
254
+ };
255
+ /**
256
+ * Create a read-only table field whose rows are structs.
257
+ *
258
+ * The row field labels become the table column headings. Table fields are for
259
+ * display only and are excluded from form submissions via the read-only marker.
260
+ */
261
+ const TableField = (itemFields, options) => applyFieldAnnotations(Schema.Array(Schema.Struct(itemFields)).annotations({ [FormTableInput]: true }), {
262
+ ...options,
263
+ readOnly: true
264
+ });
265
+ const RadioField = (options) => {
266
+ const values = options.options.map((option) => option.value);
267
+ const metadata = { options: options.options };
268
+ return applyFieldAnnotations(Schema.Literal(...values).annotations({ [FormRadioInput]: metadata }), options);
269
+ };
270
+ /**
271
+ * Create a searchable lookup/select field.
272
+ *
273
+ * The underlying value is a string (the selected item's value/ID).
274
+ * The `query` function is embedded in the schema annotation and executed
275
+ * server-side by the `lookupSuggestions` GraphQL resolver, which calls
276
+ * `Form.executeLookup()` to provide the Effect runtime context. Any
277
+ * service dependencies used via `yield*` are resolved automatically.
278
+ *
279
+ * @param options - Standard field options (label, description, etc.) plus
280
+ * a `query` function receiving a search filter and max result count,
281
+ * returning an Effect that yields {@link LookupItem LookupItem[]}.
282
+ *
283
+ * @example
284
+ * ```typescript
285
+ * const schema = Schema.Struct({
286
+ * regionId: LookupField({
287
+ * label: "Region",
288
+ * description: "AWS region for this project",
289
+ * query: (filter, limit) =>
290
+ * Effect.gen(function* () {
291
+ * const ops = yield* OrgOperations
292
+ * return yield* ops.searchRegions(filter, limit)
293
+ * }),
294
+ * }),
295
+ * })
296
+ * ```
297
+ */
298
+ const LookupField = (options) => {
299
+ const metadata = { ...options.query != null && { query: options.query } };
300
+ const base = Schema.String.annotations({ [FormLookupInput]: metadata });
301
+ return applyFieldAnnotations(base, options);
302
+ };
303
+ /**
304
+ * Create a text field with searchable suggestions.
305
+ *
306
+ * Unlike {@link LookupField}, the submitted value can be either one of the
307
+ * suggestion values or arbitrary text entered by the user. Use this for fields
308
+ * where known records are helpful but not exhaustive.
309
+ */
310
+ const SuggestionField = (options) => {
311
+ const metadata = { ...options.query != null && { query: options.query } };
312
+ const base = Schema.String.annotations({
313
+ [FormLookupInput]: metadata,
314
+ [FormSuggestionInput]: true
315
+ });
316
+ return applyFieldAnnotations(base, options);
317
+ };
318
+ const CalendarSlotField = (options) => {
319
+ const metadata = {
320
+ timeZone: options.timeZone,
321
+ locale: options.locale ?? "en",
322
+ ...options.query != null && { query: options.query },
323
+ ...options.calendar != null && { calendar: options.calendar },
324
+ ...options.emptyMessageHtml != null && { emptyMessageHtml: options.emptyMessageHtml },
325
+ ...options.loadErrorMessageHtml != null && { loadErrorMessageHtml: options.loadErrorMessageHtml }
326
+ };
327
+ return applyFieldAnnotations(Schema.String.annotations({ [FormCalendarSlotInput]: metadata }), options);
328
+ };
329
+ /**
330
+ * Create a provider-user field.
331
+ *
332
+ * The submitted value is still a string: the selected provider user's id or
333
+ * email. `CurrentProviderUser` can be used as a symbolic default for later
334
+ * runtime resolution.
335
+ */
336
+ const ProviderUserField = (options) => applyFieldAnnotations(Schema.String.annotations({ [FormProviderUserInput]: true }), options);
337
+ //#endregion
338
+ //#region ../form-schema/src/lib/annotation-helpers.ts
339
+ /** Look through field wrappers on the encoded side, never into container children. */
340
+ const fieldAnnotation = (ast, key) => {
341
+ const direct = ast.annotations[key];
342
+ if (direct !== void 0) return direct;
343
+ if (ast._tag === "Transformation" || ast._tag === "Refinement") return fieldAnnotation(ast.from, key);
344
+ if (ast._tag === "Union") for (const type of ast.types) {
345
+ const value = fieldAnnotation(type, key);
346
+ if (value !== void 0) return value;
347
+ }
348
+ };
349
+ /** Property annotations override the underlying encoded field's annotations. */
350
+ const fieldInputAst = (field) => Schema.isPropertySignature(field) ? field.ast._tag === "PropertySignatureDeclaration" ? SchemaAST.annotations(field.ast.type, field.ast.annotations) : SchemaAST.annotations(field.ast.from.type, {
351
+ ...field.ast.from.annotations,
352
+ ...field.ast.to.annotations
353
+ }) : field.ast;
354
+ const hasStructuralOnlyAnnotation = (field) => fieldAnnotation(fieldInputAst(field), STRUCTURAL_ONLY_SYMBOL) !== void 0;
355
+ const hasFlattenAnnotation = (field) => fieldAnnotation(fieldInputAst(field), FLATTEN_SYMBOL) !== void 0;
356
+ const isReadOnlyField = (field) => fieldAnnotation(fieldInputAst(field), FormReadOnly) === true;
357
+ //#endregion
358
+ //#region ../form-schema/src/lib/deferred-value.ts
359
+ /** An opaque authoring-time value. Only the owning Form can resolve it. */
360
+ const DeferredValueTypeId = Symbol.for("pf/form/deferred-value");
361
+ const isDeferredValue = (value) => typeof value === "object" && value !== null && DeferredValueTypeId in value && value[DeferredValueTypeId] === true && "fallback" in value;
362
+ /** Internal annotation for a deferred structural leaf, never a value schema. */
363
+ const FormDeferredContent = Symbol.for("pf/form/deferred-content");
364
+ //#endregion
365
+ //#region ../form-schema/src/lib/email.ts
366
+ /**
367
+ * Email schema using validator.js for robust email validation.
368
+ *
369
+ * Configured to allow:
370
+ * - UTF-8 local parts (e.g., üñîcödé@example.com)
371
+ * - IDN/punycode domains (e.g., user@日本語.jp)
372
+ * - localhost-style emails for development (e.g., user@localhost)
373
+ *
374
+ * The value is trimmed before validation.
375
+ *
376
+ * @example
377
+ * ```typescript
378
+ * import { EmailField } from "processfocus/form-schema"
379
+ *
380
+ * const form = Schema.Struct({
381
+ * contactEmail: EmailField(),
382
+ * })
383
+ * ```
384
+ */
385
+ const Email = Schema.Trim.pipe(Schema.filter((s) => isEmail(s, {
386
+ require_tld: false,
387
+ allow_utf8_local_part: true,
388
+ allow_ip_domain: true
389
+ }), { message: () => "must be a valid email address" }), Schema.annotations({
390
+ identifier: "Email",
391
+ title: "Email address",
392
+ description: "A valid email address",
393
+ jsonSchema: { format: "email" },
394
+ [FormEmailInput]: true
395
+ }));
396
+ const EmailField = (options) => applyFieldAnnotations(Email, {
397
+ autoComplete: options?.autoComplete ?? "email",
398
+ ...options
399
+ });
400
+ //#endregion
401
+ //#region ../form-schema/src/lib/field-count.ts
402
+ const isKeyObject = (segment) => typeof segment === "object" && segment !== null && "key" in segment && typeof segment.key !== "undefined";
403
+ const extractKey = (segment) => {
404
+ if (segment === void 0) return void 0;
405
+ return isKeyObject(segment) ? segment.key : segment;
406
+ };
407
+ /**
408
+ * Counts the number of top-level fields that have validation errors.
409
+ * Assumes the schema has no Context requirements (all our form schemas are context-free).
410
+ *
411
+ * @param schema - Effect Schema to validate against
412
+ * @param data - Data to validate
413
+ * @returns Number of top-level fields with validation errors
414
+ */
415
+ const countInvalidFields = (schema, data) => {
416
+ const contextFreeSchema = schema;
417
+ const result = Schema.decodeUnknownEither(contextFreeSchema)(data, {
418
+ errors: "all",
419
+ onExcessProperty: "ignore"
420
+ });
421
+ if (Either.isRight(result)) return 0;
422
+ const issues = ArrayFormatter.formatErrorSync(result.left);
423
+ return new Set(issues.map((issue) => extractKey(issue.path[0])).filter((key) => key !== void 0)).size;
424
+ };
425
+ /**
426
+ * Counts the total number of fields in a schema.
427
+ *
428
+ * @param schema - Effect Schema struct to count fields in
429
+ * @returns Total number of fields
430
+ */
431
+ const countTotalFields = (schema) => {
432
+ return Object.keys(schema.fields).length;
433
+ };
434
+ /**
435
+ * Calculates how many fields are completed (valid) vs total fields.
436
+ *
437
+ * @param schema - Effect Schema to validate against
438
+ * @param data - Data to validate
439
+ * @returns Object with fieldsCompleted and totalFields
440
+ */
441
+ const calculateFieldCompletion = (schema, data) => {
442
+ const totalFields = countTotalFields(schema);
443
+ return {
444
+ fieldsCompleted: totalFields - countInvalidFields(schema, data),
445
+ totalFields
446
+ };
447
+ };
448
+ //#endregion
449
+ //#region ../form-schema/src/lib/phone.ts
450
+ /**
451
+ * Validates a phone number using practical rules:
452
+ * - Must contain only digits, spaces, dashes, parentheses, and plus sign
453
+ * - Must have between 7 and 15 digits (ITU E.164 standard)
454
+ * - Plus sign (country code prefix) can only appear at the start
455
+ *
456
+ * This is more practical than isMobilePhone which has locale-specific
457
+ * rules that reject valid numbers.
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * import { PhoneField } from "processfocus/form-schema"
462
+ *
463
+ * const form = Schema.Struct({
464
+ * contactPhone: PhoneField(),
465
+ * })
466
+ * ```
467
+ */
468
+ const VALID_PHONE_CHARS = /^\+?[\d\s\-()]+$/;
469
+ const countDigits = (s) => {
470
+ return (s.match(/\d/g) || []).length;
471
+ };
472
+ const isPhoneNumber = (s) => {
473
+ if (!VALID_PHONE_CHARS.test(s)) return false;
474
+ const digitCount = countDigits(s);
475
+ return digitCount >= 7 && digitCount <= 15;
476
+ };
477
+ const Phone = Schema.Trim.pipe(Schema.filter((s) => isPhoneNumber(s), { message: () => "must be a valid phone number (7-15 digits)" }), Schema.annotations({
478
+ identifier: "Phone",
479
+ title: "Phone number",
480
+ description: "A valid phone number",
481
+ jsonSchema: { format: "phone" },
482
+ [FormPhoneInput]: true
483
+ }));
484
+ const PhoneField = (options) => applyFieldAnnotations(Phone, {
485
+ autoComplete: options?.autoComplete ?? "tel",
486
+ ...options
487
+ });
488
+ //#endregion
489
+ //#region ../form-schema/src/lib/property-signature.ts
490
+ /** Map field schemas while retaining Effect's property-level decoding contract. */
491
+ const mapFormPropertySignature = (field, map, mapAnnotations = (annotations) => annotations) => {
492
+ const signature = field.ast;
493
+ if (signature._tag === "PropertySignatureDeclaration") return Schema.makePropertySignature(new Schema.PropertySignatureDeclaration(map(signature.type, "input"), signature.isOptional, signature.isReadonly, mapAnnotations(signature.annotations, signature.type, "input"), signature.defaultValue));
494
+ const { from, to } = signature;
495
+ return Schema.makePropertySignature(new Schema.PropertySignatureTransformation(new Schema.FromPropertySignature(map(from.type, "input"), from.isOptional, from.isReadonly, mapAnnotations(from.annotations, from.type, "input"), from.fromKey), new Schema.ToPropertySignature(map(to.type, "output"), to.isOptional, to.isReadonly, mapAnnotations(to.annotations, from.type, "output"), to.defaultValue), signature.decode, signature.encode));
496
+ };
497
+ //#endregion
498
+ export { Wrapper as $, LINK_URL_SYMBOL as A, RadioField as B, FLATTEN_SYMBOL as C, FormRequired as Ct, LINK_COLOR_SYMBOL as D, FormTextAreaInput as Dt, Image as E, FormTableInput as Et, METRIC_BREAKDOWN_SYMBOL as F, SuggestionField as G, STRUCTURAL_ONLY_SYMBOL as H, MetricBreakdown as I, TableField as J, TEXTBLOCK_CONTENT_SYMBOL as K, NumberField as L, LinkButton as M, ListField as N, LINK_DISPLAY_SYMBOL as O, LookupField as P, TextFieldFrom as Q, NumberFieldFrom as R, DynamicTextBlock as S, FormReadOnly as St, HttpsUrlField as T, FormSuggestionInput as Tt, STRUCTURAL_TYPE_SYMBOL as U, ReadOnly as V, StructuralOnly as W, TextBlock as X, TextArea as Y, TextField as Z, BooleanField as _, FormNumberInput as _t, countInvalidFields as a, FormAutoComplete as at, DateField as b, FormProviderUserInput as bt, EmailField as c, FormDateInput as ct, isDeferredValue as d, FormEmailInput as dt, applyFieldAnnotations as et, fieldAnnotation as f, FormFileInput as ft, isReadOnlyField as g, FormMessage as gt, hasStructuralOnlyAnnotation as h, FormLookupInput as ht, calculateFieldCompletion as i, isMetricBreakdownOptions as it, Link as j, LINK_TEXT_SYMBOL as k, DeferredValueTypeId as l, FormDefault as lt, hasFlattenAnnotation as m, FormListInput as mt, Phone as n, isHttpsUrl as nt, countTotalFields as o, FormCalendarSlotInput as ot, fieldInputAst as p, FormLabel as pt, TEXTBLOCK_DYNAMIC_CONTENT_SYMBOL as q, PhoneField as r, isListFieldMetadata as rt, Email as s, FormComponentPluginType as st, mapFormPropertySignature as t, isFieldPermissionMetadata as tt, FormDeferredContent as u, FormDescription as ut, CalendarSlotField as v, FormPermission as vt, FileField as w, FormStaticText as wt, Divider as x, FormRadioInput as xt, CurrentProviderUser as y, FormPhoneInput as yt, ProviderUserField as z };
@@ -0,0 +1,9 @@
1
+ export * from "./form-rule/src/index.js";
2
+ export declare const validateOrganisation: (organisation: {
3
+ readonly processes: () => ReadonlyArray<{
4
+ readonly node: {
5
+ readonly path: string;
6
+ };
7
+ validateFlows(): Readonly<Record<string, readonly string[]>>;
8
+ }>;
9
+ }) => readonly string[];
@@ -0,0 +1,5 @@
1
+ import { n as formRuleReferencesFieldNames, r as evaluateFormRules, t as formRuleConditionPaths } from "./paths-BkzLn-rG.mjs";
2
+ //#region src/testing.ts
3
+ const validateOrganisation = (organisation) => organisation.processes().flatMap((process) => Object.values(process.validateFlows()).flat().map((message) => `${process.node.path}: ${message}`));
4
+ //#endregion
5
+ export { evaluateFormRules, formRuleConditionPaths, formRuleReferencesFieldNames, validateOrganisation };
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "processfocus",
3
+ "version": "0.1.0-next.0",
4
+ "type": "module",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/processfocus/processfocus.git",
9
+ "directory": "packages/sdk"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE.md"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.mjs"
20
+ },
21
+ "./auth": {
22
+ "types": "./dist/auth.d.ts",
23
+ "import": "./dist/auth.mjs"
24
+ },
25
+ "./calendar": {
26
+ "types": "./dist/calendar.d.ts",
27
+ "import": "./dist/calendar.mjs"
28
+ },
29
+ "./forms": {
30
+ "types": "./dist/forms.d.ts",
31
+ "import": "./dist/forms.mjs"
32
+ },
33
+ "./manifest": {
34
+ "types": "./dist/manifest.d.ts",
35
+ "import": "./dist/manifest.mjs"
36
+ },
37
+ "./plugin": {
38
+ "types": "./dist/plugin.d.ts",
39
+ "import": "./dist/plugin.mjs"
40
+ },
41
+ "./testing": {
42
+ "types": "./dist/testing.d.ts",
43
+ "import": "./dist/testing.mjs"
44
+ },
45
+ "./package.json": "./package.json"
46
+ },
47
+ "dependencies": {
48
+ "@processfocus/runtime": "0.1.0-next.0",
49
+ "constructs": "^10.8.1",
50
+ "effect": "^3.22.2",
51
+ "graphology": "^0.26.0",
52
+ "validator": "^13.15.35"
53
+ },
54
+ "peerDependencies": {
55
+ "react": "^19.3.0"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public",
59
+ "tag": "next"
60
+ },
61
+ "nx": {
62
+ "tags": [
63
+ "visibility:public-source",
64
+ "distribution:publishable"
65
+ ]
66
+ }
67
+ }