nuxt-atelier 0.0.0-stage → 0.1.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 (331) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -2
  3. package/dist/adapter.d.mts +5 -0
  4. package/dist/adapter.mjs +2 -0
  5. package/dist/cli/index.d.mts +1 -0
  6. package/dist/cli/index.mjs +380 -0
  7. package/dist/module.d.mts +147 -0
  8. package/dist/module.json +13 -0
  9. package/dist/module.mjs +425 -0
  10. package/dist/project.d.mts +34 -0
  11. package/dist/project.mjs +35 -0
  12. package/dist/runtime/app/blocks.d.ts +4 -0
  13. package/dist/runtime/app/blocks.js +23 -0
  14. package/dist/runtime/app/components/Blocks.d.ts +28 -0
  15. package/dist/runtime/app/components/Blocks.js +85 -0
  16. package/dist/runtime/app/components/Field.d.ts +24 -0
  17. package/dist/runtime/app/components/Field.js +13 -0
  18. package/dist/runtime/app/components/Form.d.vue.ts +21 -0
  19. package/dist/runtime/app/components/Form.vue +293 -0
  20. package/dist/runtime/app/components/Form.vue.d.ts +21 -0
  21. package/dist/runtime/app/components/Image.d.ts +72 -0
  22. package/dist/runtime/app/components/Image.js +21 -0
  23. package/dist/runtime/app/components/Picture.d.ts +63 -0
  24. package/dist/runtime/app/components/Picture.js +26 -0
  25. package/dist/runtime/app/components/RichText.d.ts +49 -0
  26. package/dist/runtime/app/components/RichText.js +22 -0
  27. package/dist/runtime/app/composables/useAtelierArea.d.ts +22 -0
  28. package/dist/runtime/app/composables/useAtelierArea.js +6 -0
  29. package/dist/runtime/app/composables/useAtelierConfig.d.ts +7 -0
  30. package/dist/runtime/app/composables/useAtelierConfig.js +4 -0
  31. package/dist/runtime/app/composables/useAtelierLocalePath.d.ts +5 -0
  32. package/dist/runtime/app/composables/useAtelierLocalePath.js +6 -0
  33. package/dist/runtime/app/composables/useAtelierPreview.d.ts +6 -0
  34. package/dist/runtime/app/composables/useAtelierPreview.js +4 -0
  35. package/dist/runtime/app/composables/useAtelierQuery.d.ts +20 -0
  36. package/dist/runtime/app/composables/useAtelierQuery.js +22 -0
  37. package/dist/runtime/app/composables/useAtelierRouteEntry.d.ts +29 -0
  38. package/dist/runtime/app/composables/useAtelierRouteEntry.js +16 -0
  39. package/dist/runtime/app/composables/useAtelierSiteSearch.d.ts +22 -0
  40. package/dist/runtime/app/composables/useAtelierSiteSearch.js +17 -0
  41. package/dist/runtime/app/csrf.d.ts +5 -0
  42. package/dist/runtime/app/csrf.js +4 -0
  43. package/dist/runtime/app/editor/bridge.d.ts +2 -0
  44. package/dist/runtime/app/editor/bridge.js +168 -0
  45. package/dist/runtime/app/editor/frames.d.ts +1 -0
  46. package/dist/runtime/app/editor/frames.js +1 -0
  47. package/dist/runtime/app/editor/rich-off.d.ts +9 -0
  48. package/dist/runtime/app/editor/rich-off.js +1 -0
  49. package/dist/runtime/app/index.d.ts +19 -0
  50. package/dist/runtime/app/index.js +9 -0
  51. package/dist/runtime/app/media.d.ts +36 -0
  52. package/dist/runtime/app/media.js +20 -0
  53. package/dist/runtime/app/pages/AtelierPage.d.ts +4 -0
  54. package/dist/runtime/app/pages/AtelierPage.js +56 -0
  55. package/dist/runtime/app/plugins/editor.client.d.ts +2 -0
  56. package/dist/runtime/app/plugins/editor.client.js +19 -0
  57. package/dist/runtime/builtin/blocks/app/blocks/atelier-form.block.d.ts +2 -0
  58. package/dist/runtime/builtin/blocks/app/blocks/atelier-form.block.js +8 -0
  59. package/dist/runtime/builtin/blocks/server/atelier/collections/atelier-patterns.d.ts +28 -0
  60. package/dist/runtime/builtin/blocks/server/atelier/collections/atelier-patterns.js +10 -0
  61. package/dist/runtime/builtin/blocks/server/atelier/collections/atelier-shared-blocks.d.ts +27 -0
  62. package/dist/runtime/builtin/blocks/server/atelier/collections/atelier-shared-blocks.js +10 -0
  63. package/dist/runtime/builtin/content/server/atelier/collections/atelier-forms.d.ts +182 -0
  64. package/dist/runtime/builtin/content/server/atelier/collections/atelier-forms.js +41 -0
  65. package/dist/runtime/builtin/content/server/atelier/collections/atelier-templates.d.ts +32 -0
  66. package/dist/runtime/builtin/content/server/atelier/collections/atelier-templates.js +11 -0
  67. package/dist/runtime/server/adapter.d.ts +17 -0
  68. package/dist/runtime/server/adapter.js +71 -0
  69. package/dist/runtime/server/api/audit.d.ts +2 -0
  70. package/dist/runtime/server/api/audit.js +17 -0
  71. package/dist/runtime/server/api/auth/login.post.d.ts +2 -0
  72. package/dist/runtime/server/api/auth/login.post.js +35 -0
  73. package/dist/runtime/server/api/auth/logout.post.d.ts +4 -0
  74. package/dist/runtime/server/api/auth/logout.post.js +10 -0
  75. package/dist/runtime/server/api/auth/me.get.d.ts +5 -0
  76. package/dist/runtime/server/api/auth/me.get.js +3 -0
  77. package/dist/runtime/server/api/auth/passkeys.d.ts +2 -0
  78. package/dist/runtime/server/api/auth/passkeys.js +131 -0
  79. package/dist/runtime/server/api/auth/providers.get.d.ts +9 -0
  80. package/dist/runtime/server/api/auth/providers.get.js +3 -0
  81. package/dist/runtime/server/api/collab.d.ts +50 -0
  82. package/dist/runtime/server/api/collab.js +85 -0
  83. package/dist/runtime/server/api/collections.d.ts +74 -0
  84. package/dist/runtime/server/api/collections.js +182 -0
  85. package/dist/runtime/server/api/comments.d.ts +20 -0
  86. package/dist/runtime/server/api/comments.js +104 -0
  87. package/dist/runtime/server/api/content.d.ts +8 -0
  88. package/dist/runtime/server/api/content.js +59 -0
  89. package/dist/runtime/server/api/dashboard.d.ts +28 -0
  90. package/dist/runtime/server/api/dashboard.js +31 -0
  91. package/dist/runtime/server/api/demo.d.ts +12 -0
  92. package/dist/runtime/server/api/demo.js +37 -0
  93. package/dist/runtime/server/api/editor.d.ts +7 -0
  94. package/dist/runtime/server/api/editor.js +81 -0
  95. package/dist/runtime/server/api/forms.d.ts +57 -0
  96. package/dist/runtime/server/api/forms.js +215 -0
  97. package/dist/runtime/server/api/health-live.d.ts +2 -0
  98. package/dist/runtime/server/api/health-live.js +2 -0
  99. package/dist/runtime/server/api/health-ready.d.ts +2 -0
  100. package/dist/runtime/server/api/health-ready.js +35 -0
  101. package/dist/runtime/server/api/jobs.d.ts +2 -0
  102. package/dist/runtime/server/api/jobs.js +47 -0
  103. package/dist/runtime/server/api/media-files.d.ts +2 -0
  104. package/dist/runtime/server/api/media-files.js +52 -0
  105. package/dist/runtime/server/api/media.d.ts +58 -0
  106. package/dist/runtime/server/api/media.js +153 -0
  107. package/dist/runtime/server/api/not-found.d.ts +2 -0
  108. package/dist/runtime/server/api/not-found.js +5 -0
  109. package/dist/runtime/server/api/notifications.d.ts +7 -0
  110. package/dist/runtime/server/api/notifications.js +29 -0
  111. package/dist/runtime/server/api/openapi.d.ts +4 -0
  112. package/dist/runtime/server/api/openapi.js +10 -0
  113. package/dist/runtime/server/api/preview-links.d.ts +6 -0
  114. package/dist/runtime/server/api/preview-links.js +39 -0
  115. package/dist/runtime/server/api/redirects.d.ts +4 -0
  116. package/dist/runtime/server/api/redirects.js +39 -0
  117. package/dist/runtime/server/api/reuse.d.ts +14 -0
  118. package/dist/runtime/server/api/reuse.js +45 -0
  119. package/dist/runtime/server/api/roles.d.ts +4 -0
  120. package/dist/runtime/server/api/roles.js +33 -0
  121. package/dist/runtime/server/api/routes.d.ts +2 -0
  122. package/dist/runtime/server/api/routes.js +83 -0
  123. package/dist/runtime/server/api/schema.d.ts +53 -0
  124. package/dist/runtime/server/api/schema.js +72 -0
  125. package/dist/runtime/server/api/search.d.ts +19 -0
  126. package/dist/runtime/server/api/search.js +91 -0
  127. package/dist/runtime/server/api/settings.d.ts +20 -0
  128. package/dist/runtime/server/api/settings.js +30 -0
  129. package/dist/runtime/server/api/setup.d.ts +5 -0
  130. package/dist/runtime/server/api/setup.js +39 -0
  131. package/dist/runtime/server/api/shared-blocks.d.ts +11 -0
  132. package/dist/runtime/server/api/shared-blocks.js +34 -0
  133. package/dist/runtime/server/api/singletons.d.ts +49 -0
  134. package/dist/runtime/server/api/singletons.js +106 -0
  135. package/dist/runtime/server/api/sitemap.d.ts +2 -0
  136. package/dist/runtime/server/api/sitemap.js +4 -0
  137. package/dist/runtime/server/api/tokens.d.ts +6 -0
  138. package/dist/runtime/server/api/tokens.js +40 -0
  139. package/dist/runtime/server/api/users.d.ts +5 -0
  140. package/dist/runtime/server/api/users.js +111 -0
  141. package/dist/runtime/server/api/webhooks.d.ts +14 -0
  142. package/dist/runtime/server/api/webhooks.js +63 -0
  143. package/dist/runtime/server/auth/adapter.d.ts +43 -0
  144. package/dist/runtime/server/auth/adapter.js +9 -0
  145. package/dist/runtime/server/auth/audit.d.ts +28 -0
  146. package/dist/runtime/server/auth/audit.js +38 -0
  147. package/dist/runtime/server/auth/builtin.d.ts +18 -0
  148. package/dist/runtime/server/auth/builtin.js +117 -0
  149. package/dist/runtime/server/auth/password.d.ts +9 -0
  150. package/dist/runtime/server/auth/password.js +52 -0
  151. package/dist/runtime/server/auth/rate-limit.d.ts +19 -0
  152. package/dist/runtime/server/auth/rate-limit.js +46 -0
  153. package/dist/runtime/server/auth/roles.d.ts +29 -0
  154. package/dist/runtime/server/auth/roles.js +83 -0
  155. package/dist/runtime/server/auth/tokens.d.ts +31 -0
  156. package/dist/runtime/server/auth/tokens.js +49 -0
  157. package/dist/runtime/server/cache.d.ts +30 -0
  158. package/dist/runtime/server/cache.js +43 -0
  159. package/dist/runtime/server/collab/notify.d.ts +11 -0
  160. package/dist/runtime/server/collab/notify.js +37 -0
  161. package/dist/runtime/server/collab/realtime.d.ts +17 -0
  162. package/dist/runtime/server/collab/realtime.js +34 -0
  163. package/dist/runtime/server/collab/store.d.ts +91 -0
  164. package/dist/runtime/server/collab/store.js +145 -0
  165. package/dist/runtime/server/content-access.d.ts +78 -0
  166. package/dist/runtime/server/content-access.js +144 -0
  167. package/dist/runtime/server/content-adapters.d.ts +21 -0
  168. package/dist/runtime/server/content-adapters.js +12 -0
  169. package/dist/runtime/server/crawlers-text.d.ts +20 -0
  170. package/dist/runtime/server/crawlers-text.js +36 -0
  171. package/dist/runtime/server/crawlers.d.ts +11 -0
  172. package/dist/runtime/server/crawlers.js +67 -0
  173. package/dist/runtime/server/db/driver.d.ts +58 -0
  174. package/dist/runtime/server/db/driver.js +155 -0
  175. package/dist/runtime/server/db/entries.d.ts +18 -0
  176. package/dist/runtime/server/db/entries.js +29 -0
  177. package/dist/runtime/server/db/loaders.d.ts +2 -0
  178. package/dist/runtime/server/db/loaders.js +6 -0
  179. package/dist/runtime/server/db/migrations.d.ts +50 -0
  180. package/dist/runtime/server/db/migrations.js +132 -0
  181. package/dist/runtime/server/db/query.d.ts +50 -0
  182. package/dist/runtime/server/db/query.js +139 -0
  183. package/dist/runtime/server/db/state.d.ts +5 -0
  184. package/dist/runtime/server/db/state.js +51 -0
  185. package/dist/runtime/server/db/store.d.ts +353 -0
  186. package/dist/runtime/server/db/store.js +1318 -0
  187. package/dist/runtime/server/db/tables.d.ts +53 -0
  188. package/dist/runtime/server/db/tables.js +516 -0
  189. package/dist/runtime/server/define.d.ts +18 -0
  190. package/dist/runtime/server/define.js +16 -0
  191. package/dist/runtime/server/demo/middleware.d.ts +2 -0
  192. package/dist/runtime/server/demo/middleware.js +11 -0
  193. package/dist/runtime/server/demo/plugin.d.ts +2 -0
  194. package/dist/runtime/server/demo/plugin.js +24 -0
  195. package/dist/runtime/server/demo/sessions.d.ts +45 -0
  196. package/dist/runtime/server/demo/sessions.js +107 -0
  197. package/dist/runtime/server/errors.d.ts +16 -0
  198. package/dist/runtime/server/errors.js +58 -0
  199. package/dist/runtime/server/forms.d.ts +76 -0
  200. package/dist/runtime/server/forms.js +90 -0
  201. package/dist/runtime/server/index.d.ts +190 -0
  202. package/dist/runtime/server/index.js +319 -0
  203. package/dist/runtime/server/jobs.d.ts +78 -0
  204. package/dist/runtime/server/jobs.js +193 -0
  205. package/dist/runtime/server/logger.d.ts +9 -0
  206. package/dist/runtime/server/logger.js +26 -0
  207. package/dist/runtime/server/mail-transports.d.ts +23 -0
  208. package/dist/runtime/server/mail-transports.js +30 -0
  209. package/dist/runtime/server/mail.d.ts +10 -0
  210. package/dist/runtime/server/mail.js +40 -0
  211. package/dist/runtime/server/media/images.d.ts +39 -0
  212. package/dist/runtime/server/media/images.js +60 -0
  213. package/dist/runtime/server/media/library.d.ts +120 -0
  214. package/dist/runtime/server/media/library.js +318 -0
  215. package/dist/runtime/server/media/no-sharp.d.ts +1 -0
  216. package/dist/runtime/server/media/no-sharp.js +1 -0
  217. package/dist/runtime/server/media/storage.d.ts +25 -0
  218. package/dist/runtime/server/media/storage.js +59 -0
  219. package/dist/runtime/server/middleware/csrf.d.ts +2 -0
  220. package/dist/runtime/server/middleware/csrf.js +24 -0
  221. package/dist/runtime/server/middleware/page-cache.d.ts +7 -0
  222. package/dist/runtime/server/middleware/page-cache.js +41 -0
  223. package/dist/runtime/server/middleware/redirects.d.ts +2 -0
  224. package/dist/runtime/server/middleware/redirects.js +27 -0
  225. package/dist/runtime/server/middleware/request-id.d.ts +6 -0
  226. package/dist/runtime/server/middleware/request-id.js +9 -0
  227. package/dist/runtime/server/middleware/site.d.ts +2 -0
  228. package/dist/runtime/server/middleware/site.js +11 -0
  229. package/dist/runtime/server/openapi.d.ts +8 -0
  230. package/dist/runtime/server/openapi.js +281 -0
  231. package/dist/runtime/server/plugins/admin-csp.d.ts +5 -0
  232. package/dist/runtime/server/plugins/admin-csp.js +45 -0
  233. package/dist/runtime/server/plugins/forms.d.ts +2 -0
  234. package/dist/runtime/server/plugins/forms.js +36 -0
  235. package/dist/runtime/server/plugins/jobs.d.ts +2 -0
  236. package/dist/runtime/server/plugins/jobs.js +22 -0
  237. package/dist/runtime/server/plugins/limits.d.ts +2 -0
  238. package/dist/runtime/server/plugins/limits.js +8 -0
  239. package/dist/runtime/server/plugins/migrations.d.ts +2 -0
  240. package/dist/runtime/server/plugins/migrations.js +11 -0
  241. package/dist/runtime/server/plugins/page-cache.d.ts +2 -0
  242. package/dist/runtime/server/plugins/page-cache.js +18 -0
  243. package/dist/runtime/server/plugins/robots.d.ts +2 -0
  244. package/dist/runtime/server/plugins/robots.js +17 -0
  245. package/dist/runtime/server/plugins/secret.d.ts +2 -0
  246. package/dist/runtime/server/plugins/secret.js +12 -0
  247. package/dist/runtime/server/plugins/shutdown.d.ts +2 -0
  248. package/dist/runtime/server/plugins/shutdown.js +5 -0
  249. package/dist/runtime/server/plugins/sitemap.d.ts +2 -0
  250. package/dist/runtime/server/plugins/sitemap.js +9 -0
  251. package/dist/runtime/server/redirects.d.ts +27 -0
  252. package/dist/runtime/server/redirects.js +92 -0
  253. package/dist/runtime/server/routes/robots.txt.d.ts +2 -0
  254. package/dist/runtime/server/routes/robots.txt.js +11 -0
  255. package/dist/runtime/server/routes/sitemap.xml.d.ts +2 -0
  256. package/dist/runtime/server/routes/sitemap.xml.js +9 -0
  257. package/dist/runtime/server/routes/ws.d.ts +2 -0
  258. package/dist/runtime/server/routes/ws.js +63 -0
  259. package/dist/runtime/server/routes.d.ts +26 -0
  260. package/dist/runtime/server/routes.js +74 -0
  261. package/dist/runtime/server/schedule.d.ts +30 -0
  262. package/dist/runtime/server/schedule.js +22 -0
  263. package/dist/runtime/server/scheduling.d.ts +22 -0
  264. package/dist/runtime/server/scheduling.js +45 -0
  265. package/dist/runtime/server/schema.d.ts +24 -0
  266. package/dist/runtime/server/search/adapter.d.ts +40 -0
  267. package/dist/runtime/server/search/adapter.js +74 -0
  268. package/dist/runtime/server/search/service.d.ts +37 -0
  269. package/dist/runtime/server/search/service.js +120 -0
  270. package/dist/runtime/server/search/text.d.ts +31 -0
  271. package/dist/runtime/server/search/text.js +63 -0
  272. package/dist/runtime/server/secret-check.d.ts +2 -0
  273. package/dist/runtime/server/secret-check.js +7 -0
  274. package/dist/runtime/server/secrets.d.ts +11 -0
  275. package/dist/runtime/server/secrets.js +36 -0
  276. package/dist/runtime/server/settings.d.ts +42 -0
  277. package/dist/runtime/server/settings.js +48 -0
  278. package/dist/runtime/server/shadowing.d.ts +10 -0
  279. package/dist/runtime/server/shadowing.js +16 -0
  280. package/dist/runtime/server/site-roles.d.ts +10 -0
  281. package/dist/runtime/server/site-roles.js +24 -0
  282. package/dist/runtime/server/sites.d.ts +32 -0
  283. package/dist/runtime/server/sites.js +38 -0
  284. package/dist/runtime/server/tasks/jobs.d.ts +10 -0
  285. package/dist/runtime/server/tasks/jobs.js +7 -0
  286. package/dist/runtime/server/types.d.ts +97 -0
  287. package/dist/runtime/server/types.js +0 -0
  288. package/dist/runtime/server/webhook-jobs.d.ts +18 -0
  289. package/dist/runtime/server/webhook-jobs.js +37 -0
  290. package/dist/runtime/server/webhooks.d.ts +95 -0
  291. package/dist/runtime/server/webhooks.js +212 -0
  292. package/dist/runtime/shared/adapter.d.ts +96 -0
  293. package/dist/runtime/shared/adapter.js +82 -0
  294. package/dist/runtime/shared/blocks.d.ts +63 -0
  295. package/dist/runtime/shared/blocks.js +51 -0
  296. package/dist/runtime/shared/bridge.d.ts +83 -0
  297. package/dist/runtime/shared/bridge.js +47 -0
  298. package/dist/runtime/shared/diff.d.ts +48 -0
  299. package/dist/runtime/shared/diff.js +110 -0
  300. package/dist/runtime/shared/fields.d.ts +368 -0
  301. package/dist/runtime/shared/fields.js +310 -0
  302. package/dist/runtime/shared/forms.d.ts +70 -0
  303. package/dist/runtime/shared/forms.js +94 -0
  304. package/dist/runtime/shared/i18n.d.ts +26 -0
  305. package/dist/runtime/shared/i18n.js +18 -0
  306. package/dist/runtime/shared/infer.d.ts +76 -0
  307. package/dist/runtime/shared/infer.js +0 -0
  308. package/dist/runtime/shared/limits.d.ts +12 -0
  309. package/dist/runtime/shared/limits.js +19 -0
  310. package/dist/runtime/shared/locales.d.ts +16 -0
  311. package/dist/runtime/shared/locales.js +8 -0
  312. package/dist/runtime/shared/memory-adapter.d.ts +11 -0
  313. package/dist/runtime/shared/memory-adapter.js +44 -0
  314. package/dist/runtime/shared/policy.d.ts +64 -0
  315. package/dist/runtime/shared/policy.js +53 -0
  316. package/dist/runtime/shared/query.d.ts +134 -0
  317. package/dist/runtime/shared/query.js +15 -0
  318. package/dist/runtime/shared/reconcile.d.ts +47 -0
  319. package/dist/runtime/shared/reconcile.js +90 -0
  320. package/dist/runtime/shared/rich-text-render.d.ts +24 -0
  321. package/dist/runtime/shared/rich-text-render.js +110 -0
  322. package/dist/runtime/shared/rich-text.d.ts +12 -0
  323. package/dist/runtime/shared/rich-text.js +79 -0
  324. package/dist/runtime/shared/seo.d.ts +18 -0
  325. package/dist/runtime/shared/seo.js +17 -0
  326. package/dist/shared/nuxt-atelier.BTg-ZFUZ.mjs +874 -0
  327. package/dist/shared/nuxt-atelier.BwO-U9M9.mjs +48 -0
  328. package/dist/storage.d.mts +1 -0
  329. package/dist/storage.mjs +1 -0
  330. package/dist/types.d.mts +5 -0
  331. package/package.json +109 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ano Rebel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # Nuxt Atelier
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/nuxt-atelier?label=npm&color=cb3837)](https://www.npmjs.com/package/nuxt-atelier)
4
+ [![JSR](https://jsr.io/badges/@nuxt-atelier/core)](https://jsr.io/@nuxt-atelier/core)
5
+ [![JSR score](https://jsr.io/badges/@nuxt-atelier/core/score)](https://jsr.io/@nuxt-atelier/core)
6
+ [![CI](https://github.com/AnoRebel/nuxt-atelier/actions/workflows/ci.yml/badge.svg)](https://github.com/AnoRebel/nuxt-atelier/actions/workflows/ci.yml)
7
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
8
+
9
+ A production-grade CMS for Nuxt with a visual page builder that renders your site's own components.
10
+
11
+ **[Documentation](https://nuxt-atelier.anorebel.net)** · **[Live demo](https://nuxt-atelier-demo.anorebel.net)** (Rayleigh, a portfolio built on Nuxt Atelier; each visitor gets their own copy to edit)
12
+
13
+ > **Status:** early development, released on npm and JSR. APIs will change until `1.0.0`.
14
+
15
+ ## What it is
16
+
17
+ - **A Nuxt module**: `modules: ['nuxt-atelier']`. It never takes over `app.vue`, and the admin is optional.
18
+ - **Code-first content**: collections, singletons and fields defined in TypeScript drive the database, API, validation, types and admin forms.
19
+ - **Blocks from your own components**: define blocks in a Vue SFC with `defineBlock()` or in a separate `*.block.ts` file, using any UI library (Nuxt UI, shadcn-vue, Tailwind, plain CSS).
20
+ - **Visual editor**: your real site runs in an iframe with drag and drop, inline editing, undo/redo and responsive preview. Public visitors never download editor code.
21
+ - **Pluggable storage and auth**: SQLite/libSQL, PostgreSQL and MySQL via Drizzle, a public content adapter contract for other backends, built-in auth with optional passkeys, and a Better Auth adapter.
22
+ - **Everything else a site needs**: drafts and revisions, scheduled publishing, localization, media library, SEO and sitemaps, redirects, forms, search, multi-site, webhooks and jobs.
23
+ - **Public APIs only**: built exclusively on documented Nuxt, Nitro and Vite APIs, enforced in CI. It supports Nuxt ≥ 4.6 and is Nuxt 5 ready.
24
+
25
+ ## Repository layout
26
+
27
+ | Path | Package |
28
+ |---|---|
29
+ | `packages/core` | `nuxt-atelier`: module, schema, server, renderer |
30
+ | `packages/admin` | `@nuxt-atelier/admin`: headless admin + crystal-neuo kit |
31
+ | `packages/editor` | `@nuxt-atelier/editor`: visual editor |
32
+ | `packages/layer` | `@nuxt-atelier/layer`: optional starter layer |
33
+ | `packages/*` | adapters (auth, i18n, storage, AI) |
34
+ | `playground/` | development app |
35
+ | `docs/` | documentation site |
36
+
37
+ ## Contributing
38
+
39
+ See [CONTRIBUTING.md](./CONTRIBUTING.md). Please read the section on AI-assisted contributions before opening a pull request.
40
+
41
+ ## Credits
42
+
43
+ Nuxt Atelier would not exist without the projects that explored this space first. Their ideas, and the problems their users ran into, shaped much of this design:
44
+
45
+ - **[blökkli](https://github.com/blokkli/editor)** ([blokk.li](https://blokk.li)): the interactive page editor for Nuxt that showed how good in-context block editing can feel. The adapter-driven editor, the capability-based adapter contract and many editing interactions are inspired by it.
46
+ - **[Pruvious](https://github.com/pruvious/pruvious)** ([pruvious.com](https://pruvious.com)): a full CMS for Nuxt apps, which proved that the schema, admin, API and blocks can live inside the Nuxt app itself. The reactive preview edit state and the code-first collections are inspired by it.
47
+ - **[Nuxt](https://nuxt.com)**, **[Nitro](https://nitro.build)** and the wider UnJS and Vue ecosystems, which this project builds on entirely.
48
+
49
+ No code from these projects is copied into the packages. The one exception is an example: [`examples/rayleigh`](./examples/rayleigh) ports Pruvious's [Rayleigh](https://github.com/pruvious/rayleigh) portfolio template by Muris Ceman (MIT), keeping its design, components and demo content under their original copyright. If you need a CMS today, check them out.
50
+
51
+ ## How this project is built
52
+
53
+ Nuxt Atelier is made with AI assistance. It is not an AI-generated project: a human maintainer owns the product direction, the architecture and the specifications, and writes and reviews the code. AI coding assistants help with parts of the work, and those parts are done under heavy human supervision and control: every AI-assisted change is reviewed, understood and approved by the maintainer before it lands, and anything that can't be explained is not merged.
54
+
55
+ ## License
56
+
57
+ [MIT](./LICENSE)
@@ -0,0 +1,5 @@
1
+ export { AdapterCapabilities, AdapterContext, BlockLocation, BlockOperationError, BlockTypeDescriptor, CONTENT_ADAPTER_CONTRACT, ContentAdapter, ContentRef, DefinedContentAdapter, EditState, Permissions, RevisionSummary, blockOperations, defineContentAdapter } from '../dist/runtime/shared/adapter.js';
2
+ export { MemoryAdapterOptions, createMemoryAdapter } from '../dist/runtime/shared/memory-adapter.js';
3
+ export { Field, Fields } from '../dist/runtime/shared/fields.js';
4
+ export { BlockInstance } from '../dist/runtime/shared/infer.js';
5
+ import '../dist/runtime/server/media/storage.js';
@@ -0,0 +1,2 @@
1
+ export { BlockOperationError, CONTENT_ADAPTER_CONTRACT, blockOperations, defineContentAdapter } from '../dist/runtime/shared/adapter.js';
2
+ export { createMemoryAdapter } from '../dist/runtime/shared/memory-adapter.js';
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,380 @@
1
+ #!/usr/bin/env node
2
+ import { join, resolve, relative } from 'node:path';
3
+ import process from 'node:process';
4
+ import { parseArgs } from 'node:util';
5
+ import { connect } from '../../dist/runtime/server/db/driver.js';
6
+ import { allDrivers } from '../../dist/runtime/server/db/loaders.js';
7
+ import { l as loadProject, w as withMigrationLock, b as projectMigrationStatus, g as generateMigration, r as rehearseProjectMigrations, a as applyProjectMigrations } from '../shared/nuxt-atelier.BTg-ZFUZ.mjs';
8
+ import { createJobQueue } from '../../dist/runtime/server/jobs.js';
9
+ import { existsSync, readFileSync, writeFileSync, readdirSync, mkdirSync, createWriteStream, createReadStream } from 'node:fs';
10
+ import { createInterface } from 'node:readline';
11
+ import { pipeline } from 'node:stream/promises';
12
+ import { createGzip, createGunzip } from 'node:zlib';
13
+ import { getTableColumns, sql, eq } from 'drizzle-orm';
14
+ import { withTransaction } from '../../dist/runtime/server/db/store.js';
15
+ import { buildTables } from '../../dist/runtime/server/db/tables.js';
16
+ import { createAuditLog } from '../../dist/runtime/server/auth/audit.js';
17
+ import { hashPassword } from '../../dist/runtime/server/auth/password.js';
18
+ import { ADMIN_ROLE } from '../../dist/runtime/shared/policy.js';
19
+ import 'node:crypto';
20
+ import 'node:fs/promises';
21
+ import 'node:os';
22
+ import 'node:url';
23
+ import '@nuxt/kit';
24
+ import 'jiti';
25
+ import 'valibot';
26
+ import '../../dist/runtime/shared/limits.js';
27
+ import '../../dist/runtime/shared/locales.js';
28
+ import '../../dist/runtime/server/db/migrations.js';
29
+ import '@vue/compiler-sfc';
30
+ import 'oxc-parser';
31
+ import '../../dist/runtime/shared/fields.js';
32
+ import '../../dist/runtime/server/search/text.js';
33
+
34
+ const secret = () => btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(32))));
35
+ const STARTER = `import { blocks, defineCollection, slug, text } from '#atelier/server'
36
+
37
+ // Pages of the site, served at /{slug}, with their content as blocks
38
+ export default defineCollection({
39
+ versioned: true,
40
+ route: { pattern: '/{slug}' },
41
+ fields: {
42
+ title: text({ required: true }),
43
+ slug: slug({ required: true, unique: true, from: 'title' }),
44
+ content: blocks(),
45
+ },
46
+ })
47
+ `;
48
+ function init(root) {
49
+ const done = [];
50
+ const envFile = join(root, ".env");
51
+ const env = existsSync(envFile) ? readFileSync(envFile, "utf8") : "";
52
+ const missing = [["NUXT_APP_SECRET", "signs sessions and preview links"], ["NUXT_ATELIER_JOBS_SECRET", "authorizes the background job trigger"]].filter(([name]) => !new RegExp(`^${name}=`, "m").test(env));
53
+ if (missing.length) {
54
+ const lines = missing.map(([name, purpose]) => `# ${purpose}
55
+ ${name}=${secret()}`).join("\n");
56
+ writeFileSync(envFile, `${env}${env && !env.endsWith("\n") ? "\n" : ""}${lines}
57
+ `);
58
+ done.push(`Added ${missing.map(([name]) => name).join(" and ")} to .env (keep it out of git)`);
59
+ }
60
+ const collections = join(root, "server/atelier/collections");
61
+ if (!existsSync(collections) || !readdirSync(collections).length) {
62
+ mkdirSync(collections, { recursive: true });
63
+ writeFileSync(join(collections, "pages.ts"), STARTER);
64
+ done.push("Wrote server/atelier/collections/pages.ts, a first collection");
65
+ }
66
+ return done;
67
+ }
68
+
69
+ const ARCHIVE_FORMAT = "nuxt-atelier-export";
70
+ const ARCHIVE_VERSION = 1;
71
+ const PAGE = 500;
72
+ function contentTables(driver, schema) {
73
+ const tables = buildTables(driver.dialect, schema);
74
+ return Object.entries(tables).filter(([name]) => name !== "atelier_sessions" && name !== "atelier_rate_limits").toSorted(([a], [b]) => a.localeCompare(b));
75
+ }
76
+ async function exportContent(driver, schema, out) {
77
+ const db = driver.db;
78
+ const tables = contentTables(driver, schema);
79
+ const write = (line) => new Promise((resolve, reject) => out.write(`${JSON.stringify(line)}
80
+ `, (error) => error ? reject(error) : resolve()));
81
+ const header = { format: ARCHIVE_FORMAT, version: ARCHIVE_VERSION, exportedAt: (/* @__PURE__ */ new Date()).toISOString(), dialect: driver.dialect, tables: tables.map(([name]) => name) };
82
+ await write(header);
83
+ const counts = {};
84
+ for (const [name, table] of tables) {
85
+ const order = Object.values(getTableColumns(table));
86
+ counts[name] = 0;
87
+ for (let offset = 0; ; offset += PAGE) {
88
+ const rows = await db.select().from(table).orderBy(...order).limit(PAGE).offset(offset);
89
+ for (const row of rows)
90
+ await write({ table: name, row });
91
+ counts[name] += rows.length;
92
+ if (rows.length < PAGE)
93
+ break;
94
+ }
95
+ }
96
+ return counts;
97
+ }
98
+ async function importContent(driver, schema, input) {
99
+ const tables = Object.fromEntries(contentTables(driver, schema));
100
+ const lines = createInterface({ input, crlfDelay: Infinity })[Symbol.asyncIterator]();
101
+ const first = await lines.next();
102
+ const header = first.done ? void 0 : JSON.parse(first.value);
103
+ if (header?.format !== ARCHIVE_FORMAT)
104
+ throw new Error("[nuxt-atelier] Not a Nuxt Atelier export: the first line has no export header");
105
+ if (header.version !== ARCHIVE_VERSION)
106
+ throw new Error(`[nuxt-atelier] This export is format version ${header.version}; this version of nuxt-atelier reads version ${ARCHIVE_VERSION}`);
107
+ const missing = (header.tables ?? []).filter((name) => !tables[name]);
108
+ if (missing.length)
109
+ throw new Error(`[nuxt-atelier] The export has content for tables this app's schema doesn't define: ${missing.join(", ")}. Add the collections, or migrate, before importing.`);
110
+ return withTransaction(driver, "Importing content", async (tx) => {
111
+ for (const [name, table] of Object.entries(tables)) {
112
+ const [{ count }] = await tx.select({ count: sql`count(*)` }).from(table);
113
+ if (Number(count) > 0)
114
+ throw new Error(`[nuxt-atelier] Import needs an empty database, but ${name} has ${count} rows`);
115
+ }
116
+ const counts = {};
117
+ let batch = { name: "", rows: [] };
118
+ const flush = async () => {
119
+ if (batch.rows.length)
120
+ await tx.insert(tables[batch.name]).values(batch.rows);
121
+ batch.rows = [];
122
+ };
123
+ for (let line = await lines.next(); !line.done; line = await lines.next()) {
124
+ if (!line.value.trim())
125
+ continue;
126
+ const { table, row } = JSON.parse(line.value);
127
+ if (table !== batch.name || batch.rows.length >= PAGE) {
128
+ await flush();
129
+ batch = { name: table, rows: [] };
130
+ }
131
+ batch.rows.push(row);
132
+ counts[table] = (counts[table] ?? 0) + 1;
133
+ }
134
+ await flush();
135
+ return counts;
136
+ });
137
+ }
138
+ const gzipped = (file) => file.endsWith(".gz");
139
+ async function exportToFile(driver, schema, file) {
140
+ const out = createWriteStream(file);
141
+ if (!gzipped(file)) {
142
+ const counts2 = await exportContent(driver, schema, out);
143
+ await new Promise((resolve) => out.end(resolve));
144
+ return counts2;
145
+ }
146
+ const gzip = createGzip();
147
+ const done = pipeline(gzip, out);
148
+ const counts = await exportContent(driver, schema, gzip);
149
+ gzip.end();
150
+ await done;
151
+ return counts;
152
+ }
153
+ function importFromFile(driver, schema, file) {
154
+ const input = createReadStream(file);
155
+ return importContent(driver, schema, gzipped(file) ? input.pipe(createGunzip()) : input);
156
+ }
157
+
158
+ const randomPassword = () => btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(15)))).replaceAll("+", "-").replaceAll("/", "_");
159
+ function checkPassword(password) {
160
+ if (password.length < 8 || password.length > 1024)
161
+ throw new Error("Use a password of at least 8 characters");
162
+ }
163
+ const tablesOf = (driver) => buildTables(driver.dialect, { collections: {}, singletons: {} });
164
+ async function createAdmin(driver, input) {
165
+ checkPassword(input.password);
166
+ const { atelier_users: users } = tablesOf(driver);
167
+ const db = driver.db;
168
+ const email = input.email.trim().toLowerCase();
169
+ if (!/^[^\s@]+@[^\s@]+$/.test(email))
170
+ throw new Error(`"${input.email}" isn't an email address`);
171
+ if ((await db.select({ id: users.id }).from(users).where(eq(users.email, email)).limit(1)).length)
172
+ throw new Error(`A user with the email ${email} already exists: use \`atelier user reset-password\``);
173
+ const now = (/* @__PURE__ */ new Date()).toISOString();
174
+ const id = crypto.randomUUID();
175
+ await db.insert(users).values({ id, email, name: input.name ?? null, role: ADMIN_ROLE, passwordHash: await hashPassword(input.password), createdAt: now, updatedAt: now });
176
+ await createAuditLog(driver).record({ action: "user.created", actorId: null, target: { type: "user", id }, details: { email, role: ADMIN_ROLE, by: "cli" } });
177
+ return { id, email };
178
+ }
179
+ async function resetPassword(driver, input) {
180
+ checkPassword(input.password);
181
+ const { atelier_users: users, atelier_sessions: sessions } = tablesOf(driver);
182
+ const db = driver.db;
183
+ const email = input.email.trim().toLowerCase();
184
+ const [user] = await db.select({ id: users.id }).from(users).where(eq(users.email, email)).limit(1);
185
+ if (!user)
186
+ throw new Error(`No user with the email ${email}`);
187
+ await db.update(users).set({ passwordHash: await hashPassword(input.password), updatedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq(users.id, user.id));
188
+ const revoked = await db.select({ id: sessions.id }).from(sessions).where(eq(sessions.userId, user.id));
189
+ await db.delete(sessions).where(eq(sessions.userId, user.id));
190
+ await createAuditLog(driver).record({ action: "user.updated", actorId: null, target: { type: "user", id: user.id }, details: { password: "changed", sessions: "revoked", by: "cli" } });
191
+ return { id: user.id, sessions: revoked.length };
192
+ }
193
+
194
+ const USAGE = `Usage: atelier <command> [options]
195
+
196
+ Commands:
197
+ init add secrets to .env and a first collection, where missing
198
+ migrate generate write a migration for schema changes to server/atelier/migrations/<dialect>/
199
+ migrate apply apply pending migrations to the database (--dry-run: rehearse them, keeping nothing)
200
+ migrate status list applied and pending migrations
201
+ export <file> write all content to a portable archive (gzipped when <file> ends in .gz)
202
+ import <file> load an archive into an empty, migrated database (any engine)
203
+ user create-admin create an administrator (--email, --name; a password is generated unless --password-stdin)
204
+ user reset-password set a user's password and sign them out everywhere (--email; generated unless --password-stdin)
205
+ jobs list background jobs, newest first (--status queued|running|failed)
206
+ jobs retry <id> queue a failed job again
207
+ jobs run run due jobs now, on the running site (--url, default NUXT_PUBLIC_ATELIER_SITE_URL;
208
+ sends NUXT_ATELIER_JOBS_SECRET)
209
+ search rebuild index all published content for site search again, on the running site (--url, as
210
+ jobs run)
211
+
212
+ Options:
213
+ --root <dir> the Nuxt app (default: current directory)
214
+ --dialect <name> generate for sqlite, postgres or mysql (default: from the database URL)
215
+ --name <name> migration name
216
+ --drop <c>[.<field>] confirm deleting a removed collection or field and its data (repeatable)
217
+ --rename <c>.<old>=<new> | <old c>=<new c>
218
+ declare a renamed field or collection, keeping its data (repeatable)
219
+ --email, --name for the user commands
220
+ --password-stdin read the password from standard input instead of generating one
221
+ --status, --url for the jobs commands
222
+
223
+ The database URL comes from NUXT_ATELIER_DATABASE_URL or the atelier.database.url option.`;
224
+ async function main() {
225
+ const { positionals, values } = parseArgs({
226
+ allowPositionals: true,
227
+ options: {
228
+ "root": { type: "string", default: process.cwd() },
229
+ "dialect": { type: "string" },
230
+ "name": { type: "string" },
231
+ "drop": { type: "string", multiple: true },
232
+ "rename": { type: "string", multiple: true },
233
+ "dry-run": { type: "boolean" },
234
+ "email": { type: "string" },
235
+ "password-stdin": { type: "boolean" },
236
+ "status": { type: "string" },
237
+ "url": { type: "string" },
238
+ "help": { type: "boolean", short: "h" }
239
+ }
240
+ });
241
+ const [group, command, argument] = positionals;
242
+ if (group === "init" && !values.help) {
243
+ const done = init(resolve(values.root));
244
+ console.log(done.length ? done.join("\n") : "Nothing to do: .env has its secrets and there are collections.");
245
+ console.log("Next: add 'nuxt-atelier' to modules in nuxt.config.ts (npx nuxi module add nuxt-atelier), then run `atelier migrate generate`.");
246
+ return 0;
247
+ }
248
+ if (group === "jobs" && command === "run" && !values.help)
249
+ return runJobs(values.url);
250
+ if (group === "search" && command === "rebuild" && !values.help)
251
+ return rebuildSearch(values.url);
252
+ if (values.help || !command || !["migrate", "export", "import", "user", "jobs"].includes(group)) {
253
+ console.log(USAGE);
254
+ return values.help ? 0 : 1;
255
+ }
256
+ if (values.dialect && !["sqlite", "postgres", "mysql"].includes(values.dialect))
257
+ throw new Error(`--dialect: expected sqlite, postgres or mysql`);
258
+ const project = await loadProject(resolve(values.root));
259
+ if (group === "user" || group === "jobs") {
260
+ const driver = await connect(project.databaseUrl, { loaders: allDrivers });
261
+ try {
262
+ return await (group === "user" ? userCommand(driver, command, values) : jobsCommand(driver, command, argument, values.status));
263
+ } finally {
264
+ await driver.close();
265
+ }
266
+ }
267
+ if (group === "export" || group === "import") {
268
+ const driver = await connect(project.databaseUrl, { loaders: allDrivers });
269
+ try {
270
+ const counts = group === "export" ? await exportToFile(driver, project.schema, resolve(command)) : await importFromFile(driver, project.schema, resolve(command));
271
+ const total = Object.values(counts).reduce((a, b) => a + b, 0);
272
+ console.log(`${group === "export" ? "Exported" : "Imported"} ${total} rows:
273
+ ${Object.entries(counts).map(([t, n]) => ` ${t}: ${n}`).join("\n")}`);
274
+ } finally {
275
+ await driver.close();
276
+ }
277
+ } else if (command === "generate") {
278
+ const folder = await withMigrationLock(project.databaseUrl, () => generateMigration(project, { dialect: values.dialect, name: values.name, drop: values.drop, rename: values.rename }));
279
+ console.log(folder ? `Wrote ${relative(process.cwd(), folder)}/migration.sql: review it and commit it.` : "No schema changes.");
280
+ } else if (command === "apply" && values["dry-run"]) {
281
+ const results = await withMigrationLock(project.databaseUrl, () => rehearseProjectMigrations(project, values.dialect));
282
+ if (!results.length) {
283
+ console.log("Nothing to rehearse: the database is up to date.");
284
+ return 0;
285
+ }
286
+ for (const r of results)
287
+ console.log(r.result === "ok" ? ` ok ${r.name}` : r.result === "failed" ? ` FAILED ${r.name}
288
+ ${r.error}` : ` not run ${r.name} (after a failure)`);
289
+ const failed = results.some((r) => r.result === "failed");
290
+ console.log(failed ? "Rehearsal failed: nothing was changed. Fix the migration before applying it." : "Rehearsal passed: nothing was changed. Apply with `atelier migrate apply`.");
291
+ return failed ? 1 : 0;
292
+ } else if (command === "apply") {
293
+ const applied = await withMigrationLock(project.databaseUrl, () => applyProjectMigrations(project, values.dialect));
294
+ console.log(applied.length ? `Applied:
295
+ ${applied.map((n) => ` ${n}`).join("\n")}` : "Database is up to date.");
296
+ } else if (command === "status") {
297
+ const { applied, pending } = await projectMigrationStatus(project);
298
+ console.log(`Applied: ${applied.length}`);
299
+ console.log(pending.length ? `Pending:
300
+ ${pending.map((n) => ` ${n}`).join("\n")}` : "Pending: none");
301
+ } else {
302
+ console.log(USAGE);
303
+ return 1;
304
+ }
305
+ return 0;
306
+ }
307
+ async function readStdin() {
308
+ let text = "";
309
+ for await (const chunk of process.stdin)
310
+ text += chunk;
311
+ return text.replace(/\r?\n$/, "");
312
+ }
313
+ async function userCommand(driver, command, values) {
314
+ if (command !== "create-admin" && command !== "reset-password") {
315
+ console.log(USAGE);
316
+ return 1;
317
+ }
318
+ if (!values.email)
319
+ throw new Error(`atelier user ${command} needs --email`);
320
+ const generated = !values["password-stdin"];
321
+ const password = generated ? randomPassword() : await readStdin();
322
+ if (command === "create-admin") {
323
+ const user = await createAdmin(driver, { email: values.email, name: values.name, password });
324
+ console.log(`Created the administrator ${user.email}.`);
325
+ } else {
326
+ const { sessions } = await resetPassword(driver, { email: values.email, password });
327
+ console.log(`Reset the password of ${values.email.trim().toLowerCase()} and signed out ${sessions} session${sessions === 1 ? "" : "s"}.`);
328
+ }
329
+ if (generated)
330
+ console.log(`Password: ${password}
331
+ Shown only now: pass it on safely, and have them change it.`);
332
+ return 0;
333
+ }
334
+ async function jobsCommand(driver, command, id, status) {
335
+ const queue = createJobQueue(driver);
336
+ if (command === "list") {
337
+ if (status && !["queued", "running", "failed"].includes(status))
338
+ throw new Error("--status: expected queued, running or failed");
339
+ const jobs = await queue.list({ status, limit: 200 });
340
+ console.log(jobs.length ? jobs.map((j) => `${j.id} ${j.status.padEnd(7)} ${j.name} due ${j.runAt} attempts ${j.attempts}/${j.maxAttempts}${j.lastError ? `
341
+ ${j.lastError}` : ""}`).join("\n") : "No jobs.");
342
+ return 0;
343
+ }
344
+ if (command === "retry" && id) {
345
+ if (!await queue.retry(id))
346
+ throw new Error(`No failed job "${id}"`);
347
+ console.log(`Queued ${id} again.`);
348
+ return 0;
349
+ }
350
+ console.log(USAGE);
351
+ return 1;
352
+ }
353
+ async function callSite(command, path, url = process.env.NUXT_PUBLIC_ATELIER_SITE_URL) {
354
+ const secret = process.env.NUXT_ATELIER_JOBS_SECRET;
355
+ if (!url)
356
+ throw new Error(`atelier ${command} needs the site: --url https://example.com, or NUXT_PUBLIC_ATELIER_SITE_URL`);
357
+ if (!secret)
358
+ throw new Error(`atelier ${command} needs NUXT_ATELIER_JOBS_SECRET, the same as the site's`);
359
+ return fetch(new URL(path, url), { method: "POST", headers: { authorization: `Bearer ${secret}` } });
360
+ }
361
+ async function rebuildSearch(url) {
362
+ const response = await callSite("search rebuild", "/api/_atelier/search/rebuild", url);
363
+ if (!response.ok)
364
+ throw new Error(`The site answered ${response.status}${response.status === 403 ? ": is NUXT_ATELIER_JOBS_SECRET set there, the same?" : ""}`);
365
+ const { indexed } = await response.json();
366
+ console.log(`Indexed ${indexed} entries.`);
367
+ return 0;
368
+ }
369
+ async function runJobs(url) {
370
+ const response = await callSite("jobs run", "/api/_atelier/jobs/run", url);
371
+ if (!response.ok)
372
+ throw new Error(`The site answered ${response.status}${response.status === 404 ? ": is NUXT_ATELIER_JOBS_SECRET set there?" : ""}`);
373
+ const { ran, failed, remaining } = await response.json();
374
+ console.log(`Ran ${ran}, failed ${failed}, ${remaining} due still queued.`);
375
+ return 0;
376
+ }
377
+ main().then((code) => process.exit(code), (error) => {
378
+ console.error(process.env.ATELIER_DEBUG ? error : error.message);
379
+ process.exit(1);
380
+ });