@10x-media/form-builder 0.1.0-beta.4 → 0.1.0-beta.6
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/CHANGELOG.md +112 -0
- package/README.md +3 -3
- package/dist/actions/body/serializeBody.d.ts +8 -5
- package/dist/actions/body/serializeBody.js.map +1 -1
- package/dist/actions/body/textOfBody.d.ts +13 -0
- package/dist/actions/body/textOfBody.js +35 -0
- package/dist/actions/body/textOfBody.js.map +1 -0
- package/dist/actions/builtin/confirmation.js +81 -48
- package/dist/actions/builtin/confirmation.js.map +1 -1
- package/dist/actions/builtin/emailTeam.js +67 -38
- package/dist/actions/builtin/emailTeam.js.map +1 -1
- package/dist/actions/builtin/index.d.ts +9 -3
- package/dist/actions/builtin/index.js +8 -5
- package/dist/actions/builtin/index.js.map +1 -1
- package/dist/actions/defineAction.d.ts +1 -1
- package/dist/actions/emailRecipients.d.ts +12 -0
- package/dist/actions/emailRecipients.js +72 -0
- package/dist/actions/emailRecipients.js.map +1 -0
- package/dist/actions/fromAddresses.d.ts +21 -0
- package/dist/actions/fromAddresses.js +74 -0
- package/dist/actions/fromAddresses.js.map +1 -0
- package/dist/actions/task.js +9 -8
- package/dist/actions/task.js.map +1 -1
- package/dist/aggregation/aggregateResponses.d.ts +9 -0
- package/dist/aggregation/aggregateResponses.js +8 -14
- package/dist/aggregation/aggregateResponses.js.map +1 -1
- package/dist/aggregation/resolveResultsRequest.d.ts +19 -6
- package/dist/aggregation/resolveResultsRequest.js +58 -12
- package/dist/aggregation/resolveResultsRequest.js.map +1 -1
- package/dist/calc/computeCalcFields.js +2 -1
- package/dist/calc/computeCalcFields.js.map +1 -1
- package/dist/client/ByteSizeField.d.ts +8 -0
- package/dist/client/ByteSizeField.js +3 -1
- package/dist/client/ByteSizeField.js.map +1 -1
- package/dist/client/ClosePollButton.d.ts +15 -0
- package/dist/client/ClosePollButton.js +80 -0
- package/dist/client/ClosePollButton.js.map +1 -0
- package/dist/client/CondensedArray.d.ts +15 -0
- package/dist/client/CondensedArray.js +97 -0
- package/dist/client/CondensedArray.js.map +1 -0
- package/dist/client/ConsentBlockLabel.d.ts +15 -0
- package/dist/client/ConsentBlockLabel.js +71 -0
- package/dist/client/ConsentBlockLabel.js.map +1 -0
- package/dist/client/ConsentSourceRowLabel.d.ts +9 -0
- package/dist/client/ConsentSourceRowLabel.js +21 -0
- package/dist/client/ConsentSourceRowLabel.js.map +1 -0
- package/dist/client/EndpointOptionsSelect.d.ts +46 -0
- package/dist/client/EndpointOptionsSelect.js +106 -0
- package/dist/client/EndpointOptionsSelect.js.map +1 -0
- package/dist/client/FieldBlockLabel.d.ts +18 -0
- package/dist/client/FieldBlockLabel.js +34 -0
- package/dist/client/FieldBlockLabel.js.map +1 -0
- package/dist/client/FieldNameSelect.d.ts +21 -4
- package/dist/client/FieldNameSelect.js +29 -15
- package/dist/client/FieldNameSelect.js.map +1 -1
- package/dist/client/FlowBuilder.d.ts +2 -1
- package/dist/client/FlowBuilder.js +63 -57
- package/dist/client/FlowBuilder.js.map +1 -1
- package/dist/client/RecipientsSelect.d.ts +31 -0
- package/dist/client/RecipientsSelect.js +174 -0
- package/dist/client/RecipientsSelect.js.map +1 -0
- package/dist/client/RuleDescription.d.ts +21 -0
- package/dist/client/RuleDescription.js +19 -0
- package/dist/client/RuleDescription.js.map +1 -0
- package/dist/client/admin.css +41 -0
- package/dist/client/endpointOptions.js +29 -0
- package/dist/client/endpointOptions.js.map +1 -0
- package/dist/client/flowAuthoring.js +114 -7
- package/dist/client/flowAuthoring.js.map +1 -1
- package/dist/client/synthesizeClientField.js +15 -8
- package/dist/client/synthesizeClientField.js.map +1 -1
- package/dist/collections/buttonFields.d.ts +34 -0
- package/dist/collections/buttonFields.js +35 -0
- package/dist/collections/buttonFields.js.map +1 -0
- package/dist/collections/cells/FieldCountCell.d.ts +15 -0
- package/dist/collections/cells/FieldCountCell.js +18 -0
- package/dist/collections/cells/FieldCountCell.js.map +1 -0
- package/dist/collections/cells/FlowStepsCell.d.ts +14 -0
- package/dist/collections/cells/FlowStepsCell.js +17 -0
- package/dist/collections/cells/FlowStepsCell.js.map +1 -0
- package/dist/collections/formSubmissions.js +23 -17
- package/dist/collections/formSubmissions.js.map +1 -1
- package/dist/collections/forms.js +323 -134
- package/dist/collections/forms.js.map +1 -1
- package/dist/collections/redirectFields.d.ts +29 -0
- package/dist/consent/applyConsentStatements.d.ts +14 -0
- package/dist/consent/applyConsentStatements.js +17 -0
- package/dist/consent/applyConsentStatements.js.map +1 -0
- package/dist/consent/captureConsent.d.ts +31 -11
- package/dist/consent/captureConsent.js +53 -13
- package/dist/consent/captureConsent.js.map +1 -1
- package/dist/consent/consentSourcesField.d.ts +62 -0
- package/dist/consent/consentSourcesField.js +86 -0
- package/dist/consent/consentSourcesField.js.map +1 -0
- package/dist/consent/resolveConsentEntries.d.ts +24 -0
- package/dist/consent/resolveConsentEntries.js +43 -0
- package/dist/consent/resolveConsentEntries.js.map +1 -0
- package/dist/consent/resolveConsentSourcesRequest.d.ts +37 -0
- package/dist/consent/resolveConsentSourcesRequest.js +55 -0
- package/dist/consent/resolveConsentSourcesRequest.js.map +1 -0
- package/dist/consent/resolveConsentStatements.d.ts +45 -0
- package/dist/consent/resolveConsentStatements.js +44 -0
- package/dist/consent/resolveConsentStatements.js.map +1 -0
- package/dist/consent/resolvePublishedVersionRef.d.ts +17 -11
- package/dist/consent/resolvePublishedVersionRef.js +13 -10
- package/dist/consent/resolvePublishedVersionRef.js.map +1 -1
- package/dist/consent/types.d.ts +53 -0
- package/dist/email/departments.d.ts +59 -0
- package/dist/email/departments.js +87 -0
- package/dist/email/departments.js.map +1 -0
- package/dist/email/departmentsField.d.ts +53 -0
- package/dist/email/departmentsField.js +73 -0
- package/dist/email/departmentsField.js.map +1 -0
- package/dist/exports/client.d.ts +11 -1
- package/dist/exports/client.js +11 -1
- package/dist/exports/react.d.ts +8 -3
- package/dist/exports/react.js +6 -2
- package/dist/exports/rsc.d.ts +3 -1
- package/dist/exports/rsc.js +4 -2
- package/dist/exports/types.d.ts +16 -8
- package/dist/fields/buildFieldBlocks.js +28 -13
- package/dist/fields/buildFieldBlocks.js.map +1 -1
- package/dist/fields/builtin/calculation.js +7 -0
- package/dist/fields/builtin/calculation.js.map +1 -1
- package/dist/fields/builtin/checkbox.js +8 -0
- package/dist/fields/builtin/checkbox.js.map +1 -1
- package/dist/fields/builtin/consent.js +32 -21
- package/dist/fields/builtin/consent.js.map +1 -1
- package/dist/fields/builtin/country.d.ts +13 -0
- package/dist/fields/builtin/country.js +30 -0
- package/dist/fields/builtin/country.js.map +1 -0
- package/dist/fields/builtin/date.js +2 -0
- package/dist/fields/builtin/date.js.map +1 -1
- package/dist/fields/builtin/file.js +14 -7
- package/dist/fields/builtin/file.js.map +1 -1
- package/dist/fields/builtin/index.d.ts +8 -6
- package/dist/fields/builtin/index.js +12 -11
- package/dist/fields/builtin/index.js.map +1 -1
- package/dist/fields/builtin/message.js +8 -4
- package/dist/fields/builtin/message.js.map +1 -1
- package/dist/fields/builtin/repeater.js +1 -0
- package/dist/fields/builtin/repeater.js.map +1 -1
- package/dist/fields/builtin/select.js +1 -0
- package/dist/fields/builtin/select.js.map +1 -1
- package/dist/fields/builtin/state.d.ts +13 -0
- package/dist/fields/builtin/state.js +30 -0
- package/dist/fields/builtin/state.js.map +1 -0
- package/dist/fields/data/regions.d.ts +21 -0
- package/dist/fields/data/regions.js +1238 -0
- package/dist/fields/data/regions.js.map +1 -0
- package/dist/fields/fieldKey.d.ts +15 -0
- package/dist/fields/fieldKey.js +16 -0
- package/dist/fields/fieldKey.js.map +1 -0
- package/dist/fields/fieldNamesOfType.js +13 -8
- package/dist/fields/fieldNamesOfType.js.map +1 -1
- package/dist/fields/instanceOptions.js +20 -0
- package/dist/fields/instanceOptions.js.map +1 -0
- package/dist/fields/registry.d.ts +1 -0
- package/dist/fields/registry.js +21 -2
- package/dist/fields/registry.js.map +1 -1
- package/dist/fields/sharedConfig.js +46 -9
- package/dist/fields/sharedConfig.js.map +1 -1
- package/dist/fields/types.d.ts +63 -5
- package/dist/flow/engine.d.ts +6 -4
- package/dist/flow/engine.js +11 -6
- package/dist/flow/engine.js.map +1 -1
- package/dist/flow/normalizeFlow.js +16 -7
- package/dist/flow/normalizeFlow.js.map +1 -1
- package/dist/flow/types.d.ts +12 -3
- package/dist/flow/types.js +11 -0
- package/dist/flow/types.js.map +1 -0
- package/dist/form/pollState.d.ts +4 -4
- package/dist/form/pollState.js.map +1 -1
- package/dist/form/toFormDocument.d.ts +54 -12
- package/dist/form/toFormDocument.js +56 -8
- package/dist/form/toFormDocument.js.map +1 -1
- package/dist/form/types.d.ts +31 -14
- package/dist/index.d.ts +153 -29
- package/dist/index.js +47 -15
- package/dist/index.js.map +1 -1
- package/dist/plugin/customState.js +26 -0
- package/dist/plugin/customState.js.map +1 -0
- package/dist/plugin/registerCollections.js +24 -13
- package/dist/plugin/registerCollections.js.map +1 -1
- package/dist/plugin/uploadsCollection.d.ts +5 -0
- package/dist/plugin/uploadsCollection.js +10 -1
- package/dist/plugin/uploadsCollection.js.map +1 -1
- package/dist/poll/applyPollOptions.js +3 -2
- package/dist/poll/applyPollOptions.js.map +1 -1
- package/dist/poll/buildPollOptionSourceFields.js +2 -5
- package/dist/poll/buildPollOptionSourceFields.js.map +1 -1
- package/dist/poll/closeJob.d.ts +52 -0
- package/dist/poll/closeJob.js +119 -0
- package/dist/poll/closeJob.js.map +1 -0
- package/dist/poll/definePollOptionSource.d.ts +10 -1
- package/dist/poll/definePollOptionSource.js.map +1 -1
- package/dist/poll/definePollType.d.ts +34 -0
- package/dist/poll/definePollType.js +6 -0
- package/dist/poll/definePollType.js.map +1 -0
- package/dist/poll/effectivePollOptions.d.ts +38 -0
- package/dist/poll/effectivePollOptions.js +64 -0
- package/dist/poll/effectivePollOptions.js.map +1 -0
- package/dist/poll/mostVoted.d.ts +21 -0
- package/dist/poll/mostVoted.js +32 -0
- package/dist/poll/mostVoted.js.map +1 -0
- package/dist/poll/outcomeBeforeChange.js +91 -0
- package/dist/poll/outcomeBeforeChange.js.map +1 -0
- package/dist/poll/outcomeFields.d.ts +38 -0
- package/dist/poll/outcomeFields.js +52 -0
- package/dist/poll/outcomeFields.js.map +1 -0
- package/dist/poll/pollTypeRegistry.d.ts +34 -0
- package/dist/poll/pollTypeRegistry.js +71 -0
- package/dist/poll/pollTypeRegistry.js.map +1 -0
- package/dist/poll/resolvePollCloseRequest.js +105 -0
- package/dist/poll/resolvePollCloseRequest.js.map +1 -0
- package/dist/poll/resolvePollOptions.d.ts +2 -1
- package/dist/poll/resolvePollOptions.js +5 -17
- package/dist/poll/resolvePollOptions.js.map +1 -1
- package/dist/poll/resolvePollOptionsRequest.js +51 -0
- package/dist/poll/resolvePollOptionsRequest.js.map +1 -0
- package/dist/poll/resolvePollOutcome.d.ts +22 -9
- package/dist/poll/resolvePollOutcome.js +54 -14
- package/dist/poll/resolvePollOutcome.js.map +1 -1
- package/dist/poll/resultsField.js +21 -0
- package/dist/poll/resultsField.js.map +1 -0
- package/dist/prefill/valuesFromSearchParams.js +2 -1
- package/dist/prefill/valuesFromSearchParams.js.map +1 -1
- package/dist/react/Form.d.ts +8 -8
- package/dist/react/Form.js +74 -62
- package/dist/react/Form.js.map +1 -1
- package/dist/react/FormContext.d.ts +6 -4
- package/dist/react/FormContext.js.map +1 -1
- package/dist/react/FormControls.d.ts +3 -3
- package/dist/react/FormControls.js +3 -3
- package/dist/react/FormControls.js.map +1 -1
- package/dist/react/FormResults.d.ts +5 -5
- package/dist/react/FormResults.js +6 -6
- package/dist/react/FormResults.js.map +1 -1
- package/dist/react/Poll.d.ts +2 -2
- package/dist/react/Poll.js +5 -5
- package/dist/react/Poll.js.map +1 -1
- package/dist/react/contract.d.ts +2 -3
- package/dist/react/contract.js.map +1 -1
- package/dist/react/primitives/Checkbox.d.ts +4 -2
- package/dist/react/primitives/Checkbox.js +2 -1
- package/dist/react/primitives/Checkbox.js.map +1 -1
- package/dist/react/primitives/FieldShell.d.ts +2 -4
- package/dist/react/primitives/FieldShell.js +12 -19
- package/dist/react/primitives/FieldShell.js.map +1 -1
- package/dist/react/renderers/calculation.js +1 -2
- package/dist/react/renderers/calculation.js.map +1 -1
- package/dist/react/renderers/checkbox.js +1 -2
- package/dist/react/renderers/checkbox.js.map +1 -1
- package/dist/react/renderers/consent.js +78 -34
- package/dist/react/renderers/consent.js.map +1 -1
- package/dist/react/renderers/date.js +1 -3
- package/dist/react/renderers/date.js.map +1 -1
- package/dist/react/renderers/email.js +1 -2
- package/dist/react/renderers/email.js.map +1 -1
- package/dist/react/renderers/file.js +1 -2
- package/dist/react/renderers/file.js.map +1 -1
- package/dist/react/renderers/index.js +3 -0
- package/dist/react/renderers/index.js.map +1 -1
- package/dist/react/renderers/number.js +1 -2
- package/dist/react/renderers/number.js.map +1 -1
- package/dist/react/renderers/region.js +45 -0
- package/dist/react/renderers/region.js.map +1 -0
- package/dist/react/renderers/repeater.js +7 -10
- package/dist/react/renderers/repeater.js.map +1 -1
- package/dist/react/renderers/select.js +1 -2
- package/dist/react/renderers/select.js.map +1 -1
- package/dist/react/renderers/text.js +1 -2
- package/dist/react/renderers/text.js.map +1 -1
- package/dist/react/renderers/textarea.js +1 -2
- package/dist/react/renderers/textarea.js.map +1 -1
- package/dist/react/state.d.ts +0 -3
- package/dist/react/state.js +7 -11
- package/dist/react/state.js.map +1 -1
- package/dist/react/useField.d.ts +0 -1
- package/dist/react/useField.js +0 -1
- package/dist/react/useField.js.map +1 -1
- package/dist/react/useFormState.d.ts +1 -1
- package/dist/react/useFormState.js +1 -1
- package/dist/react/useFormState.js.map +1 -1
- package/dist/react/validateField.js +3 -6
- package/dist/react/validateField.js.map +1 -1
- package/dist/recall/interpolate.d.ts +4 -3
- package/dist/recall/interpolate.js +5 -4
- package/dist/recall/interpolate.js.map +1 -1
- package/dist/recall/resolver.d.ts +1 -1
- package/dist/recall/resolver.js +14 -2
- package/dist/recall/resolver.js.map +1 -1
- package/dist/spam/captcha.d.ts +1 -1
- package/dist/spam/captcha.js +1 -1
- package/dist/spam/captcha.js.map +1 -1
- package/dist/submissions/SubmissionAnswers.js +6 -2
- package/dist/submissions/SubmissionAnswers.js.map +1 -1
- package/dist/submissions/SubmissionAnswersClient.js +100 -64
- package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
- package/dist/submissions/createSubmission.d.ts +36 -0
- package/dist/submissions/createSubmission.js +26 -0
- package/dist/submissions/createSubmission.js.map +1 -0
- package/dist/submissions/runSubmission.d.ts +10 -0
- package/dist/submissions/runSubmission.js +31 -19
- package/dist/submissions/runSubmission.js.map +1 -1
- package/dist/submissions/types.d.ts +11 -4
- package/dist/submissions/validateSubmission.js +39 -23
- package/dist/submissions/validateSubmission.js.map +1 -1
- package/dist/submissions/votedCookie.js +3 -3
- package/dist/submissions/votedCookie.js.map +1 -1
- package/dist/translations/de.js +104 -26
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +105 -27
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/keys.d.ts +99 -21
- package/dist/translations/keys.js +100 -22
- package/dist/translations/keys.js.map +1 -1
- package/dist/uploads/resolveFileRef.js +2 -1
- package/dist/uploads/resolveFileRef.js.map +1 -1
- package/dist/validation/buildRuleBlocks.js +18 -17
- package/dist/validation/buildRuleBlocks.js.map +1 -1
- package/dist/validation/builtin/email.js +1 -0
- package/dist/validation/builtin/email.js.map +1 -1
- package/dist/validation/builtin/matchesField.js +3 -7
- package/dist/validation/builtin/matchesField.js.map +1 -1
- package/dist/validation/builtin/max.js +1 -0
- package/dist/validation/builtin/max.js.map +1 -1
- package/dist/validation/builtin/maxDate.js +1 -0
- package/dist/validation/builtin/maxDate.js.map +1 -1
- package/dist/validation/builtin/maxLength.js +1 -0
- package/dist/validation/builtin/maxLength.js.map +1 -1
- package/dist/validation/builtin/min.js +1 -0
- package/dist/validation/builtin/min.js.map +1 -1
- package/dist/validation/builtin/minDate.js +1 -0
- package/dist/validation/builtin/minDate.js.map +1 -1
- package/dist/validation/builtin/minLength.js +1 -0
- package/dist/validation/builtin/minLength.js.map +1 -1
- package/dist/validation/builtin/notAlreadySubmitted.js +1 -0
- package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -1
- package/dist/validation/builtin/oneOf.js +1 -0
- package/dist/validation/builtin/oneOf.js.map +1 -1
- package/dist/validation/builtin/pattern.js +11 -2
- package/dist/validation/builtin/pattern.js.map +1 -1
- package/dist/validation/builtin/url.js +1 -0
- package/dist/validation/builtin/url.js.map +1 -1
- package/dist/validation/builtin/validateRegexParams.js +44 -0
- package/dist/validation/builtin/validateRegexParams.js.map +1 -0
- package/dist/validation/fieldTargetParam.d.ts +22 -0
- package/dist/validation/fieldTargetParam.js +38 -0
- package/dist/validation/fieldTargetParam.js.map +1 -0
- package/dist/validation/runValidation.js +8 -29
- package/dist/validation/runValidation.js.map +1 -1
- package/dist/validation/types.d.ts +5 -11
- package/package.json +6 -6
- package/dist/consent/buildConsentSourceConfig.js +0 -49
- package/dist/consent/buildConsentSourceConfig.js.map +0 -1
- package/dist/consent/builtin/index.d.ts +0 -17
- package/dist/consent/builtin/index.js +0 -21
- package/dist/consent/builtin/index.js.map +0 -1
- package/dist/consent/builtin/pageReference.js +0 -75
- package/dist/consent/builtin/pageReference.js.map +0 -1
- package/dist/consent/builtin/static.js +0 -48
- package/dist/consent/builtin/static.js.map +0 -1
- package/dist/consent/defineConsentSource.d.ts +0 -35
- package/dist/consent/defineConsentSource.js +0 -6
- package/dist/consent/defineConsentSource.js.map +0 -1
- package/dist/consent/registry.d.ts +0 -16
- package/dist/consent/registry.js +0 -16
- package/dist/consent/registry.js.map +0 -1
- package/dist/consent/resolveConsentLinks.d.ts +0 -19
- package/dist/consent/resolveConsentLinks.js +0 -26
- package/dist/consent/resolveConsentLinks.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import { AnyPollOptionSource, PollOption, PollOptionResolveArgs, PollOptionSource, definePollOptionSource } from "./poll/definePollOptionSource.js";
|
|
1
2
|
import { FileFieldConfig, FileRef, FileRefError } from "./uploads/types.js";
|
|
2
|
-
import { AnyFormFieldDefinition, FormFieldDefinition, FormFieldFormat, FormFieldValidate, FormFieldValueKind } from "./fields/types.js";
|
|
3
|
+
import { AnyFormFieldDefinition, FormFieldDefinition, FormFieldFormat, FormFieldValidate, FormFieldValueKind, OmittableSharedField, ResolveFieldOptionsArgs } from "./fields/types.js";
|
|
3
4
|
import { TranslationsOption } from "./translations/index.js";
|
|
4
5
|
import { BodyConverter, BodyConverterArgs, BodyRender, defaultBodyConverters, sanitizeUrl } from "./actions/body/converters.js";
|
|
5
6
|
import { BodyContext, RichTextBodyOption, SerializeBodyArgs, serializeBody } from "./actions/body/serializeBody.js";
|
|
7
|
+
import { textOfBody } from "./actions/body/textOfBody.js";
|
|
6
8
|
import { AggregationBucket, AggregationRow, FieldAggregation, FieldMeta, SubmissionStatusFilter } from "./aggregation/types.js";
|
|
7
9
|
import { CalcExpression } from "./calc/types.js";
|
|
8
10
|
import { calcExpressionOf, computeCalcFields } from "./calc/computeCalcFields.js";
|
|
9
11
|
import { evaluateCalc } from "./calc/evaluate.js";
|
|
10
12
|
import { evaluateCondition } from "./conditions/evaluate.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
+
import { ConsentSourceEntry, ConsentSourcePage, ConsentSourcesResolver } from "./consent/types.js";
|
|
14
|
+
import { ConsentStatement, ConsentStatements, ResolveConsentStatementsArgs, resolveConsentStatements } from "./consent/resolveConsentStatements.js";
|
|
15
|
+
import { fieldKey } from "./fields/fieldKey.js";
|
|
16
|
+
import { FormButtonSettings, FormDocument, FormPollSettings, FormResponseSettings } from "./form/types.js";
|
|
13
17
|
import { ToFormDocumentOptions, toFormDocument } from "./form/toFormDocument.js";
|
|
14
18
|
import { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from "./fields/registry.js";
|
|
15
19
|
import { PrefillOptions, valuesFromSearchParams } from "./prefill/valuesFromSearchParams.js";
|
|
16
20
|
import { FormEventSink } from "./events/types.js";
|
|
17
|
-
import { AnyValidationRuleDefinition, ValidationRuleDefinition, ValidationRuleResult
|
|
21
|
+
import { AnyValidationRuleDefinition, ValidationRuleDefinition, ValidationRuleResult } from "./validation/types.js";
|
|
18
22
|
import { PresentationDensity, PresentationDescriptor, PresentationSurface } from "./presentations/types.js";
|
|
19
23
|
import { interpolate } from "./recall/interpolate.js";
|
|
20
24
|
import { RecallResolver, buildRecallResolver, optionLabelsFor } from "./recall/resolver.js";
|
|
@@ -22,21 +26,32 @@ import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "./spam/constants.js";
|
|
|
22
26
|
import { formatBytes } from "./uploads/formatBytes.js";
|
|
23
27
|
import { isPollClosed } from "./form/pollState.js";
|
|
24
28
|
import { PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig, resolvePollOptionSources } from "./poll/registry.js";
|
|
29
|
+
import { ResolveEffectivePollOptionsArgs, resolveEffectivePollOptions } from "./poll/effectivePollOptions.js";
|
|
25
30
|
import { ResolvePollOptionsArgs, resolvePollOptions } from "./poll/resolvePollOptions.js";
|
|
26
31
|
import { ResolvePollOutcomeArgs, resolvePollOutcome } from "./poll/resolvePollOutcome.js";
|
|
27
32
|
import { hasVotedCookie, votedCookieName } from "./submissions/votedCookie.js";
|
|
28
33
|
import { ActionDefinition, ActionRunArgs, AnyActionDefinition, defineAction } from "./actions/defineAction.js";
|
|
34
|
+
import { FromAddressOption, FromAddressesResolver } from "./actions/fromAddresses.js";
|
|
29
35
|
import { ActionOption, ActionRegistry, ActionsConfig, resolveActions } from "./actions/registry.js";
|
|
30
36
|
import { ActionResult } from "./actions/runActions.js";
|
|
31
37
|
import { AggregateFieldResponsesArgs, AggregateFormResponsesArgs, aggregateFieldResponses, aggregateFormResponses, fieldHasOptions } from "./aggregation/aggregateResponses.js";
|
|
32
38
|
import { FormResultsAccess, FormResultsAccessArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult, resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
|
|
39
|
+
import { ButtonFieldsOverride, ButtonsOption, DefaultButtonFields, buildDefaultButtonFields, buildNextLabelField, buildPrevLabelField, buildSubmitLabelField } from "./collections/buttonFields.js";
|
|
33
40
|
import { FieldCondition } from "./conditions/types.js";
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
41
|
+
import { ConsentProof, ConsentSnapshotMode, captureConsent } from "./consent/captureConsent.js";
|
|
42
|
+
import { ConsentSourcesFieldOptions, consentSourcesField } from "./consent/consentSourcesField.js";
|
|
43
|
+
import { ResolveConsentEntriesArgs, resolveConsentEntries } from "./consent/resolveConsentEntries.js";
|
|
44
|
+
import { ConsentSourceOption, ResolveConsentSourcesRequestArgs, ResolveConsentSourcesRequestResult, resolveConsentSourcesRequest } from "./consent/resolveConsentSourcesRequest.js";
|
|
45
|
+
import { ResolvePublishedVersionRefArgs, resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
|
|
46
|
+
import { RecipientsConfig } from "./actions/emailRecipients.js";
|
|
47
|
+
import { RedirectFieldsOverride, RedirectOption, ResponseOption } from "./collections/redirectFields.js";
|
|
48
|
+
import { DepartmentEmailsResolver, DepartmentOption, ResolveDepartmentOptionsArgs, ResolveDepartmentsRequestArgs, ResolveDepartmentsRequestResult, resolveDepartmentOptions } from "./email/departments.js";
|
|
37
49
|
import { CollectionOverrides } from "./plugin/collectionOverrides.js";
|
|
38
50
|
import { CaptchaProvider, CaptchaVerifyArgs, IdentifyFn, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, SpamConfig, SpamMetadataConfig, SpamOption } from "./spam/types.js";
|
|
39
51
|
import { UploadsOption } from "./plugin/uploadsCollection.js";
|
|
52
|
+
import { DefaultOutcomeFields, OutcomeFieldsOverride, buildDefaultOutcomeFields, buildResolvedAtField, buildWinningValuesField } from "./poll/outcomeFields.js";
|
|
53
|
+
import { PollOutcomeStrategy, PollOutcomeStrategyArgs, definePollType } from "./poll/definePollType.js";
|
|
54
|
+
import { PollTypeRegistry, PollTypesConfig, manualStrategy, pollTypesOf, resolvePollTypes, sourceStrategy, stashPollTypes } from "./poll/pollTypeRegistry.js";
|
|
40
55
|
import { ValidationRuleOption, ValidationRuleRegistry, ValidationRulesConfig } from "./validation/registry.js";
|
|
41
56
|
import { escapeHtml } from "./actions/body/escapeHtml.js";
|
|
42
57
|
import { renderAllValues, renderAllValuesTable } from "./actions/body/wildcards.js";
|
|
@@ -44,13 +59,16 @@ import { buildDefaultActionDefinitions, defaultActionDefinitions } from "./actio
|
|
|
44
59
|
import { SIGNATURE_HEADER, signPayload } from "./actions/sign.js";
|
|
45
60
|
import { aggregateRowForField, aggregateRowsForFields } from "./aggregation/aggregateRows.js";
|
|
46
61
|
import { normalizeCalc } from "./calc/normalizeCalc.js";
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
|
|
62
|
+
import { applyConsentStatements } from "./consent/applyConsentStatements.js";
|
|
63
|
+
import { DepartmentsFieldOptions, departmentsField } from "./email/departmentsField.js";
|
|
50
64
|
import { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
|
|
65
|
+
import { countryField } from "./fields/builtin/country.js";
|
|
51
66
|
import { fileMimeTypeOptions } from "./fields/builtin/file.js";
|
|
67
|
+
import { stateField } from "./fields/builtin/state.js";
|
|
52
68
|
import { defineFormField } from "./fields/defineFormField.js";
|
|
53
69
|
import { localizedIf } from "./fields/localizedIf.js";
|
|
70
|
+
import { POLL_CLOSE_TASK_SLUG, PollCloseTaskInput, buildPollCloseTask, enqueuePollClose, registerPollCloseTask, runPollClose, shouldAutoResolvePoll } from "./poll/closeJob.js";
|
|
71
|
+
import { mostVotedStrategy, topBucketValues } from "./poll/mostVoted.js";
|
|
54
72
|
import { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from "./presentations/defaults.js";
|
|
55
73
|
import { defineCaptchaProvider } from "./spam/captcha.js";
|
|
56
74
|
import { defaultIdentify } from "./spam/identify.js";
|
|
@@ -59,10 +77,13 @@ import { RecaptchaProviderOptions, recaptchaProvider } from "./spam/providers/re
|
|
|
59
77
|
import { TurnstileProviderOptions, turnstileProvider } from "./spam/providers/turnstile.js";
|
|
60
78
|
import { createKvRateLimiter } from "./spam/rateLimiter.js";
|
|
61
79
|
import { resolveSpamConfig } from "./spam/resolveSpam.js";
|
|
80
|
+
import { CreateSubmissionArgs, CreatedSubmission, createSubmission } from "./submissions/createSubmission.js";
|
|
62
81
|
import { resolveFileRef } from "./uploads/resolveFileRef.js";
|
|
63
82
|
import { captureFileRef } from "./uploads/captureFileRef.js";
|
|
64
83
|
import { defaultValidationRules, defaultValidationRulesByType } from "./validation/builtin/index.js";
|
|
65
84
|
import { defineValidationRule } from "./validation/defineValidationRule.js";
|
|
85
|
+
import { FieldTargetParamOptions, fieldTargetParam } from "./validation/fieldTargetParam.js";
|
|
86
|
+
import { CollectionSlug } from "payload";
|
|
66
87
|
|
|
67
88
|
//#region src/index.d.ts
|
|
68
89
|
type FormBuilderPluginOptions = {
|
|
@@ -76,29 +97,121 @@ type FormBuilderPluginOptions = {
|
|
|
76
97
|
translations?: TranslationsOption; /** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */
|
|
77
98
|
events?: FormEventSink;
|
|
78
99
|
/**
|
|
79
|
-
* Content-bearing author fields (labels, placeholders, option labels,
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
100
|
+
* Content-bearing author fields (labels, placeholders, option labels, action subjects and
|
|
101
|
+
* bodies) are localized by default. Payload strips the `localized` flag on hosts without
|
|
102
|
+
* `localization` configured, so the default is safe everywhere. Set `false` to keep form
|
|
103
|
+
* content single-locale even on localized hosts. Spread-overrides of the prebuilt default
|
|
104
|
+
* exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`) carry `localized`
|
|
105
|
+
* flags from the default-true set; when opting out, derive overrides from
|
|
106
|
+
* `buildDefaultFieldDefinitions(false)` / `buildDefaultActionDefinitions(false)` instead.
|
|
107
|
+
* Consent statements are unaffected either way: they live on the host's own
|
|
108
|
+
* `consentSourcesField()`, which carries its own `localized` option.
|
|
87
109
|
*/
|
|
88
110
|
localizeContent?: boolean; /** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
89
111
|
fields?: FieldTypesConfig; /** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
90
112
|
rules?: ValidationRulesConfig; /** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
91
113
|
actions?: ActionsConfig;
|
|
92
114
|
/**
|
|
93
|
-
* Customize how rich text
|
|
94
|
-
* Lexical/richText editor
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
115
|
+
* Customize how the plugin's rich text is authored and rendered. `editor` is the default
|
|
116
|
+
* Lexical/richText editor for every plugin richText field (message content, consent
|
|
117
|
+
* statement, response message, action bodies); `bodyEditor` overrides the action body
|
|
118
|
+
* fields specifically, falling back to `editor`. `converters` spread over the default
|
|
119
|
+
* Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to
|
|
120
|
+
* target chat or plain-text channels instead of email HTML). A custom `serialize` receives
|
|
121
|
+
* the submitted `form` (id/title) and `req`, enabling per-tenant lookups or handing the raw
|
|
122
|
+
* body off to a renderer like react-email.
|
|
123
|
+
*/
|
|
124
|
+
richText?: RichTextBodyOption;
|
|
125
|
+
/**
|
|
126
|
+
* Email routing for the `emailTeam` and `confirmation` actions. Both sub-options are opt-in by the
|
|
127
|
+
* presence of a resolver (not a `false`/`true`/object flag) and share a shape: a `req`-scoped
|
|
128
|
+
* resolver, evaluated per request via an endpoint, whose choice is validated at save time only and
|
|
129
|
+
* never re-checked when the action sends (the config is admin-authored, not visitor-controlled).
|
|
130
|
+
*
|
|
131
|
+
* `fromAddresses` gives both actions a `from` select whose options come from the resolver; absent,
|
|
132
|
+
* neither action has a `from` field and every send uses the email adapter's default sender. The
|
|
133
|
+
* intended use is multi-tenant hosts where each tenant may only send from particular addresses
|
|
134
|
+
* (derive the tenant from `req`, return its allowed senders). Values are the literal string
|
|
135
|
+
* `payload.sendEmail` accepts as `from` (e.g. `'Name <addr@x.com>'` or a plain address).
|
|
136
|
+
*
|
|
137
|
+
* `departments` turns the `emailTeam` `to` into a select whose options come from the resolver
|
|
138
|
+
* (a `/:id/departments` endpoint); the intended use is to place `departmentsField()` on a document
|
|
139
|
+
* you own and read it back with `resolveDepartmentOptions`, which resolves each department's address
|
|
140
|
+
* for the requesting locale. Because `to` is localized, each admin locale stores its own resolved
|
|
141
|
+
* address and a submission's locale selects the address it routes to (Payload-native, no per-send
|
|
142
|
+
* lookup). Storing the resolved address, rather than a department id resolved live at send (consent's
|
|
143
|
+
* model), is deliberate: the routing target a form was saved with stays audit-stable even if the
|
|
144
|
+
* resolver's data later changes, so do not "fix" it into a live lookup. Multi-tenant hosts scope
|
|
145
|
+
* which document they read by the tenant derived from `req`; absent, the recipient fields simply
|
|
146
|
+
* offer no preset department options (still free-typed emails and field tokens).
|
|
147
|
+
*/
|
|
148
|
+
email?: {
|
|
149
|
+
fromAddresses?: FromAddressesResolver;
|
|
150
|
+
departments?: DepartmentEmailsResolver; /** Narrows the recipient fields' behavior (free-typed emails, field tokens). See {@link RecipientsConfig}. */
|
|
151
|
+
recipients?: RecipientsConfig;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Where the consent statements a form can reference come from. Absent (the default): no sources,
|
|
155
|
+
* so the built-in `consent` field type is not registered at all and authors cannot add a consent
|
|
156
|
+
* field with nothing to reference (a developer-registered custom `consent` type via `fields`
|
|
157
|
+
* still wins).
|
|
158
|
+
*
|
|
159
|
+
* `sources` is an async `req`-scoped resolver returning the sources available to this request.
|
|
160
|
+
* The intended shape: place `consentSourcesField()` on a collection or global you own and read it
|
|
161
|
+
* back here. Multi-tenant hosts scope that read by the tenant derived from `req`, so a tenant's
|
|
162
|
+
* authors only ever see, and their visitors only ever agree to, their own statements. A form
|
|
163
|
+
* stores only a source's row `id`; the statement is resolved live per request (see
|
|
164
|
+
* `resolveConsentStatements`) and the proof is rebuilt from the source at submit, so neither is
|
|
165
|
+
* ever a copy the client could stale or forge.
|
|
166
|
+
*/
|
|
167
|
+
consent?: {
|
|
168
|
+
sources: ConsentSourcesResolver;
|
|
169
|
+
/**
|
|
170
|
+
* What each submission snapshots of the agreed consent wording, for a versioned audit trail.
|
|
171
|
+
* `'both'` (default) stores a `statementHash`, the plain `statementText`, and the source name;
|
|
172
|
+
* `'hash'` keeps only the tamper-evident hash; `'text'` only the readable text; `false` keeps the
|
|
173
|
+
* lean id-only proof. The proof stays id-based regardless; this only adds the wording snapshot.
|
|
174
|
+
*/
|
|
175
|
+
snapshot?: ConsentSnapshotMode;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Form-level button labels: `submitLabel` at the bottom of the Fields tab, `prevLabel` and
|
|
179
|
+
* `nextLabel` in a row at the bottom of the Flow tab (shown once the flow has a step). The
|
|
180
|
+
* rendered chrome resolves each label as `<Form>` prop, then the stored value, then the
|
|
181
|
+
* translated default. `fields` composes them: it receives the three default fields as a
|
|
182
|
+
* `{ submit, prev, next }` map with the content localization flag already applied and returns
|
|
183
|
+
* the map, so wrapping a default in a row with a host field (e.g. an icon select) or replacing
|
|
184
|
+
* one is explicit. `FormDocument.buttons` reassembles only those three known labels, so a
|
|
185
|
+
* host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.
|
|
186
|
+
*/
|
|
187
|
+
buttons?: ButtonsOption;
|
|
188
|
+
/**
|
|
189
|
+
* The success-response group. `redirect.fields` composes the fields inside the `response.redirect`
|
|
190
|
+
* group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the
|
|
191
|
+
* polymorphic `reference` relationship when `redirectRelationships` is set) and returns the group's
|
|
192
|
+
* final field array, so a host can prepend a custom link field (the pattern most projects already
|
|
193
|
+
* have), swap `url` for their own picker, reorder, or filter. Omit it and the group stays the
|
|
194
|
+
* built-in `url` (+ optional `reference`), unchanged.
|
|
195
|
+
*
|
|
196
|
+
* The plugin's built-in redirect handling reads `redirect.url` (and `redirect.reference` when
|
|
197
|
+
* configured); `toFormDocument` passes the whole `response` group through, so a host that replaces
|
|
198
|
+
* `url` with their own link field owns resolving it to a destination in their frontend, the same as
|
|
199
|
+
* the internal-reference case.
|
|
200
|
+
*/
|
|
201
|
+
response?: ResponseOption;
|
|
202
|
+
/**
|
|
203
|
+
* Collections whose documents `response.redirect` can reference (`response.redirect.reference`),
|
|
204
|
+
* letting an author redirect a visitor to an internal document instead of a URL after a
|
|
205
|
+
* successful submit. Absent (the default): no `reference` field exists at all, matching today's
|
|
206
|
+
* URL-only redirect. Always polymorphic, even for a single slug (a `CollectionSlug[]` array, not
|
|
207
|
+
* a bare `CollectionSlug`), so a host adding a second collection later never changes the stored
|
|
208
|
+
* shape, the same precedent as `consentSourcesField()`'s `page` picker. The plugin never resolves
|
|
209
|
+
* the reference to a URL itself (it has no notion of the host's routing); `toFormDocument` passes
|
|
210
|
+
* the raw `{ relationTo, value }` pair through on `FormDocument.response.redirect.reference` for
|
|
211
|
+
* the host to resolve. Mirrors the `redirectRelationships` option of Payload's native
|
|
212
|
+
* `plugin-form-builder`.
|
|
99
213
|
*/
|
|
100
|
-
|
|
101
|
-
consentSources?: ConsentSourcesConfig;
|
|
214
|
+
redirectRelationships?: CollectionSlug[];
|
|
102
215
|
/**
|
|
103
216
|
* File uploads are bring-your-own. Default `false`: no upload collection is involved and the
|
|
104
217
|
* built-in `file` field type is removed from the registry, so form authors cannot add a field
|
|
@@ -127,15 +240,26 @@ type FormBuilderPluginOptions = {
|
|
|
127
240
|
* a poll's choices from host domain data with stable values; there are no built-ins. With at
|
|
128
241
|
* least one source registered, the forms poll group gains an `optionSource` select plus its
|
|
129
242
|
* per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.
|
|
243
|
+
* `outcomeFields` composes the poll `outcome` group: it receives the two default fields
|
|
244
|
+
* (`winningValues`, `resolvedAt`) and returns the group's final field array verbatim, so a host
|
|
245
|
+
* can swap `winningValues` for its own component (e.g. a relationship picker over the voteable
|
|
246
|
+
* records). Membership validation runs server-side regardless, so a swap cannot bypass it.
|
|
247
|
+
* `types` registers outcome strategies (`definePollType`) shown in the poll `type` select. The
|
|
248
|
+
* built-ins `manual` (default, hand-picked), `mostVoted` (auto-resolves to the top choice(s) on
|
|
249
|
+
* close), and `source` (delegates to the option source) are always registered; a host entry keyed
|
|
250
|
+
* by (or carrying) a built-in slug replaces it. A closed poll whose strategy is not `manual`
|
|
251
|
+
* auto-resolves via a scheduled job when a runner is present, or on the next results read otherwise.
|
|
130
252
|
*/
|
|
131
253
|
poll?: {
|
|
132
254
|
votedCookie?: boolean;
|
|
133
255
|
sources?: PollOptionSourcesConfig;
|
|
256
|
+
types?: PollTypesConfig;
|
|
257
|
+
outcomeFields?: OutcomeFieldsOverride;
|
|
134
258
|
};
|
|
135
259
|
/**
|
|
136
260
|
* When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the
|
|
137
|
-
* submission admin view. Default `false
|
|
138
|
-
*
|
|
261
|
+
* submission admin view. Default `false`, because the `SubmissionAnswers` UI component already
|
|
262
|
+
* represents those fields fully and they are noisy shown alongside it.
|
|
139
263
|
*/
|
|
140
264
|
showSubmissionRawFields?: boolean;
|
|
141
265
|
/**
|
|
@@ -157,5 +281,5 @@ declare module 'payload' {
|
|
|
157
281
|
}
|
|
158
282
|
declare const formBuilder: (options: FormBuilderPluginOptions) => import("payload").Plugin;
|
|
159
283
|
//#endregion
|
|
160
|
-
export { type ActionDefinition, type ActionOption, type ActionRegistry, type ActionResult, type ActionRunArgs, type ActionsConfig, type AggregateFieldResponsesArgs, type AggregateFormResponsesArgs, type AggregationBucket, type AggregationRow, type AnyActionDefinition, type
|
|
284
|
+
export { type ActionDefinition, type ActionOption, type ActionRegistry, type ActionResult, type ActionRunArgs, type ActionsConfig, type AggregateFieldResponsesArgs, type AggregateFormResponsesArgs, type AggregationBucket, type AggregationRow, type AnyActionDefinition, type AnyFormFieldDefinition, type AnyPollOptionSource, type AnyValidationRuleDefinition, type BodyContext, type BodyConverter, type BodyConverterArgs, type BodyRender, type ButtonFieldsOverride, type ButtonsOption, CAPTCHA_TOKEN_KEY, type CalcExpression, type CaptchaProvider, type CaptchaVerifyArgs, type ConsentProof, type ConsentSnapshotMode, type ConsentSourceEntry, type ConsentSourceOption, type ConsentSourcePage, type ConsentSourcesFieldOptions, type ConsentSourcesResolver, type ConsentStatement, type ConsentStatements, type CreateSubmissionArgs, type CreatedSubmission, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, type DefaultButtonFields, type DefaultOutcomeFields, type DepartmentEmailsResolver, type DepartmentOption, type DepartmentsFieldOptions, type FieldAggregation, type FieldCondition, type FieldMeta, type FieldTargetParamOptions, type FieldTypeOption, type FieldTypeRegistry, type FieldTypesConfig, type FileFieldConfig, type FileRef, type FileRefError, FormBuilderPluginOptions, type FormBuilderPluginOptions as PluginOptions, type FormButtonSettings, type FormDocument, type FormFieldDefinition, type FormFieldFormat, type FormFieldValidate, type FormFieldValueKind, type FormPollSettings, type FormResponseSettings, type FormResultsAccess, type FormResultsAccessArgs, type FromAddressOption, type FromAddressesResolver, type HcaptchaProviderOptions, type IdentifyFn, type OmittableSharedField, type OutcomeFieldsOverride, POLL_CLOSE_TASK_SLUG, type PollCloseTaskInput, type PollOption, type PollOptionResolveArgs, type PollOptionSource, type PollOptionSourceOption, type PollOptionSourceRegistry, type PollOptionSourcesConfig, type PollOutcomeStrategy, type PollOutcomeStrategyArgs, type PollTypeRegistry, type PollTypesConfig, type PrefillOptions, type PresentationDensity, type PresentationDescriptor, type PresentationSurface, type RateLimitCheckArgs, type RateLimitConfig, type RateLimitResult, type RateLimiter, type RecallResolver, type RecaptchaProviderOptions, type RedirectFieldsOverride, type RedirectOption, type ResolveConsentEntriesArgs, type ResolveConsentSourcesRequestArgs, type ResolveConsentSourcesRequestResult, type ResolveConsentStatementsArgs, type ResolveDepartmentOptionsArgs, type ResolveDepartmentsRequestArgs, type ResolveDepartmentsRequestResult, type ResolveEffectivePollOptionsArgs, type ResolveFieldOptionsArgs, type ResolvePollOptionsArgs, type ResolvePollOutcomeArgs, type ResolvePublishedVersionRefArgs, type ResolveResultsRequestArgs, type ResolveResultsRequestResult, type ResponseOption, type RichTextBodyOption, SIGNATURE_HEADER, type SerializeBodyArgs, type SpamConfig, type SpamMetadataConfig, type SpamOption, type SubmissionStatusFilter, type ToFormDocumentOptions, type TurnstileProviderOptions, type UploadsOption, type ValidationRuleDefinition, type ValidationRuleOption, type ValidationRuleRegistry, type ValidationRuleResult, type ValidationRulesConfig, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, applyConsentStatements, buildDefaultActionDefinitions, buildDefaultButtonFields, buildDefaultFieldDefinitions, buildDefaultOutcomeFields, buildNextLabelField, buildPollCloseTask, buildPrevLabelField, buildRecallResolver, buildResolvedAtField, buildSubmitLabelField, buildWinningValuesField, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, consentSourcesField, countryField, createKvRateLimiter, createSubmission, defaultActionDefinitions, defaultBodyConverters, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineFormField, definePollOptionSource, definePollType, defineValidationRule, departmentsField, enqueuePollClose, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fieldKey, fieldTargetParam, fileMimeTypeOptions, formBuilder, formatBytes, hasVotedCookie, hcaptchaProvider, interpolate, isPollClosed, localizedIf, manualStrategy, mostVotedStrategy, normalizeCalc, optionLabelsFor, pollTypesOf, recaptchaProvider, registerPollCloseTask, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentEntries, resolveConsentSourcesRequest, resolveConsentStatements, resolveDepartmentOptions, resolveEffectivePollOptions, resolveFileRef, resolveFormResultsRequest, resolvePollOptionSources, resolvePollOptions, resolvePollOutcome, resolvePollTypes, resolvePublishedVersionRef, resolveSpamConfig, runPollClose, sanitizeUrl, serializeBody, shouldAutoResolvePoll, signPayload, sourceStrategy, stashPollTypes, stateField, textOfBody, toFormDocument, topBucketValues, turnstileProvider, valuesFromSearchParams, votedCookieName };
|
|
161
285
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -8,29 +8,40 @@ import { defineAction } from "./actions/defineAction.js";
|
|
|
8
8
|
import { SIGNATURE_HEADER, signPayload } from "./actions/sign.js";
|
|
9
9
|
import { buildDefaultActionDefinitions, defaultActionDefinitions } from "./actions/builtin/index.js";
|
|
10
10
|
import { resolveActions } from "./actions/registry.js";
|
|
11
|
-
import {
|
|
12
|
-
import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
|
|
13
|
-
import { buildDefaultConsentSources, defaultConsentSources } from "./consent/builtin/index.js";
|
|
14
|
-
import { resolveConsentSources } from "./consent/registry.js";
|
|
11
|
+
import { resolveConsentEntries, stashConsentSources } from "./consent/resolveConsentEntries.js";
|
|
15
12
|
import { normalizeCalc } from "./calc/normalizeCalc.js";
|
|
16
13
|
import { defineFormField } from "./fields/defineFormField.js";
|
|
14
|
+
import { resolveFileRef } from "./uploads/resolveFileRef.js";
|
|
17
15
|
import { fileMimeTypeOptions } from "./fields/builtin/file.js";
|
|
18
16
|
import { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
|
|
19
|
-
import { resolveFieldTypes } from "./fields/registry.js";
|
|
20
|
-
import { isPollClosed } from "./form/pollState.js";
|
|
17
|
+
import { resolveFieldTypes, stashFieldTypes } from "./fields/registry.js";
|
|
21
18
|
import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "./spam/constants.js";
|
|
19
|
+
import { isPollClosed } from "./form/pollState.js";
|
|
20
|
+
import { fieldKey } from "./fields/fieldKey.js";
|
|
22
21
|
import { aggregateRowForField, aggregateRowsForFields } from "./aggregation/aggregateRows.js";
|
|
23
22
|
import { aggregateFieldResponses, aggregateFormResponses, fieldHasOptions } from "./aggregation/aggregateResponses.js";
|
|
24
|
-
import {
|
|
23
|
+
import { definePollType } from "./poll/definePollType.js";
|
|
24
|
+
import { mostVotedStrategy, topBucketValues } from "./poll/mostVoted.js";
|
|
25
25
|
import { resolvePollOptions, stashPollOptionSources } from "./poll/resolvePollOptions.js";
|
|
26
|
+
import { manualStrategy, pollTypesOf, resolvePollTypes, sourceStrategy, stashPollTypes } from "./poll/pollTypeRegistry.js";
|
|
27
|
+
import { resolvePollOutcome } from "./poll/resolvePollOutcome.js";
|
|
28
|
+
import { POLL_CLOSE_TASK_SLUG, buildPollCloseTask, enqueuePollClose, registerPollCloseTask, runPollClose, shouldAutoResolvePoll } from "./poll/closeJob.js";
|
|
29
|
+
import { resolveEffectivePollOptions } from "./poll/effectivePollOptions.js";
|
|
30
|
+
import { resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
|
|
31
|
+
import { resolveConsentSourcesRequest } from "./consent/resolveConsentSourcesRequest.js";
|
|
32
|
+
import { resolveConsentStatements } from "./consent/resolveConsentStatements.js";
|
|
33
|
+
import { resolveDepartmentOptions } from "./email/departments.js";
|
|
34
|
+
import { buildDefaultOutcomeFields, buildResolvedAtField, buildWinningValuesField } from "./poll/outcomeFields.js";
|
|
35
|
+
import { buildDefaultButtonFields, buildNextLabelField, buildPrevLabelField, buildSubmitLabelField } from "./collections/buttonFields.js";
|
|
26
36
|
import { evaluateCalc } from "./calc/evaluate.js";
|
|
27
37
|
import { calcExpressionOf, computeCalcFields } from "./calc/computeCalcFields.js";
|
|
28
38
|
import { evaluateCondition } from "./conditions/evaluate.js";
|
|
29
|
-
import {
|
|
39
|
+
import { textOfBody } from "./actions/body/textOfBody.js";
|
|
40
|
+
import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
|
|
30
41
|
import { captureConsent } from "./consent/captureConsent.js";
|
|
31
|
-
import { resolveFileRef } from "./uploads/resolveFileRef.js";
|
|
32
42
|
import { captureFileRef } from "./uploads/captureFileRef.js";
|
|
33
43
|
import { hasVotedCookie, votedCookieName } from "./submissions/votedCookie.js";
|
|
44
|
+
import { readUploadCollectionMimeTypes } from "./plugin/uploadsCollection.js";
|
|
34
45
|
import { registerCollections } from "./plugin/registerCollections.js";
|
|
35
46
|
import { registerTranslations } from "./plugin/registerTranslations.js";
|
|
36
47
|
import { resolvePollOptionSources } from "./poll/registry.js";
|
|
@@ -38,11 +49,16 @@ import { defaultIdentify } from "./spam/identify.js";
|
|
|
38
49
|
import { createKvRateLimiter } from "./spam/rateLimiter.js";
|
|
39
50
|
import { resolveSpamConfig } from "./spam/resolveSpam.js";
|
|
40
51
|
import { defineValidationRule } from "./validation/defineValidationRule.js";
|
|
52
|
+
import { fieldTargetParam } from "./validation/fieldTargetParam.js";
|
|
41
53
|
import { defaultValidationRules, defaultValidationRulesByType } from "./validation/builtin/index.js";
|
|
42
54
|
import { resolveValidationRules } from "./validation/registry.js";
|
|
55
|
+
import { applyConsentStatements } from "./consent/applyConsentStatements.js";
|
|
56
|
+
import { consentSourcesField } from "./consent/consentSourcesField.js";
|
|
57
|
+
import { departmentsField } from "./email/departmentsField.js";
|
|
58
|
+
import { countryField } from "./fields/builtin/country.js";
|
|
59
|
+
import { stateField } from "./fields/builtin/state.js";
|
|
43
60
|
import { toFormDocument } from "./form/toFormDocument.js";
|
|
44
61
|
import { definePollOptionSource } from "./poll/definePollOptionSource.js";
|
|
45
|
-
import { resolvePollOutcome } from "./poll/resolvePollOutcome.js";
|
|
46
62
|
import { valuesFromSearchParams } from "./prefill/valuesFromSearchParams.js";
|
|
47
63
|
import { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from "./presentations/defaults.js";
|
|
48
64
|
import { buildRecallResolver, optionLabelsFor } from "./recall/resolver.js";
|
|
@@ -50,6 +66,7 @@ import { defineCaptchaProvider } from "./spam/captcha.js";
|
|
|
50
66
|
import { hcaptchaProvider } from "./spam/providers/hcaptcha.js";
|
|
51
67
|
import { recaptchaProvider } from "./spam/providers/recaptcha.js";
|
|
52
68
|
import { turnstileProvider } from "./spam/providers/turnstile.js";
|
|
69
|
+
import { createSubmission } from "./submissions/createSubmission.js";
|
|
53
70
|
import { formatBytes } from "./uploads/formatBytes.js";
|
|
54
71
|
import { definePlugin } from "payload";
|
|
55
72
|
//#region src/index.ts
|
|
@@ -60,19 +77,27 @@ const formBuilder = definePlugin({
|
|
|
60
77
|
if (options.disabled === true) return config;
|
|
61
78
|
const localizeContent = options.localizeContent !== false;
|
|
62
79
|
const uploads = options.uploads ?? false;
|
|
63
|
-
const
|
|
80
|
+
const uploadMimeTypes = uploads === false ? void 0 : uploads.mimeTypes ?? readUploadCollectionMimeTypes(config, uploads.collection);
|
|
81
|
+
const consentSources = options.consent?.sources;
|
|
82
|
+
const registry = resolveFieldTypes(buildDefaultFieldDefinitions(localizeContent, options.richText?.editor, uploadMimeTypes).filter((definition) => (uploads !== false || definition.type !== "file") && (consentSources !== void 0 || definition.type !== "consent")), options.fields);
|
|
64
83
|
const ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules);
|
|
65
|
-
const
|
|
66
|
-
const
|
|
84
|
+
const fromAddresses = options.email?.fromAddresses;
|
|
85
|
+
const departments = options.email?.departments;
|
|
86
|
+
const actionRegistry = resolveActions(buildDefaultActionDefinitions(localizeContent, options.richText?.bodyEditor ?? options.richText?.editor, fromAddresses, departments, options.email?.recipients), options.actions);
|
|
67
87
|
const spam = resolveSpamConfig(options.spam);
|
|
68
88
|
const pollSourceRegistry = resolvePollOptionSources(options.poll?.sources);
|
|
89
|
+
const pollTypeRegistry = resolvePollTypes(options.poll?.types);
|
|
69
90
|
config.custom = stashPollOptionSources(config.custom, pollSourceRegistry);
|
|
91
|
+
config.custom = stashPollTypes(config.custom, pollTypeRegistry);
|
|
92
|
+
config.custom = stashFieldTypes(config.custom, registry);
|
|
93
|
+
if (consentSources) config.custom = stashConsentSources(config.custom, consentSources);
|
|
70
94
|
registerTranslations(config, options.translations);
|
|
71
95
|
registerCollections({
|
|
72
96
|
config,
|
|
73
97
|
registry,
|
|
74
98
|
ruleRegistry,
|
|
75
|
-
|
|
99
|
+
consentSources,
|
|
100
|
+
consentSnapshot: options.consent?.snapshot ?? "both",
|
|
76
101
|
actionRegistry,
|
|
77
102
|
richText: options.richText,
|
|
78
103
|
hasJobsPlugin: Boolean(plugins["@10x-media/jobs"]),
|
|
@@ -84,12 +109,19 @@ const formBuilder = definePlugin({
|
|
|
84
109
|
resultsAccess: options.results?.access,
|
|
85
110
|
votedCookie: options.poll?.votedCookie === true,
|
|
86
111
|
pollSourceRegistry,
|
|
112
|
+
pollTypeRegistry,
|
|
113
|
+
outcomeFields: options.poll?.outcomeFields,
|
|
114
|
+
buttons: options.buttons,
|
|
115
|
+
response: options.response,
|
|
116
|
+
fromAddresses,
|
|
117
|
+
departments,
|
|
118
|
+
redirectRelationships: options.redirectRelationships,
|
|
87
119
|
overrides: options.overrides
|
|
88
120
|
});
|
|
89
121
|
return config;
|
|
90
122
|
}
|
|
91
123
|
});
|
|
92
124
|
//#endregion
|
|
93
|
-
export { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, SIGNATURE_HEADER, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, buildDefaultActionDefinitions,
|
|
125
|
+
export { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, POLL_CLOSE_TASK_SLUG, SIGNATURE_HEADER, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, applyConsentStatements, buildDefaultActionDefinitions, buildDefaultButtonFields, buildDefaultFieldDefinitions, buildDefaultOutcomeFields, buildNextLabelField, buildPollCloseTask, buildPrevLabelField, buildRecallResolver, buildResolvedAtField, buildSubmitLabelField, buildWinningValuesField, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, consentSourcesField, countryField, createKvRateLimiter, createSubmission, defaultActionDefinitions, defaultBodyConverters, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineFormField, definePollOptionSource, definePollType, defineValidationRule, departmentsField, enqueuePollClose, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fieldKey, fieldTargetParam, fileMimeTypeOptions, formBuilder, formatBytes, hasVotedCookie, hcaptchaProvider, interpolate, isPollClosed, localizedIf, manualStrategy, mostVotedStrategy, normalizeCalc, optionLabelsFor, pollTypesOf, recaptchaProvider, registerPollCloseTask, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentEntries, resolveConsentSourcesRequest, resolveConsentStatements, resolveDepartmentOptions, resolveEffectivePollOptions, resolveFileRef, resolveFormResultsRequest, resolvePollOptionSources, resolvePollOptions, resolvePollOutcome, resolvePollTypes, resolvePublishedVersionRef, resolveSpamConfig, runPollClose, sanitizeUrl, serializeBody, shouldAutoResolvePoll, signPayload, sourceStrategy, stashPollTypes, stateField, textOfBody, toFormDocument, topBucketValues, turnstileProvider, valuesFromSearchParams, votedCookieName };
|
|
94
126
|
|
|
95
127
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type Config, definePlugin } from 'payload'\nimport type { RichTextBodyOption } from './actions/body/serializeBody'\nimport { buildDefaultActionDefinitions } from './actions/builtin'\nimport type { ActionsConfig } from './actions/registry'\nimport { resolveActions } from './actions/registry'\nimport type { FormResultsAccess } from './aggregation/resolveResultsRequest'\nimport { buildDefaultConsentSources } from './consent/builtin'\nimport type { ConsentSourcesConfig } from './consent/registry'\nimport { resolveConsentSources } from './consent/registry'\nimport type { FormEventSink } from './events/types'\nimport { buildDefaultFieldDefinitions } from './fields/builtin'\nimport { type FieldTypesConfig, resolveFieldTypes } from './fields/registry'\nimport type { CollectionOverrides } from './plugin/collectionOverrides'\nimport { registerCollections } from './plugin/registerCollections'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport type { UploadsOption } from './plugin/uploadsCollection'\nimport type { PollOptionSourcesConfig } from './poll/registry'\nimport { resolvePollOptionSources } from './poll/registry'\nimport { stashPollOptionSources } from './poll/resolvePollOptions'\nimport { resolveSpamConfig } from './spam/resolveSpam'\nimport type { SpamOption } from './spam/types'\nimport type { TranslationsOption } from './translations'\nimport { defaultValidationRules } from './validation/builtin'\nimport { resolveValidationRules, type ValidationRulesConfig } from './validation/registry'\n\nexport type FormBuilderPluginOptions = {\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/form-builder/i18n`. Values win\n\t * over the built-in locales key-by-key; locales the plugin does not ship are\n\t * added whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\t/** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */\n\tevents?: FormEventSink\n\t/**\n\t * Content-bearing author fields (labels, placeholders, option labels, consent statements,\n\t * action subjects and bodies) are localized by default. Payload strips the `localized` flag\n\t * on hosts without `localization` configured, so the default is safe everywhere. Set `false`\n\t * to keep form content single-locale even on localized hosts. Spread-overrides of the prebuilt\n\t * default exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`,\n\t * `defaultConsentSources`) carry `localized` flags from the default-true set; when opting out,\n\t * derive overrides from `buildDefaultFieldDefinitions(false)` /\n\t * `buildDefaultActionDefinitions(false)` / `buildDefaultConsentSources(false)` instead.\n\t */\n\tlocalizeContent?: boolean\n\t/** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tfields?: FieldTypesConfig\n\t/** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\trules?: ValidationRulesConfig\n\t/** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tactions?: ActionsConfig\n\t/**\n\t * Customize how rich text action bodies are authored and rendered. `editor` overrides the\n\t * Lexical/richText editor on both the emailTeam and confirmation action body fields.\n\t * `converters` spread over the default Lexical node converters; `serialize` replaces the\n\t * whole pipeline (e.g. to target chat or plain-text channels instead of email HTML). A\n\t * custom `serialize` receives the submitted `form` (id/title) and `req`, enabling per-tenant\n\t * lookups or handing the raw body off to a renderer like react-email.\n\t */\n\trichText?: RichTextBodyOption\n\t/** Add, override, or remove consent source types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tconsentSources?: ConsentSourcesConfig\n\t/**\n\t * File uploads are bring-your-own. Default `false`: no upload collection is involved and the\n\t * built-in `file` field type is removed from the registry, so form authors cannot add a field\n\t * with nowhere to land (a developer-registered custom `file` type via `fields` still wins).\n\t * `{ collection: 'slug' }` points at a host-owned upload collection (created by the app with\n\t * its storage adapter); the plugin validates it at boot, appends its hidden `owner` field when\n\t * absent, and prepends the spam upload hooks.\n\t */\n\tuploads?: UploadsOption\n\t/** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */\n\tspam?: SpamOption\n\t/**\n\t * Aggregate-results endpoint options. `access` gates anonymous reads after the form is loaded\n\t * and before anything is served; absent keeps the plugin-default gating (poll opt-in +\n\t * visibility + enumerable-field guard). Multi-tenant hosts should compare `form.tenant` against\n\t * the tenant derived from `req` so one tenant's poll counts are never readable under another\n\t * tenant's id. Authenticated callers bypass this seam.\n\t */\n\tresults?: { access?: FormResultsAccess }\n\t/**\n\t * Poll behavior. `votedCookie: true` sets an httpOnly `fb-voted-{formId}=1` cookie on each\n\t * successful submission to a poll-enabled form, letting SSR hosts read the voted state via\n\t * `hasVotedCookie` and pass it to `<Poll hasVoted>`. Default `false`.\n\t * `sources` registers poll option sources (`definePollOptionSource`), letting authors populate\n\t * a poll's choices from host domain data with stable values; there are no built-ins. With at\n\t * least one source registered, the forms poll group gains an `optionSource` select plus its\n\t * per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.\n\t */\n\tpoll?: { votedCookie?: boolean; sources?: PollOptionSourcesConfig }\n\t/**\n\t * When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the\n\t * submission admin view. Default `false` — those fields are fully represented by the\n\t * `SubmissionAnswers` UI component and are noisy when shown alongside it.\n\t */\n\tshowSubmissionRawFields?: boolean\n\t/**\n\t * Override individual plugin-managed collections using explicit spreads. Each key accepts a\n\t * `CollectionOverrides` object: top-level keys are spread with the plugin's defaults (spread\n\t * order per key determines who wins), hooks are appended after the plugin's own hooks, and\n\t * `fields` is a function that receives the default fields and returns the final array so\n\t * additions/removals are always intentional.\n\t */\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/form-builder': FormBuilderPluginOptions\n\t}\n}\n\nexport const formBuilder = definePlugin<FormBuilderPluginOptions>({\n\tslug: '@10x-media/form-builder',\n\torder: 50,\n\tplugin: ({ config, plugins, ...options }): Config => {\n\t\tif (options.disabled === true) {\n\t\t\treturn config\n\t\t}\n\t\tconst localizeContent = options.localizeContent !== false\n\t\tconst uploads = options.uploads ?? false\n\t\t// Without an uploads collection the built-in file type has nowhere to store anything, so it\n\t\t// never enters the registry; an explicit `fields.file` definition remains a developer choice.\n\t\tconst defaultFieldDefinitions = buildDefaultFieldDefinitions(localizeContent).filter(\n\t\t\t(definition) => uploads !== false || definition.type !== 'file'\n\t\t)\n\t\tconst registry = resolveFieldTypes(defaultFieldDefinitions, options.fields)\n\t\tconst ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules)\n\t\tconst consentRegistry = resolveConsentSources(\n\t\t\tbuildDefaultConsentSources(localizeContent),\n\t\t\toptions.consentSources\n\t\t)\n\t\tconst actionRegistry = resolveActions(\n\t\t\tbuildDefaultActionDefinitions(localizeContent, options.richText?.editor),\n\t\t\toptions.actions\n\t\t)\n\t\tconst spam = resolveSpamConfig(options.spam)\n\t\tconst pollSourceRegistry = resolvePollOptionSources(options.poll?.sources)\n\t\t// Stashed on config.custom so the root-level resolvePollOptions helper can reach the\n\t\t// registry through `payload.config` at request time, without threading plugin state.\n\t\tconfig.custom = stashPollOptionSources(config.custom, pollSourceRegistry)\n\t\tregisterTranslations(config, options.translations)\n\t\tregisterCollections({\n\t\t\tconfig,\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentRegistry,\n\t\t\tactionRegistry,\n\t\t\trichText: options.richText,\n\t\t\thasJobsPlugin: Boolean(plugins['@10x-media/jobs']),\n\t\t\tevents: options.events,\n\t\t\tuploads,\n\t\t\tspam,\n\t\t\tshowSubmissionRawFields: options.showSubmissionRawFields ?? false,\n\t\t\tlocalizeContent,\n\t\t\tresultsAccess: options.results?.access,\n\t\t\tvotedCookie: options.poll?.votedCookie === true,\n\t\t\tpollSourceRegistry,\n\t\t\toverrides: options.overrides,\n\t\t})\n\t\treturn config\n\t},\n})\n\nexport type {\n\tBodyConverter,\n\tBodyConverterArgs,\n\tBodyRender,\n} from './actions/body/converters'\nexport { defaultBodyConverters, sanitizeUrl } from './actions/body/converters'\nexport { escapeHtml } from './actions/body/escapeHtml'\nexport type {\n\tBodyContext,\n\tRichTextBodyOption,\n\tSerializeBodyArgs,\n} from './actions/body/serializeBody'\nexport { serializeBody } from './actions/body/serializeBody'\nexport { renderAllValues, renderAllValuesTable } from './actions/body/wildcards'\nexport { buildDefaultActionDefinitions, defaultActionDefinitions } from './actions/builtin'\nexport type { ActionDefinition, ActionRunArgs, AnyActionDefinition } from './actions/defineAction'\nexport { defineAction } from './actions/defineAction'\nexport type { ActionOption, ActionRegistry, ActionsConfig } from './actions/registry'\nexport { resolveActions } from './actions/registry'\nexport type { ActionResult } from './actions/runActions'\nexport { SIGNATURE_HEADER, signPayload } from './actions/sign'\nexport type {\n\tAggregateFieldResponsesArgs,\n\tAggregateFormResponsesArgs,\n} from './aggregation/aggregateResponses'\nexport {\n\taggregateFieldResponses,\n\taggregateFormResponses,\n\tfieldHasOptions,\n} from './aggregation/aggregateResponses'\nexport { aggregateRowForField, aggregateRowsForFields } from './aggregation/aggregateRows'\nexport type {\n\tFormResultsAccess,\n\tFormResultsAccessArgs,\n\tResolveResultsRequestArgs,\n\tResolveResultsRequestResult,\n} from './aggregation/resolveResultsRequest'\nexport { resolveFormResultsRequest } from './aggregation/resolveResultsRequest'\nexport type {\n\tAggregationBucket,\n\tAggregationRow,\n\tFieldAggregation,\n\tFieldMeta,\n\tSubmissionStatusFilter,\n} from './aggregation/types'\nexport { calcExpressionOf, computeCalcFields } from './calc/computeCalcFields'\nexport { evaluateCalc } from './calc/evaluate'\nexport { normalizeCalc } from './calc/normalizeCalc'\nexport type { CalcExpression } from './calc/types'\nexport { evaluateCondition } from './conditions/evaluate'\nexport type { FieldCondition } from './conditions/types'\nexport { buildDefaultConsentSources, defaultConsentSources } from './consent/builtin'\nexport type { ConsentProof } from './consent/captureConsent'\nexport { captureConsent } from './consent/captureConsent'\nexport type {\n\tAnyConsentSource,\n\tConsentLink,\n\tConsentResolveArgs,\n\tConsentResolved,\n\tConsentSource,\n} from './consent/defineConsentSource'\nexport { defineConsentSource } from './consent/defineConsentSource'\nexport type {\n\tConsentSourceOption,\n\tConsentSourceRegistry,\n\tConsentSourcesConfig,\n} from './consent/registry'\nexport { resolveConsentSources } from './consent/registry'\nexport { resolveConsentLinks } from './consent/resolveConsentLinks'\nexport { resolvePublishedVersionRef } from './consent/resolvePublishedVersionRef'\nexport {\n\tbuildDefaultFieldDefinitions,\n\tdefaultFieldDefinitions,\n\tdefaultFieldDefinitionsByType,\n} from './fields/builtin'\nexport { fileMimeTypeOptions } from './fields/builtin/file'\nexport { defineFormField } from './fields/defineFormField'\nexport { localizedIf } from './fields/localizedIf'\nexport type { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from './fields/registry'\nexport type {\n\tAnyFormFieldDefinition,\n\tFormFieldDefinition,\n\tFormFieldFormat,\n\tFormFieldValidate,\n\tFormFieldValueKind,\n} from './fields/types'\nexport { isPollClosed } from './form/pollState'\nexport type { ToFormDocumentOptions } from './form/toFormDocument'\nexport { toFormDocument } from './form/toFormDocument'\nexport type {\n\tFormDisplaySettings,\n\tFormDocument,\n\tFormPollSettings,\n\tFormResponseSettings,\n} from './form/types'\nexport type { UploadsOption } from './plugin/uploadsCollection'\nexport type {\n\tAnyPollOptionSource,\n\tPollOption,\n\tPollOptionResolveArgs,\n\tPollOptionSource,\n} from './poll/definePollOptionSource'\nexport { definePollOptionSource } from './poll/definePollOptionSource'\nexport type {\n\tPollOptionSourceOption,\n\tPollOptionSourceRegistry,\n\tPollOptionSourcesConfig,\n} from './poll/registry'\nexport { resolvePollOptionSources } from './poll/registry'\nexport type { ResolvePollOptionsArgs } from './poll/resolvePollOptions'\nexport { resolvePollOptions } from './poll/resolvePollOptions'\nexport type { ResolvePollOutcomeArgs } from './poll/resolvePollOutcome'\nexport { resolvePollOutcome } from './poll/resolvePollOutcome'\nexport type { PrefillOptions } from './prefill/valuesFromSearchParams'\nexport { valuesFromSearchParams } from './prefill/valuesFromSearchParams'\nexport { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from './presentations/defaults'\nexport type {\n\tPresentationDensity,\n\tPresentationDescriptor,\n\tPresentationSurface,\n} from './presentations/types'\nexport { interpolate } from './recall/interpolate'\nexport type { RecallResolver } from './recall/resolver'\nexport { buildRecallResolver, optionLabelsFor } from './recall/resolver'\nexport { defineCaptchaProvider } from './spam/captcha'\nexport { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from './spam/constants'\nexport { defaultIdentify } from './spam/identify'\nexport type { HcaptchaProviderOptions } from './spam/providers/hcaptcha'\nexport { hcaptchaProvider } from './spam/providers/hcaptcha'\nexport type { RecaptchaProviderOptions } from './spam/providers/recaptcha'\nexport { recaptchaProvider } from './spam/providers/recaptcha'\nexport type { TurnstileProviderOptions } from './spam/providers/turnstile'\nexport { turnstileProvider } from './spam/providers/turnstile'\nexport { createKvRateLimiter } from './spam/rateLimiter'\nexport { resolveSpamConfig } from './spam/resolveSpam'\nexport type {\n\tCaptchaProvider,\n\tCaptchaVerifyArgs,\n\tIdentifyFn,\n\tRateLimitCheckArgs,\n\tRateLimitConfig,\n\tRateLimiter,\n\tRateLimitResult,\n\tSpamConfig,\n\tSpamMetadataConfig,\n\tSpamOption,\n} from './spam/types'\nexport { hasVotedCookie, votedCookieName } from './submissions/votedCookie'\nexport { captureFileRef } from './uploads/captureFileRef'\nexport { formatBytes } from './uploads/formatBytes'\nexport { resolveFileRef } from './uploads/resolveFileRef'\nexport type { FileFieldConfig, FileRef, FileRefError } from './uploads/types'\nexport { defaultValidationRules, defaultValidationRulesByType } from './validation/builtin'\nexport { defineValidationRule } from './validation/defineValidationRule'\nexport type {\n\tValidationRuleOption,\n\tValidationRuleRegistry,\n\tValidationRulesConfig,\n} from './validation/registry'\nexport type {\n\tAnyValidationRuleDefinition,\n\tValidationRuleDefinition,\n\tValidationRuleResult,\n\tValidationSeverity,\n} from './validation/types'\nexport type { FormBuilderPluginOptions as PluginOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsHA,MAAa,cAAc,aAAuC;CACjE,MAAM;CACN,OAAO;CACP,SAAS,EAAE,QAAQ,SAAS,GAAG,cAAsB;EACpD,IAAI,QAAQ,aAAa,MACxB,OAAO;EAER,MAAM,kBAAkB,QAAQ,oBAAoB;EACpD,MAAM,UAAU,QAAQ,WAAW;EAMnC,MAAM,WAAW,kBAHe,6BAA6B,eAAe,EAAE,QAC5E,eAAe,YAAY,SAAS,WAAW,SAAS,MAED,GAAG,QAAQ,MAAM;EAC1E,MAAM,eAAe,uBAAuB,wBAAwB,QAAQ,KAAK;EACjF,MAAM,kBAAkB,sBACvB,2BAA2B,eAAe,GAC1C,QAAQ,cACT;EACA,MAAM,iBAAiB,eACtB,8BAA8B,iBAAiB,QAAQ,UAAU,MAAM,GACvE,QAAQ,OACT;EACA,MAAM,OAAO,kBAAkB,QAAQ,IAAI;EAC3C,MAAM,qBAAqB,yBAAyB,QAAQ,MAAM,OAAO;EAGzE,OAAO,SAAS,uBAAuB,OAAO,QAAQ,kBAAkB;EACxE,qBAAqB,QAAQ,QAAQ,YAAY;EACjD,oBAAoB;GACnB;GACA;GACA;GACA;GACA;GACA,UAAU,QAAQ;GAClB,eAAe,QAAQ,QAAQ,kBAAkB;GACjD,QAAQ,QAAQ;GAChB;GACA;GACA,yBAAyB,QAAQ,2BAA2B;GAC5D;GACA,eAAe,QAAQ,SAAS;GAChC,aAAa,QAAQ,MAAM,gBAAgB;GAC3C;GACA,WAAW,QAAQ;EACpB,CAAC;EACD,OAAO;CACR;AACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type CollectionSlug, type Config, definePlugin } from 'payload'\nimport type { RichTextBodyOption } from './actions/body/serializeBody'\nimport { buildDefaultActionDefinitions } from './actions/builtin'\nimport type { RecipientsConfig } from './actions/emailRecipients'\nimport type { FromAddressesResolver } from './actions/fromAddresses'\nimport type { ActionsConfig } from './actions/registry'\nimport { resolveActions } from './actions/registry'\nimport type { FormResultsAccess } from './aggregation/resolveResultsRequest'\nimport type { ButtonsOption } from './collections/buttonFields'\nimport type { ResponseOption } from './collections/redirectFields'\nimport type { ConsentSnapshotMode } from './consent/captureConsent'\nimport { stashConsentSources } from './consent/resolveConsentEntries'\nimport type { ConsentSourcesResolver } from './consent/types'\nimport type { DepartmentEmailsResolver } from './email/departments'\nimport type { FormEventSink } from './events/types'\nimport { buildDefaultFieldDefinitions } from './fields/builtin'\nimport { type FieldTypesConfig, resolveFieldTypes, stashFieldTypes } from './fields/registry'\nimport type { CollectionOverrides } from './plugin/collectionOverrides'\nimport { registerCollections } from './plugin/registerCollections'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport { readUploadCollectionMimeTypes, type UploadsOption } from './plugin/uploadsCollection'\nimport type { OutcomeFieldsOverride } from './poll/outcomeFields'\nimport type { PollTypesConfig } from './poll/pollTypeRegistry'\nimport { resolvePollTypes, stashPollTypes } from './poll/pollTypeRegistry'\nimport type { PollOptionSourcesConfig } from './poll/registry'\nimport { resolvePollOptionSources } from './poll/registry'\nimport { stashPollOptionSources } from './poll/resolvePollOptions'\nimport { resolveSpamConfig } from './spam/resolveSpam'\nimport type { SpamOption } from './spam/types'\nimport type { TranslationsOption } from './translations'\nimport { defaultValidationRules } from './validation/builtin'\nimport { resolveValidationRules, type ValidationRulesConfig } from './validation/registry'\n\nexport type FormBuilderPluginOptions = {\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/form-builder/i18n`. Values win\n\t * over the built-in locales key-by-key; locales the plugin does not ship are\n\t * added whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\t/** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */\n\tevents?: FormEventSink\n\t/**\n\t * Content-bearing author fields (labels, placeholders, option labels, action subjects and\n\t * bodies) are localized by default. Payload strips the `localized` flag on hosts without\n\t * `localization` configured, so the default is safe everywhere. Set `false` to keep form\n\t * content single-locale even on localized hosts. Spread-overrides of the prebuilt default\n\t * exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`) carry `localized`\n\t * flags from the default-true set; when opting out, derive overrides from\n\t * `buildDefaultFieldDefinitions(false)` / `buildDefaultActionDefinitions(false)` instead.\n\t * Consent statements are unaffected either way: they live on the host's own\n\t * `consentSourcesField()`, which carries its own `localized` option.\n\t */\n\tlocalizeContent?: boolean\n\t/** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tfields?: FieldTypesConfig\n\t/** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\trules?: ValidationRulesConfig\n\t/** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tactions?: ActionsConfig\n\t/**\n\t * Customize how the plugin's rich text is authored and rendered. `editor` is the default\n\t * Lexical/richText editor for every plugin richText field (message content, consent\n\t * statement, response message, action bodies); `bodyEditor` overrides the action body\n\t * fields specifically, falling back to `editor`. `converters` spread over the default\n\t * Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to\n\t * target chat or plain-text channels instead of email HTML). A custom `serialize` receives\n\t * the submitted `form` (id/title) and `req`, enabling per-tenant lookups or handing the raw\n\t * body off to a renderer like react-email.\n\t */\n\trichText?: RichTextBodyOption\n\t/**\n\t * Email routing for the `emailTeam` and `confirmation` actions. Both sub-options are opt-in by the\n\t * presence of a resolver (not a `false`/`true`/object flag) and share a shape: a `req`-scoped\n\t * resolver, evaluated per request via an endpoint, whose choice is validated at save time only and\n\t * never re-checked when the action sends (the config is admin-authored, not visitor-controlled).\n\t *\n\t * `fromAddresses` gives both actions a `from` select whose options come from the resolver; absent,\n\t * neither action has a `from` field and every send uses the email adapter's default sender. The\n\t * intended use is multi-tenant hosts where each tenant may only send from particular addresses\n\t * (derive the tenant from `req`, return its allowed senders). Values are the literal string\n\t * `payload.sendEmail` accepts as `from` (e.g. `'Name <addr@x.com>'` or a plain address).\n\t *\n\t * `departments` turns the `emailTeam` `to` into a select whose options come from the resolver\n\t * (a `/:id/departments` endpoint); the intended use is to place `departmentsField()` on a document\n\t * you own and read it back with `resolveDepartmentOptions`, which resolves each department's address\n\t * for the requesting locale. Because `to` is localized, each admin locale stores its own resolved\n\t * address and a submission's locale selects the address it routes to (Payload-native, no per-send\n\t * lookup). Storing the resolved address, rather than a department id resolved live at send (consent's\n\t * model), is deliberate: the routing target a form was saved with stays audit-stable even if the\n\t * resolver's data later changes, so do not \"fix\" it into a live lookup. Multi-tenant hosts scope\n\t * which document they read by the tenant derived from `req`; absent, the recipient fields simply\n\t * offer no preset department options (still free-typed emails and field tokens).\n\t */\n\temail?: {\n\t\tfromAddresses?: FromAddressesResolver\n\t\tdepartments?: DepartmentEmailsResolver\n\t\t/** Narrows the recipient fields' behavior (free-typed emails, field tokens). See {@link RecipientsConfig}. */\n\t\trecipients?: RecipientsConfig\n\t}\n\t/**\n\t * Where the consent statements a form can reference come from. Absent (the default): no sources,\n\t * so the built-in `consent` field type is not registered at all and authors cannot add a consent\n\t * field with nothing to reference (a developer-registered custom `consent` type via `fields`\n\t * still wins).\n\t *\n\t * `sources` is an async `req`-scoped resolver returning the sources available to this request.\n\t * The intended shape: place `consentSourcesField()` on a collection or global you own and read it\n\t * back here. Multi-tenant hosts scope that read by the tenant derived from `req`, so a tenant's\n\t * authors only ever see, and their visitors only ever agree to, their own statements. A form\n\t * stores only a source's row `id`; the statement is resolved live per request (see\n\t * `resolveConsentStatements`) and the proof is rebuilt from the source at submit, so neither is\n\t * ever a copy the client could stale or forge.\n\t */\n\tconsent?: {\n\t\tsources: ConsentSourcesResolver\n\t\t/**\n\t\t * What each submission snapshots of the agreed consent wording, for a versioned audit trail.\n\t\t * `'both'` (default) stores a `statementHash`, the plain `statementText`, and the source name;\n\t\t * `'hash'` keeps only the tamper-evident hash; `'text'` only the readable text; `false` keeps the\n\t\t * lean id-only proof. The proof stays id-based regardless; this only adds the wording snapshot.\n\t\t */\n\t\tsnapshot?: ConsentSnapshotMode\n\t}\n\t/**\n\t * Form-level button labels: `submitLabel` at the bottom of the Fields tab, `prevLabel` and\n\t * `nextLabel` in a row at the bottom of the Flow tab (shown once the flow has a step). The\n\t * rendered chrome resolves each label as `<Form>` prop, then the stored value, then the\n\t * translated default. `fields` composes them: it receives the three default fields as a\n\t * `{ submit, prev, next }` map with the content localization flag already applied and returns\n\t * the map, so wrapping a default in a row with a host field (e.g. an icon select) or replacing\n\t * one is explicit. `FormDocument.buttons` reassembles only those three known labels, so a\n\t * host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.\n\t */\n\tbuttons?: ButtonsOption\n\t/**\n\t * The success-response group. `redirect.fields` composes the fields inside the `response.redirect`\n\t * group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the\n\t * polymorphic `reference` relationship when `redirectRelationships` is set) and returns the group's\n\t * final field array, so a host can prepend a custom link field (the pattern most projects already\n\t * have), swap `url` for their own picker, reorder, or filter. Omit it and the group stays the\n\t * built-in `url` (+ optional `reference`), unchanged.\n\t *\n\t * The plugin's built-in redirect handling reads `redirect.url` (and `redirect.reference` when\n\t * configured); `toFormDocument` passes the whole `response` group through, so a host that replaces\n\t * `url` with their own link field owns resolving it to a destination in their frontend, the same as\n\t * the internal-reference case.\n\t */\n\tresponse?: ResponseOption\n\t/**\n\t * Collections whose documents `response.redirect` can reference (`response.redirect.reference`),\n\t * letting an author redirect a visitor to an internal document instead of a URL after a\n\t * successful submit. Absent (the default): no `reference` field exists at all, matching today's\n\t * URL-only redirect. Always polymorphic, even for a single slug (a `CollectionSlug[]` array, not\n\t * a bare `CollectionSlug`), so a host adding a second collection later never changes the stored\n\t * shape, the same precedent as `consentSourcesField()`'s `page` picker. The plugin never resolves\n\t * the reference to a URL itself (it has no notion of the host's routing); `toFormDocument` passes\n\t * the raw `{ relationTo, value }` pair through on `FormDocument.response.redirect.reference` for\n\t * the host to resolve. Mirrors the `redirectRelationships` option of Payload's native\n\t * `plugin-form-builder`.\n\t */\n\tredirectRelationships?: CollectionSlug[]\n\t/**\n\t * File uploads are bring-your-own. Default `false`: no upload collection is involved and the\n\t * built-in `file` field type is removed from the registry, so form authors cannot add a field\n\t * with nowhere to land (a developer-registered custom `file` type via `fields` still wins).\n\t * `{ collection: 'slug' }` points at a host-owned upload collection (created by the app with\n\t * its storage adapter); the plugin validates it at boot, appends its hidden `owner` field when\n\t * absent, and prepends the spam upload hooks.\n\t */\n\tuploads?: UploadsOption\n\t/** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */\n\tspam?: SpamOption\n\t/**\n\t * Aggregate-results endpoint options. `access` gates anonymous reads after the form is loaded\n\t * and before anything is served; absent keeps the plugin-default gating (poll opt-in +\n\t * visibility + enumerable-field guard). Multi-tenant hosts should compare `form.tenant` against\n\t * the tenant derived from `req` so one tenant's poll counts are never readable under another\n\t * tenant's id. Authenticated callers bypass this seam.\n\t */\n\tresults?: { access?: FormResultsAccess }\n\t/**\n\t * Poll behavior. `votedCookie: true` sets an httpOnly `fb-voted-{formId}=1` cookie on each\n\t * successful submission to a poll-enabled form, letting SSR hosts read the voted state via\n\t * `hasVotedCookie` and pass it to `<Poll hasVoted>`. Default `false`.\n\t * `sources` registers poll option sources (`definePollOptionSource`), letting authors populate\n\t * a poll's choices from host domain data with stable values; there are no built-ins. With at\n\t * least one source registered, the forms poll group gains an `optionSource` select plus its\n\t * per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.\n\t * `outcomeFields` composes the poll `outcome` group: it receives the two default fields\n\t * (`winningValues`, `resolvedAt`) and returns the group's final field array verbatim, so a host\n\t * can swap `winningValues` for its own component (e.g. a relationship picker over the voteable\n\t * records). Membership validation runs server-side regardless, so a swap cannot bypass it.\n\t * `types` registers outcome strategies (`definePollType`) shown in the poll `type` select. The\n\t * built-ins `manual` (default, hand-picked), `mostVoted` (auto-resolves to the top choice(s) on\n\t * close), and `source` (delegates to the option source) are always registered; a host entry keyed\n\t * by (or carrying) a built-in slug replaces it. A closed poll whose strategy is not `manual`\n\t * auto-resolves via a scheduled job when a runner is present, or on the next results read otherwise.\n\t */\n\tpoll?: {\n\t\tvotedCookie?: boolean\n\t\tsources?: PollOptionSourcesConfig\n\t\ttypes?: PollTypesConfig\n\t\toutcomeFields?: OutcomeFieldsOverride\n\t}\n\t/**\n\t * When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the\n\t * submission admin view. Default `false`, because the `SubmissionAnswers` UI component already\n\t * represents those fields fully and they are noisy shown alongside it.\n\t */\n\tshowSubmissionRawFields?: boolean\n\t/**\n\t * Override individual plugin-managed collections using explicit spreads. Each key accepts a\n\t * `CollectionOverrides` object: top-level keys are spread with the plugin's defaults (spread\n\t * order per key determines who wins), hooks are appended after the plugin's own hooks, and\n\t * `fields` is a function that receives the default fields and returns the final array so\n\t * additions/removals are always intentional.\n\t */\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/form-builder': FormBuilderPluginOptions\n\t}\n}\n\nexport const formBuilder = definePlugin<FormBuilderPluginOptions>({\n\tslug: '@10x-media/form-builder',\n\torder: 50,\n\tplugin: ({ config, plugins, ...options }): Config => {\n\t\tif (options.disabled === true) {\n\t\t\treturn config\n\t\t}\n\t\tconst localizeContent = options.localizeContent !== false\n\t\tconst uploads = options.uploads ?? false\n\t\t// The file field's MIME picker is constrained to what the host upload collection accepts: the\n\t\t// explicit `uploads.mimeTypes` override, else the collection's own `upload.mimeTypes`. Read here,\n\t\t// before the field registry freezes below (attachUploadsCollection runs too late).\n\t\tconst uploadMimeTypes =\n\t\t\tuploads === false\n\t\t\t\t? undefined\n\t\t\t\t: (uploads.mimeTypes ?? readUploadCollectionMimeTypes(config, uploads.collection))\n\t\tconst consentSources = options.consent?.sources\n\t\t// A built-in with nowhere to point never enters the registry, so an author is never offered a\n\t\t// field that cannot work: file without an uploads collection has nowhere to store anything,\n\t\t// consent without sources has no statement to reference. An explicit `fields.file` /\n\t\t// `fields.consent` definition remains a developer choice.\n\t\tconst defaultFieldDefinitions = buildDefaultFieldDefinitions(\n\t\t\tlocalizeContent,\n\t\t\toptions.richText?.editor,\n\t\t\tuploadMimeTypes\n\t\t).filter(\n\t\t\t(definition) =>\n\t\t\t\t(uploads !== false || definition.type !== 'file') &&\n\t\t\t\t(consentSources !== undefined || definition.type !== 'consent')\n\t\t)\n\t\tconst registry = resolveFieldTypes(defaultFieldDefinitions, options.fields)\n\t\tconst ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules)\n\t\tconst fromAddresses = options.email?.fromAddresses\n\t\tconst departments = options.email?.departments\n\t\tconst actionRegistry = resolveActions(\n\t\t\tbuildDefaultActionDefinitions(\n\t\t\t\tlocalizeContent,\n\t\t\t\toptions.richText?.bodyEditor ?? options.richText?.editor,\n\t\t\t\tfromAddresses,\n\t\t\t\tdepartments,\n\t\t\t\toptions.email?.recipients\n\t\t\t),\n\t\t\toptions.actions\n\t\t)\n\t\tconst spam = resolveSpamConfig(options.spam)\n\t\tconst pollSourceRegistry = resolvePollOptionSources(options.poll?.sources)\n\t\tconst pollTypeRegistry = resolvePollTypes(options.poll?.types)\n\t\t// Stashed on config.custom so the root-level resolvePollOptions, resolveEffectivePollOptions,\n\t\t// resolvePollOutcome, and resolveConsentStatements helpers can reach these through\n\t\t// `payload.config` at request time, without threading plugin state through the host's own\n\t\t// server code. The field-type registry rides along so resolveEffectivePollOptions can look up a\n\t\t// results field's definition (and its `resolveOptions`) from a bare `payload` instance.\n\t\tconfig.custom = stashPollOptionSources(config.custom, pollSourceRegistry)\n\t\tconfig.custom = stashPollTypes(config.custom, pollTypeRegistry)\n\t\tconfig.custom = stashFieldTypes(config.custom, registry)\n\t\tif (consentSources) {\n\t\t\tconfig.custom = stashConsentSources(config.custom, consentSources)\n\t\t}\n\t\tregisterTranslations(config, options.translations)\n\t\tregisterCollections({\n\t\t\tconfig,\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tconsentSnapshot: options.consent?.snapshot ?? 'both',\n\t\t\tactionRegistry,\n\t\t\trichText: options.richText,\n\t\t\thasJobsPlugin: Boolean(plugins['@10x-media/jobs']),\n\t\t\tevents: options.events,\n\t\t\tuploads,\n\t\t\tspam,\n\t\t\tshowSubmissionRawFields: options.showSubmissionRawFields ?? false,\n\t\t\tlocalizeContent,\n\t\t\tresultsAccess: options.results?.access,\n\t\t\tvotedCookie: options.poll?.votedCookie === true,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields: options.poll?.outcomeFields,\n\t\t\tbuttons: options.buttons,\n\t\t\tresponse: options.response,\n\t\t\tfromAddresses,\n\t\t\tdepartments,\n\t\t\tredirectRelationships: options.redirectRelationships,\n\t\t\toverrides: options.overrides,\n\t\t})\n\t\treturn config\n\t},\n})\n\nexport type {\n\tBodyConverter,\n\tBodyConverterArgs,\n\tBodyRender,\n} from './actions/body/converters'\nexport { defaultBodyConverters, sanitizeUrl } from './actions/body/converters'\nexport { escapeHtml } from './actions/body/escapeHtml'\nexport type {\n\tBodyContext,\n\tRichTextBodyOption,\n\tSerializeBodyArgs,\n} from './actions/body/serializeBody'\nexport { serializeBody } from './actions/body/serializeBody'\nexport { textOfBody } from './actions/body/textOfBody'\nexport { renderAllValues, renderAllValuesTable } from './actions/body/wildcards'\nexport { buildDefaultActionDefinitions, defaultActionDefinitions } from './actions/builtin'\nexport type { ActionDefinition, ActionRunArgs, AnyActionDefinition } from './actions/defineAction'\nexport { defineAction } from './actions/defineAction'\nexport type { FromAddressesResolver, FromAddressOption } from './actions/fromAddresses'\nexport type { ActionOption, ActionRegistry, ActionsConfig } from './actions/registry'\nexport { resolveActions } from './actions/registry'\nexport type { ActionResult } from './actions/runActions'\nexport { SIGNATURE_HEADER, signPayload } from './actions/sign'\nexport type {\n\tAggregateFieldResponsesArgs,\n\tAggregateFormResponsesArgs,\n} from './aggregation/aggregateResponses'\nexport {\n\taggregateFieldResponses,\n\taggregateFormResponses,\n\tfieldHasOptions,\n} from './aggregation/aggregateResponses'\nexport { aggregateRowForField, aggregateRowsForFields } from './aggregation/aggregateRows'\nexport type {\n\tFormResultsAccess,\n\tFormResultsAccessArgs,\n\tResolveResultsRequestArgs,\n\tResolveResultsRequestResult,\n} from './aggregation/resolveResultsRequest'\nexport { resolveFormResultsRequest } from './aggregation/resolveResultsRequest'\nexport type {\n\tAggregationBucket,\n\tAggregationRow,\n\tFieldAggregation,\n\tFieldMeta,\n\tSubmissionStatusFilter,\n} from './aggregation/types'\nexport { calcExpressionOf, computeCalcFields } from './calc/computeCalcFields'\nexport { evaluateCalc } from './calc/evaluate'\nexport { normalizeCalc } from './calc/normalizeCalc'\nexport type { CalcExpression } from './calc/types'\nexport type {\n\tButtonFieldsOverride,\n\tButtonsOption,\n\tDefaultButtonFields,\n} from './collections/buttonFields'\nexport {\n\tbuildDefaultButtonFields,\n\tbuildNextLabelField,\n\tbuildPrevLabelField,\n\tbuildSubmitLabelField,\n} from './collections/buttonFields'\nexport type {\n\tRedirectFieldsOverride,\n\tRedirectOption,\n\tResponseOption,\n} from './collections/redirectFields'\nexport { evaluateCondition } from './conditions/evaluate'\nexport type { FieldCondition } from './conditions/types'\nexport { applyConsentStatements } from './consent/applyConsentStatements'\nexport type { ConsentProof, ConsentSnapshotMode } from './consent/captureConsent'\nexport { captureConsent } from './consent/captureConsent'\nexport type { ConsentSourcesFieldOptions } from './consent/consentSourcesField'\nexport { consentSourcesField } from './consent/consentSourcesField'\nexport type { ResolveConsentEntriesArgs } from './consent/resolveConsentEntries'\nexport { resolveConsentEntries } from './consent/resolveConsentEntries'\nexport type {\n\tConsentSourceOption,\n\tResolveConsentSourcesRequestArgs,\n\tResolveConsentSourcesRequestResult,\n} from './consent/resolveConsentSourcesRequest'\nexport { resolveConsentSourcesRequest } from './consent/resolveConsentSourcesRequest'\nexport type {\n\tConsentStatement,\n\tConsentStatements,\n\tResolveConsentStatementsArgs,\n} from './consent/resolveConsentStatements'\nexport { resolveConsentStatements } from './consent/resolveConsentStatements'\nexport type { ResolvePublishedVersionRefArgs } from './consent/resolvePublishedVersionRef'\nexport { resolvePublishedVersionRef } from './consent/resolvePublishedVersionRef'\nexport type {\n\tConsentSourceEntry,\n\tConsentSourcePage,\n\tConsentSourcesResolver,\n} from './consent/types'\nexport type {\n\tDepartmentEmailsResolver,\n\tDepartmentOption,\n\tResolveDepartmentOptionsArgs,\n\tResolveDepartmentsRequestArgs,\n\tResolveDepartmentsRequestResult,\n} from './email/departments'\nexport { resolveDepartmentOptions } from './email/departments'\nexport type { DepartmentsFieldOptions } from './email/departmentsField'\nexport { departmentsField } from './email/departmentsField'\nexport {\n\tbuildDefaultFieldDefinitions,\n\tdefaultFieldDefinitions,\n\tdefaultFieldDefinitionsByType,\n} from './fields/builtin'\nexport { countryField } from './fields/builtin/country'\nexport { fileMimeTypeOptions } from './fields/builtin/file'\nexport { stateField } from './fields/builtin/state'\nexport { defineFormField } from './fields/defineFormField'\nexport { fieldKey } from './fields/fieldKey'\nexport { localizedIf } from './fields/localizedIf'\nexport type { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from './fields/registry'\nexport type {\n\tAnyFormFieldDefinition,\n\tFormFieldDefinition,\n\tFormFieldFormat,\n\tFormFieldValidate,\n\tFormFieldValueKind,\n\tOmittableSharedField,\n\tResolveFieldOptionsArgs,\n} from './fields/types'\nexport { isPollClosed } from './form/pollState'\nexport type { ToFormDocumentOptions } from './form/toFormDocument'\nexport { toFormDocument } from './form/toFormDocument'\nexport type {\n\tFormButtonSettings,\n\tFormDocument,\n\tFormPollSettings,\n\tFormResponseSettings,\n} from './form/types'\nexport type { UploadsOption } from './plugin/uploadsCollection'\nexport type { PollCloseTaskInput } from './poll/closeJob'\nexport {\n\tbuildPollCloseTask,\n\tenqueuePollClose,\n\tPOLL_CLOSE_TASK_SLUG,\n\tregisterPollCloseTask,\n\trunPollClose,\n\tshouldAutoResolvePoll,\n} from './poll/closeJob'\nexport type {\n\tAnyPollOptionSource,\n\tPollOption,\n\tPollOptionResolveArgs,\n\tPollOptionSource,\n} from './poll/definePollOptionSource'\nexport { definePollOptionSource } from './poll/definePollOptionSource'\nexport type { PollOutcomeStrategy, PollOutcomeStrategyArgs } from './poll/definePollType'\nexport { definePollType } from './poll/definePollType'\nexport type { ResolveEffectivePollOptionsArgs } from './poll/effectivePollOptions'\nexport { resolveEffectivePollOptions } from './poll/effectivePollOptions'\nexport { mostVotedStrategy, topBucketValues } from './poll/mostVoted'\nexport type { DefaultOutcomeFields, OutcomeFieldsOverride } from './poll/outcomeFields'\nexport {\n\tbuildDefaultOutcomeFields,\n\tbuildResolvedAtField,\n\tbuildWinningValuesField,\n} from './poll/outcomeFields'\nexport type { PollTypeRegistry, PollTypesConfig } from './poll/pollTypeRegistry'\nexport {\n\tmanualStrategy,\n\tpollTypesOf,\n\tresolvePollTypes,\n\tsourceStrategy,\n\tstashPollTypes,\n} from './poll/pollTypeRegistry'\nexport type {\n\tPollOptionSourceOption,\n\tPollOptionSourceRegistry,\n\tPollOptionSourcesConfig,\n} from './poll/registry'\nexport { resolvePollOptionSources } from './poll/registry'\nexport type { ResolvePollOptionsArgs } from './poll/resolvePollOptions'\nexport { resolvePollOptions } from './poll/resolvePollOptions'\nexport type { ResolvePollOutcomeArgs } from './poll/resolvePollOutcome'\nexport { resolvePollOutcome } from './poll/resolvePollOutcome'\nexport type { PrefillOptions } from './prefill/valuesFromSearchParams'\nexport { valuesFromSearchParams } from './prefill/valuesFromSearchParams'\nexport { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from './presentations/defaults'\nexport type {\n\tPresentationDensity,\n\tPresentationDescriptor,\n\tPresentationSurface,\n} from './presentations/types'\nexport { interpolate } from './recall/interpolate'\nexport type { RecallResolver } from './recall/resolver'\nexport { buildRecallResolver, optionLabelsFor } from './recall/resolver'\nexport { defineCaptchaProvider } from './spam/captcha'\nexport { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from './spam/constants'\nexport { defaultIdentify } from './spam/identify'\nexport type { HcaptchaProviderOptions } from './spam/providers/hcaptcha'\nexport { hcaptchaProvider } from './spam/providers/hcaptcha'\nexport type { RecaptchaProviderOptions } from './spam/providers/recaptcha'\nexport { recaptchaProvider } from './spam/providers/recaptcha'\nexport type { TurnstileProviderOptions } from './spam/providers/turnstile'\nexport { turnstileProvider } from './spam/providers/turnstile'\nexport { createKvRateLimiter } from './spam/rateLimiter'\nexport { resolveSpamConfig } from './spam/resolveSpam'\nexport type {\n\tCaptchaProvider,\n\tCaptchaVerifyArgs,\n\tIdentifyFn,\n\tRateLimitCheckArgs,\n\tRateLimitConfig,\n\tRateLimiter,\n\tRateLimitResult,\n\tSpamConfig,\n\tSpamMetadataConfig,\n\tSpamOption,\n} from './spam/types'\nexport type { CreatedSubmission, CreateSubmissionArgs } from './submissions/createSubmission'\nexport { createSubmission } from './submissions/createSubmission'\nexport { hasVotedCookie, votedCookieName } from './submissions/votedCookie'\nexport { captureFileRef } from './uploads/captureFileRef'\nexport { formatBytes } from './uploads/formatBytes'\nexport { resolveFileRef } from './uploads/resolveFileRef'\nexport type { FileFieldConfig, FileRef, FileRefError } from './uploads/types'\nexport { defaultValidationRules, defaultValidationRulesByType } from './validation/builtin'\nexport { defineValidationRule } from './validation/defineValidationRule'\nexport type { FieldTargetParamOptions } from './validation/fieldTargetParam'\nexport { fieldTargetParam } from './validation/fieldTargetParam'\nexport type {\n\tValidationRuleOption,\n\tValidationRuleRegistry,\n\tValidationRulesConfig,\n} from './validation/registry'\nexport type {\n\tAnyValidationRuleDefinition,\n\tValidationRuleDefinition,\n\tValidationRuleResult,\n} from './validation/types'\nexport type { FormBuilderPluginOptions as PluginOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwOA,MAAa,cAAc,aAAuC;CACjE,MAAM;CACN,OAAO;CACP,SAAS,EAAE,QAAQ,SAAS,GAAG,cAAsB;EACpD,IAAI,QAAQ,aAAa,MACxB,OAAO;EAER,MAAM,kBAAkB,QAAQ,oBAAoB;EACpD,MAAM,UAAU,QAAQ,WAAW;EAInC,MAAM,kBACL,YAAY,QACT,KAAA,IACC,QAAQ,aAAa,8BAA8B,QAAQ,QAAQ,UAAU;EAClF,MAAM,iBAAiB,QAAQ,SAAS;EAcxC,MAAM,WAAW,kBATe,6BAC/B,iBACA,QAAQ,UAAU,QAClB,eACD,EAAE,QACA,gBACC,YAAY,SAAS,WAAW,SAAS,YACzC,mBAAmB,KAAA,KAAa,WAAW,SAAS,UAEE,GAAG,QAAQ,MAAM;EAC1E,MAAM,eAAe,uBAAuB,wBAAwB,QAAQ,KAAK;EACjF,MAAM,gBAAgB,QAAQ,OAAO;EACrC,MAAM,cAAc,QAAQ,OAAO;EACnC,MAAM,iBAAiB,eACtB,8BACC,iBACA,QAAQ,UAAU,cAAc,QAAQ,UAAU,QAClD,eACA,aACA,QAAQ,OAAO,UAChB,GACA,QAAQ,OACT;EACA,MAAM,OAAO,kBAAkB,QAAQ,IAAI;EAC3C,MAAM,qBAAqB,yBAAyB,QAAQ,MAAM,OAAO;EACzE,MAAM,mBAAmB,iBAAiB,QAAQ,MAAM,KAAK;EAM7D,OAAO,SAAS,uBAAuB,OAAO,QAAQ,kBAAkB;EACxE,OAAO,SAAS,eAAe,OAAO,QAAQ,gBAAgB;EAC9D,OAAO,SAAS,gBAAgB,OAAO,QAAQ,QAAQ;EACvD,IAAI,gBACH,OAAO,SAAS,oBAAoB,OAAO,QAAQ,cAAc;EAElE,qBAAqB,QAAQ,QAAQ,YAAY;EACjD,oBAAoB;GACnB;GACA;GACA;GACA;GACA,iBAAiB,QAAQ,SAAS,YAAY;GAC9C;GACA,UAAU,QAAQ;GAClB,eAAe,QAAQ,QAAQ,kBAAkB;GACjD,QAAQ,QAAQ;GAChB;GACA;GACA,yBAAyB,QAAQ,2BAA2B;GAC5D;GACA,eAAe,QAAQ,SAAS;GAChC,aAAa,QAAQ,MAAM,gBAAgB;GAC3C;GACA;GACA,eAAe,QAAQ,MAAM;GAC7B,SAAS,QAAQ;GACjB,UAAU,QAAQ;GAClB;GACA;GACA,uBAAuB,QAAQ;GAC/B,WAAW,QAAQ;EACpB,CAAC;EACD,OAAO;CACR;AACD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/plugin/customState.ts
|
|
2
|
+
/** Root key under `config.custom` where the plugin stashes runtime state for root-level helpers. */
|
|
3
|
+
const CUSTOM_KEY = "@10x-media/form-builder";
|
|
4
|
+
/**
|
|
5
|
+
* Merge `patch` into the plugin's slice of `config.custom`, leaving every other key untouched.
|
|
6
|
+
* Root-level helpers (`resolvePollOptions`, `resolveConsentStatements`) are called by hosts with a
|
|
7
|
+
* `payload` instance and no plugin state, so the plugin parks what they need on the config at boot
|
|
8
|
+
* and they read it back through `payload.config`. Both readers share one key, so the plugin's slice
|
|
9
|
+
* is patched rather than replaced.
|
|
10
|
+
*/
|
|
11
|
+
const stashCustomState = (custom, patch) => {
|
|
12
|
+
const existing = custom?.[CUSTOM_KEY] != null && typeof custom[CUSTOM_KEY] === "object" ? custom[CUSTOM_KEY] : {};
|
|
13
|
+
return {
|
|
14
|
+
...custom ?? {},
|
|
15
|
+
[CUSTOM_KEY]: {
|
|
16
|
+
...existing,
|
|
17
|
+
...patch
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/** The plugin's slice of `payload.config.custom`, or an empty object when the plugin never booted. */
|
|
22
|
+
const customStateOf = (payload) => payload.config.custom?.[CUSTOM_KEY] ?? {};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { customStateOf, stashCustomState };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=customState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customState.js","names":[],"sources":["../../src/plugin/customState.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\n/** Root key under `config.custom` where the plugin stashes runtime state for root-level helpers. */\nconst CUSTOM_KEY = '@10x-media/form-builder'\n\n/**\n * Merge `patch` into the plugin's slice of `config.custom`, leaving every other key untouched.\n * Root-level helpers (`resolvePollOptions`, `resolveConsentStatements`) are called by hosts with a\n * `payload` instance and no plugin state, so the plugin parks what they need on the config at boot\n * and they read it back through `payload.config`. Both readers share one key, so the plugin's slice\n * is patched rather than replaced.\n */\nexport const stashCustomState = <TState extends Record<string, unknown>>(\n\tcustom: Record<string, unknown> | undefined,\n\tpatch: TState\n): Record<string, unknown> => {\n\tconst existing =\n\t\tcustom?.[CUSTOM_KEY] != null && typeof custom[CUSTOM_KEY] === 'object'\n\t\t\t? (custom[CUSTOM_KEY] as Record<string, unknown>)\n\t\t\t: {}\n\treturn { ...(custom ?? {}), [CUSTOM_KEY]: { ...existing, ...patch } }\n}\n\n/** The plugin's slice of `payload.config.custom`, or an empty object when the plugin never booted. */\nexport const customStateOf = <TState extends Record<string, unknown>>(\n\tpayload: Payload\n): Partial<TState> => (payload.config.custom?.[CUSTOM_KEY] as Partial<TState> | undefined) ?? {}\n"],"mappings":";;AAGA,MAAM,aAAa;;;;;;;;AASnB,MAAa,oBACZ,QACA,UAC6B;CAC7B,MAAM,WACL,SAAS,eAAe,QAAQ,OAAO,OAAO,gBAAgB,WAC1D,OAAO,cACR,CAAC;CACL,OAAO;EAAE,GAAI,UAAU,CAAC;GAAK,aAAa;GAAE,GAAG;GAAU,GAAG;EAAM;CAAE;AACrE;;AAGA,MAAa,iBACZ,YACsB,QAAQ,OAAO,SAAS,eAA+C,CAAC"}
|