@10x-media/form-builder 0.1.0-beta.9 → 4.0.0-alpha.2
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 +185 -0
- package/README.md +12 -4
- package/dist/actions/assertNoBlockCollision.js +18 -0
- package/dist/actions/assertNoBlockCollision.js.map +1 -0
- package/dist/actions/body/serializeBody.d.ts +16 -14
- package/dist/actions/body/serializeBody.js +5 -8
- package/dist/actions/body/serializeBody.js.map +1 -1
- package/dist/actions/builtin/confirmation.js +2 -1
- package/dist/actions/builtin/confirmation.js.map +1 -1
- package/dist/actions/builtin/emailAction.d.ts +15 -3
- package/dist/actions/builtin/emailAction.js +72 -20
- package/dist/actions/builtin/emailAction.js.map +1 -1
- package/dist/actions/builtin/emailTeam.js +11 -5
- package/dist/actions/builtin/emailTeam.js.map +1 -1
- package/dist/actions/defineAction.d.ts +37 -6
- package/dist/actions/defineAction.js +14 -1
- package/dist/actions/defineAction.js.map +1 -1
- package/dist/actions/dispatch.d.ts +12 -0
- package/dist/actions/dispatch.js +103 -30
- package/dist/actions/dispatch.js.map +1 -1
- package/dist/actions/dispatchContext.js +19 -0
- package/dist/actions/dispatchContext.js.map +1 -0
- package/dist/actions/emailRecipients.js +38 -8
- package/dist/actions/emailRecipients.js.map +1 -1
- package/dist/actions/emailRender.d.ts +27 -0
- package/dist/actions/fromAddresses.d.ts +19 -1
- package/dist/actions/fromAddresses.js +66 -9
- package/dist/actions/fromAddresses.js.map +1 -1
- package/dist/actions/recipientSources.d.ts +23 -0
- package/dist/actions/recipientSources.js +11 -0
- package/dist/actions/recipientSources.js.map +1 -0
- package/dist/actions/registry.js +3 -1
- package/dist/actions/registry.js.map +1 -1
- package/dist/actions/runActions.d.ts +2 -0
- package/dist/actions/runActions.js +13 -8
- package/dist/actions/runActions.js.map +1 -1
- package/dist/actions/sign.js.map +1 -1
- package/dist/actions/submissionContext.d.ts +34 -0
- package/dist/actions/task.js +43 -16
- package/dist/actions/task.js.map +1 -1
- package/dist/aggregation/aggregateResponses.js +3 -4
- package/dist/aggregation/aggregateResponses.js.map +1 -1
- package/dist/aggregation/resolveResultsRequest.d.ts +6 -0
- package/dist/aggregation/resolveResultsRequest.js +69 -26
- package/dist/aggregation/resolveResultsRequest.js.map +1 -1
- package/dist/calc/computeCalcFields.d.ts +5 -3
- package/dist/calc/computeCalcFields.js +4 -3
- package/dist/calc/computeCalcFields.js.map +1 -1
- package/dist/calc/evaluate.d.ts +26 -3
- package/dist/calc/evaluate.js +33 -11
- package/dist/calc/evaluate.js.map +1 -1
- package/dist/calc/formatCalc.d.ts +11 -0
- package/dist/calc/formatCalc.js +35 -0
- package/dist/calc/formatCalc.js.map +1 -0
- package/dist/calc/formatCalcValue.d.ts +17 -0
- package/dist/calc/formatCalcValue.js +17 -0
- package/dist/calc/formatCalcValue.js.map +1 -0
- package/dist/calc/normalizeCalc.d.ts +17 -3
- package/dist/calc/normalizeCalc.js +39 -17
- package/dist/calc/normalizeCalc.js.map +1 -1
- package/dist/calc/registry.d.ts +43 -0
- package/dist/calc/registry.js +27 -0
- package/dist/calc/registry.js.map +1 -0
- package/dist/calc/resolveCalcContext.d.ts +36 -0
- package/dist/calc/resolveCalcContext.js +87 -0
- package/dist/calc/resolveCalcContext.js.map +1 -0
- package/dist/calc/types.d.ts +19 -4
- package/dist/calc/types.js +3 -2
- package/dist/calc/types.js.map +1 -1
- package/dist/client/ByteSizeField.js +11 -8
- package/dist/client/ByteSizeField.js.map +1 -1
- package/dist/client/CalcExpressionBuilder.d.ts +20 -0
- package/dist/client/CalcExpressionBuilder.js +888 -0
- package/dist/client/CalcExpressionBuilder.js.map +1 -0
- package/dist/client/ClosePollButton.js +3 -3
- package/dist/client/ClosePollButton.js.map +1 -1
- package/dist/client/CondensedArray.d.ts +2 -2
- package/dist/client/CondensedArray.js +5 -7
- package/dist/client/CondensedArray.js.map +1 -1
- package/dist/client/ConditionBuilder.js +5 -7
- package/dist/client/ConditionBuilder.js.map +1 -1
- package/dist/client/ConditionRow.js +3 -3
- package/dist/client/ConditionRow.js.map +1 -1
- package/dist/client/ConsentBlockLabel.js +2 -2
- package/dist/client/ConsentBlockLabel.js.map +1 -1
- package/dist/client/ConsentRetentionNotice.d.ts +11 -0
- package/dist/client/ConsentRetentionNotice.js +23 -0
- package/dist/client/ConsentRetentionNotice.js.map +1 -0
- package/dist/client/EndpointOptionsSelect.d.ts +17 -7
- package/dist/client/EndpointOptionsSelect.js +18 -14
- package/dist/client/EndpointOptionsSelect.js.map +1 -1
- package/dist/client/FieldBlockLabel.js +2 -2
- package/dist/client/FieldBlockLabel.js.map +1 -1
- package/dist/client/FieldNameSelect.d.ts +1 -0
- package/dist/client/FieldNameSelect.js +2 -4
- package/dist/client/FieldNameSelect.js.map +1 -1
- package/dist/client/FlowBuilder.js +31 -23
- package/dist/client/FlowBuilder.js.map +1 -1
- package/dist/client/FormConditionField.js +0 -1
- package/dist/client/FormConditionField.js.map +1 -1
- package/dist/client/RecipientsSelect.d.ts +9 -2
- package/dist/client/RecipientsSelect.js +31 -10
- package/dist/client/RecipientsSelect.js.map +1 -1
- package/dist/client/admin.css +345 -72
- package/dist/client/endpointOptions.d.ts +11 -0
- package/dist/client/endpointOptions.js +17 -8
- package/dist/client/endpointOptions.js.map +1 -1
- package/dist/collections/formSubmissions.js +145 -51
- package/dist/collections/formSubmissions.js.map +1 -1
- package/dist/collections/forms.js +170 -65
- package/dist/collections/forms.js.map +1 -1
- package/dist/collections/formsEndpoints.js +31 -26
- package/dist/collections/formsEndpoints.js.map +1 -1
- package/dist/collections/settingsFields.d.ts +32 -0
- package/dist/collections/settingsFields.js +55 -0
- package/dist/collections/settingsFields.js.map +1 -0
- package/dist/consent/captureConsent.d.ts +2 -1
- package/dist/consent/captureConsent.js +4 -1
- package/dist/consent/captureConsent.js.map +1 -1
- package/dist/consent/consentSourcesField.d.ts +7 -1
- package/dist/consent/consentSourcesField.js +15 -1
- package/dist/consent/consentSourcesField.js.map +1 -1
- package/dist/consent/effectiveStatement.js +16 -0
- package/dist/consent/effectiveStatement.js.map +1 -0
- package/dist/consent/resolveConsentSourcesRequest.js +2 -2
- package/dist/consent/resolveConsentSourcesRequest.js.map +1 -1
- package/dist/consent/resolveConsentStatements.js +3 -1
- package/dist/consent/resolveConsentStatements.js.map +1 -1
- package/dist/consent/resolvePublishedVersionRef.js +1 -0
- package/dist/consent/resolvePublishedVersionRef.js.map +1 -1
- package/dist/consent/types.d.ts +8 -0
- package/dist/context/formContext.d.ts +30 -0
- package/dist/context/formContext.js +54 -0
- package/dist/context/formContext.js.map +1 -0
- package/dist/email/departmentsField.d.ts +6 -1
- package/dist/email/departmentsField.js +6 -1
- package/dist/email/departmentsField.js.map +1 -1
- package/dist/exports/client.d.ts +3 -1
- package/dist/exports/client.js +3 -1
- package/dist/exports/i18n.d.ts +14 -2
- package/dist/exports/i18n.js +14 -2
- package/dist/exports/react.d.ts +23 -5
- package/dist/exports/react.js +17 -1
- package/dist/exports/rsc.d.ts +4 -1
- package/dist/exports/rsc.js +7 -4
- package/dist/exports/shared.d.ts +21 -0
- package/dist/exports/shared.js +18 -0
- package/dist/exports/types.d.ts +4 -3
- package/dist/fields/buildFieldBlocks.js +2 -1
- package/dist/fields/buildFieldBlocks.js.map +1 -1
- package/dist/fields/builtin/calculation.d.ts +17 -0
- package/dist/fields/builtin/calculation.js +70 -127
- package/dist/fields/builtin/calculation.js.map +1 -1
- package/dist/fields/builtin/checkbox.js +15 -0
- package/dist/fields/builtin/checkbox.js.map +1 -1
- package/dist/fields/builtin/consent.js +21 -1
- package/dist/fields/builtin/consent.js.map +1 -1
- package/dist/fields/builtin/email.js +7 -0
- package/dist/fields/builtin/email.js.map +1 -1
- package/dist/fields/builtin/index.d.ts +6 -2
- package/dist/fields/builtin/index.js +9 -4
- package/dist/fields/builtin/index.js.map +1 -1
- package/dist/fields/builtin/select.js +20 -1
- package/dist/fields/builtin/select.js.map +1 -1
- package/dist/fields/builtin/text.js +7 -0
- package/dist/fields/builtin/text.js.map +1 -1
- package/dist/fields/instanceOptions.js +1 -1
- package/dist/fields/instanceOptions.js.map +1 -1
- package/dist/fields/sharedConfig.js +15 -11
- package/dist/fields/sharedConfig.js.map +1 -1
- package/dist/fields/types.d.ts +8 -2
- package/dist/form/findFormAtLocale.d.ts +30 -0
- package/dist/form/findFormAtLocale.js +88 -0
- package/dist/form/findFormAtLocale.js.map +1 -0
- package/dist/form/pollState.d.ts +2 -1
- package/dist/form/pollState.js.map +1 -1
- package/dist/form/toFormDocument.d.ts +18 -6
- package/dist/form/toFormDocument.js +3 -1
- package/dist/form/toFormDocument.js.map +1 -1
- package/dist/form/types.d.ts +9 -1
- package/dist/index.d.ts +29 -7
- package/dist/index.js +74 -18
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +119 -4
- package/dist/plugin/collectionSlugs.d.ts +28 -0
- package/dist/plugin/collectionSlugs.js +65 -0
- package/dist/plugin/collectionSlugs.js.map +1 -0
- package/dist/plugin/customState.js +1 -1
- package/dist/plugin/customState.js.map +1 -1
- package/dist/plugin/registerCollections.js +38 -21
- package/dist/plugin/registerCollections.js.map +1 -1
- package/dist/poll/closeJob.d.ts +4 -3
- package/dist/poll/closeJob.js +13 -10
- package/dist/poll/closeJob.js.map +1 -1
- package/dist/poll/outcomeBeforeChange.js +2 -2
- package/dist/poll/outcomeBeforeChange.js.map +1 -1
- package/dist/poll/pollTypeRegistry.js +1 -1
- package/dist/poll/resolvePollCloseRequest.js +5 -4
- package/dist/poll/resolvePollCloseRequest.js.map +1 -1
- package/dist/poll/resolvePollOptionsRequest.js +2 -2
- package/dist/poll/resolvePollOptionsRequest.js.map +1 -1
- package/dist/poll/resolvePollOutcome.d.ts +6 -0
- package/dist/poll/resolvePollOutcome.js +20 -6
- package/dist/poll/resolvePollOutcome.js.map +1 -1
- package/dist/poll/votes/aggregateFromVotes.d.ts +27 -0
- package/dist/poll/votes/aggregateFromVotes.js +55 -0
- package/dist/poll/votes/aggregateFromVotes.js.map +1 -0
- package/dist/poll/votes/answerValues.js +16 -0
- package/dist/poll/votes/answerValues.js.map +1 -0
- package/dist/poll/votes/bumpPollVote.js +91 -0
- package/dist/poll/votes/bumpPollVote.js.map +1 -0
- package/dist/poll/votes/recountPollVotes.d.ts +20 -0
- package/dist/poll/votes/recountPollVotes.js +63 -0
- package/dist/poll/votes/recountPollVotes.js.map +1 -0
- package/dist/poll/votes/voteTallyHook.js +76 -0
- package/dist/poll/votes/voteTallyHook.js.map +1 -0
- package/dist/poll/votes/votesCollection.d.ts +23 -0
- package/dist/poll/votes/votesCollection.js +96 -0
- package/dist/poll/votes/votesCollection.js.map +1 -0
- package/dist/react/Form.d.ts +49 -7
- package/dist/react/Form.js +48 -13
- package/dist/react/Form.js.map +1 -1
- package/dist/react/FormContext.d.ts +8 -1
- package/dist/react/FormContext.js.map +1 -1
- package/dist/react/FormResults.d.ts +4 -2
- package/dist/react/FormResults.js +21 -8
- package/dist/react/FormResults.js.map +1 -1
- package/dist/react/Poll.d.ts +25 -2
- package/dist/react/Poll.js +76 -25
- package/dist/react/Poll.js.map +1 -1
- package/dist/react/adapters.d.ts +35 -0
- package/dist/react/adapters.js +11 -0
- package/dist/react/adapters.js.map +1 -0
- package/dist/react/captcha/HcaptchaCaptcha.d.ts +4 -1
- package/dist/react/captcha/HcaptchaCaptcha.js +2 -2
- package/dist/react/captcha/HcaptchaCaptcha.js.map +1 -1
- package/dist/react/captcha/RecaptchaCaptcha.d.ts +4 -1
- package/dist/react/captcha/RecaptchaCaptcha.js +2 -2
- package/dist/react/captcha/RecaptchaCaptcha.js.map +1 -1
- package/dist/react/captcha/TurnstileCaptcha.d.ts +4 -1
- package/dist/react/captcha/TurnstileCaptcha.js +2 -2
- package/dist/react/captcha/TurnstileCaptcha.js.map +1 -1
- package/dist/react/captcha/useCaptchaScript.js +23 -5
- package/dist/react/captcha/useCaptchaScript.js.map +1 -1
- package/dist/react/fetchResults.d.ts +6 -3
- package/dist/react/fetchResults.js +10 -5
- package/dist/react/fetchResults.js.map +1 -1
- package/dist/react/primitives/Checkbox.d.ts +4 -2
- package/dist/react/primitives/Checkbox.js +3 -2
- package/dist/react/primitives/Checkbox.js.map +1 -1
- package/dist/react/primitives/ChoiceGroup.d.ts +40 -0
- package/dist/react/primitives/ChoiceGroup.js +33 -0
- package/dist/react/primitives/ChoiceGroup.js.map +1 -0
- package/dist/react/primitives/FieldShell.d.ts +11 -1
- package/dist/react/primitives/FieldShell.js +43 -33
- package/dist/react/primitives/FieldShell.js.map +1 -1
- package/dist/react/primitives/Input.d.ts +3 -1
- package/dist/react/primitives/Input.js +2 -1
- package/dist/react/primitives/Input.js.map +1 -1
- package/dist/react/renderers/calculation.js +6 -1
- package/dist/react/renderers/calculation.js.map +1 -1
- package/dist/react/renderers/checkbox.js +2 -1
- package/dist/react/renderers/checkbox.js.map +1 -1
- package/dist/react/renderers/consent.js +8 -3
- package/dist/react/renderers/consent.js.map +1 -1
- package/dist/react/renderers/email.js +3 -1
- package/dist/react/renderers/email.js.map +1 -1
- package/dist/react/renderers/repeater.js +5 -0
- package/dist/react/renderers/repeater.js.map +1 -1
- package/dist/react/renderers/select.js +20 -2
- package/dist/react/renderers/select.js.map +1 -1
- package/dist/react/renderers/text.js +3 -1
- package/dist/react/renderers/text.js.map +1 -1
- package/dist/react/state.d.ts +10 -0
- package/dist/react/state.js +45 -1
- package/dist/react/state.js.map +1 -1
- package/dist/react/submitForm.d.ts +20 -3
- package/dist/react/submitForm.js +8 -4
- package/dist/react/submitForm.js.map +1 -1
- package/dist/react/useCalcValues.d.ts +10 -0
- package/dist/react/useCalcValues.js +13 -0
- package/dist/react/useCalcValues.js.map +1 -0
- package/dist/react/useField.js +2 -1
- package/dist/react/useField.js.map +1 -1
- package/dist/recall/resolver.js +1 -1
- package/dist/recall/resolver.js.map +1 -1
- package/dist/spam/constants.js +7 -1
- package/dist/spam/constants.js.map +1 -1
- package/dist/spam/spamGuard.js +2 -1
- package/dist/spam/spamGuard.js.map +1 -1
- package/dist/submissions/SubmissionAnswersClient.js +14 -14
- package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
- package/dist/submissions/createSubmission.d.ts +7 -1
- package/dist/submissions/createSubmission.js +10 -5
- package/dist/submissions/createSubmission.js.map +1 -1
- package/dist/submissions/formIdOf.js +13 -0
- package/dist/submissions/formIdOf.js.map +1 -0
- package/dist/submissions/resolveVotedSubmission.d.ts +27 -0
- package/dist/submissions/resolveVotedSubmission.js +51 -0
- package/dist/submissions/resolveVotedSubmission.js.map +1 -0
- package/dist/submissions/runSubmission.js +6 -5
- package/dist/submissions/runSubmission.js.map +1 -1
- package/dist/submissions/submissionLocale.js +39 -0
- package/dist/submissions/submissionLocale.js.map +1 -0
- package/dist/submissions/validateSubmission.js +125 -79
- package/dist/submissions/validateSubmission.js.map +1 -1
- package/dist/submissions/verifyContext.js +35 -0
- package/dist/submissions/verifyContext.js.map +1 -0
- package/dist/submissions/voteChange.js +21 -0
- package/dist/submissions/voteChange.js.map +1 -0
- package/dist/submissions/voteChangeEndpoint.js +110 -0
- package/dist/submissions/voteChangeEndpoint.js.map +1 -0
- package/dist/submissions/votedCookie.d.ts +10 -4
- package/dist/submissions/votedCookie.js +49 -11
- package/dist/submissions/votedCookie.js.map +1 -1
- package/dist/translations/ar.d.ts +7 -0
- package/dist/translations/ar.js +379 -0
- package/dist/translations/ar.js.map +1 -0
- package/dist/translations/clientRuntimeKeys.d.ts +17 -0
- package/dist/translations/clientRuntimeKeys.js +48 -0
- package/dist/translations/clientRuntimeKeys.js.map +1 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +78 -3
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +78 -3
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.d.ts +7 -0
- package/dist/translations/es.js +379 -0
- package/dist/translations/es.js.map +1 -0
- package/dist/translations/fr.d.ts +7 -0
- package/dist/translations/fr.js +379 -0
- package/dist/translations/fr.js.map +1 -0
- package/dist/translations/id.d.ts +7 -0
- package/dist/translations/id.js +379 -0
- package/dist/translations/id.js.map +1 -0
- package/dist/translations/index.d.ts +23 -6
- package/dist/translations/index.js +31 -6
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/keys.d.ts +76 -1
- package/dist/translations/keys.js +76 -1
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.d.ts +7 -0
- package/dist/translations/ko.js +379 -0
- package/dist/translations/ko.js.map +1 -0
- package/dist/translations/makeTranslate.d.ts +7 -3
- package/dist/translations/makeTranslate.js +12 -3
- package/dist/translations/makeTranslate.js.map +1 -1
- package/dist/translations/pt.d.ts +7 -0
- package/dist/translations/pt.js +379 -0
- package/dist/translations/pt.js.map +1 -0
- package/dist/translations/ru.d.ts +7 -0
- package/dist/translations/ru.js +379 -0
- package/dist/translations/ru.js.map +1 -0
- package/dist/translations/uk.d.ts +7 -0
- package/dist/translations/uk.js +379 -0
- package/dist/translations/uk.js.map +1 -0
- package/dist/translations/zh.d.ts +7 -0
- package/dist/translations/zh.js +379 -0
- package/dist/translations/zh.js.map +1 -0
- package/dist/validation/builtin/index.js +2 -0
- package/dist/validation/builtin/index.js.map +1 -1
- package/dist/validation/builtin/integer.js +15 -0
- package/dist/validation/builtin/integer.js.map +1 -0
- package/dist/validation/builtin/notAlreadySubmitted.js +5 -3
- package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -1
- package/package.json +29 -16
- package/styles/form-builder.css +84 -0
package/dist/index.js
CHANGED
|
@@ -1,46 +1,57 @@
|
|
|
1
|
+
import { assertNoActionBlockCollision } from "./actions/assertNoBlockCollision.js";
|
|
1
2
|
import { localizedIf } from "./fields/localizedIf.js";
|
|
2
3
|
import { interpolate } from "./recall/interpolate.js";
|
|
3
4
|
import { escapeHtml } from "./actions/body/escapeHtml.js";
|
|
4
5
|
import { defaultBodyConverters, sanitizeUrl } from "./actions/body/converters.js";
|
|
5
6
|
import { renderAllValues, renderAllValuesTable } from "./actions/body/wildcards.js";
|
|
6
7
|
import { serializeBody } from "./actions/body/serializeBody.js";
|
|
7
|
-
import { defineAction } from "./actions/defineAction.js";
|
|
8
|
+
import { ActionError, defineAction } from "./actions/defineAction.js";
|
|
8
9
|
import { SIGNATURE_HEADER, signPayload } from "./actions/sign.js";
|
|
9
10
|
import { buildDefaultActionDefinitions, defaultActionDefinitions } from "./actions/builtin/index.js";
|
|
10
11
|
import { resolveActions } from "./actions/registry.js";
|
|
12
|
+
import { assertNoCalcFunctionCollision, assertValidCalcSourceKeys, defineCalcFunction, defineCalcSource } from "./calc/registry.js";
|
|
11
13
|
import { resolveConsentEntries, stashConsentSources } from "./consent/resolveConsentEntries.js";
|
|
14
|
+
import { formatCalcValue } from "./calc/formatCalcValue.js";
|
|
12
15
|
import { normalizeCalc } from "./calc/normalizeCalc.js";
|
|
13
16
|
import { defineFormField } from "./fields/defineFormField.js";
|
|
14
17
|
import { resolveFileRef } from "./uploads/resolveFileRef.js";
|
|
15
18
|
import { fileMimeTypeOptions } from "./fields/builtin/file.js";
|
|
16
19
|
import { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
|
|
17
20
|
import { resolveFieldTypes, stashFieldTypes } from "./fields/registry.js";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
21
|
+
import { DEFAULT_COLLECTION_SLUGS, DEFAULT_VOTED_COOKIE_PREFIX, collectionSlugsOf, resolveCollectionSlugs, resolveVotedCookiePrefix, stashCollectionSlugs } from "./plugin/collectionSlugs.js";
|
|
22
|
+
import { stashFallbackLocale } from "./form/findFormAtLocale.js";
|
|
23
|
+
import { INLINE_DISPATCH_DEADLINE_MS } from "./actions/dispatch.js";
|
|
20
24
|
import { isPollClosed } from "./form/pollState.js";
|
|
25
|
+
import { POLL_VOTES_SLUG, RESPONDENTS_VALUE, VOTE_SHARDS } from "./poll/votes/votesCollection.js";
|
|
26
|
+
import { signFormContext, verifyFormContext } from "./context/formContext.js";
|
|
27
|
+
import { hasVotedCookie, votedCookieName } from "./submissions/votedCookie.js";
|
|
28
|
+
import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "./spam/constants.js";
|
|
21
29
|
import { fieldKey } from "./fields/fieldKey.js";
|
|
30
|
+
import { calcWeightKey, evaluateCalc } from "./calc/evaluate.js";
|
|
31
|
+
import { calcExpressionOf, computeCalcFields } from "./calc/computeCalcFields.js";
|
|
32
|
+
import { calcUsesSources, resolveCalcContext } from "./calc/resolveCalcContext.js";
|
|
33
|
+
import { resolvePollOptions, stashPollOptionSources } from "./poll/resolvePollOptions.js";
|
|
34
|
+
import { resolveEffectivePollOptions } from "./poll/effectivePollOptions.js";
|
|
35
|
+
import { evaluateCondition } from "./conditions/evaluate.js";
|
|
36
|
+
import { textOfBody } from "./actions/body/textOfBody.js";
|
|
37
|
+
import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
|
|
38
|
+
import { captureConsent } from "./consent/captureConsent.js";
|
|
39
|
+
import { captureFileRef } from "./uploads/captureFileRef.js";
|
|
40
|
+
import { resolveConsentStatements } from "./consent/resolveConsentStatements.js";
|
|
22
41
|
import { aggregateRowForField, aggregateRowsForFields } from "./aggregation/aggregateRows.js";
|
|
23
42
|
import { aggregateFieldResponses, aggregateFormResponses, fieldHasOptions } from "./aggregation/aggregateResponses.js";
|
|
24
43
|
import { definePollType } from "./poll/definePollType.js";
|
|
25
44
|
import { mostVotedStrategy, topBucketValues } from "./poll/mostVoted.js";
|
|
26
|
-
import { resolvePollOptions, stashPollOptionSources } from "./poll/resolvePollOptions.js";
|
|
27
45
|
import { manualStrategy, pollTypesOf, resolvePollTypes, sourceStrategy, stashPollTypes } from "./poll/pollTypeRegistry.js";
|
|
46
|
+
import { aggregateFromVotes } from "./poll/votes/aggregateFromVotes.js";
|
|
28
47
|
import { resolvePollOutcome } from "./poll/resolvePollOutcome.js";
|
|
29
48
|
import { POLL_CLOSE_TASK_SLUG, buildPollCloseTask, enqueuePollClose, registerPollCloseTask, runPollClose, shouldAutoResolvePoll } from "./poll/closeJob.js";
|
|
30
|
-
import { resolveEffectivePollOptions } from "./poll/effectivePollOptions.js";
|
|
31
49
|
import { buildDefaultOutcomeFields, buildResolvedAtField, buildWinningValuesField } from "./poll/outcomeFields.js";
|
|
32
50
|
import { buildDefaultButtonFields, buildNextLabelField, buildPrevLabelField, buildSubmitLabelField } from "./collections/buttonFields.js";
|
|
33
51
|
import { resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
|
|
34
52
|
import { resolveConsentSourcesRequest } from "./consent/resolveConsentSourcesRequest.js";
|
|
35
53
|
import { resolveDepartmentOptions } from "./email/departments.js";
|
|
36
|
-
import {
|
|
37
|
-
import { calcExpressionOf, computeCalcFields } from "./calc/computeCalcFields.js";
|
|
38
|
-
import { evaluateCondition } from "./conditions/evaluate.js";
|
|
39
|
-
import { textOfBody } from "./actions/body/textOfBody.js";
|
|
40
|
-
import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
|
|
41
|
-
import { captureConsent } from "./consent/captureConsent.js";
|
|
42
|
-
import { captureFileRef } from "./uploads/captureFileRef.js";
|
|
43
|
-
import { hasVotedCookie, votedCookieName } from "./submissions/votedCookie.js";
|
|
54
|
+
import { buildDefaultSettingsFields } from "./collections/settingsFields.js";
|
|
44
55
|
import { readUploadCollectionMimeTypes } from "./plugin/uploadsCollection.js";
|
|
45
56
|
import { registerCollections } from "./plugin/registerCollections.js";
|
|
46
57
|
import { registerTranslations } from "./plugin/registerTranslations.js";
|
|
@@ -52,6 +63,7 @@ import { defineValidationRule } from "./validation/defineValidationRule.js";
|
|
|
52
63
|
import { fieldTargetParam } from "./validation/fieldTargetParam.js";
|
|
53
64
|
import { defaultValidationRules, defaultValidationRulesByType } from "./validation/builtin/index.js";
|
|
54
65
|
import { resolveValidationRules } from "./validation/registry.js";
|
|
66
|
+
import { formatCalc } from "./calc/formatCalc.js";
|
|
55
67
|
import { applyConsentStatements } from "./consent/applyConsentStatements.js";
|
|
56
68
|
import { consentSourcesField } from "./consent/consentSourcesField.js";
|
|
57
69
|
import { departmentsField } from "./email/departmentsField.js";
|
|
@@ -59,6 +71,7 @@ import { countryField } from "./fields/builtin/country.js";
|
|
|
59
71
|
import { stateField } from "./fields/builtin/state.js";
|
|
60
72
|
import { toFormDocument } from "./form/toFormDocument.js";
|
|
61
73
|
import { definePollOptionSource } from "./poll/definePollOptionSource.js";
|
|
74
|
+
import { recountPollVotes } from "./poll/votes/recountPollVotes.js";
|
|
62
75
|
import { valuesFromSearchParams } from "./prefill/valuesFromSearchParams.js";
|
|
63
76
|
import { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from "./presentations/defaults.js";
|
|
64
77
|
import { buildRecallResolver, optionLabelsFor } from "./recall/resolver.js";
|
|
@@ -67,47 +80,76 @@ import { hcaptchaProvider } from "./spam/providers/hcaptcha.js";
|
|
|
67
80
|
import { recaptchaProvider } from "./spam/providers/recaptcha.js";
|
|
68
81
|
import { turnstileProvider } from "./spam/providers/turnstile.js";
|
|
69
82
|
import { createSubmission } from "./submissions/createSubmission.js";
|
|
83
|
+
import { resolveVotedSubmission } from "./submissions/resolveVotedSubmission.js";
|
|
70
84
|
import { formatBytes } from "./uploads/formatBytes.js";
|
|
71
85
|
import { definePlugin } from "payload";
|
|
72
86
|
//#region src/index.ts
|
|
73
|
-
const
|
|
87
|
+
const definition = definePlugin({
|
|
74
88
|
slug: "@10x-media/form-builder",
|
|
75
89
|
order: 50,
|
|
76
|
-
plugin: ({ config,
|
|
90
|
+
plugin: ({ config, options = {}, plugins }) => {
|
|
77
91
|
if (options.disabled === true) return config;
|
|
78
92
|
const localizeContent = options.localizeContent !== false;
|
|
79
93
|
const uploads = options.uploads ?? false;
|
|
94
|
+
const slugs = resolveCollectionSlugs(options);
|
|
95
|
+
const votedCookiePrefix = resolveVotedCookiePrefix(options.poll?.cookiePrefix);
|
|
96
|
+
const calcSources = options.calc?.sources ?? {};
|
|
97
|
+
const calcFunctions = options.calc?.functions ?? {};
|
|
98
|
+
assertNoCalcFunctionCollision(calcFunctions);
|
|
99
|
+
assertValidCalcSourceKeys(calcSources);
|
|
100
|
+
const calcAllowed = {
|
|
101
|
+
sources: new Set(Object.keys(calcSources)),
|
|
102
|
+
functions: new Set(Object.keys(calcFunctions))
|
|
103
|
+
};
|
|
104
|
+
const calcSourceMeta = Object.entries(calcSources).map(([key, source]) => ({
|
|
105
|
+
key,
|
|
106
|
+
label: source.label,
|
|
107
|
+
scalar: typeof source.resolve === "function",
|
|
108
|
+
weights: typeof source.resolveWeights === "function"
|
|
109
|
+
}));
|
|
80
110
|
const uploadMimeTypes = uploads === false ? void 0 : uploads.mimeTypes ?? readUploadCollectionMimeTypes(config, uploads.collection);
|
|
81
111
|
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);
|
|
112
|
+
const registry = resolveFieldTypes(buildDefaultFieldDefinitions(localizeContent, options.richText?.editor, uploadMimeTypes, calcAllowed, calcSourceMeta).filter((definition) => (uploads !== false || definition.type !== "file") && (consentSources !== void 0 || definition.type !== "consent")), options.fields);
|
|
83
113
|
const ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules);
|
|
84
114
|
const fromAddresses = options.email?.fromAddresses;
|
|
115
|
+
const fromSources = options.email?.fromSources;
|
|
85
116
|
const departments = options.email?.departments;
|
|
86
117
|
const actionRegistry = resolveActions(buildDefaultActionDefinitions({
|
|
87
118
|
localize: localizeContent,
|
|
88
119
|
editor: options.richText?.bodyEditor ?? options.richText?.editor,
|
|
89
120
|
fromAddresses,
|
|
121
|
+
fromSources,
|
|
90
122
|
departments,
|
|
91
|
-
|
|
123
|
+
localizeRecipients: options.email?.localizeRecipients,
|
|
124
|
+
recipients: options.email?.recipients,
|
|
125
|
+
recipientSources: options.email?.recipientSources,
|
|
126
|
+
render: options.email?.render
|
|
92
127
|
}), options.actions);
|
|
128
|
+
assertNoActionBlockCollision(config, actionRegistry);
|
|
93
129
|
const spam = resolveSpamConfig(options.spam);
|
|
94
130
|
const pollSourceRegistry = resolvePollOptionSources(options.poll?.sources);
|
|
95
131
|
const pollTypeRegistry = resolvePollTypes(options.poll?.types);
|
|
96
132
|
config.custom = stashPollOptionSources(config.custom, pollSourceRegistry);
|
|
97
133
|
config.custom = stashPollTypes(config.custom, pollTypeRegistry);
|
|
98
134
|
config.custom = stashFieldTypes(config.custom, registry);
|
|
135
|
+
config.custom = stashCollectionSlugs(config.custom, slugs, votedCookiePrefix);
|
|
99
136
|
if (consentSources) config.custom = stashConsentSources(config.custom, consentSources);
|
|
137
|
+
if (options.fallbackLocale) config.custom = stashFallbackLocale(config.custom, options.fallbackLocale);
|
|
100
138
|
registerTranslations(config, options.translations);
|
|
101
139
|
registerCollections({
|
|
102
140
|
config,
|
|
103
141
|
registry,
|
|
104
142
|
ruleRegistry,
|
|
143
|
+
calcAllowed,
|
|
144
|
+
calcSources,
|
|
145
|
+
calcFunctions,
|
|
105
146
|
consentSources,
|
|
106
147
|
consentSnapshot: options.consent?.snapshot ?? "both",
|
|
107
148
|
consentResolveOnRead: options.consent?.resolveOnRead,
|
|
108
149
|
actionRegistry,
|
|
109
150
|
richText: options.richText,
|
|
110
151
|
hasJobsPlugin: Boolean(plugins["@10x-media/jobs"]),
|
|
152
|
+
dispatchDeadlineMs: options.dispatch?.deadlineMs,
|
|
111
153
|
events: options.events,
|
|
112
154
|
uploads,
|
|
113
155
|
spam,
|
|
@@ -118,17 +160,31 @@ const formBuilder = definePlugin({
|
|
|
118
160
|
pollSourceRegistry,
|
|
119
161
|
pollTypeRegistry,
|
|
120
162
|
outcomeFields: options.poll?.outcomeFields,
|
|
163
|
+
pollVotes: options.poll?.votes === false ? false : options.poll?.votes ?? {},
|
|
121
164
|
buttons: options.buttons,
|
|
165
|
+
settings: options.settings,
|
|
122
166
|
response: options.response,
|
|
123
167
|
fromAddresses,
|
|
168
|
+
fromSources,
|
|
124
169
|
departments,
|
|
125
170
|
redirectRelationships: options.redirectRelationships,
|
|
171
|
+
slugs,
|
|
126
172
|
overrides: options.overrides
|
|
127
173
|
});
|
|
128
174
|
return config;
|
|
129
175
|
}
|
|
130
176
|
});
|
|
177
|
+
/**
|
|
178
|
+
* Form builder plugin for Payload: forms, submissions and their actions.
|
|
179
|
+
* Runs at `options.order` (default `50`), so a plugin that wraps every
|
|
180
|
+
* collection already in the config sets a higher order of its own.
|
|
181
|
+
*/
|
|
182
|
+
const formBuilder = (options = {}) => {
|
|
183
|
+
const plugin = definition(options);
|
|
184
|
+
if (options.order !== void 0) plugin.order = options.order;
|
|
185
|
+
return plugin;
|
|
186
|
+
};
|
|
131
187
|
//#endregion
|
|
132
|
-
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 };
|
|
188
|
+
export { ActionError, CAPTCHA_TOKEN_KEY, DEFAULT_COLLECTION_SLUGS, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, DEFAULT_VOTED_COOKIE_PREFIX, INLINE_DISPATCH_DEADLINE_MS, POLL_CLOSE_TASK_SLUG, POLL_VOTES_SLUG, RESPONDENTS_VALUE, SIGNATURE_HEADER, VOTE_SHARDS, aggregateFieldResponses, aggregateFormResponses, aggregateFromVotes, aggregateRowForField, aggregateRowsForFields, applyConsentStatements, buildDefaultActionDefinitions, buildDefaultButtonFields, buildDefaultFieldDefinitions, buildDefaultOutcomeFields, buildDefaultSettingsFields, buildNextLabelField, buildPollCloseTask, buildPrevLabelField, buildRecallResolver, buildResolvedAtField, buildSubmitLabelField, buildWinningValuesField, calcExpressionOf, calcUsesSources, calcWeightKey, captureConsent, captureFileRef, collectionSlugsOf, computeCalcFields, consentSourcesField, countryField, createKvRateLimiter, createSubmission, defaultActionDefinitions, defaultBodyConverters, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCalcFunction, defineCalcSource, defineCaptchaProvider, defineFormField, definePollOptionSource, definePollType, defineValidationRule, departmentsField, enqueuePollClose, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fieldKey, fieldTargetParam, fileMimeTypeOptions, formBuilder, formatBytes, formatCalc, formatCalcValue, hasVotedCookie, hcaptchaProvider, interpolate, isPollClosed, localizedIf, manualStrategy, mostVotedStrategy, normalizeCalc, optionLabelsFor, pollTypesOf, recaptchaProvider, recountPollVotes, registerPollCloseTask, renderAllValues, renderAllValuesTable, resolveActions, resolveCalcContext, resolveConsentEntries, resolveConsentSourcesRequest, resolveConsentStatements, resolveDepartmentOptions, resolveEffectivePollOptions, resolveFileRef, resolveFormResultsRequest, resolvePollOptionSources, resolvePollOptions, resolvePollOutcome, resolvePollTypes, resolvePublishedVersionRef, resolveSpamConfig, resolveVotedSubmission, runPollClose, sanitizeUrl, serializeBody, shouldAutoResolvePoll, signFormContext, signPayload, sourceStrategy, stashPollTypes, stateField, textOfBody, toFormDocument, topBucketValues, turnstileProvider, valuesFromSearchParams, verifyFormContext, votedCookieName };
|
|
133
189
|
|
|
134
190
|
//# 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 { buildDefaultActionDefinitions } from './actions/builtin'\nimport { resolveActions } from './actions/registry'\nimport { stashConsentSources } from './consent/resolveConsentEntries'\nimport { buildDefaultFieldDefinitions } from './fields/builtin'\nimport { resolveFieldTypes, stashFieldTypes } from './fields/registry'\nimport type { FormBuilderPluginOptions } from './options'\nimport { registerCollections } from './plugin/registerCollections'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport { readUploadCollectionMimeTypes } from './plugin/uploadsCollection'\nimport { resolvePollTypes, stashPollTypes } from './poll/pollTypeRegistry'\nimport { resolvePollOptionSources } from './poll/registry'\nimport { stashPollOptionSources } from './poll/resolvePollOptions'\nimport { resolveSpamConfig } from './spam/resolveSpam'\nimport { defaultValidationRules } from './validation/builtin'\nimport { resolveValidationRules } from './validation/registry'\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\tlocalize: localizeContent,\n\t\t\t\teditor: options.richText?.bodyEditor ?? options.richText?.editor,\n\t\t\t\tfromAddresses,\n\t\t\t\tdepartments,\n\t\t\t\trecipients: options.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\tconsentResolveOnRead: options.consent?.resolveOnRead,\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 {\n\tFormBuilderPluginOptions,\n\tFormBuilderPluginOptions as PluginOptions,\n} from './options'\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'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,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,8BAA8B;GAC7B,UAAU;GACV,QAAQ,QAAQ,UAAU,cAAc,QAAQ,UAAU;GAC1D;GACA;GACA,YAAY,QAAQ,OAAO;EAC5B,CAAC,GACD,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,sBAAsB,QAAQ,SAAS;GACvC;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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type Config, definePlugin, type Plugin } from 'payload'\nimport { assertNoActionBlockCollision } from './actions/assertNoBlockCollision'\nimport { buildDefaultActionDefinitions } from './actions/builtin'\nimport { resolveActions } from './actions/registry'\nimport { assertNoCalcFunctionCollision, assertValidCalcSourceKeys } from './calc/registry'\nimport { stashConsentSources } from './consent/resolveConsentEntries'\nimport { buildDefaultFieldDefinitions } from './fields/builtin'\nimport { resolveFieldTypes, stashFieldTypes } from './fields/registry'\nimport { stashFallbackLocale } from './form/findFormAtLocale'\nimport type { FormBuilderPluginOptions } from './options'\nimport {\n\tresolveCollectionSlugs,\n\tresolveVotedCookiePrefix,\n\tstashCollectionSlugs,\n} from './plugin/collectionSlugs'\nimport { registerCollections } from './plugin/registerCollections'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport { readUploadCollectionMimeTypes } from './plugin/uploadsCollection'\nimport { resolvePollTypes, stashPollTypes } from './poll/pollTypeRegistry'\nimport { resolvePollOptionSources } from './poll/registry'\nimport { stashPollOptionSources } from './poll/resolvePollOptions'\nimport { resolveSpamConfig } from './spam/resolveSpam'\nimport { defaultValidationRules } from './validation/builtin'\nimport { resolveValidationRules } from './validation/registry'\n\nconst definition = definePlugin<FormBuilderPluginOptions>({\n\tslug: '@10x-media/form-builder',\n\torder: 50,\n\tplugin: ({ config, options = {}, plugins }): 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// Resolved once, validated at boot: collection builders receive these directly, and every\n\t\t// runtime path (jobs, endpoints, host-called helpers) reads the same object off the config.\n\t\tconst slugs = resolveCollectionSlugs(options)\n\t\tconst votedCookiePrefix = resolveVotedCookiePrefix(options.poll?.cookiePrefix)\n\t\tconst calcSources = options.calc?.sources ?? {}\n\t\tconst calcFunctions = options.calc?.functions ?? {}\n\t\t// Fail fast: the evaluator resolves built-ins first, so a colliding custom function could never\n\t\t// run; a source key with a space would make the weight-map key (`calcWeightKey`) ambiguous.\n\t\tassertNoCalcFunctionCollision(calcFunctions)\n\t\tassertValidCalcSourceKeys(calcSources)\n\t\t// The allowed extension names, threaded into every normalizeCalc gate (the calculation field's\n\t\t// validate and the forms beforeValidate) so a stored expression can only ever reference a\n\t\t// registered source or function.\n\t\tconst calcAllowed = {\n\t\t\tsources: new Set(Object.keys(calcSources)),\n\t\t\tfunctions: new Set(Object.keys(calcFunctions)),\n\t\t}\n\t\t// Serializable source metadata for the builder UI: key, label, and implemented modes. The\n\t\t// resolver functions themselves never leave the server.\n\t\tconst calcSourceMeta = Object.entries(calcSources).map(([key, source]) => ({\n\t\t\tkey,\n\t\t\tlabel: source.label,\n\t\t\tscalar: typeof source.resolve === 'function',\n\t\t\tweights: typeof source.resolveWeights === 'function',\n\t\t}))\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\tcalcAllowed,\n\t\t\tcalcSourceMeta\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 fromSources = options.email?.fromSources\n\t\tconst departments = options.email?.departments\n\t\tconst actionRegistry = resolveActions(\n\t\t\tbuildDefaultActionDefinitions({\n\t\t\t\tlocalize: localizeContent,\n\t\t\t\teditor: options.richText?.bodyEditor ?? options.richText?.editor,\n\t\t\t\tfromAddresses,\n\t\t\t\tfromSources,\n\t\t\t\tdepartments,\n\t\t\t\tlocalizeRecipients: options.email?.localizeRecipients,\n\t\t\t\trecipients: options.email?.recipients,\n\t\t\t\trecipientSources: options.email?.recipientSources,\n\t\t\t\trender: options.email?.render,\n\t\t\t}),\n\t\t\toptions.actions\n\t\t)\n\t\t// Fail fast if a custom action type collides with a host block slug (Payload resolves blocks\n\t\t// globally by slug, which would silently merge the content block's fields into saved actions).\n\t\tassertNoActionBlockCollision(config, actionRegistry)\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\tconfig.custom = stashCollectionSlugs(config.custom, slugs, votedCookiePrefix)\n\t\tif (consentSources) {\n\t\t\tconfig.custom = stashConsentSources(config.custom, consentSources)\n\t\t}\n\t\tif (options.fallbackLocale) {\n\t\t\tconfig.custom = stashFallbackLocale(config.custom, options.fallbackLocale)\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\tcalcAllowed,\n\t\t\tcalcSources,\n\t\t\tcalcFunctions,\n\t\t\tconsentSources,\n\t\t\tconsentSnapshot: options.consent?.snapshot ?? 'both',\n\t\t\tconsentResolveOnRead: options.consent?.resolveOnRead,\n\t\t\tactionRegistry,\n\t\t\trichText: options.richText,\n\t\t\thasJobsPlugin: Boolean(plugins['@10x-media/jobs']),\n\t\t\tdispatchDeadlineMs: options.dispatch?.deadlineMs,\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\tpollVotes: options.poll?.votes === false ? false : (options.poll?.votes ?? {}),\n\t\t\tbuttons: options.buttons,\n\t\t\tsettings: options.settings,\n\t\t\tresponse: options.response,\n\t\t\tfromAddresses,\n\t\t\tfromSources,\n\t\t\tdepartments,\n\t\t\tredirectRelationships: options.redirectRelationships,\n\t\t\tslugs,\n\t\t\toverrides: options.overrides,\n\t\t})\n\t\treturn config\n\t},\n})\n\n/**\n * Form builder plugin for Payload: forms, submissions and their actions.\n * Runs at `options.order` (default `50`), so a plugin that wraps every\n * collection already in the config sets a higher order of its own.\n */\nexport const formBuilder = (options: FormBuilderPluginOptions = {}): Plugin => {\n\tconst plugin = definition(options)\n\tif (options.order !== undefined) {\n\t\tplugin.order = options.order\n\t}\n\treturn plugin\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 {\n\tActionDefinition,\n\tActionRunArgs,\n\tActionValidateArgs,\n\tAnyActionDefinition,\n} from './actions/defineAction'\nexport { ActionError, defineAction } from './actions/defineAction'\nexport { INLINE_DISPATCH_DEADLINE_MS } from './actions/dispatch'\nexport type { EmailActionType, EmailRender, EmailRenderArgs } from './actions/emailRender'\nexport type {\n\tFromAddressesResolver,\n\tFromAddressOption,\n\tFromAddressSource,\n\tFromAddressSourceRegistry,\n} from './actions/fromAddresses'\nexport type {\n\tRecipientResolveArgs,\n\tRecipientSource,\n\tRecipientSourceRegistry,\n} from './actions/recipientSources'\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 { SubmissionContextArgs, SubmissionForm } from './actions/submissionContext'\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 type { CalcResolved } from './calc/evaluate'\nexport { calcWeightKey, evaluateCalc } from './calc/evaluate'\nexport { formatCalc } from './calc/formatCalc'\nexport type { CalcDisplayConfig } from './calc/formatCalcValue'\nexport { formatCalcValue } from './calc/formatCalcValue'\nexport type { CalcAllowed } from './calc/normalizeCalc'\nexport { normalizeCalc } from './calc/normalizeCalc'\nexport type {\n\tCalcFunction,\n\tCalcSource,\n\tCalcSourceResolveArgs,\n\tCalcWeightResolveArgs,\n} from './calc/registry'\nexport { defineCalcFunction, defineCalcSource } from './calc/registry'\nexport type { ResolveCalcContextArgs } from './calc/resolveCalcContext'\nexport { calcUsesSources, resolveCalcContext } from './calc/resolveCalcContext'\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 type {\n\tDefaultSettingsFields,\n\tSettingsFieldsOverride,\n\tSettingsOption,\n} from './collections/settingsFields'\nexport { buildDefaultSettingsFields } from './collections/settingsFields'\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 { FormContextReference } from './context/formContext'\nexport { signFormContext, verifyFormContext } from './context/formContext'\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 type {\n\tFormFallbackLocale,\n\tFormFallbackLocaleArgs,\n\tFormFallbackLocaleResult,\n} from './form/findFormAtLocale'\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 {\n\tFormBuilderPluginOptions,\n\tFormBuilderPluginOptions as PluginOptions,\n} from './options'\nexport type { FormBuilderCollectionSlugs } from './plugin/collectionSlugs'\nexport {\n\tcollectionSlugsOf,\n\tDEFAULT_COLLECTION_SLUGS,\n\tDEFAULT_VOTED_COOKIE_PREFIX,\n} from './plugin/collectionSlugs'\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 { aggregateFromVotes } from './poll/votes/aggregateFromVotes'\nexport { recountPollVotes } from './poll/votes/recountPollVotes'\nexport { POLL_VOTES_SLUG, RESPONDENTS_VALUE, VOTE_SHARDS } from './poll/votes/votesCollection'\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 type { VotedSubmission } from './submissions/resolveVotedSubmission'\nexport { resolveVotedSubmission } from './submissions/resolveVotedSubmission'\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'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,aAAa,aAAuC;CACzD,MAAM;CACN,OAAO;CACP,SAAS,EAAE,QAAQ,UAAU,CAAC,GAAG,cAAsB;EACtD,IAAI,QAAQ,aAAa,MACxB,OAAO;EAER,MAAM,kBAAkB,QAAQ,oBAAoB;EACpD,MAAM,UAAU,QAAQ,WAAW;EAGnC,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,oBAAoB,yBAAyB,QAAQ,MAAM,YAAY;EAC7E,MAAM,cAAc,QAAQ,MAAM,WAAW,CAAC;EAC9C,MAAM,gBAAgB,QAAQ,MAAM,aAAa,CAAC;EAGlD,8BAA8B,aAAa;EAC3C,0BAA0B,WAAW;EAIrC,MAAM,cAAc;GACnB,SAAS,IAAI,IAAI,OAAO,KAAK,WAAW,CAAC;GACzC,WAAW,IAAI,IAAI,OAAO,KAAK,aAAa,CAAC;EAC9C;EAGA,MAAM,iBAAiB,OAAO,QAAQ,WAAW,EAAE,KAAK,CAAC,KAAK,aAAa;GAC1E;GACA,OAAO,OAAO;GACd,QAAQ,OAAO,OAAO,YAAY;GAClC,SAAS,OAAO,OAAO,mBAAmB;EAC3C,EAAE;EAIF,MAAM,kBACL,YAAY,QACT,KAAA,IACC,QAAQ,aAAa,8BAA8B,QAAQ,QAAQ,UAAU;EAClF,MAAM,iBAAiB,QAAQ,SAAS;EAgBxC,MAAM,WAAW,kBAXe,6BAC/B,iBACA,QAAQ,UAAU,QAClB,iBACA,aACA,cACD,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,cAAc,QAAQ,OAAO;EACnC,MAAM,iBAAiB,eACtB,8BAA8B;GAC7B,UAAU;GACV,QAAQ,QAAQ,UAAU,cAAc,QAAQ,UAAU;GAC1D;GACA;GACA;GACA,oBAAoB,QAAQ,OAAO;GACnC,YAAY,QAAQ,OAAO;GAC3B,kBAAkB,QAAQ,OAAO;GACjC,QAAQ,QAAQ,OAAO;EACxB,CAAC,GACD,QAAQ,OACT;EAGA,6BAA6B,QAAQ,cAAc;EACnD,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,OAAO,SAAS,qBAAqB,OAAO,QAAQ,OAAO,iBAAiB;EAC5E,IAAI,gBACH,OAAO,SAAS,oBAAoB,OAAO,QAAQ,cAAc;EAElE,IAAI,QAAQ,gBACX,OAAO,SAAS,oBAAoB,OAAO,QAAQ,QAAQ,cAAc;EAE1E,qBAAqB,QAAQ,QAAQ,YAAY;EACjD,oBAAoB;GACnB;GACA;GACA;GACA;GACA;GACA;GACA;GACA,iBAAiB,QAAQ,SAAS,YAAY;GAC9C,sBAAsB,QAAQ,SAAS;GACvC;GACA,UAAU,QAAQ;GAClB,eAAe,QAAQ,QAAQ,kBAAkB;GACjD,oBAAoB,QAAQ,UAAU;GACtC,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,WAAW,QAAQ,MAAM,UAAU,QAAQ,QAAS,QAAQ,MAAM,SAAS,CAAC;GAC5E,SAAS,QAAQ;GACjB,UAAU,QAAQ;GAClB,UAAU,QAAQ;GAClB;GACA;GACA;GACA,uBAAuB,QAAQ;GAC/B;GACA,WAAW,QAAQ;EACpB,CAAC;EACD,OAAO;CACR;AACD,CAAC;;;;;;AAOD,MAAa,eAAe,UAAoC,CAAC,MAAc;CAC9E,MAAM,SAAS,WAAW,OAAO;CACjC,IAAI,QAAQ,UAAU,KAAA,GACrB,OAAO,QAAQ,QAAQ;CAExB,OAAO;AACR"}
|
package/dist/options.d.ts
CHANGED
|
@@ -4,14 +4,19 @@ import { ConsentSourcesResolver } from "./consent/types.js";
|
|
|
4
4
|
import { FieldTypesConfig } from "./fields/registry.js";
|
|
5
5
|
import { FormEventSink } from "./events/types.js";
|
|
6
6
|
import { PollOptionSourcesConfig } from "./poll/registry.js";
|
|
7
|
-
import {
|
|
7
|
+
import { RecipientSourceRegistry } from "./actions/recipientSources.js";
|
|
8
|
+
import { FromAddressSourceRegistry, FromAddressesResolver } from "./actions/fromAddresses.js";
|
|
8
9
|
import { ActionsConfig } from "./actions/registry.js";
|
|
9
10
|
import { FormResultsAccess } from "./aggregation/resolveResultsRequest.js";
|
|
10
11
|
import { ButtonsOption } from "./collections/buttonFields.js";
|
|
11
12
|
import { ConsentSnapshotMode } from "./consent/captureConsent.js";
|
|
12
13
|
import { DepartmentEmailsResolver } from "./email/departments.js";
|
|
13
14
|
import { RecipientsConfig } from "./actions/emailRecipients.js";
|
|
15
|
+
import { EmailRender } from "./actions/emailRender.js";
|
|
16
|
+
import { CalcFunction, CalcSource } from "./calc/registry.js";
|
|
14
17
|
import { ResponseOption } from "./collections/redirectFields.js";
|
|
18
|
+
import { SettingsOption } from "./collections/settingsFields.js";
|
|
19
|
+
import { FormFallbackLocale } from "./form/findFormAtLocale.js";
|
|
15
20
|
import { CollectionOverrides } from "./plugin/collectionOverrides.js";
|
|
16
21
|
import { SpamOption } from "./spam/types.js";
|
|
17
22
|
import { UploadsOption } from "./plugin/uploadsCollection.js";
|
|
@@ -23,6 +28,12 @@ import { CollectionSlug } from "payload";
|
|
|
23
28
|
//#region src/options.d.ts
|
|
24
29
|
type FormBuilderPluginOptions = {
|
|
25
30
|
disabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Plugin order. Payload runs plugins sorted by it, ascending, default `0`.
|
|
33
|
+
* A plugin that has to see the form collections runs above it.
|
|
34
|
+
* @default 50
|
|
35
|
+
*/
|
|
36
|
+
order?: number;
|
|
26
37
|
/**
|
|
27
38
|
* Per-locale overrides for this plugin's UI strings, keyed by the typed
|
|
28
39
|
* translation keys exported from `@10x-media/form-builder/i18n`. Values win
|
|
@@ -42,10 +53,50 @@ type FormBuilderPluginOptions = {
|
|
|
42
53
|
* Consent statements are unaffected either way: they live on the host's own
|
|
43
54
|
* `consentSourcesField()`, which carries its own `localized` option.
|
|
44
55
|
*/
|
|
45
|
-
localizeContent?: boolean;
|
|
56
|
+
localizeContent?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Chooses the fallback locale per form for the plugin's server-side reads of it (validating a
|
|
59
|
+
* submission, running its actions, serving poll results), for hosts where the right fallback
|
|
60
|
+
* depends on the form's owner rather than on the config, e.g. a tenant whose default locale is not
|
|
61
|
+
* the config-wide one, or to force one on a host with `localization.fallback: false`. It receives
|
|
62
|
+
* the form as read with the config's own fallback (depth 0, so a
|
|
63
|
+
* non-localized owner relationship such as `form.tenant` is on it) and returns a locale code, an
|
|
64
|
+
* ordered list of codes, `false` for no fallback, or `undefined` to keep the default. The form is
|
|
65
|
+
* read again only when the result differs from the fallback already applied. Absent, a form falls
|
|
66
|
+
* back like any Payload read. Render the form on your page with the same fallback so what the
|
|
67
|
+
* visitor sees matches what the server validates and sends. See {@link FormFallbackLocale}.
|
|
68
|
+
*/
|
|
69
|
+
fallbackLocale?: FormFallbackLocale; /** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
46
70
|
fields?: FieldTypesConfig; /** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
47
71
|
rules?: ValidationRulesConfig; /** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
48
72
|
actions?: ActionsConfig;
|
|
73
|
+
/**
|
|
74
|
+
* How post-submit action work is dispatched. `deadlineMs` bounds every inline action pass: the
|
|
75
|
+
* essential pass that runs before the submit response, and the inline fallback used when no job
|
|
76
|
+
* runner is present. Defaults to 5000 (exported as `INLINE_DISPATCH_DEADLINE_MS`). An
|
|
77
|
+
* `essential` action making outbound calls should size its own timeouts under this bound, and a
|
|
78
|
+
* host that cannot fit its provider under the default raises it here instead of guessing.
|
|
79
|
+
*/
|
|
80
|
+
dispatch?: {
|
|
81
|
+
deadlineMs?: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Calculation extensions. `sources` registers named value resolvers the calculation field can
|
|
85
|
+
* reference: `resolve` supplies one number per render/submission (a tax rate, a member
|
|
86
|
+
* discount), `resolveWeights` supplies per-option numbers for a chosen field (a product's
|
|
87
|
+
* price per selectable product). Values resolve server-side, ride the form document for the
|
|
88
|
+
* client's live preview, and re-resolve at submit, so the client never supplies them.
|
|
89
|
+
* `functions` registers extra calculation functions; client-side live preview additionally
|
|
90
|
+
* needs the same map passed to the Form component.
|
|
91
|
+
*
|
|
92
|
+
* Resolvers receive an unauthenticated visitor `req` on public reads and submits: never feed
|
|
93
|
+
* data derived from it into access-escalated queries, and gate per-user-sensitive numbers on
|
|
94
|
+
* `req.user`, because resolved values are embedded on every readable form document.
|
|
95
|
+
*/
|
|
96
|
+
calc?: {
|
|
97
|
+
sources?: Record<string, CalcSource>;
|
|
98
|
+
functions?: Record<string, CalcFunction>;
|
|
99
|
+
};
|
|
49
100
|
/**
|
|
50
101
|
* Customize how the plugin's rich text is authored and rendered. `editor` is the default
|
|
51
102
|
* Lexical/richText editor for every plugin richText field (message content, consent
|
|
@@ -54,8 +105,9 @@ type FormBuilderPluginOptions = {
|
|
|
54
105
|
* back to `editor`. `converters` spread over the default
|
|
55
106
|
* Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to
|
|
56
107
|
* target chat or plain-text channels instead of email HTML). A custom `serialize` receives
|
|
57
|
-
* the submitted `form` (id/title)
|
|
58
|
-
* body off to a renderer like
|
|
108
|
+
* the submitted `form` (id/title), `req`, the submission `locale`, and the rendering
|
|
109
|
+
* `actionType`, enabling per-tenant lookups or handing the raw body off to a renderer like
|
|
110
|
+
* react-email. To only wrap emails in a layout, use `email.render` instead.
|
|
59
111
|
*/
|
|
60
112
|
richText?: RichTextBodyOption;
|
|
61
113
|
/**
|
|
@@ -83,8 +135,41 @@ type FormBuilderPluginOptions = {
|
|
|
83
135
|
*/
|
|
84
136
|
email?: {
|
|
85
137
|
fromAddresses?: FromAddressesResolver;
|
|
138
|
+
/**
|
|
139
|
+
* Senders resolved at send time, offered in the `from` select alongside (and ahead of) the
|
|
140
|
+
* `fromAddresses` literals. Where a literal freezes the address an action was saved with, a
|
|
141
|
+
* source stores its namespaced `value` (e.g. `tenant:default`) and re-resolves the address on
|
|
142
|
+
* every send, so sender identity follows the host: a tenant that changes its from-address
|
|
143
|
+
* changes it for every existing form at once. `resolve` receives the same run-time args as a
|
|
144
|
+
* recipient source (the form, the submission, the request); the form document is the stable
|
|
145
|
+
* tenant handle on the queued path. See {@link FromAddressSource}.
|
|
146
|
+
*/
|
|
147
|
+
fromSources?: FromAddressSourceRegistry;
|
|
86
148
|
departments?: DepartmentEmailsResolver; /** Narrows the recipient fields' behavior (free-typed emails, field tokens). See {@link RecipientsConfig}. */
|
|
87
149
|
recipients?: RecipientsConfig;
|
|
150
|
+
/**
|
|
151
|
+
* Localize the email actions' recipient lists (`to`, `cc`, `bcc`, `replyTo`), so each locale
|
|
152
|
+
* stores and routes to its own addresses or departments. Off by default: routing is usually the
|
|
153
|
+
* same in every locale, and with per-locale lists a locale the editor never filled in has no
|
|
154
|
+
* recipients unless it falls back (mind `localization.fallback: false`; see `fallbackLocale`).
|
|
155
|
+
* Ignored with `localizeContent: false`. Switching it on or off changes how existing
|
|
156
|
+
* forms store these fields, so it needs a data migration.
|
|
157
|
+
*/
|
|
158
|
+
localizeRecipients?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Server-resolved recipients, offered in every recipient field as their own option group and
|
|
161
|
+
* resolved to addresses at send time. Each source's `value` is a namespaced string (so it cannot
|
|
162
|
+
* collide with an address); its `resolve` receives the verified form context. See {@link RecipientSource}.
|
|
163
|
+
*/
|
|
164
|
+
recipientSources?: RecipientSourceRegistry;
|
|
165
|
+
/**
|
|
166
|
+
* Produces the final `html` of every `emailTeam` and `confirmation` email from the already
|
|
167
|
+
* serialized body, e.g. to wrap it in a branded layout localized by the submission's `locale`
|
|
168
|
+
* and varied by `actionType`. Runs after `richText.serialize` (when set), so the two compose:
|
|
169
|
+
* `serialize` replaces how an action body is rendered for any channel, `render` only wraps
|
|
170
|
+
* email. Absent, the serialized body is sent as is. See {@link EmailRender}.
|
|
171
|
+
*/
|
|
172
|
+
render?: EmailRender;
|
|
88
173
|
};
|
|
89
174
|
/**
|
|
90
175
|
* Where the consent statements a form can reference come from. Absent (the default): no sources,
|
|
@@ -130,6 +215,12 @@ type FormBuilderPluginOptions = {
|
|
|
130
215
|
* host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.
|
|
131
216
|
*/
|
|
132
217
|
buttons?: ButtonsOption;
|
|
218
|
+
/**
|
|
219
|
+
* Form-level flag fields (`multistep`, `pollEnabled`, `persistSubmissions`), sidebar
|
|
220
|
+
* checkboxes by default. `fields` composes them from the defaults so a host can
|
|
221
|
+
* relocate, wrap, extend, or drop them.
|
|
222
|
+
*/
|
|
223
|
+
settings?: SettingsOption;
|
|
133
224
|
/**
|
|
134
225
|
* The success-response group. `redirect.fields` composes the fields inside the `response.redirect`
|
|
135
226
|
* group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the
|
|
@@ -197,9 +288,27 @@ type FormBuilderPluginOptions = {
|
|
|
197
288
|
*/
|
|
198
289
|
poll?: {
|
|
199
290
|
votedCookie?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Name prefix of the httpOnly voted cookie (default `fb-voted-`, so `fb-voted-{formId}`), for
|
|
293
|
+
* hosts with cookie naming or consent-classification rules. Applies to both the `votedCookie`
|
|
294
|
+
* marker and the signed `allowChange` cookie. Must be a valid cookie-name token; validated at
|
|
295
|
+
* boot. Pass `payload` to `hasVotedCookie`/`votedCookieName` so they read the same name.
|
|
296
|
+
* Changing it on a live site orphans every cookie already issued.
|
|
297
|
+
*/
|
|
298
|
+
cookiePrefix?: string;
|
|
200
299
|
sources?: PollOptionSourcesConfig;
|
|
201
300
|
types?: PollTypesConfig;
|
|
202
301
|
outcomeFields?: OutcomeFieldsOverride;
|
|
302
|
+
/**
|
|
303
|
+
* Poll vote tally store (default on). Votes are counted into an append-only hidden
|
|
304
|
+
* collection of aggregate rows at submit time, so results reads are O(options), never
|
|
305
|
+
* truncate, and survive `persistSubmissions: false`. `false` restores scan-based results
|
|
306
|
+
* (and then a persist-off poll is rejected at save). `overrides` opens the tally
|
|
307
|
+
* collection, including its `slug` (default `form-poll-votes`).
|
|
308
|
+
*/
|
|
309
|
+
votes?: false | {
|
|
310
|
+
overrides?: CollectionOverrides;
|
|
311
|
+
};
|
|
203
312
|
};
|
|
204
313
|
/**
|
|
205
314
|
* When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the
|
|
@@ -213,6 +322,12 @@ type FormBuilderPluginOptions = {
|
|
|
213
322
|
* order per key determines who wins), hooks are appended after the plugin's own hooks, and
|
|
214
323
|
* `fields` is a function that receives the default fields and returns the final array so
|
|
215
324
|
* additions/removals are always intentional.
|
|
325
|
+
*
|
|
326
|
+
* `slug` renames a collection (defaults `forms` and `form-submissions`); the plugin resolves it
|
|
327
|
+
* at boot and uses it everywhere, including relationships, jobs, and the voted cookie. Browser
|
|
328
|
+
* components keep posting to the default REST paths until handed the same slugs through
|
|
329
|
+
* `<Form collections>`. Read the live slugs server-side with `collectionSlugsOf(payload)`.
|
|
330
|
+
* Renaming on a live database is a migration: existing rows stay under the old collection.
|
|
216
331
|
*/
|
|
217
332
|
overrides?: {
|
|
218
333
|
forms?: CollectionOverrides;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CollectionSlug, Payload } from "payload";
|
|
2
|
+
|
|
3
|
+
//#region src/plugin/collectionSlugs.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The slugs of the collections the plugin registers, after host overrides. Typed as `CollectionSlug`
|
|
6
|
+
* because each one is a registered collection, so a host's generated slug union always contains it
|
|
7
|
+
* and the values pass straight to `payload.find({ collection })`.
|
|
8
|
+
*/
|
|
9
|
+
type FormBuilderCollectionSlugs = {
|
|
10
|
+
forms: CollectionSlug;
|
|
11
|
+
formSubmissions: CollectionSlug;
|
|
12
|
+
pollVotes: CollectionSlug;
|
|
13
|
+
};
|
|
14
|
+
declare const DEFAULT_COLLECTION_SLUGS: Readonly<{
|
|
15
|
+
readonly forms: "forms";
|
|
16
|
+
readonly formSubmissions: "form-submissions";
|
|
17
|
+
readonly pollVotes: "form-poll-votes";
|
|
18
|
+
}>;
|
|
19
|
+
declare const DEFAULT_VOTED_COOKIE_PREFIX = "fb-voted-";
|
|
20
|
+
/**
|
|
21
|
+
* The collection slugs the plugin registered on this Payload instance, for code that queries the
|
|
22
|
+
* plugin's collections (`payload.find({ collection: collectionSlugsOf(payload).formSubmissions })`).
|
|
23
|
+
* The defaults when the plugin is disabled or absent.
|
|
24
|
+
*/
|
|
25
|
+
declare const collectionSlugsOf: (payload: Payload) => FormBuilderCollectionSlugs;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { DEFAULT_COLLECTION_SLUGS, DEFAULT_VOTED_COOKIE_PREFIX, FormBuilderCollectionSlugs, collectionSlugsOf };
|
|
28
|
+
//# sourceMappingURL=collectionSlugs.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { customStateOf, stashCustomState } from "./customState.js";
|
|
2
|
+
//#region src/plugin/collectionSlugs.ts
|
|
3
|
+
const DEFAULT_COLLECTION_SLUGS = Object.freeze({
|
|
4
|
+
forms: "forms",
|
|
5
|
+
formSubmissions: "form-submissions",
|
|
6
|
+
pollVotes: "form-poll-votes"
|
|
7
|
+
});
|
|
8
|
+
const DEFAULT_VOTED_COOKIE_PREFIX = "fb-voted-";
|
|
9
|
+
const OPTION_PATHS = {
|
|
10
|
+
forms: "overrides.forms.slug",
|
|
11
|
+
formSubmissions: "overrides.formSubmissions.slug",
|
|
12
|
+
pollVotes: "poll.votes.overrides.slug"
|
|
13
|
+
};
|
|
14
|
+
const slugOf = (override, fallback) => {
|
|
15
|
+
const slug = override?.slug?.trim();
|
|
16
|
+
return slug ? slug : fallback;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Resolve every plugin collection slug from the `slug` each collection's override carries,
|
|
20
|
+
* falling back to the defaults. Throws when two plugin collections would share a slug, since
|
|
21
|
+
* Payload would merge them into one collection with the other's fields and hooks.
|
|
22
|
+
*/
|
|
23
|
+
const resolveCollectionSlugs = (options) => {
|
|
24
|
+
const votes = options.poll?.votes;
|
|
25
|
+
const slugs = {
|
|
26
|
+
forms: slugOf(options.overrides?.forms, DEFAULT_COLLECTION_SLUGS.forms),
|
|
27
|
+
formSubmissions: slugOf(options.overrides?.formSubmissions, DEFAULT_COLLECTION_SLUGS.formSubmissions),
|
|
28
|
+
pollVotes: slugOf(votes === false ? void 0 : votes?.overrides, DEFAULT_COLLECTION_SLUGS.pollVotes)
|
|
29
|
+
};
|
|
30
|
+
const registered = Object.keys(slugs).filter((key) => key !== "pollVotes" || votes !== false);
|
|
31
|
+
for (const [index, key] of registered.entries()) {
|
|
32
|
+
const clash = registered.slice(index + 1).find((other) => slugs[other] === slugs[key]);
|
|
33
|
+
if (clash) throw new Error(`@10x-media/form-builder: ${OPTION_PATHS[key]} and ${OPTION_PATHS[clash]} both resolve to "${slugs[key]}"; each plugin collection needs its own slug.`);
|
|
34
|
+
}
|
|
35
|
+
return slugs;
|
|
36
|
+
};
|
|
37
|
+
const COOKIE_NAME_TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
38
|
+
/** Validate `poll.cookiePrefix` at boot, so a bad name fails loudly instead of breaking `Set-Cookie`. */
|
|
39
|
+
const resolveVotedCookiePrefix = (prefix) => {
|
|
40
|
+
if (prefix === void 0) return DEFAULT_VOTED_COOKIE_PREFIX;
|
|
41
|
+
if (!COOKIE_NAME_TOKEN.test(prefix)) throw new Error(`@10x-media/form-builder: poll.cookiePrefix "${prefix}" is not a valid cookie name; use letters, digits, and !#$%&'*+-.^_\`|~ only.`);
|
|
42
|
+
return prefix;
|
|
43
|
+
};
|
|
44
|
+
const stashCollectionSlugs = (custom, collectionSlugs, votedCookiePrefix) => stashCustomState(custom, {
|
|
45
|
+
collectionSlugs,
|
|
46
|
+
...votedCookiePrefix === void 0 ? {} : { votedCookiePrefix }
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* The collection slugs the plugin registered on this Payload instance, for code that queries the
|
|
50
|
+
* plugin's collections (`payload.find({ collection: collectionSlugsOf(payload).formSubmissions })`).
|
|
51
|
+
* The defaults when the plugin is disabled or absent.
|
|
52
|
+
*/
|
|
53
|
+
const collectionSlugsOf = (payload) => customStateOf(payload).collectionSlugs ?? { ...DEFAULT_COLLECTION_SLUGS };
|
|
54
|
+
/**
|
|
55
|
+
* The resolved slugs typed as the default literals, for the plugin's own Local API calls. A plugin
|
|
56
|
+
* collection keeps the plugin's document shape under any slug, which is exactly what generated types
|
|
57
|
+
* for the default slugs describe, so reads narrow as they did when the slugs were constants. Host
|
|
58
|
+
* code uses `collectionSlugsOf`, whose `string` slugs match whatever the host registered.
|
|
59
|
+
*/
|
|
60
|
+
const pluginSlugsOf = (payload) => collectionSlugsOf(payload);
|
|
61
|
+
const votedCookiePrefixOf = (payload) => customStateOf(payload).votedCookiePrefix ?? "fb-voted-";
|
|
62
|
+
//#endregion
|
|
63
|
+
export { DEFAULT_COLLECTION_SLUGS, DEFAULT_VOTED_COOKIE_PREFIX, collectionSlugsOf, pluginSlugsOf, resolveCollectionSlugs, resolveVotedCookiePrefix, stashCollectionSlugs, votedCookiePrefixOf };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=collectionSlugs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectionSlugs.js","names":[],"sources":["../../src/plugin/collectionSlugs.ts"],"sourcesContent":["import type { CollectionSlug, Payload } from 'payload'\nimport { customStateOf, stashCustomState } from './customState'\n\n/**\n * The slugs of the collections the plugin registers, after host overrides. Typed as `CollectionSlug`\n * because each one is a registered collection, so a host's generated slug union always contains it\n * and the values pass straight to `payload.find({ collection })`.\n */\nexport type FormBuilderCollectionSlugs = {\n\tforms: CollectionSlug\n\tformSubmissions: CollectionSlug\n\tpollVotes: CollectionSlug\n}\n\nexport const DEFAULT_COLLECTION_SLUGS = Object.freeze({\n\tforms: 'forms',\n\tformSubmissions: 'form-submissions',\n\tpollVotes: 'form-poll-votes',\n} as const)\n\nexport const DEFAULT_VOTED_COOKIE_PREFIX = 'fb-voted-'\n\ntype SlugOverride = { slug?: string } | undefined\n\n/** The slice of the plugin options slugs are read from; structural so this module stays a leaf. */\nexport type CollectionSlugOptions = {\n\toverrides?: { forms?: SlugOverride; formSubmissions?: SlugOverride }\n\tpoll?: { votes?: false | { overrides?: SlugOverride } }\n}\n\nconst OPTION_PATHS: Record<keyof FormBuilderCollectionSlugs, string> = {\n\tforms: 'overrides.forms.slug',\n\tformSubmissions: 'overrides.formSubmissions.slug',\n\tpollVotes: 'poll.votes.overrides.slug',\n}\n\nconst slugOf = (override: SlugOverride, fallback: string): CollectionSlug => {\n\tconst slug = override?.slug?.trim()\n\t// Registered under this very slug at boot, so it is a member of the host's generated union.\n\treturn (slug ? slug : fallback) as CollectionSlug\n}\n\n/**\n * Resolve every plugin collection slug from the `slug` each collection's override carries,\n * falling back to the defaults. Throws when two plugin collections would share a slug, since\n * Payload would merge them into one collection with the other's fields and hooks.\n */\nexport const resolveCollectionSlugs = (\n\toptions: CollectionSlugOptions\n): FormBuilderCollectionSlugs => {\n\tconst votes = options.poll?.votes\n\tconst slugs: FormBuilderCollectionSlugs = {\n\t\tforms: slugOf(options.overrides?.forms, DEFAULT_COLLECTION_SLUGS.forms),\n\t\tformSubmissions: slugOf(\n\t\t\toptions.overrides?.formSubmissions,\n\t\t\tDEFAULT_COLLECTION_SLUGS.formSubmissions\n\t\t),\n\t\tpollVotes: slugOf(\n\t\t\tvotes === false ? undefined : votes?.overrides,\n\t\t\tDEFAULT_COLLECTION_SLUGS.pollVotes\n\t\t),\n\t}\n\tconst registered = (Object.keys(slugs) as (keyof FormBuilderCollectionSlugs)[]).filter(\n\t\t(key) => key !== 'pollVotes' || votes !== false\n\t)\n\tfor (const [index, key] of registered.entries()) {\n\t\tconst clash = registered.slice(index + 1).find((other) => slugs[other] === slugs[key])\n\t\tif (clash) {\n\t\t\tthrow new Error(\n\t\t\t\t`@10x-media/form-builder: ${OPTION_PATHS[key]} and ${OPTION_PATHS[clash]} both resolve to \"${slugs[key]}\"; each plugin collection needs its own slug.`\n\t\t\t)\n\t\t}\n\t}\n\treturn slugs\n}\n\nconst COOKIE_NAME_TOKEN = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/\n\n/** Validate `poll.cookiePrefix` at boot, so a bad name fails loudly instead of breaking `Set-Cookie`. */\nexport const resolveVotedCookiePrefix = (prefix: string | undefined): string => {\n\tif (prefix === undefined) {\n\t\treturn DEFAULT_VOTED_COOKIE_PREFIX\n\t}\n\tif (!COOKIE_NAME_TOKEN.test(prefix)) {\n\t\tthrow new Error(\n\t\t\t`@10x-media/form-builder: poll.cookiePrefix \"${prefix}\" is not a valid cookie name; use letters, digits, and !#$%&'*+-.^_\\`|~ only.`\n\t\t)\n\t}\n\treturn prefix\n}\n\ntype SlugState = { collectionSlugs: FormBuilderCollectionSlugs; votedCookiePrefix?: string }\n\nexport const stashCollectionSlugs = (\n\tcustom: Record<string, unknown> | undefined,\n\tcollectionSlugs: FormBuilderCollectionSlugs,\n\tvotedCookiePrefix?: string\n): Record<string, unknown> =>\n\tstashCustomState<SlugState>(custom, {\n\t\tcollectionSlugs,\n\t\t...(votedCookiePrefix === undefined ? {} : { votedCookiePrefix }),\n\t})\n\n/**\n * The collection slugs the plugin registered on this Payload instance, for code that queries the\n * plugin's collections (`payload.find({ collection: collectionSlugsOf(payload).formSubmissions })`).\n * The defaults when the plugin is disabled or absent.\n */\nexport const collectionSlugsOf = (payload: Payload): FormBuilderCollectionSlugs =>\n\tcustomStateOf<SlugState>(payload).collectionSlugs ?? { ...DEFAULT_COLLECTION_SLUGS }\n\n/**\n * The resolved slugs typed as the default literals, for the plugin's own Local API calls. A plugin\n * collection keeps the plugin's document shape under any slug, which is exactly what generated types\n * for the default slugs describe, so reads narrow as they did when the slugs were constants. Host\n * code uses `collectionSlugsOf`, whose `string` slugs match whatever the host registered.\n */\nexport const pluginSlugsOf = (payload: Payload): typeof DEFAULT_COLLECTION_SLUGS =>\n\tcollectionSlugsOf(payload) as unknown as typeof DEFAULT_COLLECTION_SLUGS\n\nexport const votedCookiePrefixOf = (payload: Payload): string =>\n\tcustomStateOf<SlugState>(payload).votedCookiePrefix ?? DEFAULT_VOTED_COOKIE_PREFIX\n"],"mappings":";;AAcA,MAAa,2BAA2B,OAAO,OAAO;CACrD,OAAO;CACP,iBAAiB;CACjB,WAAW;AACZ,CAAU;AAEV,MAAa,8BAA8B;AAU3C,MAAM,eAAiE;CACtE,OAAO;CACP,iBAAiB;CACjB,WAAW;AACZ;AAEA,MAAM,UAAU,UAAwB,aAAqC;CAC5E,MAAM,OAAO,UAAU,MAAM,KAAK;CAElC,OAAQ,OAAO,OAAO;AACvB;;;;;;AAOA,MAAa,0BACZ,YACgC;CAChC,MAAM,QAAQ,QAAQ,MAAM;CAC5B,MAAM,QAAoC;EACzC,OAAO,OAAO,QAAQ,WAAW,OAAO,yBAAyB,KAAK;EACtE,iBAAiB,OAChB,QAAQ,WAAW,iBACnB,yBAAyB,eAC1B;EACA,WAAW,OACV,UAAU,QAAQ,KAAA,IAAY,OAAO,WACrC,yBAAyB,SAC1B;CACD;CACA,MAAM,aAAc,OAAO,KAAK,KAAK,EAA2C,QAC9E,QAAQ,QAAQ,eAAe,UAAU,KAC3C;CACA,KAAK,MAAM,CAAC,OAAO,QAAQ,WAAW,QAAQ,GAAG;EAChD,MAAM,QAAQ,WAAW,MAAM,QAAQ,CAAC,EAAE,MAAM,UAAU,MAAM,WAAW,MAAM,IAAI;EACrF,IAAI,OACH,MAAM,IAAI,MACT,4BAA4B,aAAa,KAAK,OAAO,aAAa,OAAO,oBAAoB,MAAM,KAAK,8CACzG;CAEF;CACA,OAAO;AACR;AAEA,MAAM,oBAAoB;;AAG1B,MAAa,4BAA4B,WAAuC;CAC/E,IAAI,WAAW,KAAA,GACd,OAAO;CAER,IAAI,CAAC,kBAAkB,KAAK,MAAM,GACjC,MAAM,IAAI,MACT,+CAA+C,OAAO,8EACvD;CAED,OAAO;AACR;AAIA,MAAa,wBACZ,QACA,iBACA,sBAEA,iBAA4B,QAAQ;CACnC;CACA,GAAI,sBAAsB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAkB;AAChE,CAAC;;;;;;AAOF,MAAa,qBAAqB,YACjC,cAAyB,OAAO,EAAE,mBAAmB,EAAE,GAAG,yBAAyB;;;;;;;AAQpF,MAAa,iBAAiB,YAC7B,kBAAkB,OAAO;AAE1B,MAAa,uBAAuB,YACnC,cAAyB,OAAO,EAAE,qBAAA"}
|
|
@@ -19,7 +19,7 @@ const stashCustomState = (custom, patch) => {
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
/** The plugin's slice of `payload.config.custom`, or an empty object when the plugin never booted. */
|
|
22
|
-
const customStateOf = (payload) => payload.config
|
|
22
|
+
const customStateOf = (payload) => payload.config?.custom?.[CUSTOM_KEY] ?? {};
|
|
23
23
|
//#endregion
|
|
24
24
|
export { customStateOf, stashCustomState };
|
|
25
25
|
|