@kurbo/dkit 0.4.0

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 (241) hide show
  1. package/README.md +24 -0
  2. package/dist/bin.js +8066 -0
  3. package/dist/bin.js.map +1 -0
  4. package/package.json +58 -0
  5. package/vendor/registry/blocks/blog-detail/module.json +27 -0
  6. package/vendor/registry/blocks/blog-detail/ui/minimal/next/blog-detail.tsx +26 -0
  7. package/vendor/registry/blocks/blog-detail/ui/minimal/nuxt/BlogDetail.vue +27 -0
  8. package/vendor/registry/blocks/blog-detail/ui/shadcn/next/blog-detail.tsx +106 -0
  9. package/vendor/registry/blocks/blog-detail/ui/shadcn/nuxt/BlogDetail.vue +116 -0
  10. package/vendor/registry/blocks/blog-list/module.json +26 -0
  11. package/vendor/registry/blocks/blog-list/ui/minimal/next/blog-list.tsx +130 -0
  12. package/vendor/registry/blocks/blog-list/ui/minimal/nuxt/BlogList.vue +62 -0
  13. package/vendor/registry/blocks/blog-list/ui/shadcn/next/blog-list.tsx +109 -0
  14. package/vendor/registry/blocks/blog-list/ui/shadcn/nuxt/BlogList.vue +100 -0
  15. package/vendor/registry/blocks/blog-list-cards/module.json +27 -0
  16. package/vendor/registry/blocks/blog-list-cards/ui/minimal/next/blog-list-cards.tsx +130 -0
  17. package/vendor/registry/blocks/blog-list-cards/ui/minimal/nuxt/BlogListCards.vue +114 -0
  18. package/vendor/registry/blocks/blog-list-cards/ui/shadcn/next/blog-list-cards.tsx +119 -0
  19. package/vendor/registry/blocks/blog-list-cards/ui/shadcn/nuxt/BlogListCards.vue +113 -0
  20. package/vendor/registry/blocks/booking-form-ui/module.json +15 -0
  21. package/vendor/registry/blocks/booking-form-ui/ui/minimal/next/booking-form.tsx +89 -0
  22. package/vendor/registry/blocks/booking-form-ui/ui/shadcn/next/booking-form.tsx +92 -0
  23. package/vendor/registry/blocks/contact-form-ui/module.json +27 -0
  24. package/vendor/registry/blocks/contact-form-ui/ui/minimal/next/contact-form.tsx +45 -0
  25. package/vendor/registry/blocks/contact-form-ui/ui/minimal/nuxt/ContactForm.vue +79 -0
  26. package/vendor/registry/blocks/contact-form-ui/ui/shadcn/next/contact-form.tsx +55 -0
  27. package/vendor/registry/blocks/contact-form-ui/ui/shadcn/nuxt/ContactForm.vue +92 -0
  28. package/vendor/registry/blocks/faq-list/module.json +15 -0
  29. package/vendor/registry/blocks/faq-list/ui/minimal/next/faq-list.tsx +78 -0
  30. package/vendor/registry/blocks/faq-list/ui/shadcn/next/faq-list.tsx +77 -0
  31. package/vendor/registry/blocks/maintenance-gate/module.json +13 -0
  32. package/vendor/registry/blocks/maintenance-gate/ui/minimal/next/maintenance-gate.tsx +135 -0
  33. package/vendor/registry/blocks/maintenance-gate/ui/shadcn/next/maintenance-gate.tsx +87 -0
  34. package/vendor/registry/blocks/nav-footer/module.json +13 -0
  35. package/vendor/registry/blocks/nav-footer/ui/minimal/next/nav-footer.tsx +55 -0
  36. package/vendor/registry/blocks/nav-footer/ui/shadcn/next/nav-footer.tsx +41 -0
  37. package/vendor/registry/blocks/nav-header/module.json +14 -0
  38. package/vendor/registry/blocks/nav-header/ui/minimal/next/nav-header.tsx +244 -0
  39. package/vendor/registry/blocks/nav-header/ui/shadcn/next/nav-header-client.tsx +185 -0
  40. package/vendor/registry/blocks/nav-header/ui/shadcn/next/nav-header.tsx +12 -0
  41. package/vendor/registry/blocks/page-detail/module.json +26 -0
  42. package/vendor/registry/blocks/page-detail/ui/minimal/next/page-detail.tsx +26 -0
  43. package/vendor/registry/blocks/page-detail/ui/minimal/nuxt/PageDetail.vue +26 -0
  44. package/vendor/registry/blocks/page-detail/ui/shadcn/next/page-detail.tsx +61 -0
  45. package/vendor/registry/blocks/page-detail/ui/shadcn/nuxt/PageDetail.vue +62 -0
  46. package/vendor/registry/blocks/project-detail/module.json +15 -0
  47. package/vendor/registry/blocks/project-detail/ui/minimal/next/project-detail.tsx +58 -0
  48. package/vendor/registry/blocks/project-detail/ui/shadcn/next/project-detail.tsx +91 -0
  49. package/vendor/registry/blocks/project-list/module.json +14 -0
  50. package/vendor/registry/blocks/project-list/ui/minimal/next/project-list.tsx +104 -0
  51. package/vendor/registry/blocks/project-list/ui/shadcn/next/project-list.tsx +81 -0
  52. package/vendor/registry/blocks/project-list-cards/module.json +15 -0
  53. package/vendor/registry/blocks/project-list-cards/ui/minimal/next/project-list-cards.tsx +125 -0
  54. package/vendor/registry/blocks/project-list-cards/ui/shadcn/next/project-list-cards.tsx +94 -0
  55. package/vendor/registry/blocks/projects-carousel/module.json +15 -0
  56. package/vendor/registry/blocks/projects-carousel/ui/minimal/next/projects-carousel-client.tsx +239 -0
  57. package/vendor/registry/blocks/projects-carousel/ui/minimal/next/projects-carousel.tsx +24 -0
  58. package/vendor/registry/blocks/projects-carousel/ui/shadcn/next/projects-carousel-client.tsx +102 -0
  59. package/vendor/registry/blocks/projects-carousel/ui/shadcn/next/projects-carousel.tsx +24 -0
  60. package/vendor/registry/blocks/service-detail/module.json +15 -0
  61. package/vendor/registry/blocks/service-detail/ui/minimal/next/service-detail.tsx +49 -0
  62. package/vendor/registry/blocks/service-detail/ui/shadcn/next/service-detail.tsx +75 -0
  63. package/vendor/registry/blocks/service-list/module.json +14 -0
  64. package/vendor/registry/blocks/service-list/ui/minimal/next/service-list.tsx +103 -0
  65. package/vendor/registry/blocks/service-list/ui/shadcn/next/service-list.tsx +80 -0
  66. package/vendor/registry/blocks/service-list-cards/module.json +15 -0
  67. package/vendor/registry/blocks/service-list-cards/ui/minimal/next/service-list-cards.tsx +124 -0
  68. package/vendor/registry/blocks/service-list-cards/ui/shadcn/next/service-list-cards.tsx +92 -0
  69. package/vendor/registry/blocks/site-brand/module.json +13 -0
  70. package/vendor/registry/blocks/site-brand/ui/minimal/next/site-brand.tsx +61 -0
  71. package/vendor/registry/blocks/site-brand/ui/shadcn/next/site-brand.tsx +48 -0
  72. package/vendor/registry/blocks/site-logo/module.json +13 -0
  73. package/vendor/registry/blocks/site-logo/ui/minimal/next/site-logo.tsx +37 -0
  74. package/vendor/registry/blocks/site-logo/ui/shadcn/next/site-logo.tsx +34 -0
  75. package/vendor/registry/blocks/social-links/module.json +13 -0
  76. package/vendor/registry/blocks/social-links/ui/minimal/next/social-links.tsx +55 -0
  77. package/vendor/registry/blocks/social-links/ui/shadcn/next/social-links.tsx +46 -0
  78. package/vendor/registry/blocks/team-detail/module.json +15 -0
  79. package/vendor/registry/blocks/team-detail/ui/minimal/next/team-detail.tsx +113 -0
  80. package/vendor/registry/blocks/team-detail/ui/shadcn/next/team-detail.tsx +77 -0
  81. package/vendor/registry/blocks/team-list/module.json +14 -0
  82. package/vendor/registry/blocks/team-list/ui/minimal/next/team-list.tsx +113 -0
  83. package/vendor/registry/blocks/team-list/ui/shadcn/next/team-list.tsx +77 -0
  84. package/vendor/registry/blocks/team-list-cards/module.json +15 -0
  85. package/vendor/registry/blocks/team-list-cards/ui/minimal/next/team-list-cards.tsx +111 -0
  86. package/vendor/registry/blocks/team-list-cards/ui/shadcn/next/team-list-cards.tsx +83 -0
  87. package/vendor/registry/blocks/testimonials-carousel/module.json +15 -0
  88. package/vendor/registry/blocks/testimonials-carousel/ui/minimal/next/testimonials-carousel-client.tsx +230 -0
  89. package/vendor/registry/blocks/testimonials-carousel/ui/minimal/next/testimonials-carousel.tsx +23 -0
  90. package/vendor/registry/blocks/testimonials-carousel/ui/shadcn/next/testimonials-carousel-client.tsx +91 -0
  91. package/vendor/registry/blocks/testimonials-carousel/ui/shadcn/next/testimonials-carousel.tsx +23 -0
  92. package/vendor/registry/blocks/testimonials-list/module.json +14 -0
  93. package/vendor/registry/blocks/testimonials-list/ui/minimal/next/testimonials-list.tsx +109 -0
  94. package/vendor/registry/blocks/testimonials-list/ui/shadcn/next/testimonials-list.tsx +72 -0
  95. package/vendor/registry/blocks/testimonials-list-cards/module.json +15 -0
  96. package/vendor/registry/blocks/testimonials-list-cards/ui/minimal/next/testimonials-list-cards.tsx +114 -0
  97. package/vendor/registry/blocks/testimonials-list-cards/ui/shadcn/next/testimonials-list-cards.tsx +72 -0
  98. package/vendor/registry/core/languages/policies.json +25 -0
  99. package/vendor/registry/core/languages/seed.json +16 -0
  100. package/vendor/registry/core/languages/snapshot.json +94 -0
  101. package/vendor/registry/modules/blog/access/policies.json +49 -0
  102. package/vendor/registry/modules/blog/access/policies.multilocale.json +67 -0
  103. package/vendor/registry/modules/blog/lib.multilocale.ts +552 -0
  104. package/vendor/registry/modules/blog/lib.ts +346 -0
  105. package/vendor/registry/modules/blog/module.json +50 -0
  106. package/vendor/registry/modules/blog/schema/snapshot.json +701 -0
  107. package/vendor/registry/modules/blog/schema/snapshot.multilocale.json +884 -0
  108. package/vendor/registry/modules/blog/services/ATTRIBUTION.md +8 -0
  109. package/vendor/registry/modules/blog/services/assets/ada-lovelace-avatar.jpg +0 -0
  110. package/vendor/registry/modules/blog/services/assets/hello-from-dkit-cover.jpg +0 -0
  111. package/vendor/registry/modules/blog/services/seed.json +70 -0
  112. package/vendor/registry/modules/blog/services/seed.multilocale.json +90 -0
  113. package/vendor/registry/modules/blog/types.multilocale.ts +96 -0
  114. package/vendor/registry/modules/blog/types.ts +62 -0
  115. package/vendor/registry/modules/booking-form/access/policies.json +25 -0
  116. package/vendor/registry/modules/booking-form/access/policies.multilocale.json +27 -0
  117. package/vendor/registry/modules/booking-form/lib.multilocale.ts +71 -0
  118. package/vendor/registry/modules/booking-form/lib.ts +77 -0
  119. package/vendor/registry/modules/booking-form/module.json +32 -0
  120. package/vendor/registry/modules/booking-form/schema/snapshot.json +294 -0
  121. package/vendor/registry/modules/booking-form/schema/snapshot.multilocale.json +467 -0
  122. package/vendor/registry/modules/booking-form/services/flows.json +19 -0
  123. package/vendor/registry/modules/booking-form/types.multilocale.ts +29 -0
  124. package/vendor/registry/modules/booking-form/types.ts +27 -0
  125. package/vendor/registry/modules/contact-form/access/policies.json +25 -0
  126. package/vendor/registry/modules/contact-form/access/policies.multilocale.json +27 -0
  127. package/vendor/registry/modules/contact-form/lib.multilocale.ts +65 -0
  128. package/vendor/registry/modules/contact-form/lib.ts +67 -0
  129. package/vendor/registry/modules/contact-form/module.json +32 -0
  130. package/vendor/registry/modules/contact-form/schema/snapshot.json +193 -0
  131. package/vendor/registry/modules/contact-form/schema/snapshot.multilocale.json +293 -0
  132. package/vendor/registry/modules/contact-form/services/flows.json +19 -0
  133. package/vendor/registry/modules/contact-form/types.multilocale.ts +21 -0
  134. package/vendor/registry/modules/contact-form/types.ts +19 -0
  135. package/vendor/registry/modules/faq/access/policies.json +25 -0
  136. package/vendor/registry/modules/faq/access/policies.multilocale.json +18 -0
  137. package/vendor/registry/modules/faq/lib.multilocale.ts +120 -0
  138. package/vendor/registry/modules/faq/lib.ts +73 -0
  139. package/vendor/registry/modules/faq/module.json +31 -0
  140. package/vendor/registry/modules/faq/schema/snapshot.json +180 -0
  141. package/vendor/registry/modules/faq/schema/snapshot.multilocale.json +116 -0
  142. package/vendor/registry/modules/faq/services/seed.json +38 -0
  143. package/vendor/registry/modules/faq/services/seed.multilocale.json +32 -0
  144. package/vendor/registry/modules/faq/types.multilocale.ts +31 -0
  145. package/vendor/registry/modules/faq/types.ts +17 -0
  146. package/vendor/registry/modules/navigation/access/policies.json +31 -0
  147. package/vendor/registry/modules/navigation/access/policies.multilocale.json +51 -0
  148. package/vendor/registry/modules/navigation/lib.multilocale.ts +198 -0
  149. package/vendor/registry/modules/navigation/lib.ts +252 -0
  150. package/vendor/registry/modules/navigation/module.json +46 -0
  151. package/vendor/registry/modules/navigation/schema/snapshot.json +453 -0
  152. package/vendor/registry/modules/navigation/schema/snapshot.multilocale.json +864 -0
  153. package/vendor/registry/modules/navigation/services/seed.json +103 -0
  154. package/vendor/registry/modules/navigation/services/seed.multilocale.json +88 -0
  155. package/vendor/registry/modules/navigation/types.multilocale.ts +60 -0
  156. package/vendor/registry/modules/navigation/types.ts +44 -0
  157. package/vendor/registry/modules/pages/access/policies.json +25 -0
  158. package/vendor/registry/modules/pages/access/policies.multilocale.json +18 -0
  159. package/vendor/registry/modules/pages/lib.multilocale.ts +166 -0
  160. package/vendor/registry/modules/pages/lib.ts +123 -0
  161. package/vendor/registry/modules/pages/module.json +39 -0
  162. package/vendor/registry/modules/pages/schema/snapshot.json +247 -0
  163. package/vendor/registry/modules/pages/schema/snapshot.multilocale.json +187 -0
  164. package/vendor/registry/modules/pages/services/seed.json +24 -0
  165. package/vendor/registry/modules/pages/services/seed.multilocale.json +34 -0
  166. package/vendor/registry/modules/pages/types.multilocale.ts +37 -0
  167. package/vendor/registry/modules/pages/types.ts +21 -0
  168. package/vendor/registry/modules/projects/access/policies.json +31 -0
  169. package/vendor/registry/modules/projects/access/policies.multilocale.json +43 -0
  170. package/vendor/registry/modules/projects/lib.multilocale.ts +111 -0
  171. package/vendor/registry/modules/projects/lib.ts +138 -0
  172. package/vendor/registry/modules/projects/module.json +48 -0
  173. package/vendor/registry/modules/projects/schema/snapshot.json +348 -0
  174. package/vendor/registry/modules/projects/schema/snapshot.multilocale.json +577 -0
  175. package/vendor/registry/modules/projects/services/ATTRIBUTION.md +7 -0
  176. package/vendor/registry/modules/projects/services/assets/brand-identity-cover.jpg +0 -0
  177. package/vendor/registry/modules/projects/services/seed.json +40 -0
  178. package/vendor/registry/modules/projects/services/seed.multilocale.json +31 -0
  179. package/vendor/registry/modules/projects/types.multilocale.ts +38 -0
  180. package/vendor/registry/modules/projects/types.ts +28 -0
  181. package/vendor/registry/modules/services/access/policies.json +31 -0
  182. package/vendor/registry/modules/services/access/policies.multilocale.json +43 -0
  183. package/vendor/registry/modules/services/lib.multilocale.ts +109 -0
  184. package/vendor/registry/modules/services/lib.ts +134 -0
  185. package/vendor/registry/modules/services/module.json +47 -0
  186. package/vendor/registry/modules/services/schema/snapshot.json +305 -0
  187. package/vendor/registry/modules/services/schema/snapshot.multilocale.json +510 -0
  188. package/vendor/registry/modules/services/services/ATTRIBUTION.md +8 -0
  189. package/vendor/registry/modules/services/services/assets/design-development.jpg +0 -0
  190. package/vendor/registry/modules/services/services/assets/strategy-consulting.jpg +0 -0
  191. package/vendor/registry/modules/services/services/seed.json +44 -0
  192. package/vendor/registry/modules/services/services/seed.multilocale.json +31 -0
  193. package/vendor/registry/modules/services/types.multilocale.ts +36 -0
  194. package/vendor/registry/modules/services/types.ts +26 -0
  195. package/vendor/registry/modules/settings/access/policies.json +31 -0
  196. package/vendor/registry/modules/settings/access/policies.multilocale.json +43 -0
  197. package/vendor/registry/modules/settings/lib.multilocale.ts +158 -0
  198. package/vendor/registry/modules/settings/lib.ts +259 -0
  199. package/vendor/registry/modules/settings/module.json +33 -0
  200. package/vendor/registry/modules/settings/schema/snapshot.json +315 -0
  201. package/vendor/registry/modules/settings/schema/snapshot.multilocale.json +586 -0
  202. package/vendor/registry/modules/settings/services/assets/dkit-logo.svg +4 -0
  203. package/vendor/registry/modules/settings/services/seed.json +31 -0
  204. package/vendor/registry/modules/settings/services/seed.multilocale.json +42 -0
  205. package/vendor/registry/modules/settings/types.multilocale.ts +72 -0
  206. package/vendor/registry/modules/settings/types.ts +94 -0
  207. package/vendor/registry/modules/team/access/policies.json +31 -0
  208. package/vendor/registry/modules/team/access/policies.multilocale.json +43 -0
  209. package/vendor/registry/modules/team/lib.multilocale.ts +88 -0
  210. package/vendor/registry/modules/team/lib.ts +120 -0
  211. package/vendor/registry/modules/team/module.json +47 -0
  212. package/vendor/registry/modules/team/schema/snapshot.json +295 -0
  213. package/vendor/registry/modules/team/schema/snapshot.multilocale.json +525 -0
  214. package/vendor/registry/modules/team/services/ATTRIBUTION.md +8 -0
  215. package/vendor/registry/modules/team/services/assets/morgan-lee-photo.jpg +0 -0
  216. package/vendor/registry/modules/team/services/assets/taylor-kim-photo.jpg +0 -0
  217. package/vendor/registry/modules/team/services/seed.json +52 -0
  218. package/vendor/registry/modules/team/services/seed.multilocale.json +30 -0
  219. package/vendor/registry/modules/team/types.multilocale.ts +33 -0
  220. package/vendor/registry/modules/team/types.ts +27 -0
  221. package/vendor/registry/modules/testimonials/access/policies.json +31 -0
  222. package/vendor/registry/modules/testimonials/access/policies.multilocale.json +43 -0
  223. package/vendor/registry/modules/testimonials/lib.multilocale.ts +93 -0
  224. package/vendor/registry/modules/testimonials/lib.ts +85 -0
  225. package/vendor/registry/modules/testimonials/module.json +41 -0
  226. package/vendor/registry/modules/testimonials/schema/snapshot.json +248 -0
  227. package/vendor/registry/modules/testimonials/schema/snapshot.multilocale.json +462 -0
  228. package/vendor/registry/modules/testimonials/services/ATTRIBUTION.md +8 -0
  229. package/vendor/registry/modules/testimonials/services/assets/jane-doe-avatar.jpg +0 -0
  230. package/vendor/registry/modules/testimonials/services/assets/sample-author-avatar.jpg +0 -0
  231. package/vendor/registry/modules/testimonials/services/seed.json +49 -0
  232. package/vendor/registry/modules/testimonials/services/seed.multilocale.json +30 -0
  233. package/vendor/registry/modules/testimonials/types.multilocale.ts +27 -0
  234. package/vendor/registry/modules/testimonials/types.ts +22 -0
  235. package/vendor/registry/registry.json +832 -0
  236. package/vendor/registry/shared/helpers.ts +16 -0
  237. package/vendor/registry/shared/i18n.ts +74 -0
  238. package/vendor/registry/shared/minimal.css +83 -0
  239. package/vendor/registry/shared/paths.ts +50 -0
  240. package/vendor/registry/shared/prose.css +113 -0
  241. package/vendor/registry/tsconfig.json +49 -0
@@ -0,0 +1,49 @@
1
+ {
2
+ "policies": [
3
+ {
4
+ "name": "dkit Blog Public Read",
5
+ "icon": "public",
6
+ "description": "Public read for blog collections (flat rules — Core-compatible). UI filters published status.",
7
+ "admin_access": false,
8
+ "app_access": false
9
+ }
10
+ ],
11
+ "permissions": [
12
+ {
13
+ "policy": "dkit Blog Public Read",
14
+ "collection": "posts",
15
+ "action": "read",
16
+ "fields": ["*"]
17
+ },
18
+ {
19
+ "policy": "dkit Blog Public Read",
20
+ "collection": "authors",
21
+ "action": "read",
22
+ "fields": ["*"]
23
+ },
24
+ {
25
+ "policy": "dkit Blog Public Read",
26
+ "collection": "categories",
27
+ "action": "read",
28
+ "fields": ["*"]
29
+ },
30
+ {
31
+ "policy": "dkit Blog Public Read",
32
+ "collection": "posts_categories",
33
+ "action": "read",
34
+ "fields": ["*"]
35
+ },
36
+ {
37
+ "policy": "dkit Blog Public Read",
38
+ "collection": "directus_files",
39
+ "action": "read",
40
+ "fields": ["*"]
41
+ }
42
+ ],
43
+ "access": [
44
+ {
45
+ "role": "$public",
46
+ "policy": "dkit Blog Public Read"
47
+ }
48
+ ]
49
+ }
@@ -0,0 +1,67 @@
1
+ {
2
+ "policies": [
3
+ {
4
+ "name": "dkit Blog Public Read",
5
+ "icon": "public",
6
+ "description": "Public read for blog collections incl. translation tables (flat rules — Core-compatible). UI filters published status.",
7
+ "admin_access": false,
8
+ "app_access": false
9
+ }
10
+ ],
11
+ "permissions": [
12
+ {
13
+ "policy": "dkit Blog Public Read",
14
+ "collection": "posts",
15
+ "action": "read",
16
+ "fields": ["*"]
17
+ },
18
+ {
19
+ "policy": "dkit Blog Public Read",
20
+ "collection": "posts_translations",
21
+ "action": "read",
22
+ "fields": ["*"]
23
+ },
24
+ {
25
+ "policy": "dkit Blog Public Read",
26
+ "collection": "authors",
27
+ "action": "read",
28
+ "fields": ["*"]
29
+ },
30
+ {
31
+ "policy": "dkit Blog Public Read",
32
+ "collection": "authors_translations",
33
+ "action": "read",
34
+ "fields": ["*"]
35
+ },
36
+ {
37
+ "policy": "dkit Blog Public Read",
38
+ "collection": "categories",
39
+ "action": "read",
40
+ "fields": ["*"]
41
+ },
42
+ {
43
+ "policy": "dkit Blog Public Read",
44
+ "collection": "categories_translations",
45
+ "action": "read",
46
+ "fields": ["*"]
47
+ },
48
+ {
49
+ "policy": "dkit Blog Public Read",
50
+ "collection": "posts_categories",
51
+ "action": "read",
52
+ "fields": ["*"]
53
+ },
54
+ {
55
+ "policy": "dkit Blog Public Read",
56
+ "collection": "directus_files",
57
+ "action": "read",
58
+ "fields": ["*"]
59
+ }
60
+ ],
61
+ "access": [
62
+ {
63
+ "role": "$public",
64
+ "policy": "dkit Blog Public Read"
65
+ }
66
+ ]
67
+ }
@@ -0,0 +1,552 @@
1
+ import {
2
+ directusAssetUrl,
3
+ directusFileId,
4
+ dkitQueryFailed,
5
+ getDirectus,
6
+ readItem,
7
+ readItems,
8
+ } from "@/lib/dkit/client";
9
+ import { collections } from "@/lib/dkit/config";
10
+ import { queryLimit, statusFilter } from "@/lib/dkit/helpers";
11
+ import {
12
+ isUsableTranslation,
13
+ pickTranslation,
14
+ requireLocaleTranslation,
15
+ resolveLocale,
16
+ translationsDeepFilter,
17
+ } from "@/lib/dkit/i18n";
18
+ import type {
19
+ BlogAuthor,
20
+ BlogAuthorTranslation,
21
+ BlogCategory,
22
+ BlogCategoryTranslation,
23
+ BlogPost,
24
+ BlogPostTranslation,
25
+ GetBlogAuthorsOptions,
26
+ GetBlogBySlugOptions,
27
+ GetBlogCategoriesOptions,
28
+ GetBlogPostsOptions,
29
+ } from "./types.multilocale";
30
+
31
+ export type {
32
+ BlogAuthor,
33
+ BlogAuthorTranslation,
34
+ BlogCategory,
35
+ BlogCategoryTranslation,
36
+ BlogPost,
37
+ BlogPostTranslation,
38
+ DirectusFileRef,
39
+ GetBlogAuthorsOptions,
40
+ GetBlogBySlugOptions,
41
+ GetBlogCategoriesOptions,
42
+ GetBlogPostsOptions,
43
+ PostsCategoriesRow,
44
+ } from "./types.multilocale";
45
+
46
+ /* ── flatten helpers ── */
47
+
48
+ type JunctionCategory = {
49
+ id?: number | string;
50
+ categories_id?: BlogCategory | string | null;
51
+ };
52
+
53
+ function flattenPost(
54
+ row: Record<string, unknown>,
55
+ locale: string,
56
+ ): BlogPost | null {
57
+ const trans = pickTranslation(
58
+ row.translations as BlogPostTranslation[] | undefined,
59
+ locale,
60
+ );
61
+ if (!isUsableTranslation(trans)) return null;
62
+
63
+ let author: BlogPost["author"] = row.author as BlogPost["author"];
64
+ if (author && typeof author === "object") {
65
+ author = flattenAuthor(author as unknown as Record<string, unknown>, locale);
66
+ }
67
+ const rawCategories = row.categories;
68
+ let categories: BlogPost["categories"] = null;
69
+ if (Array.isArray(rawCategories)) {
70
+ const out: BlogCategory[] = [];
71
+ for (const item of rawCategories) {
72
+ if (!item || typeof item !== "object") continue;
73
+ if ("title" in item && "id" in item && !("translations" in item)) {
74
+ if ((item as BlogCategory).title && (item as BlogCategory).slug) {
75
+ out.push(item as BlogCategory);
76
+ }
77
+ continue;
78
+ }
79
+ const related =
80
+ "categories_id" in item
81
+ ? (item as JunctionCategory).categories_id
82
+ : item;
83
+ if (related && typeof related === "object") {
84
+ const flat = flattenCategory(
85
+ related as unknown as Record<string, unknown>,
86
+ locale,
87
+ );
88
+ if (flat) out.push(flat);
89
+ }
90
+ }
91
+ categories = out;
92
+ }
93
+ return {
94
+ id: row.id as string,
95
+ status: row.status as BlogPost["status"],
96
+ title: trans!.title!,
97
+ slug: trans!.slug!,
98
+ excerpt: trans?.excerpt ?? null,
99
+ body: trans?.body ?? null,
100
+ published_at: (row.published_at as string | null) ?? null,
101
+ featured_image: row.featured_image as BlogPost["featured_image"],
102
+ author,
103
+ categories,
104
+ };
105
+ }
106
+
107
+ function flattenCategory(
108
+ row: Record<string, unknown>,
109
+ locale: string,
110
+ ): BlogCategory | null {
111
+ const trans = pickTranslation(
112
+ row.translations as BlogCategoryTranslation[] | undefined,
113
+ locale,
114
+ );
115
+ if (!isUsableTranslation(trans)) return null;
116
+ return {
117
+ id: row.id as string,
118
+ title: trans!.title!,
119
+ slug: trans!.slug!,
120
+ };
121
+ }
122
+
123
+ function flattenAuthor(
124
+ row: Record<string, unknown>,
125
+ locale: string,
126
+ ): BlogAuthor {
127
+ const trans = pickTranslation(
128
+ row.translations as BlogAuthorTranslation[] | undefined,
129
+ locale,
130
+ );
131
+ return {
132
+ id: row.id as string,
133
+ status: row.status as BlogAuthor["status"],
134
+ name: row.name as string,
135
+ slug: row.slug as string,
136
+ avatar: row.avatar as BlogAuthor["avatar"],
137
+ bio: trans?.bio ?? null,
138
+ };
139
+ }
140
+
141
+ /* ── field lists ── */
142
+
143
+ const POST_LIST_FIELDS = [
144
+ "id",
145
+ "status",
146
+ "published_at",
147
+ "featured_image",
148
+ { author: ["id", "name", "slug", "avatar"] },
149
+ {
150
+ translations: ["id", "languages_code", "title", "slug", "excerpt"],
151
+ },
152
+ ] as const;
153
+
154
+ const POST_DETAIL_FIELDS = [
155
+ "id",
156
+ "status",
157
+ "published_at",
158
+ "featured_image",
159
+ {
160
+ author: [
161
+ "id",
162
+ "name",
163
+ "slug",
164
+ "avatar",
165
+ { translations: ["id", "languages_code", "bio"] },
166
+ ],
167
+ },
168
+ { categories: ["id", { categories_id: ["id", { translations: ["id", "languages_code", "title", "slug"] }] }] },
169
+ {
170
+ translations: [
171
+ "id",
172
+ "languages_code",
173
+ "title",
174
+ "slug",
175
+ "excerpt",
176
+ "body",
177
+ ],
178
+ },
179
+ ] as const;
180
+
181
+ const AUTHOR_FIELDS = [
182
+ "id",
183
+ "status",
184
+ "name",
185
+ "slug",
186
+ "avatar",
187
+ { translations: ["id", "languages_code", "bio"] },
188
+ ] as const;
189
+
190
+ const CATEGORY_FIELDS = [
191
+ "id",
192
+ { translations: ["id", "languages_code", "title", "slug"] },
193
+ ] as const;
194
+
195
+ /* ── presentational helpers ── */
196
+
197
+ export function authorName(post: BlogPost): string | null {
198
+ return typeof post.author === "object" && post.author?.name
199
+ ? post.author.name
200
+ : null;
201
+ }
202
+
203
+ export function authorAvatarUrl(post: BlogPost): string | null {
204
+ if (typeof post.author !== "object" || !post.author) return null;
205
+ const id = directusFileId(post.author.avatar);
206
+ return id ? directusAssetUrl(id) : null;
207
+ }
208
+
209
+ export function featuredImageUrl(post: BlogPost): string | null {
210
+ const id = directusFileId(post.featured_image);
211
+ return id ? directusAssetUrl(id) : null;
212
+ }
213
+
214
+ export function normalizeCategories(
215
+ raw: BlogPost["categories"] | JunctionCategory[] | null | undefined,
216
+ ): BlogCategory[] {
217
+ if (!Array.isArray(raw)) return [];
218
+ const out: BlogCategory[] = [];
219
+ for (const item of raw) {
220
+ if (!item || typeof item !== "object") continue;
221
+ if ("title" in item && "id" in item) {
222
+ out.push(item as BlogCategory);
223
+ continue;
224
+ }
225
+ const related = (item as JunctionCategory).categories_id;
226
+ if (related && typeof related === "object" && "id" in related) {
227
+ out.push(related);
228
+ }
229
+ }
230
+ return out;
231
+ }
232
+
233
+ /** Posts, newest first. Defaults to status=published. */
234
+ export async function getBlogPosts(
235
+ options: GetBlogPostsOptions = {},
236
+ ): Promise<BlogPost[]> {
237
+ const client = getDirectus();
238
+ if (!client) return [];
239
+ if (!collections.posts) {
240
+ dkitQueryFailed(
241
+ 'collections.posts missing from lib/dkit/config — re-run `dkit add blog` (check collection prefix matches Directus, e.g. "dkit_posts")',
242
+ );
243
+ return [];
244
+ }
245
+ const locale = await resolveLocale(options.locale);
246
+ const status = statusFilter(options.status);
247
+ const and: Record<string, unknown>[] = [requireLocaleTranslation(locale)];
248
+ if (status) and.unshift(status);
249
+ if (options.category) {
250
+ and.push({
251
+ categories: {
252
+ categories_id: {
253
+ translations: {
254
+ _and: [
255
+ { languages_code: { _eq: locale } },
256
+ { slug: { _eq: options.category } },
257
+ ],
258
+ },
259
+ },
260
+ },
261
+ });
262
+ }
263
+ const limit = queryLimit(options.limit);
264
+ try {
265
+ const rows = await client.request(
266
+ readItems(collections.posts, {
267
+ filter: { _and: and },
268
+ deep: translationsDeepFilter(locale),
269
+ fields: [...POST_LIST_FIELDS],
270
+ sort: options.sort ?? ["-published_at"],
271
+ ...(limit !== undefined ? { limit } : {}),
272
+ }),
273
+ );
274
+ return (rows as Record<string, unknown>[])
275
+ .map((r) => flattenPost(r, locale))
276
+ .filter((p): p is BlogPost => p != null);
277
+ } catch (err) {
278
+ dkitQueryFailed(
279
+ `getBlogPosts failed (collection=${collections.posts})`,
280
+ err,
281
+ );
282
+ return [];
283
+ }
284
+ }
285
+
286
+ export async function getBlogPostBySlug(
287
+ slug: string,
288
+ options: GetBlogBySlugOptions = {},
289
+ ): Promise<BlogPost | null> {
290
+ const client = getDirectus();
291
+ if (!client) return null;
292
+ if (!collections.posts) {
293
+ dkitQueryFailed("collections.posts missing from lib/dkit/config");
294
+ return null;
295
+ }
296
+ const locale = await resolveLocale(options.locale);
297
+ const status = statusFilter(options.status);
298
+ const and: Record<string, unknown>[] = [
299
+ {
300
+ translations: {
301
+ _and: [
302
+ { languages_code: { _eq: locale } },
303
+ { slug: { _eq: slug } },
304
+ { title: { _nempty: true } },
305
+ ],
306
+ },
307
+ },
308
+ ];
309
+ if (status) and.unshift(status);
310
+ try {
311
+ const rows = await client.request(
312
+ readItems(collections.posts, {
313
+ filter: { _and: and },
314
+ deep: translationsDeepFilter(locale),
315
+ fields: [...POST_DETAIL_FIELDS],
316
+ limit: 1,
317
+ }),
318
+ );
319
+ const row = (rows as Record<string, unknown>[])[0];
320
+ return row ? flattenPost(row, locale) : null;
321
+ } catch (err) {
322
+ dkitQueryFailed(
323
+ `getBlogPostBySlug(${slug}) failed (collection=${collections.posts})`,
324
+ err,
325
+ );
326
+ return null;
327
+ }
328
+ }
329
+
330
+ export async function getBlogPostById(
331
+ id: string,
332
+ options: GetBlogBySlugOptions = {},
333
+ ): Promise<BlogPost | null> {
334
+ const client = getDirectus();
335
+ if (!client) return null;
336
+ if (!collections.posts) return null;
337
+ const locale = await resolveLocale(options.locale);
338
+ try {
339
+ const rows = await client.request(
340
+ readItems(collections.posts, {
341
+ filter: {
342
+ _and: [{ id: { _eq: id } }, requireLocaleTranslation(locale)],
343
+ },
344
+ deep: translationsDeepFilter(locale),
345
+ fields: [...POST_DETAIL_FIELDS],
346
+ limit: 1,
347
+ }),
348
+ );
349
+ const row = (rows as Record<string, unknown>[])[0];
350
+ return row ? flattenPost(row, locale) : null;
351
+ } catch (err) {
352
+ dkitQueryFailed(`getBlogPostById(${id}) failed`, err);
353
+ return null;
354
+ }
355
+ }
356
+
357
+ /** Authors, by name. */
358
+ export async function getBlogAuthors(
359
+ options: GetBlogAuthorsOptions = {},
360
+ ): Promise<BlogAuthor[]> {
361
+ const client = getDirectus();
362
+ if (!client) return [];
363
+ if (!collections.authors) return [];
364
+ const locale = await resolveLocale(options.locale);
365
+ const status = statusFilter(options.status);
366
+ const limit = queryLimit(options.limit);
367
+ try {
368
+ const rows = await client.request(
369
+ readItems(collections.authors, {
370
+ filter: status,
371
+ deep: translationsDeepFilter(locale),
372
+ fields: [...AUTHOR_FIELDS],
373
+ sort: options.sort ?? ["name"],
374
+ ...(limit !== undefined ? { limit } : {}),
375
+ }),
376
+ );
377
+ return (rows as Record<string, unknown>[]).map((r) =>
378
+ flattenAuthor(r, locale),
379
+ );
380
+ } catch (err) {
381
+ dkitQueryFailed(
382
+ `getBlogAuthors failed (collection=${collections.authors})`,
383
+ err,
384
+ );
385
+ return [];
386
+ }
387
+ }
388
+
389
+ export async function getBlogAuthorBySlug(
390
+ slug: string,
391
+ options: GetBlogBySlugOptions = {},
392
+ ): Promise<BlogAuthor | null> {
393
+ const client = getDirectus();
394
+ if (!client) return null;
395
+ if (!collections.authors) return null;
396
+ const locale = await resolveLocale(options.locale);
397
+ const status = statusFilter(options.status);
398
+ const and: Record<string, unknown>[] = [{ slug: { _eq: slug } }];
399
+ if (status) and.unshift(status);
400
+ try {
401
+ const rows = await client.request(
402
+ readItems(collections.authors, {
403
+ filter: { _and: and },
404
+ fields: [...AUTHOR_FIELDS],
405
+ limit: 1,
406
+ }),
407
+ );
408
+ const row = (rows as Record<string, unknown>[])[0];
409
+ return row ? flattenAuthor(row, locale) : null;
410
+ } catch (err) {
411
+ dkitQueryFailed(`getBlogAuthorBySlug(${slug}) failed`, err);
412
+ return null;
413
+ }
414
+ }
415
+
416
+ export async function getBlogAuthorById(
417
+ id: string,
418
+ options: GetBlogBySlugOptions = {},
419
+ ): Promise<BlogAuthor | null> {
420
+ const client = getDirectus();
421
+ if (!client) return null;
422
+ if (!collections.authors) return null;
423
+ const locale = await resolveLocale(options.locale);
424
+ try {
425
+ const row = await client.request(
426
+ readItem(collections.authors, id, {
427
+ fields: [...AUTHOR_FIELDS],
428
+ }),
429
+ );
430
+ return row ? flattenAuthor(row as Record<string, unknown>, locale) : null;
431
+ } catch (err) {
432
+ dkitQueryFailed(`getBlogAuthorById(${id}) failed`, err);
433
+ return null;
434
+ }
435
+ }
436
+
437
+ /** Categories that have a title+slug for the active locale. */
438
+ export async function getBlogCategories(
439
+ options: GetBlogCategoriesOptions = {},
440
+ ): Promise<BlogCategory[]> {
441
+ const client = getDirectus();
442
+ if (!client) return [];
443
+ if (!collections.categories) return [];
444
+ const locale = await resolveLocale(options.locale);
445
+ const limit = queryLimit(options.limit);
446
+ try {
447
+ const rows = await client.request(
448
+ readItems(collections.categories, {
449
+ filter: requireLocaleTranslation(locale),
450
+ deep: translationsDeepFilter(locale),
451
+ fields: [...CATEGORY_FIELDS],
452
+ ...(limit !== undefined ? { limit } : {}),
453
+ }),
454
+ );
455
+ return (rows as Record<string, unknown>[])
456
+ .map((r) => flattenCategory(r, locale))
457
+ .filter((c): c is BlogCategory => c != null);
458
+ } catch (err) {
459
+ dkitQueryFailed(
460
+ `getBlogCategories failed (collection=${collections.categories})`,
461
+ err,
462
+ );
463
+ return [];
464
+ }
465
+ }
466
+
467
+ export async function getBlogCategoryBySlug(
468
+ slug: string,
469
+ options: { locale?: string } = {},
470
+ ): Promise<BlogCategory | null> {
471
+ const client = getDirectus();
472
+ if (!client) return null;
473
+ if (!collections.categories) return null;
474
+ const locale = await resolveLocale(options.locale);
475
+ try {
476
+ const rows = await client.request(
477
+ readItems(collections.categories, {
478
+ filter: {
479
+ translations: {
480
+ _and: [
481
+ { languages_code: { _eq: locale } },
482
+ { slug: { _eq: slug } },
483
+ { title: { _nempty: true } },
484
+ ],
485
+ },
486
+ },
487
+ deep: translationsDeepFilter(locale),
488
+ fields: [...CATEGORY_FIELDS],
489
+ limit: 1,
490
+ }),
491
+ );
492
+ const row = (rows as Record<string, unknown>[])[0];
493
+ return row ? flattenCategory(row, locale) : null;
494
+ } catch (err) {
495
+ dkitQueryFailed(`getBlogCategoryBySlug(${slug}) failed`, err);
496
+ return null;
497
+ }
498
+ }
499
+
500
+ export async function getBlogCategoryById(
501
+ id: string,
502
+ options: { locale?: string } = {},
503
+ ): Promise<BlogCategory | null> {
504
+ const client = getDirectus();
505
+ if (!client) return null;
506
+ if (!collections.categories) return null;
507
+ const locale = await resolveLocale(options.locale);
508
+ try {
509
+ const rows = await client.request(
510
+ readItems(collections.categories, {
511
+ filter: {
512
+ _and: [{ id: { _eq: id } }, requireLocaleTranslation(locale)],
513
+ },
514
+ deep: translationsDeepFilter(locale),
515
+ fields: [...CATEGORY_FIELDS],
516
+ limit: 1,
517
+ }),
518
+ );
519
+ const row = (rows as Record<string, unknown>[])[0];
520
+ return row ? flattenCategory(row, locale) : null;
521
+ } catch (err) {
522
+ dkitQueryFailed(`getBlogCategoryById(${id}) failed`, err);
523
+ return null;
524
+ }
525
+ }
526
+
527
+ /** @deprecated prefer getBlogPosts({ category }) */
528
+ export async function getBlogPostsByCategorySlug(
529
+ categorySlug: string,
530
+ options: Omit<GetBlogPostsOptions, "category"> = {},
531
+ ): Promise<BlogPost[]> {
532
+ return getBlogPosts({ ...options, category: categorySlug });
533
+ }
534
+
535
+ /** @deprecated prefer getBlogPostBySlug */
536
+ export const getBlogPost = getBlogPostBySlug;
537
+ /** @deprecated prefer getBlogPosts */
538
+ export const getPosts = getBlogPosts;
539
+ /** @deprecated prefer getBlogPostBySlug */
540
+ export const getPostBySlug = getBlogPostBySlug;
541
+ /** @deprecated prefer getBlogPostById */
542
+ export const getPostById = getBlogPostById;
543
+ /** @deprecated prefer getBlogPostBySlug */
544
+ export const getPost = getBlogPostBySlug;
545
+ /** @deprecated prefer getBlogCategories */
546
+ export const getCategories = getBlogCategories;
547
+ /** @deprecated prefer getBlogAuthors */
548
+ export const getAuthors = getBlogAuthors;
549
+ /** @deprecated prefer getBlogAuthorBySlug */
550
+ export const getAuthorBySlug = getBlogAuthorBySlug;
551
+ /** @deprecated prefer getBlogAuthorById */
552
+ export const getAuthorById = getBlogAuthorById;