@nextlyhq/plugin-form-builder 0.0.2-alpha.74 → 0.0.2-alpha.76

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as HiddenFormField, B as UrlFormField, C as FormHookContext, D as FormNotifications, E as FormNotificationItem, F as SelectFormField, G as isFormField, H as isCheckboxFormField, I as SubmissionDocument, J as isSelectFormField, K as isFormFieldType, L as TextFormField, M as PhoneFormField, N as RadioFormField, O as FormSettings, P as ResolvedFormBuilderConfig, R as TextareaFormField, S as FormFieldTypeId, T as FormNotification, U as isEmailFormField, V as ValidationRules, W as isFileFormField, Y as isTextFormField, _ as FormBuilderPluginOptions, a as BUILT_IN_FORM_FIELD_TYPES, b as FormField, c as ConditionalLogic, d as DateFormField, f as EmailConfig, g as FormAccess, h as FileFormField, i as AnyFormField, j as NumberFormField, k as FormSubmission, l as ConditionalLogicCondition, m as FieldBlockConfig, n as NewSubmissionRow, o as BaseFormField, p as EmailFormField, q as isKnownFormField, r as NewSubmissionsData, s as CheckboxFormField, t as NEW_SUBMISSIONS_WIDGET_ID, u as CustomFormField, v as FormConfig, w as FormHooks, x as FormFieldType, y as FormDocument, z as TimeFormField } from "./new-submissions-CzlhVGhH.js";
1
+ import { A as NumberFormField, B as ValidationRules, C as FormHooks, D as FormSettings, E as FormNotifications, F as SubmissionDocument, G as isFormFieldType, H as isEmailFormField, I as TextFormField, J as isTextFormField, K as isKnownFormField, L as TextareaFormField, M as RadioFormField, N as ResolvedFormBuilderConfig, O as FormSubmission, P as SelectFormField, R as TimeFormField, S as FormHookContext, T as FormNotificationItem, U as isFileFormField, V as isCheckboxFormField, W as isFormField, X as NewSubmissionRow, Y as NEW_SUBMISSIONS_WIDGET_ID, Z as NewSubmissionsData, _ as FormConfig, a as ConditionalLogic, b as FormFieldType, c as ConsentFormField, d as EmailConfig, f as EmailFormField, g as FormBuilderPluginOptions, h as FormAccess, i as CheckboxFormField, j as PhoneFormField, k as HiddenFormField, l as CustomFormField, m as FileFormField, n as BUILT_IN_FORM_FIELD_TYPES, o as ConditionalLogicCondition, p as FieldBlockConfig, q as isSelectFormField, r as BaseFormField, s as ConsentAnswer, t as AnyFormField, u as DateFormField, v as FormDocument, w as FormNotification, x as FormFieldTypeId, y as FormField, z as UrlFormField } from "./types-XdBrUfi1.js";
2
2
  import { PluginDefinition } from "@nextlyhq/plugin-sdk";
3
3
  import { CollectionConfig, PluginContext } from "nextly";
4
4
  import { z } from "zod";
@@ -47,7 +47,7 @@ export declare function getFormBuilderConfig(nextly: unknown): ResolvedFormBuild
47
47
  * Error codes for form validation failures.
48
48
  * Used for programmatic error handling.
49
49
  */
50
- type FormValidationErrorCode = "SLUG_REQUIRED" | "SLUG_INVALID_TYPE" | "SLUG_TOO_SHORT" | "SLUG_TOO_LONG" | "SLUG_INVALID_FORMAT" | "SLUG_RESERVED" | "FIELDS_REQUIRED" | "FIELDS_INVALID_TYPE" | "FIELDS_EMPTY" | "FIELD_NAME_REQUIRED" | "FIELD_NAME_INVALID_FORMAT" | "FIELD_NAME_DUPLICATE" | "FIELD_TYPE_REQUIRED" | "FIELD_TYPE_INVALID" | "FIELD_LABEL_REQUIRED" | "OPTIONS_REQUIRED" | "OPTIONS_EMPTY" | "MIN_GREATER_THAN_MAX" | "MIN_LENGTH_GREATER_THAN_MAX" | "FILE_MAX_SIZE_INVALID" | "CONDITIONS_REQUIRED" | "CONDITION_FIELD_REQUIRED" | "CONDITION_COMPARISON_REQUIRED" | "SETTINGS_INVALID_TYPE" | "REDIRECT_URL_REQUIRED" | "REDIRECT_PAGE_REQUIRED" | "ACCESS_INVALID_TYPE" | "ACCESS_FUNCTION_INVALID";
50
+ type FormValidationErrorCode = "SLUG_REQUIRED" | "SLUG_INVALID_TYPE" | "SLUG_TOO_SHORT" | "SLUG_TOO_LONG" | "SLUG_INVALID_FORMAT" | "SLUG_RESERVED" | "FIELDS_REQUIRED" | "FIELDS_INVALID_TYPE" | "FIELDS_EMPTY" | "FIELD_NAME_REQUIRED" | "FIELD_NAME_INVALID_FORMAT" | "FIELD_NAME_DUPLICATE" | "FIELD_TYPE_REQUIRED" | "FIELD_TYPE_INVALID" | "FIELD_LABEL_REQUIRED" | "OPTIONS_REQUIRED" | "OPTIONS_EMPTY" | "MIN_GREATER_THAN_MAX" | "MIN_LENGTH_GREATER_THAN_MAX" | "FILE_MAX_SIZE_INVALID" | "CONSENT_TEXT_REQUIRED" | "CONDITIONS_REQUIRED" | "CONDITION_FIELD_REQUIRED" | "CONDITION_COMPARISON_REQUIRED" | "SETTINGS_INVALID_TYPE" | "REDIRECT_URL_REQUIRED" | "REDIRECT_PAGE_REQUIRED" | "ACCESS_INVALID_TYPE" | "ACCESS_FUNCTION_INVALID";
51
51
  /**
52
52
  * A single validation error with path and context.
53
53
  *
@@ -152,7 +152,7 @@ export declare function assertValidFormConfig(config: FormConfig): void;
152
152
  /**
153
153
  * Default form settings.
154
154
  */
155
- export declare const DEFAULT_FORM_SETTINGS: Required<Pick<FormSettings, "submitButtonText" | "confirmationType" | "successMessage" | "allowMultipleSubmissions">>;
155
+ export declare const DEFAULT_FORM_SETTINGS: Required<Pick<FormSettings, "submitButtonText" | "confirmationType" | "successMessage" | "allowMultipleSubmissions" | "oneResponse" | "oneResponseVersion" | "botCheck" | "storeIpAndBrowser">>;
156
156
  /**
157
157
  * Default notification settings.
158
158
  */
@@ -649,6 +649,27 @@ export declare const time: (config: Omit<TimeFormField, "type">) => TimeFormFiel
649
649
  * ```
650
650
  */
651
651
  export declare const hidden: (config: Omit<HiddenFormField, "type">) => HiddenFormField;
652
+ /**
653
+ * Creates a consent field configuration.
654
+ *
655
+ * A box the visitor ticks to agree to `agreementText`. It is always required,
656
+ * and the stored answer keeps the text the visitor was shown, so a later
657
+ * change to the text leaves what earlier visitors agreed to as it was. Staff
658
+ * can never edit a submitted consent.
659
+ *
660
+ * @param config - Field configuration without the `type` property
661
+ * @returns Complete consent field configuration
662
+ *
663
+ * @example
664
+ * ```typescript
665
+ * consent({
666
+ * name: 'privacy',
667
+ * label: 'Privacy',
668
+ * agreementText: 'I agree to the privacy policy',
669
+ * })
670
+ * ```
671
+ */
672
+ export declare const consent: (config: Omit<ConsentFormField, "type" | "required">) => ConsentFormField;
652
673
  /**
653
674
  * Comparison operators supported by the conditional logic system.
654
675
  */
@@ -887,12 +908,15 @@ interface ExportedJSON {
887
908
  * formatExportValue(new Date(), { type: 'date' }); // "2024-01-15"
888
909
  * ```
889
910
  */
890
- export declare function formatExportValue(value: unknown, field?: AnyFormField): string;
911
+ export declare function formatExportValue(value: unknown, field?: {
912
+ readonly type: string;
913
+ }): string;
891
914
  /**
892
915
  * Export submissions to CSV format.
893
916
  *
894
917
  * Generates an RFC 4180 compliant CSV string with:
895
- * - Form field values as columns (in form definition order)
918
+ * - Form field values as columns (in form definition order), headed by the
919
+ * fields' labels, a choice answer by its option's label
896
920
  * - Optional metadata columns at the end (_id, _status, _submittedAt, etc.)
897
921
  * - Proper escaping of special characters
898
922
  * - Optional UTF-8 BOM for Excel compatibility
@@ -1011,6 +1035,12 @@ interface SubmitFormOptions {
1011
1035
  ipAddress?: string;
1012
1036
  /** Submitter's user agent string */
1013
1037
  userAgent?: string;
1038
+ /**
1039
+ * The page it was sent from, such as the request's `Referer`. Kept as
1040
+ * its origin and path only, and only when it is a web page
1041
+ * (`pageFromReferer`).
1042
+ */
1043
+ page?: string;
1014
1044
  };
1015
1045
  /**
1016
1046
  * The HTTP request this submission arrived on.
@@ -1255,7 +1285,11 @@ interface SpamCheckConfig {
1255
1285
  windowMs: number;
1256
1286
  };
1257
1287
  /**
1258
- * reCAPTCHA configuration (for future implementation).
1288
+ * Not read here: a form's bot check (reCAPTCHA or Turnstile) is verified
1289
+ * with its provider where the submission is stored, from the plugin's
1290
+ * `spamProtection` options. Kept so a caller passing it still type-checks.
1291
+ *
1292
+ * @deprecated Configure bot checks in the plugin's `spamProtection` options.
1259
1293
  */
1260
1294
  recaptcha?: {
1261
1295
  enabled: boolean;
@@ -1283,7 +1317,7 @@ interface SpamCheckResult {
1283
1317
  /** Whether the submission is detected as spam */
1284
1318
  isSpam: boolean;
1285
1319
  /** Reason for spam detection (for logging, not exposed to user) */
1286
- reason?: "honeypot" | "rate_limit" | "recaptcha";
1320
+ reason?: "honeypot" | "rate_limit" | "recaptcha" | "turnstile";
1287
1321
  /** Additional details (for logging) */
1288
1322
  details?: string;
1289
1323
  }
@@ -1293,7 +1327,9 @@ interface SpamCheckResult {
1293
1327
  * Performs multiple spam checks based on configuration:
1294
1328
  * 1. Honeypot field detection
1295
1329
  * 2. Rate limiting by IP/form
1296
- * 3. reCAPTCHA verification (future)
1330
+ *
1331
+ * A form's bot check (reCAPTCHA or Turnstile) is verified with its provider
1332
+ * where the submission is stored (`handlers/bot-check`), not here.
1297
1333
  *
1298
1334
  * @param options - Spam check options
1299
1335
  * @returns Spam check result
@@ -1385,5 +1421,5 @@ interface ExtendedCollectionConfig extends Omit<CollectionConfig, "admin"> {
1385
1421
  */
1386
1422
  export declare function submissionsCollection(pluginConfig: ResolvedFormBuilderConfig): ExtendedCollectionConfig;
1387
1423
  export declare const formBuilderPlugin: ReturnType<typeof formBuilder>["plugin"];
1388
- export { type AnyFormField, BUILT_IN_FORM_FIELD_TYPES, type BaseFormField, type CSVExportOptions, type CheckboxFormField, type ComparisonOperator, type ConditionalLogic, type ConditionalLogicCondition, type CustomFormField, type DateFormField, type EmailConfig, type EmailFormField, type ExportedJSON, type FieldBlockConfig, type FileFormField, type FormAccess, type FormBuilderPluginOptions, type FormBuilderPluginResult, type FormConfig, type FormDocument, type FormField, type FormFieldOption, type FormFieldType, type FormFieldTypeId, type FormHookContext, type FormHooks, type FormNotification, type FormNotificationItem, type FormNotifications, type FormSettings, type FormSubmission, type FormValidationError, type FormValidationErrorCode, type FormValidationResult, type HiddenFormField, type JSONExportOptions, NEW_SUBMISSIONS_WIDGET_ID, type NewSubmissionRow, type NewSubmissionsData, type NextlyPlugin, type NumberFormField, type PhoneFormField, type RadioFormField, type ResolvedFormBuilderConfig, type SelectFormField, type SpamCheckConfig, type SpamCheckOptions, type SpamCheckResult, type SubmissionDocument, type SubmitFormContext, type SubmitFormOptions, type SubmitFormResult, type TextFormField, type TextareaFormField, type TimeFormField, type UrlFormField, type ValidationRules, isCheckboxFormField, isEmailFormField, isFileFormField, isFormField, isFormFieldType, isKnownFormField, isSelectFormField, isTextFormField };
1424
+ export { type AnyFormField, BUILT_IN_FORM_FIELD_TYPES, type BaseFormField, type CSVExportOptions, type CheckboxFormField, type ComparisonOperator, type ConditionalLogic, type ConditionalLogicCondition, type ConsentAnswer, type ConsentFormField, type CustomFormField, type DateFormField, type EmailConfig, type EmailFormField, type ExportedJSON, type FieldBlockConfig, type FileFormField, type FormAccess, type FormBuilderPluginOptions, type FormBuilderPluginResult, type FormConfig, type FormDocument, type FormField, type FormFieldOption, type FormFieldType, type FormFieldTypeId, type FormHookContext, type FormHooks, type FormNotification, type FormNotificationItem, type FormNotifications, type FormSettings, type FormSubmission, type FormValidationError, type FormValidationErrorCode, type FormValidationResult, type HiddenFormField, type JSONExportOptions, NEW_SUBMISSIONS_WIDGET_ID, type NewSubmissionRow, type NewSubmissionsData, type NextlyPlugin, type NumberFormField, type PhoneFormField, type RadioFormField, type ResolvedFormBuilderConfig, type SelectFormField, type SpamCheckConfig, type SpamCheckOptions, type SpamCheckResult, type SubmissionDocument, type SubmitFormContext, type SubmitFormOptions, type SubmitFormResult, type TextFormField, type TextareaFormField, type TimeFormField, type UrlFormField, type ValidationRules, isCheckboxFormField, isEmailFormField, isFileFormField, isFormField, isFormFieldType, isKnownFormField, isSelectFormField, isTextFormField };
1389
1425
  //# sourceMappingURL=index.d.ts.map