@10x-media/form-builder 0.1.0-beta.9 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/README.md +11 -3
  3. package/dist/actions/assertNoBlockCollision.js +18 -0
  4. package/dist/actions/assertNoBlockCollision.js.map +1 -0
  5. package/dist/actions/body/serializeBody.d.ts +16 -14
  6. package/dist/actions/body/serializeBody.js +5 -8
  7. package/dist/actions/body/serializeBody.js.map +1 -1
  8. package/dist/actions/builtin/confirmation.js +2 -1
  9. package/dist/actions/builtin/confirmation.js.map +1 -1
  10. package/dist/actions/builtin/emailAction.d.ts +15 -3
  11. package/dist/actions/builtin/emailAction.js +72 -20
  12. package/dist/actions/builtin/emailAction.js.map +1 -1
  13. package/dist/actions/builtin/emailTeam.js +11 -5
  14. package/dist/actions/builtin/emailTeam.js.map +1 -1
  15. package/dist/actions/defineAction.d.ts +37 -6
  16. package/dist/actions/defineAction.js +14 -1
  17. package/dist/actions/defineAction.js.map +1 -1
  18. package/dist/actions/dispatch.d.ts +12 -0
  19. package/dist/actions/dispatch.js +103 -30
  20. package/dist/actions/dispatch.js.map +1 -1
  21. package/dist/actions/dispatchContext.js +19 -0
  22. package/dist/actions/dispatchContext.js.map +1 -0
  23. package/dist/actions/emailRecipients.js +38 -8
  24. package/dist/actions/emailRecipients.js.map +1 -1
  25. package/dist/actions/emailRender.d.ts +27 -0
  26. package/dist/actions/fromAddresses.d.ts +19 -1
  27. package/dist/actions/fromAddresses.js +66 -9
  28. package/dist/actions/fromAddresses.js.map +1 -1
  29. package/dist/actions/recipientSources.d.ts +23 -0
  30. package/dist/actions/recipientSources.js +11 -0
  31. package/dist/actions/recipientSources.js.map +1 -0
  32. package/dist/actions/registry.js +3 -1
  33. package/dist/actions/registry.js.map +1 -1
  34. package/dist/actions/runActions.d.ts +2 -0
  35. package/dist/actions/runActions.js +13 -8
  36. package/dist/actions/runActions.js.map +1 -1
  37. package/dist/actions/sign.js.map +1 -1
  38. package/dist/actions/submissionContext.d.ts +34 -0
  39. package/dist/actions/task.js +43 -16
  40. package/dist/actions/task.js.map +1 -1
  41. package/dist/aggregation/aggregateResponses.js +3 -4
  42. package/dist/aggregation/aggregateResponses.js.map +1 -1
  43. package/dist/aggregation/resolveResultsRequest.d.ts +6 -0
  44. package/dist/aggregation/resolveResultsRequest.js +69 -26
  45. package/dist/aggregation/resolveResultsRequest.js.map +1 -1
  46. package/dist/calc/computeCalcFields.d.ts +5 -3
  47. package/dist/calc/computeCalcFields.js +4 -3
  48. package/dist/calc/computeCalcFields.js.map +1 -1
  49. package/dist/calc/evaluate.d.ts +26 -3
  50. package/dist/calc/evaluate.js +33 -11
  51. package/dist/calc/evaluate.js.map +1 -1
  52. package/dist/calc/formatCalc.d.ts +11 -0
  53. package/dist/calc/formatCalc.js +35 -0
  54. package/dist/calc/formatCalc.js.map +1 -0
  55. package/dist/calc/formatCalcValue.d.ts +17 -0
  56. package/dist/calc/formatCalcValue.js +17 -0
  57. package/dist/calc/formatCalcValue.js.map +1 -0
  58. package/dist/calc/normalizeCalc.d.ts +17 -3
  59. package/dist/calc/normalizeCalc.js +39 -17
  60. package/dist/calc/normalizeCalc.js.map +1 -1
  61. package/dist/calc/registry.d.ts +43 -0
  62. package/dist/calc/registry.js +27 -0
  63. package/dist/calc/registry.js.map +1 -0
  64. package/dist/calc/resolveCalcContext.d.ts +36 -0
  65. package/dist/calc/resolveCalcContext.js +87 -0
  66. package/dist/calc/resolveCalcContext.js.map +1 -0
  67. package/dist/calc/types.d.ts +19 -4
  68. package/dist/calc/types.js +3 -2
  69. package/dist/calc/types.js.map +1 -1
  70. package/dist/client/ByteSizeField.js +11 -8
  71. package/dist/client/ByteSizeField.js.map +1 -1
  72. package/dist/client/CalcExpressionBuilder.d.ts +20 -0
  73. package/dist/client/CalcExpressionBuilder.js +888 -0
  74. package/dist/client/CalcExpressionBuilder.js.map +1 -0
  75. package/dist/client/ClosePollButton.js +3 -3
  76. package/dist/client/ClosePollButton.js.map +1 -1
  77. package/dist/client/CondensedArray.d.ts +2 -2
  78. package/dist/client/CondensedArray.js +5 -7
  79. package/dist/client/CondensedArray.js.map +1 -1
  80. package/dist/client/ConditionBuilder.js +5 -7
  81. package/dist/client/ConditionBuilder.js.map +1 -1
  82. package/dist/client/ConditionRow.js +3 -3
  83. package/dist/client/ConditionRow.js.map +1 -1
  84. package/dist/client/ConsentBlockLabel.js +2 -2
  85. package/dist/client/ConsentBlockLabel.js.map +1 -1
  86. package/dist/client/ConsentRetentionNotice.d.ts +11 -0
  87. package/dist/client/ConsentRetentionNotice.js +23 -0
  88. package/dist/client/ConsentRetentionNotice.js.map +1 -0
  89. package/dist/client/EndpointOptionsSelect.d.ts +17 -7
  90. package/dist/client/EndpointOptionsSelect.js +18 -14
  91. package/dist/client/EndpointOptionsSelect.js.map +1 -1
  92. package/dist/client/FieldBlockLabel.js +2 -2
  93. package/dist/client/FieldBlockLabel.js.map +1 -1
  94. package/dist/client/FieldNameSelect.d.ts +1 -0
  95. package/dist/client/FieldNameSelect.js +2 -4
  96. package/dist/client/FieldNameSelect.js.map +1 -1
  97. package/dist/client/FlowBuilder.js +31 -23
  98. package/dist/client/FlowBuilder.js.map +1 -1
  99. package/dist/client/FormConditionField.js +0 -1
  100. package/dist/client/FormConditionField.js.map +1 -1
  101. package/dist/client/RecipientsSelect.d.ts +9 -2
  102. package/dist/client/RecipientsSelect.js +31 -10
  103. package/dist/client/RecipientsSelect.js.map +1 -1
  104. package/dist/client/admin.css +345 -72
  105. package/dist/client/endpointOptions.d.ts +11 -0
  106. package/dist/client/endpointOptions.js +17 -8
  107. package/dist/client/endpointOptions.js.map +1 -1
  108. package/dist/collections/formSubmissions.js +145 -51
  109. package/dist/collections/formSubmissions.js.map +1 -1
  110. package/dist/collections/forms.js +170 -65
  111. package/dist/collections/forms.js.map +1 -1
  112. package/dist/collections/formsEndpoints.js +31 -26
  113. package/dist/collections/formsEndpoints.js.map +1 -1
  114. package/dist/collections/settingsFields.d.ts +32 -0
  115. package/dist/collections/settingsFields.js +55 -0
  116. package/dist/collections/settingsFields.js.map +1 -0
  117. package/dist/consent/captureConsent.d.ts +2 -1
  118. package/dist/consent/captureConsent.js +4 -1
  119. package/dist/consent/captureConsent.js.map +1 -1
  120. package/dist/consent/consentSourcesField.d.ts +7 -1
  121. package/dist/consent/consentSourcesField.js +15 -1
  122. package/dist/consent/consentSourcesField.js.map +1 -1
  123. package/dist/consent/effectiveStatement.js +16 -0
  124. package/dist/consent/effectiveStatement.js.map +1 -0
  125. package/dist/consent/resolveConsentSourcesRequest.js +2 -2
  126. package/dist/consent/resolveConsentSourcesRequest.js.map +1 -1
  127. package/dist/consent/resolveConsentStatements.js +3 -1
  128. package/dist/consent/resolveConsentStatements.js.map +1 -1
  129. package/dist/consent/resolvePublishedVersionRef.js +1 -0
  130. package/dist/consent/resolvePublishedVersionRef.js.map +1 -1
  131. package/dist/consent/types.d.ts +8 -0
  132. package/dist/context/formContext.d.ts +30 -0
  133. package/dist/context/formContext.js +54 -0
  134. package/dist/context/formContext.js.map +1 -0
  135. package/dist/email/departmentsField.d.ts +6 -1
  136. package/dist/email/departmentsField.js +6 -1
  137. package/dist/email/departmentsField.js.map +1 -1
  138. package/dist/exports/client.d.ts +3 -1
  139. package/dist/exports/client.js +3 -1
  140. package/dist/exports/i18n.d.ts +14 -2
  141. package/dist/exports/i18n.js +14 -2
  142. package/dist/exports/react.d.ts +23 -5
  143. package/dist/exports/react.js +17 -1
  144. package/dist/exports/rsc.d.ts +4 -1
  145. package/dist/exports/rsc.js +7 -4
  146. package/dist/exports/types.d.ts +4 -3
  147. package/dist/fields/buildFieldBlocks.js +2 -1
  148. package/dist/fields/buildFieldBlocks.js.map +1 -1
  149. package/dist/fields/builtin/calculation.d.ts +17 -0
  150. package/dist/fields/builtin/calculation.js +70 -127
  151. package/dist/fields/builtin/calculation.js.map +1 -1
  152. package/dist/fields/builtin/checkbox.js +15 -0
  153. package/dist/fields/builtin/checkbox.js.map +1 -1
  154. package/dist/fields/builtin/consent.js +21 -1
  155. package/dist/fields/builtin/consent.js.map +1 -1
  156. package/dist/fields/builtin/email.js +7 -0
  157. package/dist/fields/builtin/email.js.map +1 -1
  158. package/dist/fields/builtin/index.d.ts +6 -2
  159. package/dist/fields/builtin/index.js +9 -4
  160. package/dist/fields/builtin/index.js.map +1 -1
  161. package/dist/fields/builtin/select.js +20 -1
  162. package/dist/fields/builtin/select.js.map +1 -1
  163. package/dist/fields/builtin/text.js +7 -0
  164. package/dist/fields/builtin/text.js.map +1 -1
  165. package/dist/fields/instanceOptions.js +1 -1
  166. package/dist/fields/instanceOptions.js.map +1 -1
  167. package/dist/fields/sharedConfig.js +15 -11
  168. package/dist/fields/sharedConfig.js.map +1 -1
  169. package/dist/fields/types.d.ts +8 -2
  170. package/dist/form/findFormAtLocale.d.ts +30 -0
  171. package/dist/form/findFormAtLocale.js +88 -0
  172. package/dist/form/findFormAtLocale.js.map +1 -0
  173. package/dist/form/pollState.d.ts +2 -1
  174. package/dist/form/pollState.js.map +1 -1
  175. package/dist/form/toFormDocument.d.ts +8 -0
  176. package/dist/form/toFormDocument.js +3 -1
  177. package/dist/form/toFormDocument.js.map +1 -1
  178. package/dist/form/types.d.ts +9 -1
  179. package/dist/index.d.ts +22 -6
  180. package/dist/index.js +63 -17
  181. package/dist/index.js.map +1 -1
  182. package/dist/options.d.ts +113 -4
  183. package/dist/plugin/collectionSlugs.d.ts +28 -0
  184. package/dist/plugin/collectionSlugs.js +65 -0
  185. package/dist/plugin/collectionSlugs.js.map +1 -0
  186. package/dist/plugin/customState.js +1 -1
  187. package/dist/plugin/customState.js.map +1 -1
  188. package/dist/plugin/registerCollections.js +38 -21
  189. package/dist/plugin/registerCollections.js.map +1 -1
  190. package/dist/poll/closeJob.d.ts +4 -3
  191. package/dist/poll/closeJob.js +13 -10
  192. package/dist/poll/closeJob.js.map +1 -1
  193. package/dist/poll/outcomeBeforeChange.js +2 -2
  194. package/dist/poll/outcomeBeforeChange.js.map +1 -1
  195. package/dist/poll/pollTypeRegistry.js +1 -1
  196. package/dist/poll/resolvePollCloseRequest.js +5 -4
  197. package/dist/poll/resolvePollCloseRequest.js.map +1 -1
  198. package/dist/poll/resolvePollOptionsRequest.js +2 -2
  199. package/dist/poll/resolvePollOptionsRequest.js.map +1 -1
  200. package/dist/poll/resolvePollOutcome.d.ts +6 -0
  201. package/dist/poll/resolvePollOutcome.js +20 -6
  202. package/dist/poll/resolvePollOutcome.js.map +1 -1
  203. package/dist/poll/votes/aggregateFromVotes.d.ts +27 -0
  204. package/dist/poll/votes/aggregateFromVotes.js +55 -0
  205. package/dist/poll/votes/aggregateFromVotes.js.map +1 -0
  206. package/dist/poll/votes/answerValues.js +16 -0
  207. package/dist/poll/votes/answerValues.js.map +1 -0
  208. package/dist/poll/votes/bumpPollVote.js +91 -0
  209. package/dist/poll/votes/bumpPollVote.js.map +1 -0
  210. package/dist/poll/votes/recountPollVotes.d.ts +20 -0
  211. package/dist/poll/votes/recountPollVotes.js +63 -0
  212. package/dist/poll/votes/recountPollVotes.js.map +1 -0
  213. package/dist/poll/votes/voteTallyHook.js +76 -0
  214. package/dist/poll/votes/voteTallyHook.js.map +1 -0
  215. package/dist/poll/votes/votesCollection.d.ts +23 -0
  216. package/dist/poll/votes/votesCollection.js +96 -0
  217. package/dist/poll/votes/votesCollection.js.map +1 -0
  218. package/dist/react/Form.d.ts +49 -7
  219. package/dist/react/Form.js +48 -13
  220. package/dist/react/Form.js.map +1 -1
  221. package/dist/react/FormContext.d.ts +8 -1
  222. package/dist/react/FormContext.js.map +1 -1
  223. package/dist/react/FormResults.d.ts +4 -2
  224. package/dist/react/FormResults.js +21 -8
  225. package/dist/react/FormResults.js.map +1 -1
  226. package/dist/react/Poll.d.ts +25 -2
  227. package/dist/react/Poll.js +76 -25
  228. package/dist/react/Poll.js.map +1 -1
  229. package/dist/react/adapters.d.ts +35 -0
  230. package/dist/react/adapters.js +11 -0
  231. package/dist/react/adapters.js.map +1 -0
  232. package/dist/react/captcha/HcaptchaCaptcha.d.ts +4 -1
  233. package/dist/react/captcha/HcaptchaCaptcha.js +2 -2
  234. package/dist/react/captcha/HcaptchaCaptcha.js.map +1 -1
  235. package/dist/react/captcha/RecaptchaCaptcha.d.ts +4 -1
  236. package/dist/react/captcha/RecaptchaCaptcha.js +2 -2
  237. package/dist/react/captcha/RecaptchaCaptcha.js.map +1 -1
  238. package/dist/react/captcha/TurnstileCaptcha.d.ts +4 -1
  239. package/dist/react/captcha/TurnstileCaptcha.js +2 -2
  240. package/dist/react/captcha/TurnstileCaptcha.js.map +1 -1
  241. package/dist/react/captcha/useCaptchaScript.js +23 -5
  242. package/dist/react/captcha/useCaptchaScript.js.map +1 -1
  243. package/dist/react/fetchResults.d.ts +6 -3
  244. package/dist/react/fetchResults.js +10 -5
  245. package/dist/react/fetchResults.js.map +1 -1
  246. package/dist/react/primitives/Checkbox.d.ts +4 -2
  247. package/dist/react/primitives/Checkbox.js +3 -2
  248. package/dist/react/primitives/Checkbox.js.map +1 -1
  249. package/dist/react/primitives/ChoiceGroup.d.ts +40 -0
  250. package/dist/react/primitives/ChoiceGroup.js +33 -0
  251. package/dist/react/primitives/ChoiceGroup.js.map +1 -0
  252. package/dist/react/primitives/FieldShell.d.ts +11 -1
  253. package/dist/react/primitives/FieldShell.js +43 -33
  254. package/dist/react/primitives/FieldShell.js.map +1 -1
  255. package/dist/react/primitives/Input.d.ts +3 -1
  256. package/dist/react/primitives/Input.js +2 -1
  257. package/dist/react/primitives/Input.js.map +1 -1
  258. package/dist/react/renderers/calculation.js +6 -1
  259. package/dist/react/renderers/calculation.js.map +1 -1
  260. package/dist/react/renderers/checkbox.js +2 -1
  261. package/dist/react/renderers/checkbox.js.map +1 -1
  262. package/dist/react/renderers/consent.js +8 -3
  263. package/dist/react/renderers/consent.js.map +1 -1
  264. package/dist/react/renderers/email.js +3 -1
  265. package/dist/react/renderers/email.js.map +1 -1
  266. package/dist/react/renderers/repeater.js +5 -0
  267. package/dist/react/renderers/repeater.js.map +1 -1
  268. package/dist/react/renderers/select.js +20 -2
  269. package/dist/react/renderers/select.js.map +1 -1
  270. package/dist/react/renderers/text.js +3 -1
  271. package/dist/react/renderers/text.js.map +1 -1
  272. package/dist/react/state.d.ts +10 -0
  273. package/dist/react/state.js +45 -1
  274. package/dist/react/state.js.map +1 -1
  275. package/dist/react/submitForm.d.ts +20 -3
  276. package/dist/react/submitForm.js +8 -4
  277. package/dist/react/submitForm.js.map +1 -1
  278. package/dist/react/useCalcValues.d.ts +10 -0
  279. package/dist/react/useCalcValues.js +13 -0
  280. package/dist/react/useCalcValues.js.map +1 -0
  281. package/dist/react/useField.js +2 -1
  282. package/dist/react/useField.js.map +1 -1
  283. package/dist/recall/resolver.js +1 -1
  284. package/dist/recall/resolver.js.map +1 -1
  285. package/dist/spam/constants.js +7 -1
  286. package/dist/spam/constants.js.map +1 -1
  287. package/dist/spam/spamGuard.js +2 -1
  288. package/dist/spam/spamGuard.js.map +1 -1
  289. package/dist/submissions/SubmissionAnswersClient.js +14 -14
  290. package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
  291. package/dist/submissions/createSubmission.d.ts +7 -1
  292. package/dist/submissions/createSubmission.js +10 -5
  293. package/dist/submissions/createSubmission.js.map +1 -1
  294. package/dist/submissions/formIdOf.js +13 -0
  295. package/dist/submissions/formIdOf.js.map +1 -0
  296. package/dist/submissions/resolveVotedSubmission.d.ts +27 -0
  297. package/dist/submissions/resolveVotedSubmission.js +51 -0
  298. package/dist/submissions/resolveVotedSubmission.js.map +1 -0
  299. package/dist/submissions/runSubmission.js +6 -5
  300. package/dist/submissions/runSubmission.js.map +1 -1
  301. package/dist/submissions/submissionLocale.js +39 -0
  302. package/dist/submissions/submissionLocale.js.map +1 -0
  303. package/dist/submissions/validateSubmission.js +125 -79
  304. package/dist/submissions/validateSubmission.js.map +1 -1
  305. package/dist/submissions/verifyContext.js +35 -0
  306. package/dist/submissions/verifyContext.js.map +1 -0
  307. package/dist/submissions/voteChange.js +21 -0
  308. package/dist/submissions/voteChange.js.map +1 -0
  309. package/dist/submissions/voteChangeEndpoint.js +110 -0
  310. package/dist/submissions/voteChangeEndpoint.js.map +1 -0
  311. package/dist/submissions/votedCookie.d.ts +10 -4
  312. package/dist/submissions/votedCookie.js +49 -11
  313. package/dist/submissions/votedCookie.js.map +1 -1
  314. package/dist/translations/ar.d.ts +7 -0
  315. package/dist/translations/ar.js +379 -0
  316. package/dist/translations/ar.js.map +1 -0
  317. package/dist/translations/clientRuntimeKeys.d.ts +17 -0
  318. package/dist/translations/clientRuntimeKeys.js +48 -0
  319. package/dist/translations/clientRuntimeKeys.js.map +1 -0
  320. package/dist/translations/de.d.ts +12 -0
  321. package/dist/translations/de.js +78 -3
  322. package/dist/translations/de.js.map +1 -1
  323. package/dist/translations/en.js +78 -3
  324. package/dist/translations/en.js.map +1 -1
  325. package/dist/translations/es.d.ts +7 -0
  326. package/dist/translations/es.js +379 -0
  327. package/dist/translations/es.js.map +1 -0
  328. package/dist/translations/fr.d.ts +7 -0
  329. package/dist/translations/fr.js +379 -0
  330. package/dist/translations/fr.js.map +1 -0
  331. package/dist/translations/id.d.ts +7 -0
  332. package/dist/translations/id.js +379 -0
  333. package/dist/translations/id.js.map +1 -0
  334. package/dist/translations/index.d.ts +23 -6
  335. package/dist/translations/index.js +31 -6
  336. package/dist/translations/index.js.map +1 -1
  337. package/dist/translations/keys.d.ts +76 -1
  338. package/dist/translations/keys.js +76 -1
  339. package/dist/translations/keys.js.map +1 -1
  340. package/dist/translations/ko.d.ts +7 -0
  341. package/dist/translations/ko.js +379 -0
  342. package/dist/translations/ko.js.map +1 -0
  343. package/dist/translations/makeTranslate.d.ts +7 -3
  344. package/dist/translations/makeTranslate.js +12 -3
  345. package/dist/translations/makeTranslate.js.map +1 -1
  346. package/dist/translations/pt.d.ts +7 -0
  347. package/dist/translations/pt.js +379 -0
  348. package/dist/translations/pt.js.map +1 -0
  349. package/dist/translations/ru.d.ts +7 -0
  350. package/dist/translations/ru.js +379 -0
  351. package/dist/translations/ru.js.map +1 -0
  352. package/dist/translations/uk.d.ts +7 -0
  353. package/dist/translations/uk.js +379 -0
  354. package/dist/translations/uk.js.map +1 -0
  355. package/dist/translations/zh.d.ts +7 -0
  356. package/dist/translations/zh.js +379 -0
  357. package/dist/translations/zh.js.map +1 -0
  358. package/dist/validation/builtin/index.js +2 -0
  359. package/dist/validation/builtin/index.js.map +1 -1
  360. package/dist/validation/builtin/integer.js +15 -0
  361. package/dist/validation/builtin/integer.js.map +1 -0
  362. package/dist/validation/builtin/notAlreadySubmitted.js +5 -3
  363. package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -1
  364. package/package.json +24 -16
  365. package/styles/form-builder.css +84 -0
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 { FromAddressesResolver } from "./actions/fromAddresses.js";
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";
@@ -42,10 +47,50 @@ type FormBuilderPluginOptions = {
42
47
  * Consent statements are unaffected either way: they live on the host's own
43
48
  * `consentSourcesField()`, which carries its own `localized` option.
44
49
  */
45
- localizeContent?: boolean; /** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
50
+ localizeContent?: boolean;
51
+ /**
52
+ * Chooses the fallback locale per form for the plugin's server-side reads of it (validating a
53
+ * submission, running its actions, serving poll results), for hosts where the right fallback
54
+ * depends on the form's owner rather than on the config, e.g. a tenant whose default locale is not
55
+ * the config-wide one, or to force one on a host with `localization.fallback: false`. It receives
56
+ * the form as read with the config's own fallback (depth 0, so a
57
+ * non-localized owner relationship such as `form.tenant` is on it) and returns a locale code, an
58
+ * ordered list of codes, `false` for no fallback, or `undefined` to keep the default. The form is
59
+ * read again only when the result differs from the fallback already applied. Absent, a form falls
60
+ * back like any Payload read. Render the form on your page with the same fallback so what the
61
+ * visitor sees matches what the server validates and sends. See {@link FormFallbackLocale}.
62
+ */
63
+ fallbackLocale?: FormFallbackLocale; /** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
46
64
  fields?: FieldTypesConfig; /** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
47
65
  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
66
  actions?: ActionsConfig;
67
+ /**
68
+ * How post-submit action work is dispatched. `deadlineMs` bounds every inline action pass: the
69
+ * essential pass that runs before the submit response, and the inline fallback used when no job
70
+ * runner is present. Defaults to 5000 (exported as `INLINE_DISPATCH_DEADLINE_MS`). An
71
+ * `essential` action making outbound calls should size its own timeouts under this bound, and a
72
+ * host that cannot fit its provider under the default raises it here instead of guessing.
73
+ */
74
+ dispatch?: {
75
+ deadlineMs?: number;
76
+ };
77
+ /**
78
+ * Calculation extensions. `sources` registers named value resolvers the calculation field can
79
+ * reference: `resolve` supplies one number per render/submission (a tax rate, a member
80
+ * discount), `resolveWeights` supplies per-option numbers for a chosen field (a product's
81
+ * price per selectable product). Values resolve server-side, ride the form document for the
82
+ * client's live preview, and re-resolve at submit, so the client never supplies them.
83
+ * `functions` registers extra calculation functions; client-side live preview additionally
84
+ * needs the same map passed to the Form component.
85
+ *
86
+ * Resolvers receive an unauthenticated visitor `req` on public reads and submits: never feed
87
+ * data derived from it into access-escalated queries, and gate per-user-sensitive numbers on
88
+ * `req.user`, because resolved values are embedded on every readable form document.
89
+ */
90
+ calc?: {
91
+ sources?: Record<string, CalcSource>;
92
+ functions?: Record<string, CalcFunction>;
93
+ };
49
94
  /**
50
95
  * Customize how the plugin's rich text is authored and rendered. `editor` is the default
51
96
  * Lexical/richText editor for every plugin richText field (message content, consent
@@ -54,8 +99,9 @@ type FormBuilderPluginOptions = {
54
99
  * back to `editor`. `converters` spread over the default
55
100
  * Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to
56
101
  * target chat or plain-text channels instead of email HTML). A custom `serialize` receives
57
- * the submitted `form` (id/title) and `req`, enabling per-tenant lookups or handing the raw
58
- * body off to a renderer like react-email.
102
+ * the submitted `form` (id/title), `req`, the submission `locale`, and the rendering
103
+ * `actionType`, enabling per-tenant lookups or handing the raw body off to a renderer like
104
+ * react-email. To only wrap emails in a layout, use `email.render` instead.
59
105
  */
60
106
  richText?: RichTextBodyOption;
61
107
  /**
@@ -83,8 +129,41 @@ type FormBuilderPluginOptions = {
83
129
  */
84
130
  email?: {
85
131
  fromAddresses?: FromAddressesResolver;
132
+ /**
133
+ * Senders resolved at send time, offered in the `from` select alongside (and ahead of) the
134
+ * `fromAddresses` literals. Where a literal freezes the address an action was saved with, a
135
+ * source stores its namespaced `value` (e.g. `tenant:default`) and re-resolves the address on
136
+ * every send, so sender identity follows the host: a tenant that changes its from-address
137
+ * changes it for every existing form at once. `resolve` receives the same run-time args as a
138
+ * recipient source (the form, the submission, the request); the form document is the stable
139
+ * tenant handle on the queued path. See {@link FromAddressSource}.
140
+ */
141
+ fromSources?: FromAddressSourceRegistry;
86
142
  departments?: DepartmentEmailsResolver; /** Narrows the recipient fields' behavior (free-typed emails, field tokens). See {@link RecipientsConfig}. */
87
143
  recipients?: RecipientsConfig;
144
+ /**
145
+ * Localize the email actions' recipient lists (`to`, `cc`, `bcc`, `replyTo`), so each locale
146
+ * stores and routes to its own addresses or departments. Off by default: routing is usually the
147
+ * same in every locale, and with per-locale lists a locale the editor never filled in has no
148
+ * recipients unless it falls back (mind `localization.fallback: false`; see `fallbackLocale`).
149
+ * Ignored with `localizeContent: false`. Switching it on or off changes how existing
150
+ * forms store these fields, so it needs a data migration.
151
+ */
152
+ localizeRecipients?: boolean;
153
+ /**
154
+ * Server-resolved recipients, offered in every recipient field as their own option group and
155
+ * resolved to addresses at send time. Each source's `value` is a namespaced string (so it cannot
156
+ * collide with an address); its `resolve` receives the verified form context. See {@link RecipientSource}.
157
+ */
158
+ recipientSources?: RecipientSourceRegistry;
159
+ /**
160
+ * Produces the final `html` of every `emailTeam` and `confirmation` email from the already
161
+ * serialized body, e.g. to wrap it in a branded layout localized by the submission's `locale`
162
+ * and varied by `actionType`. Runs after `richText.serialize` (when set), so the two compose:
163
+ * `serialize` replaces how an action body is rendered for any channel, `render` only wraps
164
+ * email. Absent, the serialized body is sent as is. See {@link EmailRender}.
165
+ */
166
+ render?: EmailRender;
88
167
  };
89
168
  /**
90
169
  * Where the consent statements a form can reference come from. Absent (the default): no sources,
@@ -130,6 +209,12 @@ type FormBuilderPluginOptions = {
130
209
  * host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.
131
210
  */
132
211
  buttons?: ButtonsOption;
212
+ /**
213
+ * Form-level flag fields (`multistep`, `pollEnabled`, `persistSubmissions`), sidebar
214
+ * checkboxes by default. `fields` composes them from the defaults so a host can
215
+ * relocate, wrap, extend, or drop them.
216
+ */
217
+ settings?: SettingsOption;
133
218
  /**
134
219
  * The success-response group. `redirect.fields` composes the fields inside the `response.redirect`
135
220
  * group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the
@@ -197,9 +282,27 @@ type FormBuilderPluginOptions = {
197
282
  */
198
283
  poll?: {
199
284
  votedCookie?: boolean;
285
+ /**
286
+ * Name prefix of the httpOnly voted cookie (default `fb-voted-`, so `fb-voted-{formId}`), for
287
+ * hosts with cookie naming or consent-classification rules. Applies to both the `votedCookie`
288
+ * marker and the signed `allowChange` cookie. Must be a valid cookie-name token; validated at
289
+ * boot. Pass `payload` to `hasVotedCookie`/`votedCookieName` so they read the same name.
290
+ * Changing it on a live site orphans every cookie already issued.
291
+ */
292
+ cookiePrefix?: string;
200
293
  sources?: PollOptionSourcesConfig;
201
294
  types?: PollTypesConfig;
202
295
  outcomeFields?: OutcomeFieldsOverride;
296
+ /**
297
+ * Poll vote tally store (default on). Votes are counted into an append-only hidden
298
+ * collection of aggregate rows at submit time, so results reads are O(options), never
299
+ * truncate, and survive `persistSubmissions: false`. `false` restores scan-based results
300
+ * (and then a persist-off poll is rejected at save). `overrides` opens the tally
301
+ * collection, including its `slug` (default `form-poll-votes`).
302
+ */
303
+ votes?: false | {
304
+ overrides?: CollectionOverrides;
305
+ };
203
306
  };
204
307
  /**
205
308
  * When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the
@@ -213,6 +316,12 @@ type FormBuilderPluginOptions = {
213
316
  * order per key determines who wins), hooks are appended after the plugin's own hooks, and
214
317
  * `fields` is a function that receives the default fields and returns the final array so
215
318
  * additions/removals are always intentional.
319
+ *
320
+ * `slug` renames a collection (defaults `forms` and `form-submissions`); the plugin resolves it
321
+ * at boot and uses it everywhere, including relationships, jobs, and the voted cookie. Browser
322
+ * components keep posting to the default REST paths until handed the same slugs through
323
+ * `<Form collections>`. Read the live slugs server-side with `collectionSlugsOf(payload)`.
324
+ * Renaming on a live database is a migration: existing rows stay under the old collection.
216
325
  */
217
326
  overrides?: {
218
327
  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.custom?.[CUSTOM_KEY] ?? {};
22
+ const customStateOf = (payload) => payload.config?.custom?.[CUSTOM_KEY] ?? {};
23
23
  //#endregion
24
24
  export { customStateOf, stashCustomState };
25
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"customState.js","names":[],"sources":["../../src/plugin/customState.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\n/** Root key under `config.custom` where the plugin stashes runtime state for root-level helpers. */\nconst CUSTOM_KEY = '@10x-media/form-builder'\n\n/**\n * Merge `patch` into the plugin's slice of `config.custom`, leaving every other key untouched.\n * Root-level helpers (`resolvePollOptions`, `resolveConsentStatements`) are called by hosts with a\n * `payload` instance and no plugin state, so the plugin parks what they need on the config at boot\n * and they read it back through `payload.config`. Both readers share one key, so the plugin's slice\n * is patched rather than replaced.\n */\nexport const stashCustomState = <TState extends Record<string, unknown>>(\n\tcustom: Record<string, unknown> | undefined,\n\tpatch: TState\n): Record<string, unknown> => {\n\tconst existing =\n\t\tcustom?.[CUSTOM_KEY] != null && typeof custom[CUSTOM_KEY] === 'object'\n\t\t\t? (custom[CUSTOM_KEY] as Record<string, unknown>)\n\t\t\t: {}\n\treturn { ...(custom ?? {}), [CUSTOM_KEY]: { ...existing, ...patch } }\n}\n\n/** The plugin's slice of `payload.config.custom`, or an empty object when the plugin never booted. */\nexport const customStateOf = <TState extends Record<string, unknown>>(\n\tpayload: Payload\n): Partial<TState> => (payload.config.custom?.[CUSTOM_KEY] as Partial<TState> | undefined) ?? {}\n"],"mappings":";;AAGA,MAAM,aAAa;;;;;;;;AASnB,MAAa,oBACZ,QACA,UAC6B;CAC7B,MAAM,WACL,SAAS,eAAe,QAAQ,OAAO,OAAO,gBAAgB,WAC1D,OAAO,cACR,CAAC;CACL,OAAO;EAAE,GAAI,UAAU,CAAC;GAAK,aAAa;GAAE,GAAG;GAAU,GAAG;EAAM;CAAE;AACrE;;AAGA,MAAa,iBACZ,YACsB,QAAQ,OAAO,SAAS,eAA+C,CAAC"}
1
+ {"version":3,"file":"customState.js","names":[],"sources":["../../src/plugin/customState.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\n/** Root key under `config.custom` where the plugin stashes runtime state for root-level helpers. */\nconst CUSTOM_KEY = '@10x-media/form-builder'\n\n/**\n * Merge `patch` into the plugin's slice of `config.custom`, leaving every other key untouched.\n * Root-level helpers (`resolvePollOptions`, `resolveConsentStatements`) are called by hosts with a\n * `payload` instance and no plugin state, so the plugin parks what they need on the config at boot\n * and they read it back through `payload.config`. Both readers share one key, so the plugin's slice\n * is patched rather than replaced.\n */\nexport const stashCustomState = <TState extends Record<string, unknown>>(\n\tcustom: Record<string, unknown> | undefined,\n\tpatch: TState\n): Record<string, unknown> => {\n\tconst existing =\n\t\tcustom?.[CUSTOM_KEY] != null && typeof custom[CUSTOM_KEY] === 'object'\n\t\t\t? (custom[CUSTOM_KEY] as Record<string, unknown>)\n\t\t\t: {}\n\treturn { ...(custom ?? {}), [CUSTOM_KEY]: { ...existing, ...patch } }\n}\n\n/** The plugin's slice of `payload.config.custom`, or an empty object when the plugin never booted. */\nexport const customStateOf = <TState extends Record<string, unknown>>(\n\tpayload: Payload\n): Partial<TState> => (payload.config?.custom?.[CUSTOM_KEY] as Partial<TState> | undefined) ?? {}\n"],"mappings":";;AAGA,MAAM,aAAa;;;;;;;;AASnB,MAAa,oBACZ,QACA,UAC6B;CAC7B,MAAM,WACL,SAAS,eAAe,QAAQ,OAAO,OAAO,gBAAgB,WAC1D,OAAO,cACR,CAAC;CACL,OAAO;EAAE,GAAI,UAAU,CAAC;GAAK,aAAa;GAAE,GAAG;GAAU,GAAG;EAAM;CAAE;AACrE;;AAGA,MAAa,iBACZ,YACsB,QAAQ,QAAQ,SAAS,eAA+C,CAAC"}
@@ -1,12 +1,14 @@
1
+ import { registerActionsTask } from "../actions/task.js";
2
+ import { buildPollVotesCollection } from "../poll/votes/votesCollection.js";
3
+ import { buildSubmissionsCollection } from "../collections/formSubmissions.js";
1
4
  import { registerPollCloseTask } from "../poll/closeJob.js";
2
5
  import { buildFormsCollection } from "../collections/forms.js";
3
- import { buildSubmissionsCollection } from "../collections/formSubmissions.js";
4
- import { registerActionsTask } from "../actions/task.js";
5
6
  import { attachUploadsCollection } from "./uploadsCollection.js";
6
7
  //#region src/plugin/registerCollections.ts
7
- const registerCollections = ({ config, registry, ruleRegistry, consentSources, consentSnapshot, consentResolveOnRead, actionRegistry, richText, hasJobsPlugin, events, uploads, spam, showSubmissionRawFields, localizeContent, resultsAccess, votedCookie, pollSourceRegistry, pollTypeRegistry, outcomeFields, buttons, response, fromAddresses, departments, redirectRelationships, overrides }) => {
8
+ const registerCollections = ({ config, registry, ruleRegistry, calcAllowed, calcSources, calcFunctions, consentSources, consentSnapshot, consentResolveOnRead, actionRegistry, richText, hasJobsPlugin, dispatchDeadlineMs, events, uploads, spam, showSubmissionRawFields, localizeContent, resultsAccess, votedCookie, pollSourceRegistry, pollTypeRegistry, outcomeFields, pollVotes, buttons, settings, response, fromAddresses, fromSources, departments, redirectRelationships, slugs, overrides }) => {
9
+ const pollVotesEnabled = pollVotes !== false;
8
10
  registerActionsTask(config, actionRegistry, richText);
9
- registerPollCloseTask(config);
11
+ registerPollCloseTask(config, pollVotesEnabled);
10
12
  const hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin;
11
13
  const uploadSlug = uploads === false ? void 0 : uploads.collection;
12
14
  if (uploads !== false) attachUploadsCollection({
@@ -16,25 +18,11 @@ const registerCollections = ({ config, registry, ruleRegistry, consentSources, c
16
18
  });
17
19
  config.collections = [
18
20
  ...config.collections ?? [],
19
- buildSubmissionsCollection({
20
- registry,
21
- ruleRegistry,
22
- consentSources,
23
- consentSnapshot,
24
- actionRegistry,
25
- richText,
26
- events,
27
- hasRunner,
28
- uploadSlug,
29
- spam,
30
- votedCookie,
31
- pollSourceRegistry,
32
- showRawFields: showSubmissionRawFields,
33
- overrides: overrides?.formSubmissions
34
- }),
35
21
  buildFormsCollection({
36
22
  registry,
37
23
  ruleRegistry,
24
+ calcAllowed,
25
+ calcSources,
38
26
  consentSources,
39
27
  consentResolveOnRead,
40
28
  actionRegistry,
@@ -42,16 +30,45 @@ const registerCollections = ({ config, registry, ruleRegistry, consentSources, c
42
30
  richText,
43
31
  uploadsCollectionSlug: uploadSlug,
44
32
  resultsAccess,
33
+ pollVotesEnabled,
45
34
  pollSourceRegistry,
46
35
  pollTypeRegistry,
47
36
  outcomeFields,
48
37
  buttons,
38
+ settings,
49
39
  response,
50
40
  fromAddresses,
41
+ fromSources,
51
42
  departments,
52
43
  redirectRelationships,
44
+ slugs,
53
45
  overrides: overrides?.forms
54
- })
46
+ }),
47
+ buildSubmissionsCollection({
48
+ registry,
49
+ ruleRegistry,
50
+ calcSources,
51
+ calcFunctions,
52
+ consentSources,
53
+ consentSnapshot,
54
+ actionRegistry,
55
+ richText,
56
+ events,
57
+ hasRunner,
58
+ dispatchDeadlineMs,
59
+ uploadSlug,
60
+ spam,
61
+ votedCookie,
62
+ pollSourceRegistry,
63
+ pollVotes,
64
+ showRawFields: showSubmissionRawFields,
65
+ slugs,
66
+ overrides: overrides?.formSubmissions
67
+ }),
68
+ ...pollVotes === false ? [] : [buildPollVotesCollection({
69
+ overrides: pollVotes.overrides,
70
+ slug: slugs.pollVotes
71
+ })]
55
72
  ];
56
73
  };
57
74
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"registerCollections.js","names":[],"sources":["../../src/plugin/registerCollections.ts"],"sourcesContent":["import type { CollectionSlug, Config } from 'payload'\nimport type { RichTextBodyOption } from '../actions/body/serializeBody'\nimport type { FromAddressesResolver } from '../actions/fromAddresses'\nimport type { ActionRegistry } from '../actions/registry'\nimport { registerActionsTask } from '../actions/task'\nimport type { FormResultsAccess } from '../aggregation/resolveResultsRequest'\nimport type { ButtonsOption } from '../collections/buttonFields'\nimport { buildSubmissionsCollection } from '../collections/formSubmissions'\nimport { buildFormsCollection } from '../collections/forms'\nimport type { ResponseOption } from '../collections/redirectFields'\nimport type { ConsentSnapshotMode } from '../consent/captureConsent'\nimport type { ConsentSourcesResolver } from '../consent/types'\nimport type { DepartmentEmailsResolver } from '../email/departments'\nimport type { FormEventSink } from '../events/types'\nimport type { FieldTypeRegistry } from '../fields/registry'\nimport { registerPollCloseTask } from '../poll/closeJob'\nimport type { OutcomeFieldsOverride } from '../poll/outcomeFields'\nimport type { PollTypeRegistry } from '../poll/pollTypeRegistry'\nimport type { PollOptionSourceRegistry } from '../poll/registry'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { CollectionOverrides } from './collectionOverrides'\nimport { attachUploadsCollection, type UploadsOption } from './uploadsCollection'\n\ntype RegisterCollectionsArgs = {\n\tconfig: Config\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\tconsentSources?: ConsentSourcesResolver\n\tconsentSnapshot?: ConsentSnapshotMode\n\t/** Plugin `consent.resolveOnRead` (default true); false skips the per-read consent afterRead hook. */\n\tconsentResolveOnRead?: boolean\n\tactionRegistry: ActionRegistry\n\trichText?: RichTextBodyOption\n\thasJobsPlugin: boolean\n\tevents?: FormEventSink\n\tuploads: UploadsOption\n\tspam: ResolvedSpamConfig | false\n\tshowSubmissionRawFields: boolean\n\tlocalizeContent: boolean\n\tresultsAccess?: FormResultsAccess\n\tvotedCookie: boolean\n\tpollSourceRegistry: PollOptionSourceRegistry\n\tpollTypeRegistry: PollTypeRegistry\n\toutcomeFields?: OutcomeFieldsOverride\n\tbuttons?: ButtonsOption\n\tresponse?: ResponseOption\n\tfromAddresses?: FromAddressesResolver\n\tdepartments?: DepartmentEmailsResolver\n\tredirectRelationships?: CollectionSlug[]\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\nexport const registerCollections = ({\n\tconfig,\n\tregistry,\n\truleRegistry,\n\tconsentSources,\n\tconsentSnapshot,\n\tconsentResolveOnRead,\n\tactionRegistry,\n\trichText,\n\thasJobsPlugin,\n\tevents,\n\tuploads,\n\tspam,\n\tshowSubmissionRawFields,\n\tlocalizeContent,\n\tresultsAccess,\n\tvotedCookie,\n\tpollSourceRegistry,\n\tpollTypeRegistry,\n\toutcomeFields,\n\tbuttons,\n\tresponse,\n\tfromAddresses,\n\tdepartments,\n\tredirectRelationships,\n\toverrides,\n}: RegisterCollectionsArgs): void => {\n\tregisterActionsTask(config, actionRegistry, richText)\n\tregisterPollCloseTask(config)\n\tconst hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin\n\n\tconst uploadSlug = uploads === false ? undefined : uploads.collection\n\tif (uploads !== false) {\n\t\tattachUploadsCollection({ config, slug: uploads.collection, spam })\n\t}\n\n\t// Payload has no nav-sort option, so it lists collections in registration order. Register\n\t// `form-submissions` before `forms` so the \"Forms\" nav group reads alphabetically\n\t// (`form-submissions` < `forms`); ordering plugin nav groups against a host's own collections\n\t// stays a host concern.\n\tconfig.collections = [\n\t\t...(config.collections ?? []),\n\t\tbuildSubmissionsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tconsentSnapshot,\n\t\t\tactionRegistry,\n\t\t\trichText,\n\t\t\tevents,\n\t\t\thasRunner,\n\t\t\tuploadSlug,\n\t\t\tspam,\n\t\t\tvotedCookie,\n\t\t\tpollSourceRegistry,\n\t\t\tshowRawFields: showSubmissionRawFields,\n\t\t\toverrides: overrides?.formSubmissions,\n\t\t}),\n\t\tbuildFormsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tconsentResolveOnRead,\n\t\t\tactionRegistry,\n\t\t\tlocalizeContent,\n\t\t\trichText,\n\t\t\tuploadsCollectionSlug: uploadSlug,\n\t\t\tresultsAccess,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields,\n\t\t\tbuttons,\n\t\t\tresponse,\n\t\t\tfromAddresses,\n\t\t\tdepartments,\n\t\t\tredirectRelationships,\n\t\t\toverrides: overrides?.forms,\n\t\t}),\n\t]\n}\n"],"mappings":";;;;;;AAwDA,MAAa,uBAAuB,EACnC,QACA,UACA,cACA,gBACA,iBACA,sBACA,gBACA,UACA,eACA,QACA,SACA,MACA,yBACA,iBACA,eACA,aACA,oBACA,kBACA,eACA,SACA,UACA,eACA,aACA,uBACA,gBACoC;CACpC,oBAAoB,QAAQ,gBAAgB,QAAQ;CACpD,sBAAsB,MAAM;CAC5B,MAAM,YAAY,QAAQ,OAAO,MAAM,OAAO,KAAK;CAEnD,MAAM,aAAa,YAAY,QAAQ,KAAA,IAAY,QAAQ;CAC3D,IAAI,YAAY,OACf,wBAAwB;EAAE;EAAQ,MAAM,QAAQ;EAAY;CAAK,CAAC;CAOnE,OAAO,cAAc;EACpB,GAAI,OAAO,eAAe,CAAC;EAC3B,2BAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAAe;GACf,WAAW,WAAW;EACvB,CAAC;EACD,qBAAqB;GACpB;GACA;GACA;GACA;GACA;GACA;GACA;GACA,uBAAuB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,WAAW;EACvB,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"registerCollections.js","names":[],"sources":["../../src/plugin/registerCollections.ts"],"sourcesContent":["import type { CollectionSlug, Config } from 'payload'\nimport type { RichTextBodyOption } from '../actions/body/serializeBody'\nimport type { FromAddressesResolver, FromAddressSourceRegistry } from '../actions/fromAddresses'\nimport type { ActionRegistry } from '../actions/registry'\nimport { registerActionsTask } from '../actions/task'\nimport type { FormResultsAccess } from '../aggregation/resolveResultsRequest'\nimport type { CalcAllowed } from '../calc/normalizeCalc'\nimport type { CalcFunction, CalcSource } from '../calc/registry'\nimport type { ButtonsOption } from '../collections/buttonFields'\nimport { buildSubmissionsCollection } from '../collections/formSubmissions'\nimport { buildFormsCollection } from '../collections/forms'\nimport type { ResponseOption } from '../collections/redirectFields'\nimport type { SettingsOption } from '../collections/settingsFields'\nimport type { ConsentSnapshotMode } from '../consent/captureConsent'\nimport type { ConsentSourcesResolver } from '../consent/types'\nimport type { DepartmentEmailsResolver } from '../email/departments'\nimport type { FormEventSink } from '../events/types'\nimport type { FieldTypeRegistry } from '../fields/registry'\nimport { registerPollCloseTask } from '../poll/closeJob'\nimport type { OutcomeFieldsOverride } from '../poll/outcomeFields'\nimport type { PollTypeRegistry } from '../poll/pollTypeRegistry'\nimport type { PollOptionSourceRegistry } from '../poll/registry'\nimport { buildPollVotesCollection } from '../poll/votes/votesCollection'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { CollectionOverrides } from './collectionOverrides'\nimport type { FormBuilderCollectionSlugs } from './collectionSlugs'\nimport { attachUploadsCollection, type UploadsOption } from './uploadsCollection'\n\ntype RegisterCollectionsArgs = {\n\tconfig: Config\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\t/** Registered calc extension names; gates which expressions the forms beforeValidate accepts. */\n\tcalcAllowed?: CalcAllowed\n\t/** Registered calc sources (plugin option `calc.sources`); resolved on form reads and at submit. */\n\tcalcSources?: Record<string, CalcSource>\n\t/** Registered calc functions (plugin option `calc.functions`); threaded into submit-time evaluation. */\n\tcalcFunctions?: Record<string, CalcFunction>\n\tconsentSources?: ConsentSourcesResolver\n\tconsentSnapshot?: ConsentSnapshotMode\n\t/** Plugin `consent.resolveOnRead` (default true); false skips the per-read consent afterRead hook. */\n\tconsentResolveOnRead?: boolean\n\tactionRegistry: ActionRegistry\n\trichText?: RichTextBodyOption\n\thasJobsPlugin: boolean\n\t/** Host override for the inline dispatch deadline (plugin option `dispatch.deadlineMs`). */\n\tdispatchDeadlineMs?: number\n\tevents?: FormEventSink\n\tuploads: UploadsOption\n\tspam: ResolvedSpamConfig | false\n\tshowSubmissionRawFields: boolean\n\tlocalizeContent: boolean\n\tresultsAccess?: FormResultsAccess\n\tvotedCookie: boolean\n\tpollSourceRegistry: PollOptionSourceRegistry\n\tpollTypeRegistry: PollTypeRegistry\n\toutcomeFields?: OutcomeFieldsOverride\n\t/** Resolved `poll.votes` option; `false` skips registering the hidden tally collection. */\n\tpollVotes: false | { overrides?: CollectionOverrides }\n\tbuttons?: ButtonsOption\n\tsettings?: SettingsOption\n\tresponse?: ResponseOption\n\tfromAddresses?: FromAddressesResolver\n\tfromSources?: FromAddressSourceRegistry\n\tdepartments?: DepartmentEmailsResolver\n\tredirectRelationships?: CollectionSlug[]\n\t/** Resolved plugin collection slugs; see `resolveCollectionSlugs`. */\n\tslugs: FormBuilderCollectionSlugs\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\nexport const registerCollections = ({\n\tconfig,\n\tregistry,\n\truleRegistry,\n\tcalcAllowed,\n\tcalcSources,\n\tcalcFunctions,\n\tconsentSources,\n\tconsentSnapshot,\n\tconsentResolveOnRead,\n\tactionRegistry,\n\trichText,\n\thasJobsPlugin,\n\tdispatchDeadlineMs,\n\tevents,\n\tuploads,\n\tspam,\n\tshowSubmissionRawFields,\n\tlocalizeContent,\n\tresultsAccess,\n\tvotedCookie,\n\tpollSourceRegistry,\n\tpollTypeRegistry,\n\toutcomeFields,\n\tpollVotes,\n\tbuttons,\n\tsettings,\n\tresponse,\n\tfromAddresses,\n\tfromSources,\n\tdepartments,\n\tredirectRelationships,\n\tslugs,\n\toverrides,\n}: RegisterCollectionsArgs): void => {\n\tconst pollVotesEnabled = pollVotes !== false\n\tregisterActionsTask(config, actionRegistry, richText)\n\tregisterPollCloseTask(config, pollVotesEnabled)\n\tconst hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin\n\n\tconst uploadSlug = uploads === false ? undefined : uploads.collection\n\tif (uploads !== false) {\n\t\tattachUploadsCollection({ config, slug: uploads.collection, spam })\n\t}\n\n\t// Payload lists nav entries in registration order (no nav-sort option). The primary\n\t// collection leads: forms, then form-submissions. Ordering the plugin's nav group against\n\t// host collections (including a BYO uploads collection) stays a host concern.\n\tconfig.collections = [\n\t\t...(config.collections ?? []),\n\t\tbuildFormsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tcalcAllowed,\n\t\t\tcalcSources,\n\t\t\tconsentSources,\n\t\t\tconsentResolveOnRead,\n\t\t\tactionRegistry,\n\t\t\tlocalizeContent,\n\t\t\trichText,\n\t\t\tuploadsCollectionSlug: uploadSlug,\n\t\t\tresultsAccess,\n\t\t\tpollVotesEnabled,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields,\n\t\t\tbuttons,\n\t\t\tsettings,\n\t\t\tresponse,\n\t\t\tfromAddresses,\n\t\t\tfromSources,\n\t\t\tdepartments,\n\t\t\tredirectRelationships,\n\t\t\tslugs,\n\t\t\toverrides: overrides?.forms,\n\t\t}),\n\t\tbuildSubmissionsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tcalcSources,\n\t\t\tcalcFunctions,\n\t\t\tconsentSources,\n\t\t\tconsentSnapshot,\n\t\t\tactionRegistry,\n\t\t\trichText,\n\t\t\tevents,\n\t\t\thasRunner,\n\t\t\tdispatchDeadlineMs,\n\t\t\tuploadSlug,\n\t\t\tspam,\n\t\t\tvotedCookie,\n\t\t\tpollSourceRegistry,\n\t\t\tpollVotes,\n\t\t\tshowRawFields: showSubmissionRawFields,\n\t\t\tslugs,\n\t\t\toverrides: overrides?.formSubmissions,\n\t\t}),\n\t\t...(pollVotes === false\n\t\t\t? []\n\t\t\t: [buildPollVotesCollection({ overrides: pollVotes.overrides, slug: slugs.pollVotes })]),\n\t]\n}\n"],"mappings":";;;;;;;AA2EA,MAAa,uBAAuB,EACnC,QACA,UACA,cACA,aACA,aACA,eACA,gBACA,iBACA,sBACA,gBACA,UACA,eACA,oBACA,QACA,SACA,MACA,yBACA,iBACA,eACA,aACA,oBACA,kBACA,eACA,WACA,SACA,UACA,UACA,eACA,aACA,aACA,uBACA,OACA,gBACoC;CACpC,MAAM,mBAAmB,cAAc;CACvC,oBAAoB,QAAQ,gBAAgB,QAAQ;CACpD,sBAAsB,QAAQ,gBAAgB;CAC9C,MAAM,YAAY,QAAQ,OAAO,MAAM,OAAO,KAAK;CAEnD,MAAM,aAAa,YAAY,QAAQ,KAAA,IAAY,QAAQ;CAC3D,IAAI,YAAY,OACf,wBAAwB;EAAE;EAAQ,MAAM,QAAQ;EAAY;CAAK,CAAC;CAMnE,OAAO,cAAc;EACpB,GAAI,OAAO,eAAe,CAAC;EAC3B,qBAAqB;GACpB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,uBAAuB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,WAAW;EACvB,CAAC;EACD,2BAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAAe;GACf;GACA,WAAW,WAAW;EACvB,CAAC;EACD,GAAI,cAAc,QACf,CAAC,IACD,CAAC,yBAAyB;GAAE,WAAW,UAAU;GAAW,MAAM,MAAM;EAAU,CAAC,CAAC;CACxF;AACD"}
@@ -24,13 +24,14 @@ declare const shouldAutoResolvePoll: (form: PollFormLike) => boolean;
24
24
  */
25
25
  declare const runPollClose: (args: {
26
26
  payload: Payload;
27
- input: PollCloseTaskInput;
27
+ input: PollCloseTaskInput; /** Whether the hidden tally store backs the outcome aggregation (see `resolvePollOutcome`). */
28
+ pollVotesEnabled?: boolean;
28
29
  req?: PayloadRequest;
29
30
  }) => Promise<void>;
30
31
  /** Native Payload jobs task that resolves a poll's outcome once it closes. */
31
- declare const buildPollCloseTask: () => TaskConfig;
32
+ declare const buildPollCloseTask: (pollVotesEnabled?: boolean) => TaskConfig;
32
33
  /** Register the poll-close task on `config.jobs.tasks`, creating the jobs config if absent. */
33
- declare const registerPollCloseTask: (config: Config) => void;
34
+ declare const registerPollCloseTask: (config: Config, pollVotesEnabled?: boolean) => void;
34
35
  /**
35
36
  * Schedule (or reschedule) the auto-close for a poll after a save. Enqueues a `waitUntil: closesAt`
36
37
  * job when the poll is enabled, has a `closesAt`, is still unresolved, and its strategy is not
@@ -1,6 +1,6 @@
1
+ import { pluginSlugsOf } from "../plugin/collectionSlugs.js";
1
2
  import { isPollClosed, pollConfigOf } from "../form/pollState.js";
2
3
  import { resolvePollOutcome } from "./resolvePollOutcome.js";
3
- import { FORMS_SLUG } from "../collections/forms.js";
4
4
  //#region src/poll/closeJob.ts
5
5
  const POLL_CLOSE_TASK_SLUG = "form-builder-poll-close";
6
6
  /** Payload's jobs collection; queried directly to supersede a superseded pending close job. */
@@ -25,9 +25,9 @@ const shouldAutoResolvePoll = (form) => {
25
25
  * recorded (or a job that fires slightly early) is a safe no-op. Tolerates a deleted form.
26
26
  */
27
27
  const runPollClose = async (args) => {
28
- const { payload, input, req } = args;
28
+ const { payload, input, pollVotesEnabled, req } = args;
29
29
  const form = await payload.findByID({
30
- collection: FORMS_SLUG,
30
+ collection: pluginSlugsOf(payload).forms,
31
31
  id: input.formId,
32
32
  depth: 0,
33
33
  overrideAccess: true,
@@ -37,11 +37,12 @@ const runPollClose = async (args) => {
37
37
  await resolvePollOutcome({
38
38
  payload,
39
39
  formId: input.formId,
40
+ pollVotesEnabled,
40
41
  req
41
42
  });
42
43
  };
43
44
  /** Native Payload jobs task that resolves a poll's outcome once it closes. */
44
- const buildPollCloseTask = () => ({
45
+ const buildPollCloseTask = (pollVotesEnabled = false) => ({
45
46
  slug: POLL_CLOSE_TASK_SLUG,
46
47
  inputSchema: [{
47
48
  name: "formId",
@@ -52,22 +53,23 @@ const buildPollCloseTask = () => ({
52
53
  await runPollClose({
53
54
  payload: req.payload,
54
55
  input,
56
+ pollVotesEnabled,
55
57
  req
56
58
  });
57
59
  return { output: {} };
58
60
  }
59
61
  });
60
62
  /** Register the poll-close task on `config.jobs.tasks`, creating the jobs config if absent. */
61
- const registerPollCloseTask = (config) => {
63
+ const registerPollCloseTask = (config, pollVotesEnabled = false) => {
62
64
  config.jobs ??= {};
63
65
  config.jobs.tasks ??= [];
64
- config.jobs.tasks.push(buildPollCloseTask());
66
+ config.jobs.tasks.push(buildPollCloseTask(pollVotesEnabled));
65
67
  };
66
68
  const canQueue = (payload) => typeof payload.jobs?.queue === "function";
67
69
  /**
68
- * Delete this form's pending (never-run) close jobs so a re-enqueue supersedes the prior one. Payload
69
- * 3.85's `jobs.queue` has no concurrency key, so this mirrors core's `deleteScheduledPublishJobs`:
70
- * a direct `db.deleteMany` on the jobs collection, scoped by task slug and the JSON `input.formId`.
70
+ * Delete this form's pending (never-run) close jobs so a re-enqueue supersedes the prior one. A
71
+ * concurrency key would only serialize the jobs, not replace one, so this mirrors core's
72
+ * `deleteScheduledPublishJobs`: a direct `db.deleteMany` on the jobs collection, scoped by task slug and the JSON `input.formId`.
71
73
  * Best-effort; a failure here only risks a duplicate future job, which the idempotent handler absorbs.
72
74
  */
73
75
  const deletePendingCloseJobs = async (payload, formId, req) => {
@@ -77,7 +79,7 @@ const deletePendingCloseJobs = async (payload, formId, req) => {
77
79
  req,
78
80
  where: { and: [
79
81
  { completedAt: { exists: false } },
80
- { processing: { equals: false } },
82
+ { or: [{ processingUntil: { exists: false } }, { processingUntil: { less_than_equal: (/* @__PURE__ */ new Date()).toISOString() } }] },
81
83
  { taskSlug: { equals: POLL_CLOSE_TASK_SLUG } },
82
84
  { "input.formId": { equals: String(formId) } }
83
85
  ] }
@@ -107,6 +109,7 @@ const enqueuePollClose = async (args) => {
107
109
  task: POLL_CLOSE_TASK_SLUG,
108
110
  input: { formId: String(form.id) },
109
111
  waitUntil,
112
+ overrideAccess: true,
110
113
  req
111
114
  });
112
115
  } catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"closeJob.js","names":[],"sources":["../../src/poll/closeJob.ts"],"sourcesContent":["import type { Config, Payload, PayloadRequest, TaskConfig } from 'payload'\nimport { FORMS_SLUG } from '../collections/forms'\nimport { isPollClosed, type PollConfigLike, pollConfigOf } from '../form/pollState'\nimport { resolvePollOutcome } from './resolvePollOutcome'\n\nexport const POLL_CLOSE_TASK_SLUG = 'form-builder-poll-close'\n\n/** Payload's jobs collection; queried directly to supersede a superseded pending close job. */\nconst JOBS_SLUG = 'payload-jobs'\n\n/** Input the enqueue path stores; the handler re-loads everything else from the DB. */\nexport type PollCloseTaskInput = { formId: number | string }\n\n/** The slice of a loaded form the close gate reads. */\nexport type PollFormLike = { pollEnabled?: boolean | null; poll?: unknown }\n\nconst hasEmptyWinners = (poll: PollConfigLike): boolean => {\n\tconst winners = poll.outcome?.winningValues\n\treturn (\n\t\t!Array.isArray(winners) ||\n\t\twinners.filter((value) => typeof value === 'string' && value.length > 0).length === 0\n\t)\n}\n\nconst strategyOf = (poll: PollConfigLike): string =>\n\ttypeof poll.type === 'string' && poll.type.length > 0 ? poll.type : 'manual'\n\n/**\n * True when a poll's outcome should auto-resolve now: enabled, closed, still unresolved, and its\n * strategy is not `manual`. Shared by the close-job handler and the results-read fallback so the two\n * triggers apply the exact same gate.\n */\nexport const shouldAutoResolvePoll = (form: PollFormLike): boolean => {\n\tconst poll = pollConfigOf(form.poll)\n\treturn (\n\t\tform.pollEnabled === true &&\n\t\tpoll != null &&\n\t\tisPollClosed(poll) &&\n\t\thasEmptyWinners(poll) &&\n\t\tstrategyOf(poll) !== 'manual'\n\t)\n}\n\n/**\n * Run the scheduled close for one form. Idempotent: re-loads the form and only resolves when the\n * poll is enabled, closed, still unresolved, and not `manual`, so a re-run after the outcome was\n * recorded (or a job that fires slightly early) is a safe no-op. Tolerates a deleted form.\n */\nexport const runPollClose = async (args: {\n\tpayload: Payload\n\tinput: PollCloseTaskInput\n\treq?: PayloadRequest\n}): Promise<void> => {\n\tconst { payload, input, req } = args\n\tconst form = await payload\n\t\t.findByID({ collection: FORMS_SLUG, id: input.formId, depth: 0, overrideAccess: true, req })\n\t\t.catch(() => null)\n\tif (!form || !shouldAutoResolvePoll(form as PollFormLike)) {\n\t\treturn\n\t}\n\tawait resolvePollOutcome({ payload, formId: input.formId, req })\n}\n\n/** Native Payload jobs task that resolves a poll's outcome once it closes. */\nexport const buildPollCloseTask = (): TaskConfig =>\n\t({\n\t\tslug: POLL_CLOSE_TASK_SLUG,\n\t\tinputSchema: [{ name: 'formId', type: 'text', required: true }],\n\t\thandler: async ({ input, req }) => {\n\t\t\tawait runPollClose({ payload: req.payload, input: input as PollCloseTaskInput, req })\n\t\t\treturn { output: {} }\n\t\t},\n\t}) as TaskConfig\n\n/** Register the poll-close task on `config.jobs.tasks`, creating the jobs config if absent. */\nexport const registerPollCloseTask = (config: Config): void => {\n\tconfig.jobs ??= {}\n\tconfig.jobs.tasks ??= []\n\tconfig.jobs.tasks.push(buildPollCloseTask())\n}\n\nconst canQueue = (payload: Payload): boolean => typeof payload.jobs?.queue === 'function'\n\n/**\n * Delete this form's pending (never-run) close jobs so a re-enqueue supersedes the prior one. Payload\n * 3.85's `jobs.queue` has no concurrency key, so this mirrors core's `deleteScheduledPublishJobs`:\n * a direct `db.deleteMany` on the jobs collection, scoped by task slug and the JSON `input.formId`.\n * Best-effort; a failure here only risks a duplicate future job, which the idempotent handler absorbs.\n */\nconst deletePendingCloseJobs = async (\n\tpayload: Payload,\n\tformId: number | string,\n\treq?: PayloadRequest\n): Promise<void> => {\n\ttry {\n\t\tawait payload.db.deleteMany({\n\t\t\tcollection: JOBS_SLUG,\n\t\t\treq,\n\t\t\twhere: {\n\t\t\t\tand: [\n\t\t\t\t\t{ completedAt: { exists: false } },\n\t\t\t\t\t{ processing: { equals: false } },\n\t\t\t\t\t{ taskSlug: { equals: POLL_CLOSE_TASK_SLUG } },\n\t\t\t\t\t{ 'input.formId': { equals: String(formId) } },\n\t\t\t\t],\n\t\t\t},\n\t\t})\n\t} catch (error) {\n\t\tpayload.logger?.error(\n\t\t\t`@10x-media/form-builder: failed to clear pending poll-close jobs for form ${String(formId)}: ${\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t}`\n\t\t)\n\t}\n}\n\n/**\n * Schedule (or reschedule) the auto-close for a poll after a save. Enqueues a `waitUntil: closesAt`\n * job when the poll is enabled, has a `closesAt`, is still unresolved, and its strategy is not\n * `manual`, and only when a job runner is present (`payload.jobs.queue`); otherwise the resolve-on-read\n * fallback is the safety net. Any prior pending close job for the form is deleted first so the newest\n * `closesAt` wins. Never throws; a queue failure is logged and swallowed.\n */\nexport const enqueuePollClose = async (args: {\n\tpayload: Payload\n\tform: { id: number | string; pollEnabled?: boolean | null; poll?: unknown }\n\treq?: PayloadRequest\n}): Promise<void> => {\n\tconst { payload, form, req } = args\n\tconst poll = pollConfigOf(form.poll)\n\tif (form.pollEnabled !== true || !poll) {\n\t\treturn\n\t}\n\tconst closesAt =\n\t\ttypeof poll.closesAt === 'string' && poll.closesAt.length > 0 ? poll.closesAt : undefined\n\tif (!closesAt || !hasEmptyWinners(poll) || strategyOf(poll) === 'manual' || !canQueue(payload)) {\n\t\treturn\n\t}\n\tconst waitUntil = new Date(closesAt)\n\tif (Number.isNaN(waitUntil.getTime())) {\n\t\treturn\n\t}\n\tawait deletePendingCloseJobs(payload, form.id, req)\n\ttry {\n\t\tawait payload.jobs.queue({\n\t\t\ttask: POLL_CLOSE_TASK_SLUG,\n\t\t\tinput: { formId: String(form.id) },\n\t\t\twaitUntil,\n\t\t\treq,\n\t\t})\n\t} catch (error) {\n\t\tpayload.logger?.error(\n\t\t\t`@10x-media/form-builder: failed to enqueue poll-close for form ${String(form.id)}: ${\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t}`\n\t\t)\n\t}\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"closeJob.js","names":[],"sources":["../../src/poll/closeJob.ts"],"sourcesContent":["import type { Config, Payload, PayloadRequest, TaskConfig } from 'payload'\nimport { isPollClosed, type PollConfigLike, pollConfigOf } from '../form/pollState'\nimport { pluginSlugsOf } from '../plugin/collectionSlugs'\nimport { resolvePollOutcome } from './resolvePollOutcome'\n\nexport const POLL_CLOSE_TASK_SLUG = 'form-builder-poll-close'\n\n/** Payload's jobs collection; queried directly to supersede a superseded pending close job. */\nconst JOBS_SLUG = 'payload-jobs'\n\n/** Input the enqueue path stores; the handler re-loads everything else from the DB. */\nexport type PollCloseTaskInput = { formId: number | string }\n\n/** The slice of a loaded form the close gate reads. */\nexport type PollFormLike = { pollEnabled?: boolean | null; poll?: unknown }\n\nconst hasEmptyWinners = (poll: PollConfigLike): boolean => {\n\tconst winners = poll.outcome?.winningValues\n\treturn (\n\t\t!Array.isArray(winners) ||\n\t\twinners.filter((value) => typeof value === 'string' && value.length > 0).length === 0\n\t)\n}\n\nconst strategyOf = (poll: PollConfigLike): string =>\n\ttypeof poll.type === 'string' && poll.type.length > 0 ? poll.type : 'manual'\n\n/**\n * True when a poll's outcome should auto-resolve now: enabled, closed, still unresolved, and its\n * strategy is not `manual`. Shared by the close-job handler and the results-read fallback so the two\n * triggers apply the exact same gate.\n */\nexport const shouldAutoResolvePoll = (form: PollFormLike): boolean => {\n\tconst poll = pollConfigOf(form.poll)\n\treturn (\n\t\tform.pollEnabled === true &&\n\t\tpoll != null &&\n\t\tisPollClosed(poll) &&\n\t\thasEmptyWinners(poll) &&\n\t\tstrategyOf(poll) !== 'manual'\n\t)\n}\n\n/**\n * Run the scheduled close for one form. Idempotent: re-loads the form and only resolves when the\n * poll is enabled, closed, still unresolved, and not `manual`, so a re-run after the outcome was\n * recorded (or a job that fires slightly early) is a safe no-op. Tolerates a deleted form.\n */\nexport const runPollClose = async (args: {\n\tpayload: Payload\n\tinput: PollCloseTaskInput\n\t/** Whether the hidden tally store backs the outcome aggregation (see `resolvePollOutcome`). */\n\tpollVotesEnabled?: boolean\n\treq?: PayloadRequest\n}): Promise<void> => {\n\tconst { payload, input, pollVotesEnabled, req } = args\n\tconst form = await payload\n\t\t.findByID({\n\t\t\tcollection: pluginSlugsOf(payload).forms,\n\t\t\tid: input.formId,\n\t\t\tdepth: 0,\n\t\t\toverrideAccess: true,\n\t\t\treq,\n\t\t})\n\t\t.catch(() => null)\n\tif (!form || !shouldAutoResolvePoll(form as PollFormLike)) {\n\t\treturn\n\t}\n\tawait resolvePollOutcome({ payload, formId: input.formId, pollVotesEnabled, req })\n}\n\n/** Native Payload jobs task that resolves a poll's outcome once it closes. */\nexport const buildPollCloseTask = (pollVotesEnabled = false): TaskConfig =>\n\t({\n\t\tslug: POLL_CLOSE_TASK_SLUG,\n\t\tinputSchema: [{ name: 'formId', type: 'text', required: true }],\n\t\thandler: async ({ input, req }) => {\n\t\t\tawait runPollClose({\n\t\t\t\tpayload: req.payload,\n\t\t\t\tinput: input as PollCloseTaskInput,\n\t\t\t\tpollVotesEnabled,\n\t\t\t\treq,\n\t\t\t})\n\t\t\treturn { output: {} }\n\t\t},\n\t}) as TaskConfig\n\n/** Register the poll-close task on `config.jobs.tasks`, creating the jobs config if absent. */\nexport const registerPollCloseTask = (config: Config, pollVotesEnabled = false): void => {\n\tconfig.jobs ??= {}\n\tconfig.jobs.tasks ??= []\n\tconfig.jobs.tasks.push(buildPollCloseTask(pollVotesEnabled))\n}\n\nconst canQueue = (payload: Payload): boolean => typeof payload.jobs?.queue === 'function'\n\n/**\n * Delete this form's pending (never-run) close jobs so a re-enqueue supersedes the prior one. A\n * concurrency key would only serialize the jobs, not replace one, so this mirrors core's\n * `deleteScheduledPublishJobs`: a direct `db.deleteMany` on the jobs collection, scoped by task slug and the JSON `input.formId`.\n * Best-effort; a failure here only risks a duplicate future job, which the idempotent handler absorbs.\n */\nconst deletePendingCloseJobs = async (\n\tpayload: Payload,\n\tformId: number | string,\n\treq?: PayloadRequest\n): Promise<void> => {\n\ttry {\n\t\tawait payload.db.deleteMany({\n\t\t\tcollection: JOBS_SLUG,\n\t\t\treq,\n\t\t\twhere: {\n\t\t\t\tand: [\n\t\t\t\t\t{ completedAt: { exists: false } },\n\t\t\t\t\t// Not claimed by a runner right now: no processing lease, or one that has lapsed.\n\t\t\t\t\t{\n\t\t\t\t\t\tor: [\n\t\t\t\t\t\t\t{ processingUntil: { exists: false } },\n\t\t\t\t\t\t\t{ processingUntil: { less_than_equal: new Date().toISOString() } },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{ taskSlug: { equals: POLL_CLOSE_TASK_SLUG } },\n\t\t\t\t\t{ 'input.formId': { equals: String(formId) } },\n\t\t\t\t],\n\t\t\t},\n\t\t})\n\t} catch (error) {\n\t\tpayload.logger?.error(\n\t\t\t`@10x-media/form-builder: failed to clear pending poll-close jobs for form ${String(formId)}: ${\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t}`\n\t\t)\n\t}\n}\n\n/**\n * Schedule (or reschedule) the auto-close for a poll after a save. Enqueues a `waitUntil: closesAt`\n * job when the poll is enabled, has a `closesAt`, is still unresolved, and its strategy is not\n * `manual`, and only when a job runner is present (`payload.jobs.queue`); otherwise the resolve-on-read\n * fallback is the safety net. Any prior pending close job for the form is deleted first so the newest\n * `closesAt` wins. Never throws; a queue failure is logged and swallowed.\n */\nexport const enqueuePollClose = async (args: {\n\tpayload: Payload\n\tform: { id: number | string; pollEnabled?: boolean | null; poll?: unknown }\n\treq?: PayloadRequest\n}): Promise<void> => {\n\tconst { payload, form, req } = args\n\tconst poll = pollConfigOf(form.poll)\n\tif (form.pollEnabled !== true || !poll) {\n\t\treturn\n\t}\n\tconst closesAt =\n\t\ttypeof poll.closesAt === 'string' && poll.closesAt.length > 0 ? poll.closesAt : undefined\n\tif (!closesAt || !hasEmptyWinners(poll) || strategyOf(poll) === 'manual' || !canQueue(payload)) {\n\t\treturn\n\t}\n\tconst waitUntil = new Date(closesAt)\n\tif (Number.isNaN(waitUntil.getTime())) {\n\t\treturn\n\t}\n\tawait deletePendingCloseJobs(payload, form.id, req)\n\ttry {\n\t\tawait payload.jobs.queue({\n\t\t\ttask: POLL_CLOSE_TASK_SLUG,\n\t\t\tinput: { formId: String(form.id) },\n\t\t\twaitUntil,\n\t\t\t// The save already passed the forms collection's access; the queue is the plugin's own.\n\t\t\toverrideAccess: true,\n\t\t\treq,\n\t\t})\n\t} catch (error) {\n\t\tpayload.logger?.error(\n\t\t\t`@10x-media/form-builder: failed to enqueue poll-close for form ${String(form.id)}: ${\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t}`\n\t\t)\n\t}\n}\n"],"mappings":"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"}
@@ -1,8 +1,8 @@
1
1
  import { keys } from "../translations/keys.js";
2
2
  import { asTranslate } from "../translations/server.js";
3
+ import { pluginSlugsOf } from "../plugin/collectionSlugs.js";
3
4
  import { pollConfigOf } from "../form/pollState.js";
4
5
  import { resolveEffectivePollOptions } from "./effectivePollOptions.js";
5
- import { FORMS_SLUG } from "../collections/forms.js";
6
6
  import { ValidationError } from "payload";
7
7
  //#region src/poll/outcomeBeforeChange.ts
8
8
  const WINNING_VALUES_PATH = "poll.outcome.winningValues";
@@ -46,7 +46,7 @@ const pollOutcomeBeforeChange = async ({ data, originalDoc, req }) => {
46
46
  const t = asTranslate(req.t);
47
47
  const fail = (message) => {
48
48
  throw new ValidationError({
49
- collection: FORMS_SLUG,
49
+ collection: pluginSlugsOf(req.payload).forms,
50
50
  errors: [{
51
51
  path: WINNING_VALUES_PATH,
52
52
  message