@pro-laico/create-atomic-payload 0.1.4

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 (423) hide show
  1. package/bin/cli.js +159 -0
  2. package/package.json +29 -0
  3. package/template/.env.example +35 -0
  4. package/template/.gitattributes +2 -0
  5. package/template/.prettierrc.json +6 -0
  6. package/template/.vscode/extensions.json +3 -0
  7. package/template/.vscode/launch.json +24 -0
  8. package/template/.vscode/settings.json +86 -0
  9. package/template/.yarnrc +1 -0
  10. package/template/LICENSE.md +22 -0
  11. package/template/README.md +128 -0
  12. package/template/eslint.config.mjs +32 -0
  13. package/template/next-env.d.ts +6 -0
  14. package/template/next.config.ts +36 -0
  15. package/template/package.json +75 -0
  16. package/template/public/adminFavicon.svg +1 -0
  17. package/template/public/ogImage.webp +0 -0
  18. package/template/src/access/anyone.ts +3 -0
  19. package/template/src/access/authenticated.ts +7 -0
  20. package/template/src/access/authenticatedOrPublished.ts +6 -0
  21. package/template/src/app/(frontend)/[...slug]/page.tsx +48 -0
  22. package/template/src/app/(frontend)/layout.tsx +49 -0
  23. package/template/src/app/(frontend)/next/exit-preview/route.ts +7 -0
  24. package/template/src/app/(frontend)/next/preview/route.ts +45 -0
  25. package/template/src/app/(frontend)/next/seed/route.ts +31 -0
  26. package/template/src/app/(frontend)/not-found.tsx +93 -0
  27. package/template/src/app/(frontend)/page.tsx +5 -0
  28. package/template/src/app/(frontend)/sitemap.ts +14 -0
  29. package/template/src/app/(payload)/admin/[[...segments]]/not-found.tsx +24 -0
  30. package/template/src/app/(payload)/admin/[[...segments]]/page.tsx +24 -0
  31. package/template/src/app/(payload)/admin/importMap.js +85 -0
  32. package/template/src/app/(payload)/api/[...slug]/route.ts +19 -0
  33. package/template/src/app/(payload)/custom.scss +29 -0
  34. package/template/src/app/(payload)/layout.tsx +31 -0
  35. package/template/src/blocks/actions/blocks.ts +27 -0
  36. package/template/src/blocks/actions/cookieConsent/set/block.ts +17 -0
  37. package/template/src/blocks/actions/cookieConsent/set/filter.ts +3 -0
  38. package/template/src/blocks/actions/cookieConsent/set/options.ts +35 -0
  39. package/template/src/blocks/actions/cookieConsent/toDA/block.ts +14 -0
  40. package/template/src/blocks/actions/cookieConsent/toDA/filter.ts +3 -0
  41. package/template/src/blocks/actions/cookieConsent/toDA/options.ts +19 -0
  42. package/template/src/blocks/actions/dynamicStore/boolean/set/block.ts +15 -0
  43. package/template/src/blocks/actions/dynamicStore/boolean/set/filter.ts +4 -0
  44. package/template/src/blocks/actions/dynamicStore/boolean/set/options.ts +18 -0
  45. package/template/src/blocks/actions/dynamicStore/boolean/toDA/block.ts +10 -0
  46. package/template/src/blocks/actions/dynamicStore/boolean/toDA/filter.ts +3 -0
  47. package/template/src/blocks/actions/dynamicStore/boolean/toDA/options.ts +12 -0
  48. package/template/src/blocks/actions/dynamicStore/text/cycle/block.ts +41 -0
  49. package/template/src/blocks/actions/dynamicStore/text/cycle/filter.ts +4 -0
  50. package/template/src/blocks/actions/dynamicStore/text/cycle/options.ts +23 -0
  51. package/template/src/blocks/actions/dynamicStore/text/toDA/block.ts +10 -0
  52. package/template/src/blocks/actions/dynamicStore/text/toDA/filter.ts +3 -0
  53. package/template/src/blocks/actions/dynamicStore/text/toDA/options.ts +12 -0
  54. package/template/src/blocks/actions/filters.ts +27 -0
  55. package/template/src/blocks/actions/form/errorToDA/block.ts +18 -0
  56. package/template/src/blocks/actions/form/errorToDA/filter.ts +3 -0
  57. package/template/src/blocks/actions/form/errorToDA/options.ts +15 -0
  58. package/template/src/blocks/actions/form/reset/block.ts +18 -0
  59. package/template/src/blocks/actions/form/reset/filter.ts +3 -0
  60. package/template/src/blocks/actions/form/reset/options.ts +30 -0
  61. package/template/src/blocks/actions/form/statusToDA/block.ts +12 -0
  62. package/template/src/blocks/actions/form/statusToDA/filter.ts +3 -0
  63. package/template/src/blocks/actions/form/statusToDA/options.ts +15 -0
  64. package/template/src/blocks/actions/form/submit/block.ts +18 -0
  65. package/template/src/blocks/actions/form/submit/filter.ts +3 -0
  66. package/template/src/blocks/actions/form/submit/options.ts +35 -0
  67. package/template/src/blocks/actions/portal/set/block.ts +25 -0
  68. package/template/src/blocks/actions/portal/set/filter.ts +3 -0
  69. package/template/src/blocks/actions/portal/set/options.ts +43 -0
  70. package/template/src/blocks/actions/processor.ts +263 -0
  71. package/template/src/blocks/actions/theme/set/block.ts +10 -0
  72. package/template/src/blocks/actions/theme/set/filter.ts +3 -0
  73. package/template/src/blocks/actions/theme/set/options.ts +9 -0
  74. package/template/src/blocks/actions/zap.ts +4 -0
  75. package/template/src/blocks/children/atomic/block.ts +123 -0
  76. package/template/src/blocks/children/atomic/controlBar.ts +43 -0
  77. package/template/src/blocks/children/atomic/variants/button/typeField.ts +16 -0
  78. package/template/src/blocks/children/atomic/variants/button/variants/link/component.client.tsx +21 -0
  79. package/template/src/blocks/children/atomic/variants/button/variants/link/component.tsx +13 -0
  80. package/template/src/blocks/children/atomic/variants/button/variants/link/controlBar.ts +73 -0
  81. package/template/src/blocks/children/atomic/variants/button/variants/link/settings.ts +26 -0
  82. package/template/src/blocks/children/atomic/variants/button/variants/portal/controlBar.ts +35 -0
  83. package/template/src/blocks/children/atomic/variants/button/variants/portal/dialog/component.tsx +36 -0
  84. package/template/src/blocks/children/atomic/variants/button/variants/portal/dialog/settings.ts +24 -0
  85. package/template/src/blocks/children/atomic/variants/button/variants/portal/popover/component.tsx +41 -0
  86. package/template/src/blocks/children/atomic/variants/button/variants/portal/popover/settings.ts +111 -0
  87. package/template/src/blocks/children/atomic/variants/button/variants/regular/component.client.tsx +19 -0
  88. package/template/src/blocks/children/atomic/variants/button/variants/regular/component.tsx +11 -0
  89. package/template/src/blocks/children/atomic/variants/form/component.tsx +18 -0
  90. package/template/src/blocks/children/atomic/variants/form/controlBar.ts +22 -0
  91. package/template/src/blocks/children/atomic/variants/form/settings.ts +20 -0
  92. package/template/src/blocks/children/atomic/variants/input/autoCompleteOptions.ts +51 -0
  93. package/template/src/blocks/children/atomic/variants/input/controlBar.ts +13 -0
  94. package/template/src/blocks/children/atomic/variants/input/settings.ts +35 -0
  95. package/template/src/blocks/children/atomic/variants/input/typeField.ts +23 -0
  96. package/template/src/blocks/children/atomic/variants/input/variants/checkBox/component.client.tsx +12 -0
  97. package/template/src/blocks/children/atomic/variants/input/variants/checkBox/component.tsx +6 -0
  98. package/template/src/blocks/children/atomic/variants/input/variants/checkBox/settings.ts +9 -0
  99. package/template/src/blocks/children/atomic/variants/input/variants/number/component.client.tsx +12 -0
  100. package/template/src/blocks/children/atomic/variants/input/variants/number/component.tsx +6 -0
  101. package/template/src/blocks/children/atomic/variants/input/variants/number/settings.ts +9 -0
  102. package/template/src/blocks/children/atomic/variants/input/variants/radio/component.client.tsx +12 -0
  103. package/template/src/blocks/children/atomic/variants/input/variants/radio/component.tsx +6 -0
  104. package/template/src/blocks/children/atomic/variants/input/variants/radio/settings.ts +9 -0
  105. package/template/src/blocks/children/atomic/variants/input/variants/text/component.client.tsx +12 -0
  106. package/template/src/blocks/children/atomic/variants/input/variants/text/component.tsx +7 -0
  107. package/template/src/blocks/children/atomic/variants/input/variants/text/settings.ts +12 -0
  108. package/template/src/blocks/children/atomic/variants/tag/component.client.tsx +17 -0
  109. package/template/src/blocks/children/atomic/variants/tag/component.tsx +13 -0
  110. package/template/src/blocks/children/atomic/variants/tag/controlBar.ts +6 -0
  111. package/template/src/blocks/children/atomic/variants/tag/settings.ts +9 -0
  112. package/template/src/blocks/children/blocks.ts +13 -0
  113. package/template/src/blocks/children/icon/block.ts +41 -0
  114. package/template/src/blocks/children/icon/component.tsx +17 -0
  115. package/template/src/blocks/children/image/block.ts +80 -0
  116. package/template/src/blocks/children/image/component.tsx +21 -0
  117. package/template/src/blocks/children/richText/block.ts +50 -0
  118. package/template/src/blocks/children/richText/component/converters/index.tsx +10 -0
  119. package/template/src/blocks/children/richText/component/converters/internalLink.tsx +8 -0
  120. package/template/src/blocks/children/richText/component/index.tsx +10 -0
  121. package/template/src/blocks/children/richText/component.tsx +7 -0
  122. package/template/src/blocks/children/richText/defaultLexical.ts +65 -0
  123. package/template/src/blocks/children/simpleText/block.ts +41 -0
  124. package/template/src/blocks/children/simpleText/component.client.tsx +18 -0
  125. package/template/src/blocks/children/simpleText/component.tsx +11 -0
  126. package/template/src/blocks/children/svg/block.ts +39 -0
  127. package/template/src/blocks/children/svg/component.tsx +6 -0
  128. package/template/src/blocks/children/video/block.ts +70 -0
  129. package/template/src/blocks/children/video/component.tsx +11 -0
  130. package/template/src/blocks/children/zap.ts +54 -0
  131. package/template/src/blocks/submitForm/form/rateLimiting/blocks.ts +5 -0
  132. package/template/src/blocks/submitForm/form/rateLimiting/functions.ts +1 -0
  133. package/template/src/blocks/submitForm/form/rateLimiting/simpleSlidingWindow/block.ts +23 -0
  134. package/template/src/blocks/submitForm/form/rateLimiting/simpleSlidingWindow/serverFunction.ts +46 -0
  135. package/template/src/blocks/submitForm/form/sanitation/blocks.ts +6 -0
  136. package/template/src/blocks/submitForm/form/sanitation/combineTwoFields/block.ts +19 -0
  137. package/template/src/blocks/submitForm/form/sanitation/combineTwoFields/serverFunction.ts +22 -0
  138. package/template/src/blocks/submitForm/form/sanitation/functions.ts +1 -0
  139. package/template/src/blocks/submitForm/form/validation/blocks.ts +6 -0
  140. package/template/src/blocks/submitForm/form/validation/functions.ts +1 -0
  141. package/template/src/blocks/submitForm/form/validation/isUnique/block.ts +19 -0
  142. package/template/src/blocks/submitForm/form/validation/isUnique/serverFunction.ts +40 -0
  143. package/template/src/blocks/submitForm/form/zap.ts +8 -0
  144. package/template/src/blocks/submitForm/formProcessor.ts +222 -0
  145. package/template/src/blocks/submitForm/input/sanitation/blocks.ts +5 -0
  146. package/template/src/blocks/submitForm/input/sanitation/functions.ts +1 -0
  147. package/template/src/blocks/submitForm/input/sanitation/trimText/block.ts +24 -0
  148. package/template/src/blocks/submitForm/input/sanitation/trimText/serverFunction.ts +63 -0
  149. package/template/src/blocks/submitForm/input/useOn.ts +8 -0
  150. package/template/src/blocks/submitForm/input/validation/blocks.ts +6 -0
  151. package/template/src/blocks/submitForm/input/validation/contains/block.ts +12 -0
  152. package/template/src/blocks/submitForm/input/validation/contains/serverFunction.ts +23 -0
  153. package/template/src/blocks/submitForm/input/validation/doesNotContain/block.ts +12 -0
  154. package/template/src/blocks/submitForm/input/validation/doesNotContain/serverFunction.ts +23 -0
  155. package/template/src/blocks/submitForm/input/validation/functions.ts +2 -0
  156. package/template/src/blocks/submitForm/input/zap.ts +6 -0
  157. package/template/src/blocks/submitForm/serverFunction.ts +42 -0
  158. package/template/src/collections/designSets/collection.ts +44 -0
  159. package/template/src/collections/designSets/defaults.ts +20 -0
  160. package/template/src/collections/designSets/tabs/animation.ts +71 -0
  161. package/template/src/collections/designSets/tabs/colors.ts +31 -0
  162. package/template/src/collections/designSets/tabs/fonts.ts +53 -0
  163. package/template/src/collections/designSets/tabs/miscellaneous.ts +22 -0
  164. package/template/src/collections/designSets/tabs/prose.ts +151 -0
  165. package/template/src/collections/designSets/tabs/settings.ts +52 -0
  166. package/template/src/collections/designSets/tabs/sizes.ts +30 -0
  167. package/template/src/collections/designSets/tabs/storage.ts +51 -0
  168. package/template/src/collections/designSets/tabs/variables.ts +28 -0
  169. package/template/src/collections/favicons.ts +11 -0
  170. package/template/src/collections/fonts/collection.ts +20 -0
  171. package/template/src/collections/fonts/script.ts +199 -0
  172. package/template/src/collections/footers/collection.ts +48 -0
  173. package/template/src/collections/footers/component.tsx +13 -0
  174. package/template/src/collections/headers/collection.ts +47 -0
  175. package/template/src/collections/headers/component.tsx +13 -0
  176. package/template/src/collections/iconSets/collection.ts +80 -0
  177. package/template/src/collections/iconSets/defaults.ts +81 -0
  178. package/template/src/collections/icons.ts +20 -0
  179. package/template/src/collections/images.ts +29 -0
  180. package/template/src/collections/index.ts +17 -0
  181. package/template/src/collections/muxVideos.ts +13 -0
  182. package/template/src/collections/pages/collection.ts +88 -0
  183. package/template/src/collections/pages/tabs/SEO.ts +70 -0
  184. package/template/src/collections/pages/tabs/settings.ts +17 -0
  185. package/template/src/collections/posthogProperty.ts +48 -0
  186. package/template/src/collections/shortcutSets/collection.ts +30 -0
  187. package/template/src/collections/shortcutSets/defaults.ts +1 -0
  188. package/template/src/collections/shortcutSets/protectedNames.ts +135 -0
  189. package/template/src/collections/shortcutSets/tabs/settings.ts +13 -0
  190. package/template/src/collections/shortcutSets/tabs/shortcuts.ts +70 -0
  191. package/template/src/collections/users.ts +11 -0
  192. package/template/src/collections/zap.ts +59 -0
  193. package/template/src/components/child/SSRProps.ts +381 -0
  194. package/template/src/components/child/renderChildren.tsx +148 -0
  195. package/template/src/components/livePreviewListener.tsx +10 -0
  196. package/template/src/components/providers/formProvider.tsx +11 -0
  197. package/template/src/components/providers/tracking/gtm.tsx +11 -0
  198. package/template/src/components/providers/tracking/index.tsx +46 -0
  199. package/template/src/components/providers/tracking/postHog.tsx +41 -0
  200. package/template/src/components/providers/tracking/vercel.tsx +10 -0
  201. package/template/src/components/toast/index.module.css +142 -0
  202. package/template/src/components/toast/index.tsx +55 -0
  203. package/template/src/endpoints/seed/backendForm.ts +48 -0
  204. package/template/src/endpoints/seed/designSet.ts +476 -0
  205. package/template/src/endpoints/seed/footer.ts +389 -0
  206. package/template/src/endpoints/seed/header.ts +3511 -0
  207. package/template/src/endpoints/seed/iconSet.ts +19 -0
  208. package/template/src/endpoints/seed/icons/assets/check.svg +4 -0
  209. package/template/src/endpoints/seed/icons/assets/close.svg +4 -0
  210. package/template/src/endpoints/seed/icons/assets/cookie.svg +7 -0
  211. package/template/src/endpoints/seed/icons/assets/github.svg +1 -0
  212. package/template/src/endpoints/seed/icons/assets/logo.svg +11 -0
  213. package/template/src/endpoints/seed/icons/assets/menu.svg +4 -0
  214. package/template/src/endpoints/seed/icons/assets/theme.svg +4 -0
  215. package/template/src/endpoints/seed/icons/check.ts +14 -0
  216. package/template/src/endpoints/seed/icons/close.ts +14 -0
  217. package/template/src/endpoints/seed/icons/cookie.ts +14 -0
  218. package/template/src/endpoints/seed/icons/github.ts +14 -0
  219. package/template/src/endpoints/seed/icons/index.ts +7 -0
  220. package/template/src/endpoints/seed/icons/logo.ts +14 -0
  221. package/template/src/endpoints/seed/icons/menu.ts +14 -0
  222. package/template/src/endpoints/seed/icons/theme.ts +14 -0
  223. package/template/src/endpoints/seed/index.ts +100 -0
  224. package/template/src/endpoints/seed/pages/home.ts +858 -0
  225. package/template/src/endpoints/seed/pages/index.ts +4 -0
  226. package/template/src/endpoints/seed/pages/notFoundPage.ts +287 -0
  227. package/template/src/endpoints/seed/pages/prose.ts +1436 -0
  228. package/template/src/endpoints/seed/pages/testing.ts +2181 -0
  229. package/template/src/endpoints/seed/shortcutSet.ts +187 -0
  230. package/template/src/endpoints/seed/siteMetaData.ts +10 -0
  231. package/template/src/fields/actions/changeKey.ts +12 -0
  232. package/template/src/fields/actions/index.ts +6 -0
  233. package/template/src/fields/actions/initialValueCheckbox.ts +14 -0
  234. package/template/src/fields/actions/keyText.ts +10 -0
  235. package/template/src/fields/actions/persisted.ts +14 -0
  236. package/template/src/fields/actions/setData.ts +20 -0
  237. package/template/src/fields/actions/strict/index.ts +3 -0
  238. package/template/src/fields/actions/strict/keySelect.ts +28 -0
  239. package/template/src/fields/actions/strict/listenSelect.ts +28 -0
  240. package/template/src/fields/actions/strict/performSelect.ts +30 -0
  241. package/template/src/fields/actions/strict/registry/cookieConsent.ts +14 -0
  242. package/template/src/fields/actions/strict/registry/index.ts +6 -0
  243. package/template/src/fields/actions/strict/registry/theme.ts +9 -0
  244. package/template/src/fields/active.ts +16 -0
  245. package/template/src/fields/apf/index.ts +69 -0
  246. package/template/src/fields/apf/storage.ts +38 -0
  247. package/template/src/fields/blocks/actions.ts +30 -0
  248. package/template/src/fields/blocks/backdropChildren.ts +11 -0
  249. package/template/src/fields/blocks/children.ts +15 -0
  250. package/template/src/fields/blocks/submitForm/form.ts +24 -0
  251. package/template/src/fields/blocks/submitForm/input.ts +25 -0
  252. package/template/src/fields/className.ts +26 -0
  253. package/template/src/fields/coloredEnd.ts +5 -0
  254. package/template/src/fields/defaultOpen.ts +14 -0
  255. package/template/src/fields/designSets/value.ts +80 -0
  256. package/template/src/fields/devMode.ts +11 -0
  257. package/template/src/fields/favicon.ts +18 -0
  258. package/template/src/fields/for.ts +11 -0
  259. package/template/src/fields/keepMounted.ts +11 -0
  260. package/template/src/fields/modal.ts +16 -0
  261. package/template/src/fields/slug.ts +35 -0
  262. package/template/src/fields/staticDataAttributes.ts +29 -0
  263. package/template/src/fields/tabs/block/children/actions.ts +49 -0
  264. package/template/src/fields/tabs/block/children/backdrop.ts +17 -0
  265. package/template/src/fields/tabs/block/children/settings.ts +45 -0
  266. package/template/src/fields/tabs/block/children/submitForm/form.ts +23 -0
  267. package/template/src/fields/tabs/block/children/submitForm/input.ts +14 -0
  268. package/template/src/fields/tabs/block/children/tracking.ts +25 -0
  269. package/template/src/fields/tabs/collection/storage.ts +55 -0
  270. package/template/src/fields/tagType.ts +32 -0
  271. package/template/src/fields/testPath.ts +3 -0
  272. package/template/src/fields/uniqueTitle.ts +8 -0
  273. package/template/src/fields/validationMessage.ts +13 -0
  274. package/template/src/globals/index.ts +8 -0
  275. package/template/src/globals/settings.ts +36 -0
  276. package/template/src/globals/siteMetaData.ts +29 -0
  277. package/template/src/globals/storage.ts +15 -0
  278. package/template/src/globals/tracking/global.ts +25 -0
  279. package/template/src/globals/tracking/tabs/gtm.ts +18 -0
  280. package/template/src/globals/tracking/tabs/postHog.ts +35 -0
  281. package/template/src/hooks/collection/atomicHook/atomicHook.ts +223 -0
  282. package/template/src/hooks/collection/atomicHook/processors/cssProcessor.ts +60 -0
  283. package/template/src/hooks/collection/atomicHook/processors/processDesignSet/generatePreflights.ts +36 -0
  284. package/template/src/hooks/collection/atomicHook/processors/processDesignSet/index.ts +176 -0
  285. package/template/src/hooks/collection/atomicHook/processors/unsetActive.ts +24 -0
  286. package/template/src/hooks/collection/formatSVG.ts +157 -0
  287. package/template/src/hooks/collection/revalidate.ts +53 -0
  288. package/template/src/hooks/collection/sanitizeCollection.ts +5 -0
  289. package/template/src/hooks/field/apf.ts +59 -0
  290. package/template/src/hooks/field/formatSlug.ts +23 -0
  291. package/template/src/hooks/field/href.ts +6 -0
  292. package/template/src/hooks/field/publishedAt.ts +5 -0
  293. package/template/src/hooks/frontEnd/atomicStore/create.ts +69 -0
  294. package/template/src/hooks/frontEnd/atomicStore/index.tsx +20 -0
  295. package/template/src/hooks/frontEnd/atomicStore/slices/base.ts +7 -0
  296. package/template/src/hooks/frontEnd/atomicStore/slices/consent.ts +76 -0
  297. package/template/src/hooks/frontEnd/atomicStore/slices/dynamic.ts +51 -0
  298. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/boolToDA/function.ts +14 -0
  299. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/boolToDA/zap.ts +12 -0
  300. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/cCToDA/function.ts +34 -0
  301. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/cCToDA/zap.ts +17 -0
  302. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/errorToDA/function.ts +22 -0
  303. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/errorToDA/zap.ts +10 -0
  304. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/function.ts +20 -0
  305. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/statusToDA/function.ts +24 -0
  306. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/statusToDA/zap.ts +10 -0
  307. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/textToDA/function.ts +21 -0
  308. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/textToDA/zap.ts +12 -0
  309. package/template/src/hooks/frontEnd/useActions/dispatch/attributer/zap.ts +15 -0
  310. package/template/src/hooks/frontEnd/useActions/dispatch/index.ts +2 -0
  311. package/template/src/hooks/frontEnd/useActions/dispatch/runner/cycleText/function.ts +30 -0
  312. package/template/src/hooks/frontEnd/useActions/dispatch/runner/cycleText/zap.ts +12 -0
  313. package/template/src/hooks/frontEnd/useActions/dispatch/runner/function.ts +21 -0
  314. package/template/src/hooks/frontEnd/useActions/dispatch/runner/resetForm/function.ts +7 -0
  315. package/template/src/hooks/frontEnd/useActions/dispatch/runner/resetForm/zap.ts +9 -0
  316. package/template/src/hooks/frontEnd/useActions/dispatch/runner/setBool/function.ts +10 -0
  317. package/template/src/hooks/frontEnd/useActions/dispatch/runner/setBool/zap.ts +11 -0
  318. package/template/src/hooks/frontEnd/useActions/dispatch/runner/setCCs/function.ts +33 -0
  319. package/template/src/hooks/frontEnd/useActions/dispatch/runner/setCCs/zap.ts +14 -0
  320. package/template/src/hooks/frontEnd/useActions/dispatch/runner/setThemes/function.ts +11 -0
  321. package/template/src/hooks/frontEnd/useActions/dispatch/runner/setThemes/zap.ts +10 -0
  322. package/template/src/hooks/frontEnd/useActions/dispatch/runner/submitForm/function.ts +32 -0
  323. package/template/src/hooks/frontEnd/useActions/dispatch/runner/submitForm/zap.ts +9 -0
  324. package/template/src/hooks/frontEnd/useActions/dispatch/runner/zap.ts +16 -0
  325. package/template/src/hooks/frontEnd/useActions/dispatch/zap.ts +2 -0
  326. package/template/src/hooks/frontEnd/useActions/index.ts +6 -0
  327. package/template/src/hooks/frontEnd/useActions/useActionContext.ts +21 -0
  328. package/template/src/hooks/frontEnd/useActions/useButtonActions.ts +17 -0
  329. package/template/src/hooks/frontEnd/useActions/useDaToText.ts +34 -0
  330. package/template/src/hooks/frontEnd/useActions/useForm.ts +114 -0
  331. package/template/src/hooks/frontEnd/useActions/usePortal.ts +33 -0
  332. package/template/src/hooks/frontEnd/useActions/useToDa.ts +12 -0
  333. package/template/src/hooks/global/revalidate.ts +26 -0
  334. package/template/src/payload.config.ts +78 -0
  335. package/template/src/plugins/blurDataUrls.ts +8 -0
  336. package/template/src/plugins/formBuilder.ts +40 -0
  337. package/template/src/plugins/index.ts +17 -0
  338. package/template/src/plugins/muxVideo.ts +13 -0
  339. package/template/src/plugins/nestedDocs.ts +9 -0
  340. package/template/src/plugins/vercelBlobStorage.ts +8 -0
  341. package/template/src/ts/JSONSchema.ts +93 -0
  342. package/template/src/ts/declarations.ts +24 -0
  343. package/template/src/ts/types/actions.ts +175 -0
  344. package/template/src/ts/types/apf.ts +108 -0
  345. package/template/src/ts/types/cache.ts +166 -0
  346. package/template/src/ts/types/css.ts +14 -0
  347. package/template/src/ts/types/forms.ts +214 -0
  348. package/template/src/ts/types/frontEnd.ts +115 -0
  349. package/template/src/ts/types/index.ts +49 -0
  350. package/template/src/ts/types/payload-types.ts +3684 -0
  351. package/template/src/ts/zap/ap.ts +82 -0
  352. package/template/src/ts/zap/index.ts +4 -0
  353. package/template/src/ui/apf/controls.tsx +88 -0
  354. package/template/src/ui/apf/field.tsx +81 -0
  355. package/template/src/ui/apf/index.scss +59 -0
  356. package/template/src/ui/apf/label.tsx +23 -0
  357. package/template/src/ui/assets/Icon.tsx +21 -0
  358. package/template/src/ui/assets/Logo.tsx +21 -0
  359. package/template/src/ui/assets/atomicIcon.tsx +27 -0
  360. package/template/src/ui/assets/warningIcon.ts +6 -0
  361. package/template/src/ui/blocks/actionBlock.tsx +44 -0
  362. package/template/src/ui/blocks/inputBlock.tsx +24 -0
  363. package/template/src/ui/decorative/coloredEnd.tsx +16 -0
  364. package/template/src/ui/decorative/index.scss +46 -0
  365. package/template/src/ui/fields/iconSelect/index.tsx +19 -0
  366. package/template/src/ui/fields/slug/index.scss +12 -0
  367. package/template/src/ui/fields/slug/index.tsx +72 -0
  368. package/template/src/ui/index.ts +32 -0
  369. package/template/src/ui/root/beforeDashboard/index.scss +22 -0
  370. package/template/src/ui/root/beforeDashboard/index.tsx +39 -0
  371. package/template/src/ui/root/beforeDashboard/seedButton/index.scss +12 -0
  372. package/template/src/ui/root/beforeDashboard/seedButton/index.tsx +84 -0
  373. package/template/src/ui/root/siteTriggers/index.scss +22 -0
  374. package/template/src/ui/root/siteTriggers/index.tsx +94 -0
  375. package/template/src/ui/root/siteTriggers/triggerVercelDeploy.ts +37 -0
  376. package/template/src/ui/rowLabels/animation.tsx +27 -0
  377. package/template/src/ui/rowLabels/atomic/index.scss +62 -0
  378. package/template/src/ui/rowLabels/atomic/index.tsx +96 -0
  379. package/template/src/ui/rowLabels/color.tsx +33 -0
  380. package/template/src/ui/rowLabels/designToken.tsx +30 -0
  381. package/template/src/ui/rowLabels/icon.tsx +32 -0
  382. package/template/src/ui/rowLabels/shortcut/index.scss +21 -0
  383. package/template/src/ui/rowLabels/shortcut/index.tsx +30 -0
  384. package/template/src/ui/rowLabels/simpleText.tsx +41 -0
  385. package/template/src/utilities/deepMerge.ts +30 -0
  386. package/template/src/utilities/extractSVG.ts +9 -0
  387. package/template/src/utilities/format/toKebabCase.ts +79 -0
  388. package/template/src/utilities/format/toTitleCase.ts +47 -0
  389. package/template/src/utilities/formatDurationWithTokens.ts +56 -0
  390. package/template/src/utilities/generateMetaData.ts +45 -0
  391. package/template/src/utilities/generatePreviewPath.ts +43 -0
  392. package/template/src/utilities/get/cache/getAtomicActions.ts +48 -0
  393. package/template/src/utilities/get/cache/getAtomicClasses.ts +20 -0
  394. package/template/src/utilities/get/cache/getDesignSet.ts +15 -0
  395. package/template/src/utilities/get/cache/getFooter.ts +17 -0
  396. package/template/src/utilities/get/cache/getFormSubmissions.ts +17 -0
  397. package/template/src/utilities/get/cache/getForms.ts +43 -0
  398. package/template/src/utilities/get/cache/getHeader.ts +17 -0
  399. package/template/src/utilities/get/cache/getIcon.ts +51 -0
  400. package/template/src/utilities/get/cache/getImage.ts +20 -0
  401. package/template/src/utilities/get/cache/getPage.ts +35 -0
  402. package/template/src/utilities/get/cache/getPages.ts +24 -0
  403. package/template/src/utilities/get/cache/getShortcutSet.ts +17 -0
  404. package/template/src/utilities/get/cache/getSiteCSS.ts +17 -0
  405. package/template/src/utilities/get/cache/getSiteMetadata.ts +14 -0
  406. package/template/src/utilities/get/cache/getSitemap.ts +50 -0
  407. package/template/src/utilities/get/cache/getTracking.ts +14 -0
  408. package/template/src/utilities/get/cache/index.ts +129 -0
  409. package/template/src/utilities/get/cache/react.ts +5 -0
  410. package/template/src/utilities/get/getImageURL.ts +20 -0
  411. package/template/src/utilities/get/getMeUser.ts +22 -0
  412. package/template/src/utilities/get/getURL.ts +20 -0
  413. package/template/src/utilities/log/cache.ts +8 -0
  414. package/template/src/utilities/log/manual.ts +11 -0
  415. package/template/src/utilities/log/revalidation.ts +6 -0
  416. package/template/src/utilities/mergeTags.ts +7 -0
  417. package/template/src/utilities/propertyApplicatorUtility.ts +20 -0
  418. package/template/src/utilities/revalidateTag.ts +55 -0
  419. package/template/src/utilities/runAPF.ts +10 -0
  420. package/template/src/utilities/sanitizeData.ts +24 -0
  421. package/template/src/utilities/seedNestedRelationship.ts +5 -0
  422. package/template/tailwind.config.js +9 -0
  423. package/template/tsconfig.json +49 -0
@@ -0,0 +1,41 @@
1
+ 'use client'
2
+ import { SimpleTextChild } from '@/ts/types'
3
+ import { Pill, RowLabel, useRowLabel, SectionTitle } from '@payloadcms/ui'
4
+
5
+ const TRUNCATE_LENGTH = 50
6
+ const TRUNCATE_SUFFIX = '...'
7
+
8
+ export const SimpleTextRowLabel = () => {
9
+ const { data, path, rowNumber } = useRowLabel<SimpleTextChild>()
10
+ const { text } = data
11
+
12
+ let elaborationPill: string | null = null
13
+ if (text) elaborationPill = text.length > TRUNCATE_LENGTH ? `"${text.slice(0, TRUNCATE_LENGTH)}${TRUNCATE_SUFFIX}"` : `"${text}"`
14
+
15
+ const formattedRowNumber = String(rowNumber ?? 0).padStart(2, '0')
16
+
17
+ return (
18
+ <RowLabel
19
+ path={path}
20
+ rowNumber={rowNumber}
21
+ label={
22
+ <>
23
+ <span>{formattedRowNumber}</span>
24
+ <Pill pillStyle="white" size="small">
25
+ Simple Text
26
+ </Pill>
27
+ {elaborationPill && (
28
+ <Pill pillStyle="white" size="small">
29
+ {elaborationPill}
30
+ </Pill>
31
+ )}
32
+ <SectionTitle path={`${path}.blockName`} readOnly={false} />
33
+ </>
34
+ }
35
+ />
36
+ )
37
+ }
38
+
39
+ SimpleTextRowLabel.displayName = 'SimpleTextRowLabel'
40
+
41
+ export default SimpleTextRowLabel
@@ -0,0 +1,30 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
3
+
4
+ /**
5
+ * Simple object check.
6
+ * @param item
7
+ * @returns {boolean}
8
+ */
9
+ export function isObject(item: unknown): item is object {
10
+ return typeof item === 'object' && !Array.isArray(item)
11
+ }
12
+
13
+ /**
14
+ * Deep merge two objects.
15
+ * @param target
16
+ * @param ...sources
17
+ */
18
+ export default function deepMerge<T, R>(target: T, source: R): T {
19
+ const output = { ...target }
20
+ if (isObject(target) && isObject(source)) {
21
+ Object.keys(source).forEach((key) => {
22
+ if (isObject(source[key])) {
23
+ if (!(key in target)) Object.assign(output, { [key]: source[key] })
24
+ else output[key] = deepMerge(target[key], source[key])
25
+ } else Object.assign(output, { [key]: source[key] })
26
+ })
27
+ }
28
+
29
+ return output
30
+ }
@@ -0,0 +1,9 @@
1
+ export const extractSvgContent = (svgString: string): string => svgString.match(/<svg[^>]*>([\s\S]*)<\/svg>/i)?.[1] || svgString
2
+
3
+ export const extractSvgProps = (svgString: string): Record<string, string> => {
4
+ const match = svgString.match(/<svg([^>]*)>/i)
5
+ if (!match) return {}
6
+ const props: Record<string, string> = {}
7
+ for (const [, key, value] of match[1].matchAll(/(\w+)="([^"]*)"/g)) props[key] = value
8
+ return props
9
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Configuration options for toKebabCase function.
3
+ *
4
+ * @options addQuotes, unicodeNormalization, camelCaseHandling, lowercase, dashCollapse, dashTrim
5
+ */
6
+ export interface NameKebabOptions {
7
+ /**
8
+ * Add ' to beginning and end.
9
+ *
10
+ * @Default false
11
+ */
12
+ addQuotes?: boolean
13
+ /**
14
+ * Disable unicode normalization and diacritic removal
15
+ *
16
+ * @Default false
17
+ */
18
+ unicodeNormalization?: boolean
19
+ /**
20
+ * Disable camelCase/PascalCase boundary detection
21
+ *
22
+ * @Default false
23
+ */
24
+ camelCaseHandling?: boolean
25
+ /**
26
+ * Disable conversion to lowercase
27
+ *
28
+ * @Default false
29
+ */
30
+ lowercase?: boolean
31
+ /**
32
+ * Disable collapsing multiple dashes into single dash
33
+ *
34
+ * @Default false
35
+ */
36
+ dashCollapse?: boolean
37
+ /**
38
+ * Disable trimming dashes from start and end
39
+ *
40
+ * @Default false
41
+ */
42
+ dashTrim?: boolean
43
+ }
44
+
45
+ /**
46
+ * Converts a string to kebab-case format by normalizing unicode characters, handling camelCase/PascalCase boundaries, and replacing non-alphanumeric characters with dashes.
47
+ * Returns an empty string for null/undefined input or when the result would be empty.
48
+ */
49
+ export function toKebabCase(input?: string | null, options: NameKebabOptions = {}): string {
50
+ if (!input) return ''
51
+ let s = input
52
+
53
+ // 1. Unicode normalize and strip diacritics: "Crème" -> "Creme"
54
+ if (options?.unicodeNormalization) s = s.normalize('NFKD').replace(/[\u0300-\u036f]/g, '')
55
+
56
+ // 2. Handle camelCase / PascalCase / acronym boundaries:
57
+ if (options?.camelCaseHandling) {
58
+ s = s
59
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2') // fooBar -> foo-Bar
60
+ .replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, '$1-$2') // JSONData -> JSON-Data
61
+ }
62
+
63
+ // 3. Replace any run of non-alphanumeric characters with a dash
64
+ s = s.replace(/[^A-Za-z0-9]+/g, '-')
65
+
66
+ // 4. Lowercase
67
+ if (options?.lowercase) s = s.toLowerCase()
68
+
69
+ // 5. Collapse multiple dashes and trim edges
70
+ if (options?.dashCollapse) s = s.replace(/-+/g, '-')
71
+
72
+ // 6. Trim dashes from start and end
73
+ if (options?.dashTrim) s = s.replace(/^-|-$/g, '')
74
+
75
+ // 7. Add quotes if requested
76
+ if (options?.addQuotes) s = `'${s}'`
77
+
78
+ return s
79
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Converts various text formats to Title Case by normalizing unicode characters,
3
+ * handling different case boundaries, and properly capitalizing words.
4
+ * Returns an empty string for null/undefined input or when the result would be empty.
5
+ */
6
+ export function toTitleCase(input?: string | null): string {
7
+ if (!input) return ''
8
+
9
+ // 1. Unicode normalize and strip diacritics: "Crème" -> "Creme"
10
+ let s = input.normalize('NFKD').replace(/[\u0300-\u036f]/g, '')
11
+
12
+ // 2. Handle different case boundaries and separators:
13
+ s = s
14
+ // Handle camelCase / PascalCase boundaries
15
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2') // fooBar -> foo Bar
16
+ .replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, '$1 $2') // JSONData -> JSON Data
17
+
18
+ // Handle kebab-case and snake_case
19
+ .replace(/[-_]+/g, ' ') // Replace dashes and underscores with spaces
20
+
21
+ // Handle other separators (dots, colons, etc.)
22
+ .replace(/[.\s]+/g, ' ') // Replace dots and multiple spaces with single space
23
+
24
+ // 3. Split into words and capitalize each word
25
+ const words = s.split(/\s+/).filter((word) => word.length > 0)
26
+
27
+ if (words.length === 0) return ''
28
+
29
+ // 4. Capitalize each word properly
30
+ const titleCaseWords = words.map((word) => {
31
+ // Handle acronyms (all caps words)
32
+ if (/^[A-Z]+$/.test(word)) {
33
+ return word // Keep acronyms as-is
34
+ }
35
+
36
+ // Handle mixed case words (like "iPhone", "McDonald")
37
+ if (/^[A-Z][a-z]+$/.test(word)) {
38
+ return word // Already properly capitalized
39
+ }
40
+
41
+ // Handle words that start with lowercase
42
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
43
+ })
44
+
45
+ // 5. Join words with spaces and trim
46
+ return titleCaseWords.join(' ').trim()
47
+ }
@@ -0,0 +1,56 @@
1
+ import dayjs from 'dayjs'
2
+ import duration from 'dayjs/plugin/duration'
3
+
4
+ dayjs.extend(duration)
5
+
6
+ export function formatDurationString(ms: number, template: string): string {
7
+ const dur = dayjs.duration(ms)
8
+
9
+ const tokens: Record<string, () => string> = {
10
+ '{d}': () => {
11
+ const d = dur.days()
12
+ return d > 0 ? `${d} day${d !== 1 ? 's' : ''}` : '0 days'
13
+ },
14
+ '{dh}': () => {
15
+ const d = dur.days()
16
+ const h = dur.hours()
17
+ const parts = []
18
+ if (d > 0) parts.push(`${d} day${d !== 1 ? 's' : ''}`)
19
+ if (h > 0) parts.push(`${h} hour${h !== 1 ? 's' : ''}`)
20
+ return parts.join(' and ') || '0 hours'
21
+ },
22
+ '{h}': () => {
23
+ const h = dur.asHours()
24
+ const whole = Math.floor(h)
25
+ return `${whole} hour${whole !== 1 ? 's' : ''}`
26
+ },
27
+ '{hm}': () => {
28
+ const h = dur.hours()
29
+ const m = dur.minutes()
30
+ const parts = []
31
+ if (h > 0) parts.push(`${h} hour${h !== 1 ? 's' : ''}`)
32
+ if (m > 0) parts.push(`${m} minute${m !== 1 ? 's' : ''}`)
33
+ return parts.join(' and ') || '0 minutes'
34
+ },
35
+ '{m}': () => {
36
+ const m = Math.floor(dur.asMinutes())
37
+ return `${m} minute${m !== 1 ? 's' : ''}`
38
+ },
39
+ '{ms}': () => {
40
+ const m = dur.minutes()
41
+ const s = dur.seconds()
42
+ const parts = []
43
+ if (m > 0) parts.push(`${m} minute${m !== 1 ? 's' : ''}`)
44
+ if (s > 0) parts.push(`${s} second${s !== 1 ? 's' : ''}`)
45
+ return parts.join(' and ') || '0 seconds'
46
+ },
47
+ '{s}': () => {
48
+ const s = Math.floor(dur.asSeconds())
49
+ return `${s} second${s !== 1 ? 's' : ''}`
50
+ },
51
+ }
52
+
53
+ return template.replace(/\{[a-z]+\}/g, (match) => {
54
+ return tokens[match]?.() ?? match
55
+ })
56
+ }
@@ -0,0 +1,45 @@
1
+ import { Metadata } from 'next'
2
+ import { PageReturn, SiteMetaDatum, Image } from '@/ts/types'
3
+
4
+ type GenerateMetaDataArgs = { page?: PageReturn; siteMetadata?: SiteMetaDatum }
5
+ type GenerateMetaData = (args: GenerateMetaDataArgs) => Metadata
6
+
7
+ const processImageUrl = (image: Image | string | null | undefined): string | undefined => {
8
+ if (!image || typeof image === 'string') return
9
+ const url = image.sizes?.og?.url || image.url
10
+ return url || undefined
11
+ }
12
+
13
+ /** Gets the page metadata for a given page and site metadata. Returns a finished Metadata object.*/
14
+ export const GenerateMetaData: GenerateMetaData = ({ page, siteMetadata }) => {
15
+ const { siteName, fallbackOGImage, fallbackLightFavicon, fallbackDarkFavicon, fallbackSiteDescription } = siteMetadata || {}
16
+ const { title, description, image, lightFavicon, darkFavicon, noIndex } = page?.meta || {}
17
+
18
+ const imageUrl = processImageUrl(image)
19
+ const darkFaviconUrl = processImageUrl(darkFavicon)
20
+ const lightFaviconUrl = processImageUrl(lightFavicon)
21
+ const fallbackOGImageUrl = processImageUrl(fallbackOGImage)
22
+ const fallbackDarkFaviconUrl = processImageUrl(fallbackDarkFavicon)
23
+ const fallbackLightFaviconUrl = processImageUrl(fallbackLightFavicon)
24
+
25
+ const metadata: Metadata = {
26
+ title: title || siteName || 'Atomic Payload',
27
+ robots: page ? (noIndex ? 'noindex' : 'index, follow') : 'noindex',
28
+ description: description || fallbackSiteDescription || '',
29
+ openGraph: {
30
+ siteName: siteName || 'Atomic Payload',
31
+ images: imageUrl || fallbackOGImageUrl || undefined,
32
+ description: description || fallbackSiteDescription || '',
33
+ },
34
+ }
35
+
36
+ const icons: Metadata['icons'] = []
37
+
38
+ if (lightFaviconUrl) icons.push({ url: lightFaviconUrl })
39
+ if (darkFaviconUrl) icons.push({ url: darkFaviconUrl, media: '(prefers-color-scheme: dark)' })
40
+ if (fallbackLightFaviconUrl && !lightFaviconUrl) icons.push({ url: fallbackLightFaviconUrl })
41
+ if (fallbackDarkFaviconUrl && !darkFaviconUrl) icons.push({ url: fallbackDarkFaviconUrl, media: '(prefers-color-scheme: dark)' })
42
+
43
+ const result = { ...metadata, icons }
44
+ return result
45
+ }
@@ -0,0 +1,43 @@
1
+ import { PayloadRequest } from 'payload'
2
+ import { getClientSideURL } from './get/getURL'
3
+
4
+ type Props = {
5
+ data: Partial<any>
6
+ req: PayloadRequest
7
+ }
8
+
9
+ export const generateLivePreviewPath = async ({ data, req: { payload } }: Props): Promise<string> => {
10
+ try {
11
+ let slug = typeof data?.title === 'string' ? data.title : 'testing'
12
+ let path = '/testing'
13
+ // Because href is updated by the field, we need to use breadcrumbs to get the latest href.
14
+ const href = data?.breadcrumbs && data?.breadcrumbs?.length > 0 ? data?.breadcrumbs[data?.breadcrumbs?.length - 1]?.url : undefined
15
+
16
+ //Handle For Collections With Test Path
17
+ if (typeof data?.testPath === 'string') {
18
+ try {
19
+ const page = await payload.findByID({ collection: 'pages', id: data?.testPath, select: { href: true } })
20
+ if (page?.href) path = page.href
21
+ //eslint-disable-next-line @typescript-eslint/no-unused-vars
22
+ } catch (error) {
23
+ payload.logger.info('No Page Found. Loading /testing instead.')
24
+ }
25
+ }
26
+
27
+ //Handle For Collections With Href
28
+ if (typeof href === 'string') {
29
+ path = href
30
+ if (typeof data?.slug === 'string') slug = data.slug || 'home'
31
+ }
32
+
33
+ const encodedParams = new URLSearchParams({ slug, path, collection: 'pages', previewSecret: process.env.PREVIEW_SECRET || '' })
34
+
35
+ const url = `/next/preview?${encodedParams.toString()}`
36
+
37
+ return getClientSideURL() + url
38
+ //eslint-disable-next-line @typescript-eslint/no-unused-vars
39
+ } catch (error) {
40
+ payload.logger.error('Error generating live preview path')
41
+ return '/testing'
42
+ }
43
+ }
@@ -0,0 +1,48 @@
1
+ 'use server'
2
+ import 'server-only' //DO NOT REMOVE
3
+ import configPromise from '@payload-config'
4
+ import { getPayload, Where } from 'payload'
5
+ import cacheLogger from '@/utilities/log/cache'
6
+ import { AtomicStoreInitialState, GCFunction } from '@/ts/types'
7
+
8
+ /** Gets all atomic actions stored in the pages collection. */
9
+ export const getCachedAtomicActions: GCFunction<'atomic-actions'> = async (tag, draft) => {
10
+ const payload = await getPayload({ config: configPromise })
11
+ const where: Where = { storedAtomicActions: { exists: true } }
12
+ if (!draft) Object.assign(where, { live: { equals: true } })
13
+ const draftPublished = draft ? 'draft' : 'published'
14
+
15
+ const settings = await payload.findGlobal({ slug: 'settings' })
16
+ const version = settings?.[draftPublished]?.storeVersion || 0
17
+
18
+ /* const actions = await payload
19
+ .find({
20
+ draft,
21
+ where,
22
+ limit: 0,
23
+ depth: 1,
24
+ pagination: false,
25
+ collection: 'pages',
26
+ select: { storedAtomicActions: true },
27
+ })
28
+ .then((res) => {
29
+ const allActions: StoredAtomicActions = {}
30
+
31
+ res.docs
32
+ ?.map(({ storedAtomicActions }) => storedAtomicActions)
33
+ .filter((action): action is StoredAtomicActions => Boolean(action && Object.keys(action).length > 0))
34
+ .forEach((actions) => {
35
+ Object.assign(allActions, actions)
36
+ })
37
+
38
+ return allActions
39
+ }) */
40
+
41
+ const result: AtomicStoreInitialState = {
42
+ version,
43
+ //storedAtomicActions: actions,
44
+ }
45
+
46
+ cacheLogger({ tag, draft })
47
+ return result
48
+ }
@@ -0,0 +1,20 @@
1
+ 'use server'
2
+ import 'server-only'
3
+ import { GCFunction } from '@/ts/types'
4
+ import configPromise from '@payload-config'
5
+ import { getPayload, Where } from 'payload'
6
+ import cacheLogger from '@/utilities/log/cache'
7
+
8
+ export const getCachedAtomicClasses: GCFunction<'atomic-classes'> = async (tag, draft) => {
9
+ const payload = await getPayload({ config: configPromise })
10
+
11
+ const and: Where[] = [{ or: [{ storedAtomicClasses: { exists: true } }, { href: { equals: '/' } }] }]
12
+ if (!draft) and.push({ live: { equals: true } })
13
+ const where: Where = { and }
14
+
15
+ const res = await payload.find({ collection: 'pages', draft, where, limit: 0, pagination: false, depth: 0, select: { storedAtomicClasses: true } })
16
+ const result = res.docs.flatMap((doc) => doc.storedAtomicClasses ?? [])
17
+
18
+ cacheLogger({ tag, draft })
19
+ return result
20
+ }
@@ -0,0 +1,15 @@
1
+ 'use server'
2
+ import 'server-only' //DO NOT REMOVE
3
+ import { getPayload } from 'payload'
4
+ import { GCFunction } from '@/ts/types'
5
+ import configPromise from '@payload-config'
6
+ import cacheLogger from '@/utilities/log/cache'
7
+
8
+ /** Gets the active design set. */
9
+ export const getCachedDesignSet: GCFunction<'designSet'> = async (tag, draft) => {
10
+ const payload = await getPayload({ config: configPromise })
11
+ const result = await payload.find({ collection: tag, draft, where: { active: { equals: true } }, limit: 1 }).then((res) => res.docs[0] || null)
12
+
13
+ cacheLogger({ tag, draft })
14
+ return result
15
+ }
@@ -0,0 +1,17 @@
1
+ 'use server'
2
+ import 'server-only' //DO NOT REMOVE
3
+ import { getPayload } from 'payload'
4
+ import { GCFunction } from '@/ts/types'
5
+ import configPromise from '@payload-config'
6
+ import cacheLogger from '@/utilities/log/cache'
7
+
8
+ /** Gets the active footer. */
9
+ export const getCachedFooter: GCFunction<'footer'> = async (tag, draft) => {
10
+ const payload = await getPayload({ config: configPromise })
11
+ const results = await payload
12
+ .find({ draft, collection: tag, limit: 1, pagination: false, where: { active: { equals: true } } })
13
+ .then((res) => res.docs[0])
14
+
15
+ cacheLogger({ tag, draft })
16
+ return results
17
+ }
@@ -0,0 +1,17 @@
1
+ 'use server'
2
+ import 'server-only' //DO NOT REMOVE
3
+ import { getPayload } from 'payload'
4
+ import { GCFunction } from '@/ts/types'
5
+ import configPromise from '@payload-config'
6
+ import cacheLogger from '@/utilities/log/cache'
7
+
8
+ /** Returns the form submissions. Tag: form-submissions */
9
+ export const getCachedFormSubmissions: GCFunction<'form-submissions'> = async (tag, tid) => {
10
+ const payload = await getPayload({ config: configPromise })
11
+ const results = await payload
12
+ .find({ collection: 'form-submissions', limit: 0, depth: 0, pagination: false, where: { 'form.title': { equals: tid } } })
13
+ .then((res) => res.docs.map((doc) => doc))
14
+
15
+ cacheLogger({ tag })
16
+ return results
17
+ }
@@ -0,0 +1,43 @@
1
+ 'use server'
2
+ import 'server-only' //DO NOT REMOVE
3
+ import configPromise from '@payload-config'
4
+ import { getPayload, Where } from 'payload'
5
+ import cacheLogger from '@/utilities/log/cache'
6
+ import { Form, GCFunction, StoredAtomicForm } from '@/ts/types'
7
+
8
+ /** Gets all backend forms stored in the forms collection. */
9
+ export const getCachedBackendForms: GCFunction<'backend-forms'> = async (tag) => {
10
+ const payload = await getPayload({ config: configPromise })
11
+ const results = await payload.find({ draft: false, collection: 'forms', limit: 1000, pagination: false }).then((res) => res.docs.map((doc) => doc))
12
+ cacheLogger({ tag })
13
+ return results
14
+ }
15
+
16
+ /** Gets all atomic forms stored in the pages collection. */
17
+ export const getCachedAtomicForms: GCFunction<'atomic-forms'> = async (tag, draft) => {
18
+ const payload = await getPayload({ config: configPromise })
19
+ const where: Where = { storedAtomicForms: { exists: true } }
20
+ if (!draft) Object.assign(where, { live: { equals: true } })
21
+ const results = await payload.find({ draft, collection: 'pages', limit: 1000, where, select: { storedAtomicForms: true } }).then((res) =>
22
+ res.docs
23
+ .map((doc) => doc.storedAtomicForms)
24
+ .filter(Boolean)
25
+ .flat()
26
+ .filter((form): form is StoredAtomicForm => form !== undefined),
27
+ )
28
+
29
+ cacheLogger({ tag, draft })
30
+ return results
31
+ }
32
+
33
+ /** Used in Atomic Blocks Dynamic Form Submission Only */
34
+ export const getCachedAllForms: GCFunction<'all-forms'> = async (tag, draft, atomicForms, backendForms) => {
35
+ // Add id from forms to atomicForms by matching backendForm
36
+ const mergedAtomicForms = atomicForms.map((atomicForm: StoredAtomicForm) => {
37
+ const matchingForm = backendForms.find((form: Form) => form.title === atomicForm.backendForm)
38
+ return { ...atomicForm, backendFormID: matchingForm ? matchingForm.id : '' }
39
+ })
40
+
41
+ cacheLogger({ tag, draft })
42
+ return mergedAtomicForms
43
+ }
@@ -0,0 +1,17 @@
1
+ 'use server'
2
+ import 'server-only' //DO NOT REMOVE
3
+ import { getPayload } from 'payload'
4
+ import { GCFunction } from '@/ts/types'
5
+ import configPromise from '@payload-config'
6
+ import cacheLogger from '@/utilities/log/cache'
7
+
8
+ /** Gets the active header. */
9
+ export const getCachedHeader: GCFunction<'header'> = async (tag, draft) => {
10
+ const payload = await getPayload({ config: configPromise })
11
+ const results = await payload
12
+ .find({ collection: tag, draft, limit: 1, pagination: false, where: { active: { equals: true } } })
13
+ .then((res) => res.docs[0])
14
+
15
+ cacheLogger({ tag, draft })
16
+ return results
17
+ }
@@ -0,0 +1,51 @@
1
+ 'use server'
2
+ import 'server-only' //DO NOT REMOVE
3
+ import { getPayload } from 'payload'
4
+ import configPromise from '@payload-config'
5
+ import type { GCFunction } from '@/ts/types'
6
+ import cacheLogger from '@/utilities/log/cache'
7
+ import { toTitleCase } from '@/utilities/format/toTitleCase'
8
+
9
+ /** Type guard to check if icon is a string (when depth: 0, icon is always a string ID). */
10
+ const isIconString = (item: {
11
+ name: string
12
+ icon?: (string | null) | { id: string } | null
13
+ id?: string | null
14
+ }): item is { name: string; icon: string; id?: string | null } => {
15
+ return typeof item.icon === 'string' && item.icon.length > 0
16
+ }
17
+
18
+ /** Gets the active icon sets icons array. Specifically only the name and icon reference id of each icon. */
19
+ export const getCachedIconSet: GCFunction<'iconSet'> = async (tag, draft) => {
20
+ const payload = await getPayload({ config: configPromise })
21
+ const results = await payload
22
+ .find({ collection: 'iconSet', depth: 0, limit: 1, draft, pagination: false, select: { iconsArray: true }, where: { active: { equals: true } } })
23
+ .then((res) => res.docs[0] || null)
24
+
25
+ /* Returns something like this: [
26
+ { name: 'day', icon: '691253680387340779b42915' },
27
+ { name: 'night', icon: '6912536c0387340779b4291f' }
28
+ ] */
29
+ const filteredResults = results?.iconsArray?.filter(isIconString).map(({ id, ...item }) => ({ name: item.name, icon: item.icon })) || []
30
+ cacheLogger({ tag, draft })
31
+ return { iconsArray: filteredResults }
32
+ }
33
+
34
+ /** Gets the SVG string that matches the passed in icon name, from the active icon set collection. */
35
+ export const getCachedIconByName: GCFunction<'icon'> = async (tag, tid, draft, iconSet) => {
36
+ if (!iconSet?.iconsArray) return
37
+ const iconItem = iconSet.iconsArray.find((item) => item.name === tid)
38
+ if (!iconItem?.icon || typeof iconItem.icon !== 'string') return
39
+ const payload = await getPayload({ config: configPromise })
40
+ const icon = await payload
41
+ .find({ collection: 'icon', limit: 1, draft, where: { id: { equals: iconItem.icon } } })
42
+ .then((res) => res.docs[0] || null)
43
+ cacheLogger({ tag, tid, draft })
44
+ return icon?.svgString || undefined
45
+ }
46
+
47
+ /** Formats the icon set into a list of options for the icon select field. */
48
+ export const getCachedIconOptions: GCFunction<'icon-options'> = async (tag, draft, iconSet) => {
49
+ cacheLogger({ tag, draft })
50
+ return iconSet?.iconsArray?.map((icon) => ({ value: icon.name, label: toTitleCase(icon.name) })) || []
51
+ }
@@ -0,0 +1,20 @@
1
+ 'use server'
2
+ import 'server-only' //DO NOT REMOVE
3
+ import { getPayload } from 'payload'
4
+ import { GCFunction } from '@/ts/types'
5
+ import configPromise from '@payload-config'
6
+ import cacheLogger from '@/utilities/log/cache'
7
+
8
+ export const getCachedImage: GCFunction<'image'> = async (tag, tid, version) => {
9
+ if (!tid) return ''
10
+
11
+ const payload = await getPayload({ config: configPromise })
12
+ const image = await payload.findByID({ collection: 'images', id: tid })
13
+ if (!image) return
14
+
15
+ const url = version ? image.sizes?.[version]?.url || image.url : image.url
16
+ if (!url) return
17
+
18
+ cacheLogger({ tag, tid })
19
+ return url
20
+ }
@@ -0,0 +1,35 @@
1
+ 'use server'
2
+ import 'server-only' //DO NOT REMOVE
3
+ import { GCFunction } from '@/ts/types'
4
+ import configPromise from '@payload-config'
5
+ import { getPayload, Where } from 'payload'
6
+ import cacheLogger from '@/utilities/log/cache'
7
+ import manualLogger from '@/utilities/log/manual'
8
+ import sanitizeData from '@/utilities/sanitizeData'
9
+
10
+ /** Gets a page by its href. */
11
+ export const getCachedPageByHref: GCFunction<'page'> = async (tag, tid, draft, pages) => {
12
+ if (!pages.includes(tid)) {
13
+ manualLogger(`[Warning] - Page not found - ${tid}`)
14
+ return
15
+ }
16
+ const payload = await getPayload({ config: configPromise })
17
+ const where: Where = { href: { equals: tid } }
18
+ if (!draft) Object.assign(where, { live: { equals: true } })
19
+ const results = await payload
20
+ .find({
21
+ collection: 'pages',
22
+ draft,
23
+ where,
24
+ limit: 1,
25
+ depth: 1000,
26
+ pagination: false,
27
+ overrideAccess: draft,
28
+ select: { meta: true, children: true, mainClassName: true },
29
+ })
30
+ .then((res) => res.docs?.[0] || null)
31
+ .then((res) => sanitizeData(res))
32
+
33
+ cacheLogger({ tag, tid, draft })
34
+ return results
35
+ }