@donotdev/core 0.3.1 → 0.3.3

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 (279) hide show
  1. package/functions/index.d.ts +99 -10
  2. package/functions/index.js +20 -18
  3. package/i18n/flags/af.svg +1 -0
  4. package/i18n/flags/al.svg +1 -0
  5. package/i18n/flags/am.svg +1 -0
  6. package/i18n/flags/ar.svg +1 -0
  7. package/i18n/flags/at.svg +1 -0
  8. package/i18n/flags/au.svg +1 -0
  9. package/i18n/flags/az.svg +1 -0
  10. package/i18n/flags/ba.svg +1 -0
  11. package/i18n/flags/bd.svg +1 -0
  12. package/i18n/flags/be.svg +1 -0
  13. package/i18n/flags/bg.svg +1 -0
  14. package/i18n/flags/bn.svg +1 -0
  15. package/i18n/flags/br.svg +1 -0
  16. package/i18n/flags/bs.svg +1 -0
  17. package/i18n/flags/by.svg +1 -0
  18. package/i18n/flags/bzh.svg +1 -0
  19. package/i18n/flags/ca.svg +1 -0
  20. package/i18n/flags/ch.svg +1 -0
  21. package/i18n/flags/co.svg +1 -0
  22. package/i18n/flags/cs.svg +1 -0
  23. package/i18n/flags/cy.svg +1 -0
  24. package/i18n/flags/da.svg +1 -0
  25. package/i18n/flags/de.svg +1 -0
  26. package/i18n/flags/dz.svg +1 -0
  27. package/i18n/flags/ee.svg +1 -0
  28. package/i18n/flags/el.svg +1 -0
  29. package/i18n/flags/en.svg +1 -0
  30. package/i18n/flags/es.svg +1 -0
  31. package/i18n/flags/et.svg +1 -0
  32. package/i18n/flags/eu.svg +1 -0
  33. package/i18n/flags/fa.svg +1 -0
  34. package/i18n/flags/fi.svg +1 -0
  35. package/i18n/flags/fr-cor.svg +1 -0
  36. package/i18n/flags/fr.svg +1 -0
  37. package/i18n/flags/ga.svg +1 -0
  38. package/i18n/flags/gb-sct.svg +1 -0
  39. package/i18n/flags/gb.svg +1 -0
  40. package/i18n/flags/gd.svg +1 -0
  41. package/i18n/flags/ge.svg +1 -0
  42. package/i18n/flags/gl.svg +1 -0
  43. package/i18n/flags/gu.svg +1 -0
  44. package/i18n/flags/he.svg +1 -0
  45. package/i18n/flags/hi.svg +1 -0
  46. package/i18n/flags/hr.svg +1 -0
  47. package/i18n/flags/hu.svg +1 -0
  48. package/i18n/flags/hy.svg +1 -0
  49. package/i18n/flags/id.svg +1 -0
  50. package/i18n/flags/ie.svg +1 -0
  51. package/i18n/flags/in.svg +1 -0
  52. package/i18n/flags/ir.svg +1 -0
  53. package/i18n/flags/is.svg +1 -0
  54. package/i18n/flags/it.svg +1 -0
  55. package/i18n/flags/ja.svg +1 -0
  56. package/i18n/flags/ke.svg +1 -0
  57. package/i18n/flags/kg.svg +1 -0
  58. package/i18n/flags/kh.svg +1 -0
  59. package/i18n/flags/kk.svg +1 -0
  60. package/i18n/flags/km.svg +1 -0
  61. package/i18n/flags/kn.svg +1 -0
  62. package/i18n/flags/ko.svg +1 -0
  63. package/i18n/flags/kz.svg +1 -0
  64. package/i18n/flags/la.svg +1 -0
  65. package/i18n/flags/lb.svg +1 -0
  66. package/i18n/flags/lk.svg +1 -0
  67. package/i18n/flags/lt.svg +1 -0
  68. package/i18n/flags/lv.svg +1 -0
  69. package/i18n/flags/ly.svg +1 -0
  70. package/i18n/flags/ma.svg +1 -0
  71. package/i18n/flags/md.svg +1 -0
  72. package/i18n/flags/mk.svg +1 -0
  73. package/i18n/flags/ml.svg +1 -0
  74. package/i18n/flags/mm.svg +1 -0
  75. package/i18n/flags/mn.svg +1 -0
  76. package/i18n/flags/mr.svg +1 -0
  77. package/i18n/flags/ms.svg +1 -0
  78. package/i18n/flags/mt.svg +1 -0
  79. package/i18n/flags/mx.svg +1 -0
  80. package/i18n/flags/my.svg +1 -0
  81. package/i18n/flags/ne.svg +1 -0
  82. package/i18n/flags/nl.svg +1 -0
  83. package/i18n/flags/no.svg +1 -0
  84. package/i18n/flags/np.svg +1 -0
  85. package/i18n/flags/oc.svg +1 -0
  86. package/i18n/flags/pa.svg +1 -0
  87. package/i18n/flags/pk.svg +1 -0
  88. package/i18n/flags/pl.svg +1 -0
  89. package/i18n/flags/ps.svg +1 -0
  90. package/i18n/flags/pt.svg +1 -0
  91. package/i18n/flags/rm.svg +1 -0
  92. package/i18n/flags/ro.svg +1 -0
  93. package/i18n/flags/ru.svg +1 -0
  94. package/i18n/flags/sa.svg +1 -0
  95. package/i18n/flags/si.svg +1 -0
  96. package/i18n/flags/sk.svg +1 -0
  97. package/i18n/flags/sl.svg +1 -0
  98. package/i18n/flags/sr.svg +1 -0
  99. package/i18n/flags/sv.svg +1 -0
  100. package/i18n/flags/sw.svg +1 -0
  101. package/i18n/flags/ta.svg +1 -0
  102. package/i18n/flags/te.svg +1 -0
  103. package/i18n/flags/th.svg +1 -0
  104. package/i18n/flags/tj.svg +1 -0
  105. package/i18n/flags/tl.svg +1 -0
  106. package/i18n/flags/tn.svg +1 -0
  107. package/i18n/flags/tr.svg +1 -0
  108. package/i18n/flags/ua.svg +1 -0
  109. package/i18n/flags/ur.svg +1 -0
  110. package/i18n/flags/us.svg +1 -0
  111. package/i18n/flags/uz.svg +1 -0
  112. package/i18n/flags/vi.svg +1 -0
  113. package/i18n/flags/za.svg +1 -0
  114. package/i18n/flags/zh.svg +1 -0
  115. package/i18n/locales/eager/dndev_ar.json +2 -1
  116. package/i18n/locales/eager/dndev_da.json +2 -1
  117. package/i18n/locales/eager/dndev_de.json +2 -1
  118. package/i18n/locales/eager/dndev_en.json +2 -1
  119. package/i18n/locales/eager/dndev_es.json +2 -1
  120. package/i18n/locales/eager/dndev_fr.json +2 -1
  121. package/i18n/locales/eager/dndev_it.json +2 -1
  122. package/i18n/locales/eager/dndev_ja.json +2 -1
  123. package/i18n/locales/eager/dndev_ko.json +2 -1
  124. package/i18n/locales/eager/dndev_nl.json +2 -1
  125. package/i18n/locales/eager/dndev_pl.json +2 -1
  126. package/i18n/locales/eager/dndev_pt.json +2 -1
  127. package/i18n/locales/eager/dndev_zh.json +2 -1
  128. package/i18n/locales/lazy/auth_ar.json +19 -2
  129. package/i18n/locales/lazy/auth_da.json +22 -2
  130. package/i18n/locales/lazy/auth_de.json +19 -2
  131. package/i18n/locales/lazy/auth_en.json +19 -2
  132. package/i18n/locales/lazy/auth_es.json +19 -2
  133. package/i18n/locales/lazy/auth_fr.json +19 -2
  134. package/i18n/locales/lazy/auth_it.json +19 -2
  135. package/i18n/locales/lazy/auth_ja.json +19 -2
  136. package/i18n/locales/lazy/auth_ko.json +19 -2
  137. package/i18n/locales/lazy/auth_nl.json +22 -2
  138. package/i18n/locales/lazy/auth_pl.json +19 -2
  139. package/i18n/locales/lazy/auth_pt.json +19 -2
  140. package/i18n/locales/lazy/auth_zh.json +19 -2
  141. package/i18n/locales/lazy/crud_ar.json +3 -1
  142. package/i18n/locales/lazy/crud_da.json +3 -1
  143. package/i18n/locales/lazy/crud_de.json +3 -1
  144. package/i18n/locales/lazy/crud_en.json +3 -1
  145. package/i18n/locales/lazy/crud_es.json +3 -1
  146. package/i18n/locales/lazy/crud_fr.json +3 -1
  147. package/i18n/locales/lazy/crud_it.json +3 -1
  148. package/i18n/locales/lazy/crud_ja.json +3 -1
  149. package/i18n/locales/lazy/crud_ko.json +3 -1
  150. package/i18n/locales/lazy/crud_nl.json +3 -1
  151. package/i18n/locales/lazy/crud_pl.json +3 -1
  152. package/i18n/locales/lazy/crud_pt.json +3 -1
  153. package/i18n/locales/lazy/crud_zh.json +3 -1
  154. package/index.d.ts +6927 -6153
  155. package/index.js +3 -3
  156. package/next/index.d.ts +250 -23
  157. package/next/index.js +556 -594
  158. package/next/runtime.js +3 -3
  159. package/package.json +4 -3
  160. package/server.d.ts +6950 -6153
  161. package/shared.js +2 -1
  162. package/symbol-index.json +1 -1
  163. package/vite/index.d.ts +85 -10
  164. package/vite/index.js +152 -152
  165. package/chunks/FlagBase-IQILJTOA.js +0 -1
  166. package/chunks/chunk-I6HT4XNS.js +0 -1
  167. package/chunks/chunk-PX544BGJ.js +0 -1
  168. package/chunks/flagAF-JHV34XMS.js +0 -1
  169. package/chunks/flagAL-UH6NKHXO.js +0 -1
  170. package/chunks/flagAM-7XYXA6G6.js +0 -1
  171. package/chunks/flagAR-LO3YLUZF.js +0 -1
  172. package/chunks/flagAT-6SWWBNVY.js +0 -1
  173. package/chunks/flagAU-FIJG7J4T.js +0 -1
  174. package/chunks/flagAZ-6AIO4DNL.js +0 -1
  175. package/chunks/flagBA-PIQRWY42.js +0 -1
  176. package/chunks/flagBD-7PXOE6GM.js +0 -1
  177. package/chunks/flagBE-2ZP6HCIM.js +0 -1
  178. package/chunks/flagBG-4XSHCVYH.js +0 -1
  179. package/chunks/flagBN-OF5XRA5N.js +0 -1
  180. package/chunks/flagBR-Y2266PSZ.js +0 -1
  181. package/chunks/flagBS-UV5PVKWJ.js +0 -1
  182. package/chunks/flagBY-MNAFXBA6.js +0 -1
  183. package/chunks/flagBZH-AOCZVEVI.js +0 -1
  184. package/chunks/flagCA-VR6MSBTS.js +0 -1
  185. package/chunks/flagCH-Q7MV5SPV.js +0 -1
  186. package/chunks/flagCO-C2YBOMO2.js +0 -1
  187. package/chunks/flagCS-5BC7NJX6.js +0 -1
  188. package/chunks/flagCY-PPAUTJGB.js +0 -1
  189. package/chunks/flagDA-LPI2JRTO.js +0 -1
  190. package/chunks/flagDE-MQDJAEWL.js +0 -1
  191. package/chunks/flagDZ-M6NVCF3D.js +0 -1
  192. package/chunks/flagEE-LY2JJ44X.js +0 -1
  193. package/chunks/flagEL-PP2HZIV7.js +0 -1
  194. package/chunks/flagEN-TGFHJYK7.js +0 -1
  195. package/chunks/flagES-C3H6SSSI.js +0 -1
  196. package/chunks/flagET-GEZLWRTF.js +0 -1
  197. package/chunks/flagEU-YJF5577W.js +0 -1
  198. package/chunks/flagFA-QCQKNEUZ.js +0 -1
  199. package/chunks/flagFI-LN5ICHNF.js +0 -1
  200. package/chunks/flagFR-5JPZSUVS.js +0 -1
  201. package/chunks/flagFR-COR-KPRNU2U6.js +0 -1
  202. package/chunks/flagGA-PUAQ7VY3.js +0 -1
  203. package/chunks/flagGB-SCT-RJGHRDJP.js +0 -1
  204. package/chunks/flagGB-XD2JB7EC.js +0 -1
  205. package/chunks/flagGD-ABOZBNKE.js +0 -1
  206. package/chunks/flagGE-N7C2KHVA.js +0 -1
  207. package/chunks/flagGL-AO2LC4XU.js +0 -1
  208. package/chunks/flagGU-RNGQ3TIY.js +0 -1
  209. package/chunks/flagHE-QUAWLF43.js +0 -1
  210. package/chunks/flagHI-JOOJFNKB.js +0 -1
  211. package/chunks/flagHR-2U7YEA7P.js +0 -1
  212. package/chunks/flagHU-6SPEV3OO.js +0 -1
  213. package/chunks/flagHY-L62LW6BP.js +0 -1
  214. package/chunks/flagID-LV75M4R3.js +0 -1
  215. package/chunks/flagIE-LBTC7LCK.js +0 -1
  216. package/chunks/flagIN-3UWOJ2S3.js +0 -1
  217. package/chunks/flagIR-44N33GFX.js +0 -1
  218. package/chunks/flagIS-VCPTXPLZ.js +0 -1
  219. package/chunks/flagIT-KB4NWTBO.js +0 -1
  220. package/chunks/flagJA-KLHM6VYH.js +0 -1
  221. package/chunks/flagKE-MZONPGAJ.js +0 -1
  222. package/chunks/flagKG-VF3T4E3E.js +0 -1
  223. package/chunks/flagKH-K5ZXX3DS.js +0 -1
  224. package/chunks/flagKK-ZZTJKPMR.js +0 -1
  225. package/chunks/flagKM-Y3XA6HXW.js +0 -1
  226. package/chunks/flagKN-OMVHGIUS.js +0 -1
  227. package/chunks/flagKO-UBLOXGRF.js +0 -1
  228. package/chunks/flagKZ-PYOALOB6.js +0 -1
  229. package/chunks/flagLA-4ONTEYIB.js +0 -1
  230. package/chunks/flagLB-FGOBUCL4.js +0 -1
  231. package/chunks/flagLK-BEVYO56P.js +0 -1
  232. package/chunks/flagLT-TYWQGIIQ.js +0 -1
  233. package/chunks/flagLV-S34SVWJJ.js +0 -1
  234. package/chunks/flagLY-AVR5B6N3.js +0 -1
  235. package/chunks/flagMA-KHTPMDTL.js +0 -1
  236. package/chunks/flagMD-TQMYMRQI.js +0 -1
  237. package/chunks/flagMK-C4CIIAUH.js +0 -1
  238. package/chunks/flagML-JEE5UGDD.js +0 -1
  239. package/chunks/flagMM-M72A7CHZ.js +0 -1
  240. package/chunks/flagMN-34CH7Q43.js +0 -1
  241. package/chunks/flagMR-KIJ2BPCC.js +0 -1
  242. package/chunks/flagMS-6COZCDLY.js +0 -1
  243. package/chunks/flagMT-HDBP7BED.js +0 -1
  244. package/chunks/flagMX-3XBPZTP5.js +0 -1
  245. package/chunks/flagMY-Y7C3QGRG.js +0 -1
  246. package/chunks/flagNE-LCWCYEQW.js +0 -1
  247. package/chunks/flagNL-3RFQSLLH.js +0 -1
  248. package/chunks/flagNO-RNDXHKBT.js +0 -1
  249. package/chunks/flagNP-IKVTRWFR.js +0 -1
  250. package/chunks/flagOC-JWCST6MI.js +0 -1
  251. package/chunks/flagPA-5SGZJRNZ.js +0 -1
  252. package/chunks/flagPK-KQ674PEZ.js +0 -1
  253. package/chunks/flagPL-V2ITOKFK.js +0 -1
  254. package/chunks/flagPS-WBOKI4MV.js +0 -1
  255. package/chunks/flagPT-PFIUVBWR.js +0 -1
  256. package/chunks/flagRM-MEV6U4AJ.js +0 -1
  257. package/chunks/flagRO-JPMXEGLK.js +0 -1
  258. package/chunks/flagRU-3BBKEK34.js +0 -1
  259. package/chunks/flagSA-N7OI2M6Y.js +0 -1
  260. package/chunks/flagSI-UTODFLQZ.js +0 -1
  261. package/chunks/flagSK-EV5JZ2DI.js +0 -1
  262. package/chunks/flagSL-Y4LHIV2J.js +0 -1
  263. package/chunks/flagSR-MTRWQPJ5.js +0 -1
  264. package/chunks/flagSV-LYVDSSJ4.js +0 -1
  265. package/chunks/flagSW-GJO5P4HE.js +0 -1
  266. package/chunks/flagTA-CDT3KYEB.js +0 -1
  267. package/chunks/flagTE-5EXMXH6E.js +0 -1
  268. package/chunks/flagTH-ODJA4CWB.js +0 -1
  269. package/chunks/flagTJ-CE5SV6V4.js +0 -1
  270. package/chunks/flagTL-TRVUF3XO.js +0 -1
  271. package/chunks/flagTN-G6ERYSZ3.js +0 -1
  272. package/chunks/flagTR-33VFGL2S.js +0 -1
  273. package/chunks/flagUA-HESNDKQJ.js +0 -1
  274. package/chunks/flagUR-ECIZZCDG.js +0 -1
  275. package/chunks/flagUS-M7R4WRRU.js +0 -1
  276. package/chunks/flagUZ-YW54WCES.js +0 -1
  277. package/chunks/flagVI-K3DF2THA.js +0 -1
  278. package/chunks/flagZA-5UIOKDJH.js +0 -1
  279. package/chunks/flagZH-5IE3RZVQ.js +0 -1
package/next/runtime.js CHANGED
@@ -1,3 +1,3 @@
1
- import{readFileSync as A,existsSync as _}from"node:fs";import{join as L}from"node:path";var d=null,E=0,C=6e4;function M(){let t=Date.now();if(d&&t-E<C)return d;try{let n=L(process.cwd(),"public","metadata-manifest.json");if(!_(n))return null;let o=A(n,"utf-8");return d=JSON.parse(o),E=t,d}catch{return null}}function U(t,n,o){let r=M(),a={title:o?.siteName||"Site"};if(!r)return a;let l=t.startsWith("/")?t:`/${t}`,i=r[l];if(!i)return a;let s=n||i.defaultLocale||"en",e=i.locales[s]||i.locales[i.defaultLocale]||Object.values(i.locales)[0];if(!e)return a;let c=process.env.NEXT_PUBLIC_APP_URL,p={title:e.title,...c&&{metadataBase:new URL(c)}};return e.description&&(p.description=e.description),e.keywords&&(p.keywords=e.keywords),p.openGraph={title:e.title,type:e.type||"website",...e.description&&{description:e.description},...e.image&&{images:[e.image]},...o?.siteName&&{siteName:o.siteName}},p.twitter={card:"summary_large_image",title:e.title,...e.description&&{description:e.description},...e.image&&{images:[e.image]}},e.noindex&&(p.robots={index:!1,follow:!1}),p}function k(){d=null,E=0}function g(t){return t.split("/").filter(n=>n.startsWith(":")).map(n=>n.slice(1))}async function $(t,n,o){let r=g(t.path),a=r[0];if(r.length!==1||!t.collection||!a)throw new Error(`[dndev] Cannot list the public URLs of route "${t.path}". Only single-param routes of an entity collection are expanded. Mark the page \`seo: { noindex: true }\` to keep it out of the sitemap and llms.txt.`);if(!n)throw new Error(`[dndev] Route "${t.path}" lists "${t.collection}" records but no server CRUD reader was given.`);let l;try{l=await n.query(t.collection,{where:[{field:"status",operator:"not-in",value:[...o]}],limit:1e3})}catch(s){let e=s?.details?.originalMessage??s?.message??String(s);throw new Error(`[dndev] Route "${t.path}" could not read its public "${t.collection}" records (signed-out visitor: RLS / Security Rules must allow it): ${e}`,{cause:s})}let i=[];for(let s of l.items){let e=s[a];typeof e!="string"&&typeof e!="number"||i.push({param:a,value:String(e),record:s})}return i}async function y(t,n,o){let r=[];for(let a of t){if(g(a.path).length===0){r.push({route:a,path:a.path});continue}for(let{param:l,value:i,record:s}of await $(a,n,o))r.push({route:a,path:a.path.replace(`:${l}`,encodeURIComponent(i)),record:s})}return r}async function D(t,n,o){return(await $(t,n,o)).map(({param:r,value:a})=>({[r]:a}))}function w(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}async function F(t,{baseUrl:n,routing:o,crud:r,languageUrls:a,hiddenStatuses:l}){let i=[],s=(e,c)=>{let p=a(e,n,o),f=o.languages.length>1?{alternates:{languages:p}}:{};for(let u of o.languages)i.push({url:p[u],...c,...f})};for(let{route:e,path:c,record:p}of await y(t,r,l)){if(!p){s(c,{changeFrequency:e.changeFrequency??"weekly",priority:e.priority??(c==="/"?1:.8),...e.lastModified&&{lastModified:e.lastModified}});continue}let f=p.updatedAt instanceof Date?p.updatedAt.toISOString():p.updatedAt;s(c,{changeFrequency:e.changeFrequency??"weekly",priority:e.priority??.7,...typeof f=="string"&&{lastModified:f}})}return i}function j(t){let o=['<?xml version="1.0" encoding="UTF-8"?>',`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${t.some(r=>r.alternates)?' xmlns:xhtml="http://www.w3.org/1999/xhtml"':""}>`];for(let r of t){o.push(" <url>",` <loc>${w(r.url)}</loc>`);for(let[a,l]of Object.entries(r.alternates?.languages??{}))o.push(` <xhtml:link rel="alternate" hreflang="${w(a)}" href="${w(l)}" />`);r.lastModified&&o.push(` <lastmod>${w(r.lastModified)}</lastmod>`),r.changeFrequency&&o.push(` <changefreq>${r.changeFrequency}</changefreq>`),r.priority!==void 0&&o.push(` <priority>${r.priority}</priority>`),o.push(" </url>")}return o.push("</urlset>",""),o.join(`
2
- `)}import I from"i18next";function m(t){return t.replace(/\s+/g," ").trim()}function R(t){let n=[`# ${m(t.name)}`,""];t.summary&&n.push(`> ${m(t.summary)}`,"");for(let o of t.sections)if(o.links.length!==0){n.push(`## ${m(o.heading)}`,"");for(let r of o.links){let a=`- [${m(r.title)}](${r.url})`;n.push(r.description?`${a}: ${m(r.description)}`:a)}n.push("")}return n.join(`
3
- `)}function O(t){let n=new Map;for(let o of Object.values(t))typeof o=="object"&&o!==null&&"collection"in o&&"fields"in o&&n.set(o.collection,o);return n}function N(t,n){let o=I.createInstance();return o.init({lng:t,resources:{[t]:n},ns:Object.keys(n),interpolation:{escapeValue:!1},initAsync:!1}),r=>o.getFixedT(t,[r,"crud"])}async function q(t){let{crud:n,deriveEntitySeo:o,hiddenStatuses:r}=t,a=O(t.entities),l,i=new Map,s=e=>{let c=i.get(e);return c||(c={heading:e,links:[]},i.set(e,c)),c};s(t.pagesHeading);for(let{route:e,path:c,record:p}of await y(t.routes,n,r)){let f=`${t.baseUrl}${c}`;if(!p){if(!e.title)throw new Error(`[dndev] llms.txt: page "${e.path}" has no label in the app language.`);s(e.section??t.pagesHeading).links.push({title:e.title,url:f,...e.description&&{description:e.description}});continue}let u=a.get(e.collection);if(!u)throw new Error(`[dndev] llms.txt: no entity definition for collection "${e.collection}" (route "${e.path}"). Export it from the app's \`entities\` package.`);let x=e.section??(u.namespace?t.entityHeadings[u.namespace]:void 0);if(!x)throw new Error(`[dndev] llms.txt: no heading for route "${e.path}". Add "namePlural" to the ${u.namespace??`entity-${u.name.toLowerCase()}`} translations.`);if(!l){if(!t.language||!t.translations)throw new Error("[dndev] llms.txt: source has no language/translations (getLlmsTxtSource writes them).");l=N(t.language,t.translations)}let h=o(u,p,{t:l(u.namespace),locale:t.language});if(!h.title)throw new Error(`[dndev] llms.txt: published "${e.collection}" record at "${c}" has no title (listCardFields title fields, or first text field, are empty).`);s(x).links.push({title:h.title,url:f,...h.description&&{description:h.description}})}return R({name:t.name,...t.summary&&{summary:t.summary},sections:[...i.values()]})}function V(t){let n=(t??"").trim().replace(/\/+$/,"");return n?/^https?:\/\//i.test(n)?n:`https://${n}`:null}function H(t){let n=V(t);if(!n)throw new Error("[dndev] Set NEXT_PUBLIC_APP_URL: the sitemap and llms.txt publish absolute URLs.");return n}import{createHash as B,timingSafeEqual as X}from"node:crypto";var S="DNDEV_REVALIDATE_SECRET",T="/api/dndev/revalidate",b=32,v="public",z=["/sitemap.xml","/llms.txt"];function W(t){return t.replace(/[/#?\\]|%(2f|23|3f|5c)/gi,n=>encodeURIComponent(n))}function G(t,n){return n.languages.length<2?[t]:n.languages.map(o=>`/${o}${t==="/"?"":t}`)}function P(t,n,o){let r=new Set,a=new Set;for(let l of t){let i=g(l.path);if(i.length===0){r.add(l.path);continue}let[s]=i;if(!(i.length!==1||!s||l.collection!==n.table)){for(let e of[n.record,n.oldRecord]){let c=e?.[s];typeof c!="string"&&typeof c!="number"||r.add(l.path.replace(`:${s}`,W(String(c))))}for(let e of z)a.add(e)}}for(let l of r)for(let i of G(l,o))a.add(i);return[...a].sort()}function J(t,n){let o=/^Bearer (.+)$/.exec(t??"");if(!o)return!1;let r=a=>B("sha256").update(a).digest();return X(r(o[1]),r(n))}async function K(t,{secret:n,routes:o,routing:r,readChange:a,revalidatePath:l}){if(!n||n.length<b)throw new Error(`[dndev] Set ${S} to a random secret of at least ${b} characters: the revalidation webhook (${T}) authenticates with it.`);if(!J(t.headers.get("authorization"),n))return Response.json({error:"Unauthorized"},{status:401});let i;try{i=a(await t.json())}catch(e){if(!(e instanceof Error))throw e;return Response.json({error:e.message},{status:400})}if(i.schema!==v)return Response.json({error:`Table "${i.schema}.${i.table}" is not in the "${v}" schema: only public content tables are revalidated.`},{status:400});let s=P(o,i,r);for(let e of s)l(e);return Response.json({revalidated:s})}export{T as REVALIDATE_ROUTE_PATH,S as REVALIDATE_SECRET_ENV,H as appBaseUrl,q as buildLlmsTxt,F as buildSitemap,k as clearMetadataCache,j as formatSitemapXml,U as getMetadataForPath,K as handleRevalidationWebhook,D as listStaticParams,P as revalidationPaths};
1
+ import{readFileSync as D,existsSync as I}from"node:fs";import{join as N}from"node:path";var w=null,R=0,F=6e4;function q(){let t=Date.now();if(w&&t-R<F)return w;try{let e=N(process.cwd(),"public","metadata-manifest.json");if(!I(e))return null;let n=D(e,"utf-8");return w=JSON.parse(n),R=t,w}catch{return null}}function V(t,e,n){let o=q(),a={title:n?.siteName||"Site"};if(!o)return a;let i=t.startsWith("/")?t:`/${t}`,l=o[i];if(!l)return a;let p=e||l.defaultLocale||"en",r=l.locales[p]||l.locales[l.defaultLocale]||Object.values(l.locales)[0];if(!r)return a;let s=process.env.NEXT_PUBLIC_APP_URL,c={title:r.title,...s&&{metadataBase:new URL(s)}};return r.description&&(c.description=r.description),r.keywords&&(c.keywords=r.keywords),c.openGraph={title:r.title,type:r.type||"website",...r.description&&{description:r.description},...r.image&&{images:[r.image]},...n?.siteName&&{siteName:n.siteName}},c.twitter={card:"summary_large_image",title:r.title,...r.description&&{description:r.description},...r.image&&{images:[r.image]}},r.robots&&(c.robots={index:!1,...r.robots==="noindex, nofollow"&&{follow:!1}}),c}function B(){w=null,R=0}function h(t){return t.split("/").filter(e=>e.startsWith(":")).map(e=>e.slice(1))}function x(t,e){let n=e&&Object.hasOwn(e,t.collection)?e[t.collection]:void 0;if(!n)throw new Error(`[dndev] Route "${t.path}" reads "${t.collection}" records but no read schema was given for that collection (entityReadSchemas of the app's entities).`);return n}async function P(t,e,n,o){let a=h(t.path),i=a[0];if(a.length!==1||!t.collection||!i)throw new Error(`[dndev] Cannot list the public URLs of route "${t.path}". Only single-param routes of an entity collection are expanded. Mark the page \`seo: { noindex: true }\` to keep it out of the sitemap and llms.txt.`);if(!e)throw new Error(`[dndev] Route "${t.path}" lists "${t.collection}" records but no server CRUD reader was given.`);let l=x(t,o),p;try{p=await e.query(t.collection,{where:[{field:"status",operator:"not-in",value:[...n]}],limit:1e3},l)}catch(s){let c=s?.details?.originalMessage??s?.message??String(s);throw new Error(`[dndev] Route "${t.path}" could not read its public "${t.collection}" records (signed-out visitor: RLS / Security Rules must allow it): ${c}`,{cause:s})}let r=[];for(let s of p.items){let c=s[i];typeof c!="string"&&typeof c!="number"||r.push({param:i,value:String(c),record:s})}return r}async function S(t,e,n,o){let a=[];for(let i of t){if(h(i.path).length===0){a.push({route:i,path:i.path});continue}for(let{param:l,value:p,record:r}of await P(i,e,n,o))a.push({route:i,path:i.path.replace(`:${l}`,encodeURIComponent(p)),record:r})}return a}async function H(t,e,n,o){return(await P(t,e,n,o)).map(({param:a,value:i})=>({[a]:i}))}function $(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}async function X(t,{baseUrl:e,routing:n,trailingSlash:o,crud:a,readSchemas:i,languageUrls:l,hiddenStatuses:p}){let r=[],s=(c,u)=>{let d=l(c,e,n,o),f=n.languages.length>1?{alternates:{languages:d}}:{};for(let y of n.languages)r.push({url:d[y],...u,...f})};for(let{route:c,path:u,record:d}of await S(t,a,p,i)){if(!d){s(u,{changeFrequency:c.changeFrequency??"weekly",priority:c.priority??(u==="/"?1:.8),...c.lastModified&&{lastModified:c.lastModified}});continue}let f=d.updatedAt instanceof Date?d.updatedAt.toISOString():d.updatedAt;s(u,{changeFrequency:c.changeFrequency??"weekly",priority:c.priority??.7,...typeof f=="string"&&{lastModified:f}})}return r}function z(t){let n=['<?xml version="1.0" encoding="UTF-8"?>',`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${t.some(o=>o.alternates)?' xmlns:xhtml="http://www.w3.org/1999/xhtml"':""}>`];for(let o of t){n.push(" <url>",` <loc>${$(o.url)}</loc>`);for(let[a,i]of Object.entries(o.alternates?.languages??{}))n.push(` <xhtml:link rel="alternate" hreflang="${$(a)}" href="${$(i)}" />`);o.lastModified&&n.push(` <lastmod>${$(o.lastModified)}</lastmod>`),o.changeFrequency&&n.push(` <changefreq>${o.changeFrequency}</changefreq>`),o.priority!==void 0&&n.push(` <priority>${o.priority}</priority>`),n.push(" </url>")}return n.push("</urlset>",""),n.join(`
2
+ `)}import G from"i18next";function T(t,e){return t.startsWith("/")?`${e}${t}`:t}function v(t){return typeof t=="object"&&t!==null&&"collection"in t&&"fields"in t}function L(t,e,n){for(let o of Object.values(t))if(v(o)&&o.collection===e)return o;throw new Error(`[dndev] Entity page "${n}": no entity definition for collection "${e}". Export it from the app's \`entities\` package, or mark the page \`seo: { noindex: true }\`.`)}function W(t,e,n){let o=Object.create(null);for(let a of e)!a.collection||Object.hasOwn(o,a.collection)||(o[a.collection]=n(L(t,a.collection,a.path)).get);return Object.freeze(o)}function _(t,e){let{route:n,value:o,language:a,baseUrl:i,siteName:l,type:p}=e,r=L(e.entities,n.collection,n.path),s=e.deriveEntitySeo(r,t,{t:e.translate([r.namespace,"crud"]),locale:a}),c=h(n.path)[0],u=n.path.replace(`:${c}`,encodeURIComponent(o)),d=g=>e.languageUrl(g,a,i,e.routing,e.trailingSlash),f=d(u),y=s.title?`${s.title} | ${l}`:l,m=T(s.image||e.defaultImage,i),b=p==="product"?e.buildProductJsonLd({...s,images:[...new Set(s.images.map(g=>T(g,i)))]},f):null;return{url:f,title:y,...s.description&&{description:s.description},image:m,type:p,jsonLd:b,breadcrumb:s.title?e.buildBreadcrumbJsonLd(u,l,d,s.title):null}}function E(t){return t.replace(/\s+/g," ").trim()}function A(t){let e=[`# ${E(t.name)}`,""];t.summary&&e.push(`> ${E(t.summary)}`,"");for(let n of t.sections)if(n.links.length!==0){e.push(`## ${E(n.heading)}`,"");for(let o of n.links){let a=`- [${E(o.title)}](${o.url})`;e.push(o.description?`${a}: ${E(o.description)}`:a)}e.push("")}return e.join(`
3
+ `)}function J(t){let e=new Map;for(let n of Object.values(t))v(n)&&e.set(n.collection,n);return e}function Y(t,e){let n=G.createInstance();return n.init({lng:t,resources:{[t]:e},ns:Object.keys(e),interpolation:{escapeValue:!1},initAsync:!1}),o=>n.getFixedT(t,[o,"crud"])}async function K(t){let{crud:e,readSchemas:n,deriveEntitySeo:o,hiddenStatuses:a,formatTrailingSlash:i,trailingSlash:l}=t,p=J(t.entities),r,s=new Map,c=u=>{let d=s.get(u);return d||(d={heading:u,links:[]},s.set(u,d)),d};c(t.pagesHeading);for(let{route:u,path:d,record:f}of await S(t.routes,e,a,n)){let y=`${t.baseUrl}${i(d,l)}`;if(!f){if(!u.title)throw new Error(`[dndev] llms.txt: source route "${u.path}" has no title (getLlmsTxtSource gives every static page one).`);c(u.section??t.pagesHeading).links.push({title:u.title,url:y,...u.description&&{description:u.description}});continue}let m=p.get(u.collection);if(!m)throw new Error(`[dndev] llms.txt: no entity definition for collection "${u.collection}" (route "${u.path}"). Export it from the app's \`entities\` package.`);let b=u.section??(m.namespace?t.entityHeadings[m.namespace]:void 0);if(!b)throw new Error(`[dndev] llms.txt: no heading for route "${u.path}". Add "namePlural" to the ${m.namespace??`entity-${m.name.toLowerCase()}`} translations.`);if(!r){if(!t.language||!t.translations)throw new Error("[dndev] llms.txt: source has no language/translations (getLlmsTxtSource writes them).");r=Y(t.language,t.translations)}let g=o(m,f,{t:r(m.namespace),locale:t.language});c(b).links.push({title:g.title||t.name,url:y,...g.description&&{description:g.description}})}return A({name:t.name,...t.summary&&{summary:t.summary},sections:[...s.values()]})}function Q(t){let e=(t??"").trim().replace(/\/+$/,"");return e?/^https?:\/\//i.test(e)?e:`https://${e}`:null}function Z(t){let e=Q(t);if(!e)throw new Error("[dndev] Set NEXT_PUBLIC_APP_URL: the sitemap and llms.txt publish absolute URLs.");return e}var U=new Set(["website","article"]);async function tt(t,e,n,o,a){let i=h(t.path),l=i[0];if(i.length!==1||!t.collection||!l)throw new Error(`[dndev] Entity page "${t.path}": only single-param routes of an entity collection read a record.`);if(!n)throw new Error(`[dndev] Entity page "${t.path}" reads a "${t.collection}" record but no server CRUD reader was given.`);let p=x(t,a),r;try{r=await n.query(t.collection,{where:[{field:l,operator:"==",value:e},{field:"status",operator:"not-in",value:[...o]}],limit:1},p)}catch(s){let c=s?.details?.originalMessage??s?.message??String(s);throw new Error(`[dndev] Entity page "${t.path}" could not read its public "${t.collection}" record (signed-out visitor: RLS / Security Rules must allow it): ${c}`,{cause:s})}return r.items[0]??null}function et(t,e){let{title:n,description:o,image:a,type:i,jsonLd:l,breadcrumb:p}=_(t,e);return{metadata:{title:{absolute:n},...o&&{description:o},openGraph:{title:{absolute:n},...o&&{description:o},...U.has(i)&&{type:i},images:[a]},twitter:{card:"summary_large_image",title:{absolute:n},...o&&{description:o},images:[a]}},ogType:U.has(i)?null:i,jsonLd:l,breadcrumb:p}}function nt(t){return JSON.stringify(t).replace(/</g,"\\u003c")}import{createHash as ot,timingSafeEqual as rt}from"node:crypto";var j="DNDEV_REVALIDATE_SECRET",M="/api/dndev/revalidate",C=32,O="public",at=["/sitemap.xml","/llms.txt"];function it(t){return t.replace(/[/#?\\]|%(2f|23|3f|5c)/gi,e=>encodeURIComponent(e))}function st(t,e){return e.languages.length<2?[t]:e.languages.map(n=>`/${n}${t==="/"?"":t}`)}function k(t,e,n){let o=new Set,a=new Set;for(let i of t){let l=h(i.path);if(l.length===0){o.add(i.path);continue}let[p]=l;if(!(l.length!==1||!p||i.collection!==e.table)){for(let r of[e.record,e.oldRecord]){let s=r?.[p];typeof s!="string"&&typeof s!="number"||o.add(i.path.replace(`:${p}`,it(String(s))))}for(let r of at)a.add(r)}}for(let i of o)for(let l of st(i,n))a.add(l);return[...a].sort()}function lt(t,e){let n=/^Bearer (.+)$/.exec(t??"");if(!n)return!1;let o=a=>ot("sha256").update(a).digest();return rt(o(n[1]),o(e))}async function ct(t,{secret:e,routes:n,routing:o,readChange:a,revalidatePath:i}){if(!e||e.length<C)throw new Error(`[dndev] Set ${j} to a random secret of at least ${C} characters: the revalidation webhook (${M}) authenticates with it.`);if(!lt(t.headers.get("authorization"),e))return Response.json({error:"Unauthorized"},{status:401});let l;try{l=a(await t.json())}catch(r){if(!(r instanceof Error))throw r;return Response.json({error:r.message},{status:400})}if(l.schema!==O)return Response.json({error:`Table "${l.schema}.${l.table}" is not in the "${O}" schema: only public content tables are revalidated.`},{status:400});let p=k(n,l,o);for(let r of p)i(r);return Response.json({revalidated:p})}export{M as REVALIDATE_ROUTE_PATH,j as REVALIDATE_SECRET_ENV,Z as appBaseUrl,K as buildLlmsTxt,X as buildSitemap,B as clearMetadataCache,et as entityPageSeo,W as entityReadSchemas,z as formatSitemapXml,V as getMetadataForPath,ct as handleRevalidationWebhook,nt as jsonLdScript,H as listStaticParams,tt as readEntityPageRecord,k as revalidationPaths};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/core",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -59,11 +59,12 @@
59
59
  "vite",
60
60
  "next",
61
61
  "functions",
62
- "i18n/locales"
62
+ "i18n/locales",
63
+ "i18n/flags"
63
64
  ],
64
65
  "sideEffects": false,
65
66
  "peerDependencies": {
66
- "@donotdev/components": "^0.3.2",
67
+ "@donotdev/components": "^0.3.4",
67
68
  "@sentry/react": "^10.39.0",
68
69
  "i18next": "^26.7.2",
69
70
  "i18next-browser-languagedetector": "^8.3.0",