@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,31 @@
1
+ {
2
+ "policies": [
3
+ {
4
+ "name": "dkit Testimonials Public Read",
5
+ "icon": "public",
6
+ "description": "Public read for testimonials 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 Testimonials Public Read",
14
+ "collection": "testimonials",
15
+ "action": "read",
16
+ "fields": ["*"]
17
+ },
18
+ {
19
+ "policy": "dkit Testimonials Public Read",
20
+ "collection": "directus_files",
21
+ "action": "read",
22
+ "fields": ["*"]
23
+ }
24
+ ],
25
+ "access": [
26
+ {
27
+ "role": "$public",
28
+ "policy": "dkit Testimonials Public Read"
29
+ }
30
+ ]
31
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "policies": [
3
+ {
4
+ "name": "dkit Testimonials Public Read",
5
+ "icon": "public",
6
+ "description": "Public read for testimonials incl. translations.",
7
+ "admin_access": false,
8
+ "app_access": false
9
+ }
10
+ ],
11
+ "permissions": [
12
+ {
13
+ "policy": "dkit Testimonials Public Read",
14
+ "collection": "testimonials",
15
+ "action": "read",
16
+ "fields": [
17
+ "*"
18
+ ]
19
+ },
20
+ {
21
+ "policy": "dkit Testimonials Public Read",
22
+ "collection": "testimonials_translations",
23
+ "action": "read",
24
+ "fields": [
25
+ "*"
26
+ ]
27
+ },
28
+ {
29
+ "policy": "dkit Testimonials Public Read",
30
+ "collection": "directus_files",
31
+ "action": "read",
32
+ "fields": [
33
+ "*"
34
+ ]
35
+ }
36
+ ],
37
+ "access": [
38
+ {
39
+ "role": "$public",
40
+ "policy": "dkit Testimonials Public Read"
41
+ }
42
+ ]
43
+ }
@@ -0,0 +1,93 @@
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 { GetTestimonialsOptions, Testimonial, TestimonialTranslation } from "./types.multilocale";
19
+
20
+ export type { DirectusFileRef, GetTestimonialsOptions, Testimonial, TestimonialTranslation } from "./types.multilocale";
21
+
22
+ function flattenTestimonial(row: Record<string, unknown>, locale: string): Testimonial | null {
23
+ const trans = pickTranslation(row.translations as TestimonialTranslation[] | undefined, locale);
24
+ if (!isUsableTranslation(trans, ["quote"])) return null;
25
+
26
+ return {
27
+ id: row.id as string,
28
+ status: row.status as Testimonial["status"],
29
+ quote: trans!.quote!,
30
+ author_name: row.author_name as string,
31
+ author_role: trans?.author_role ?? null,
32
+ company: (row.company as string | null) ?? null,
33
+ avatar: row.avatar as Testimonial["avatar"],
34
+ sort: (row.sort as number | null) ?? null,
35
+ };
36
+ }
37
+
38
+ const TESTIMONIAL_FIELDS = [
39
+ "id", "status", "author_name", "company", "avatar", "sort",
40
+ { translations: ["id", "languages_code", "quote", "author_role"] },
41
+ ] as const;
42
+
43
+ export function testimonialAvatarUrl(testimonial: Testimonial): string | null {
44
+ const id = directusFileId(testimonial.avatar);
45
+ return id ? directusAssetUrl(id) : null;
46
+ }
47
+
48
+ export async function getTestimonials(options: GetTestimonialsOptions = {}): Promise<Testimonial[]> {
49
+ const client = getDirectus();
50
+ if (!client) return [];
51
+ if (!collections.testimonials) { dkitQueryFailed('collections.testimonials missing — re-run `dkit add testimonials`'); return []; }
52
+ const locale = await resolveLocale(options.locale);
53
+ const status = statusFilter(options.status);
54
+ const and: Record<string, unknown>[] = [
55
+ requireLocaleTranslation(locale, ["quote"]),
56
+ ];
57
+ if (status) and.unshift(status);
58
+ const limit = queryLimit(options.limit);
59
+ try {
60
+ const rows = await client.request(readItems(collections.testimonials, {
61
+ filter: { _and: and },
62
+ deep: translationsDeepFilter(locale),
63
+ fields: [...TESTIMONIAL_FIELDS],
64
+ sort: options.sort ?? ["sort", "author_name"],
65
+ ...(limit !== undefined ? { limit } : {}),
66
+ }));
67
+ return (rows as Record<string, unknown>[])
68
+ .map((r) => flattenTestimonial(r, locale))
69
+ .filter((t): t is Testimonial => t != null);
70
+ } catch (err) { dkitQueryFailed(`getTestimonials failed`, err); return []; }
71
+ }
72
+
73
+ export async function getTestimonialById(id: string, options: { locale?: string } = {}): Promise<Testimonial | null> {
74
+ const client = getDirectus();
75
+ if (!client) return null;
76
+ if (!collections.testimonials) return null;
77
+ const locale = await resolveLocale(options.locale);
78
+ try {
79
+ const rows = await client.request(readItems(collections.testimonials, {
80
+ filter: {
81
+ _and: [
82
+ { id: { _eq: id } },
83
+ requireLocaleTranslation(locale, ["quote"]),
84
+ ],
85
+ },
86
+ deep: translationsDeepFilter(locale),
87
+ fields: [...TESTIMONIAL_FIELDS],
88
+ limit: 1,
89
+ }));
90
+ const row = (rows as Record<string, unknown>[])[0];
91
+ return row ? flattenTestimonial(row as Record<string, unknown>, locale) : null;
92
+ } catch (err) { dkitQueryFailed(`getTestimonialById(${id}) failed`, err); return null; }
93
+ }
@@ -0,0 +1,85 @@
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 type { GetTestimonialsOptions, Testimonial } from "./types";
12
+
13
+ export type {
14
+ DirectusFileRef,
15
+ GetTestimonialsOptions,
16
+ Testimonial,
17
+ } from "./types";
18
+
19
+ const TESTIMONIAL_FIELDS = [
20
+ "id",
21
+ "status",
22
+ "quote",
23
+ "author_name",
24
+ "author_role",
25
+ "company",
26
+ "avatar",
27
+ "sort",
28
+ ] as const;
29
+
30
+ export function testimonialAvatarUrl(
31
+ testimonial: Testimonial,
32
+ ): string | null {
33
+ const id = directusFileId(testimonial.avatar);
34
+ return id ? directusAssetUrl(id) : null;
35
+ }
36
+
37
+ /** Testimonials, sorted by manual sort then author name. Defaults to status=published. */
38
+ export async function getTestimonials(
39
+ options: GetTestimonialsOptions = {},
40
+ ): Promise<Testimonial[]> {
41
+ const client = getDirectus();
42
+ if (!client) return [];
43
+ if (!collections.testimonials) {
44
+ dkitQueryFailed(
45
+ 'collections.testimonials missing from lib/dkit/config — re-run `dkit add testimonials`',
46
+ );
47
+ return [];
48
+ }
49
+ const status = statusFilter(options.status);
50
+ const limit = queryLimit(options.limit);
51
+ try {
52
+ return await client.request(
53
+ readItems(collections.testimonials, {
54
+ filter: status,
55
+ fields: [...TESTIMONIAL_FIELDS],
56
+ sort: options.sort ?? ["sort", "author_name"],
57
+ ...(limit !== undefined ? { limit } : {}),
58
+ }),
59
+ );
60
+ } catch (err) {
61
+ dkitQueryFailed(
62
+ `getTestimonials failed (collection=${collections.testimonials})`,
63
+ err,
64
+ );
65
+ return [];
66
+ }
67
+ }
68
+
69
+ export async function getTestimonialById(
70
+ id: string,
71
+ ): Promise<Testimonial | null> {
72
+ const client = getDirectus();
73
+ if (!client) return null;
74
+ if (!collections.testimonials) return null;
75
+ try {
76
+ return await client.request(
77
+ readItem(collections.testimonials, id, {
78
+ fields: [...TESTIMONIAL_FIELDS],
79
+ }),
80
+ );
81
+ } catch (err) {
82
+ dkitQueryFailed(`getTestimonialById(${id}) failed`, err);
83
+ return null;
84
+ }
85
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "type": "dkit:module",
3
+ "id": "testimonials",
4
+ "title": "Testimonials",
5
+ "description": "Client quotes for social proof",
6
+ "version": "0.1.0",
7
+ "directus": {
8
+ "min": "11.0.0"
9
+ },
10
+ "dependencies": [
11
+ "@directus/sdk"
12
+ ],
13
+ "layers": [
14
+ "schema",
15
+ "access",
16
+ "services",
17
+ "types"
18
+ ],
19
+ "defaultBlocks": [
20
+ "testimonials-list"
21
+ ],
22
+ "templates": {
23
+ "list": {
24
+ "default": "testimonials-list",
25
+ "options": [
26
+ "testimonials-list",
27
+ "testimonials-list-cards",
28
+ "testimonials-carousel"
29
+ ]
30
+ }
31
+ },
32
+ "defaultBasePath": "/testimonials",
33
+ "collections": [
34
+ "proof",
35
+ "testimonials"
36
+ ],
37
+ "multilocale": {
38
+ "supported": true,
39
+ "mode": "translations"
40
+ }
41
+ }
@@ -0,0 +1,248 @@
1
+ {
2
+ "format": "dkit.rest",
3
+ "collections": [
4
+ {
5
+ "collection": "proof",
6
+ "schema": null,
7
+ "meta": {
8
+ "icon": "format_quote",
9
+ "color": "#0F766E",
10
+ "collapse": "open",
11
+ "translations": [
12
+ {
13
+ "language": "en-US",
14
+ "translation": "Proof",
15
+ "singular": "Proof",
16
+ "plural": "Proof"
17
+ }
18
+ ]
19
+ }
20
+ },
21
+ {
22
+ "collection": "testimonials",
23
+ "schema": {},
24
+ "meta": {
25
+ "icon": "reviews",
26
+ "color": "#0F766E",
27
+ "group": "proof",
28
+ "display_template": "{{author_name}}",
29
+ "archive_field": null,
30
+ "singleton": false,
31
+ "sort": 1,
32
+ "translations": [
33
+ {
34
+ "language": "en-US",
35
+ "translation": "Testimonials",
36
+ "singular": "Testimonial",
37
+ "plural": "Testimonials"
38
+ }
39
+ ],
40
+ "note": "Client quotes displayed as social proof on the public site"
41
+ },
42
+ "fields": [
43
+ {
44
+ "field": "id",
45
+ "type": "uuid",
46
+ "meta": {
47
+ "hidden": true,
48
+ "readonly": true,
49
+ "interface": "input",
50
+ "special": ["uuid"],
51
+ "sort": 1,
52
+ "width": "full",
53
+ "translations": [
54
+ { "language": "en-US", "translation": "ID" }
55
+ ]
56
+ },
57
+ "schema": {
58
+ "is_primary_key": true,
59
+ "length": 36,
60
+ "has_auto_increment": false
61
+ }
62
+ },
63
+ {
64
+ "field": "status",
65
+ "type": "string",
66
+ "meta": {
67
+ "interface": "select-dropdown",
68
+ "display": "labels",
69
+ "width": "half",
70
+ "sort": 2,
71
+ "options": {
72
+ "choices": [
73
+ { "text": "Published", "value": "published" },
74
+ { "text": "Draft", "value": "draft" }
75
+ ]
76
+ },
77
+ "display_options": {
78
+ "choices": [
79
+ {
80
+ "text": "Published",
81
+ "value": "published",
82
+ "foreground": "#FFFFFF",
83
+ "background": "#0F766E"
84
+ },
85
+ {
86
+ "text": "Draft",
87
+ "value": "draft",
88
+ "foreground": "#44403C",
89
+ "background": "#E7E5E4"
90
+ }
91
+ ]
92
+ },
93
+ "translations": [
94
+ { "language": "en-US", "translation": "Status" }
95
+ ],
96
+ "note": "Only published testimonials appear on the public site",
97
+ "validation": {
98
+ "_and": [{ "status": { "_in": ["published", "draft"] } }]
99
+ },
100
+ "validation_message": "Choose Published or Draft."
101
+ },
102
+ "schema": { "default_value": "draft", "is_nullable": false }
103
+ },
104
+ {
105
+ "field": "quote",
106
+ "type": "text",
107
+ "meta": {
108
+ "interface": "input-multiline",
109
+ "required": true,
110
+ "width": "full",
111
+ "sort": 3,
112
+ "translations": [
113
+ { "language": "en-US", "translation": "Quote" }
114
+ ],
115
+ "note": "The testimonial text displayed publicly",
116
+ "validation": {
117
+ "_and": [
118
+ { "quote": { "_regex": "^[\\s\\S]{1,1000}$" } }
119
+ ]
120
+ },
121
+ "validation_message": "Quote is required (max 1000 characters)."
122
+ },
123
+ "schema": { "is_nullable": false, "max_length": 1000 }
124
+ },
125
+ {
126
+ "field": "author_name",
127
+ "type": "string",
128
+ "meta": {
129
+ "interface": "input",
130
+ "required": true,
131
+ "width": "half",
132
+ "sort": 4,
133
+ "options": { "trim": true },
134
+ "translations": [
135
+ { "language": "en-US", "translation": "Author name" }
136
+ ],
137
+ "note": "Person who gave the testimonial",
138
+ "validation": {
139
+ "_and": [{ "author_name": { "_regex": "^.{1,120}$" } }]
140
+ },
141
+ "validation_message": "Author name is required (max 120 characters)."
142
+ },
143
+ "schema": { "is_nullable": false, "max_length": 120 }
144
+ },
145
+ {
146
+ "field": "author_role",
147
+ "type": "string",
148
+ "meta": {
149
+ "interface": "input",
150
+ "width": "half",
151
+ "sort": 5,
152
+ "options": { "trim": true },
153
+ "translations": [
154
+ { "language": "en-US", "translation": "Author role" }
155
+ ],
156
+ "note": "Job title or role (optional)",
157
+ "validation": {
158
+ "_and": [
159
+ {
160
+ "_or": [
161
+ { "author_role": { "_null": true } },
162
+ { "author_role": { "_empty": true } },
163
+ { "author_role": { "_regex": "^.{1,120}$" } }
164
+ ]
165
+ }
166
+ ]
167
+ },
168
+ "validation_message": "Author role must be at most 120 characters."
169
+ },
170
+ "schema": { "max_length": 120 }
171
+ },
172
+ {
173
+ "field": "company",
174
+ "type": "string",
175
+ "meta": {
176
+ "interface": "input",
177
+ "width": "half",
178
+ "sort": 6,
179
+ "options": { "trim": true },
180
+ "translations": [
181
+ { "language": "en-US", "translation": "Company" }
182
+ ],
183
+ "note": "Company or organization name (optional)",
184
+ "validation": {
185
+ "_and": [
186
+ {
187
+ "_or": [
188
+ { "company": { "_null": true } },
189
+ { "company": { "_empty": true } },
190
+ { "company": { "_regex": "^.{1,120}$" } }
191
+ ]
192
+ }
193
+ ]
194
+ },
195
+ "validation_message": "Company must be at most 120 characters."
196
+ },
197
+ "schema": { "max_length": 120 }
198
+ },
199
+ {
200
+ "field": "avatar",
201
+ "type": "uuid",
202
+ "meta": {
203
+ "interface": "file-image",
204
+ "special": ["file"],
205
+ "display": "image",
206
+ "width": "half",
207
+ "sort": 7,
208
+ "translations": [
209
+ { "language": "en-US", "translation": "Avatar" }
210
+ ],
211
+ "note": "Photo of the person giving the testimonial (optional)"
212
+ },
213
+ "schema": {}
214
+ },
215
+ {
216
+ "field": "sort",
217
+ "type": "integer",
218
+ "meta": {
219
+ "hidden": true,
220
+ "interface": "input",
221
+ "width": "full",
222
+ "sort": 8,
223
+ "translations": [
224
+ { "language": "en-US", "translation": "Sort" }
225
+ ]
226
+ },
227
+ "schema": {}
228
+ }
229
+ ]
230
+ }
231
+ ],
232
+ "relations": [
233
+ {
234
+ "collection": "testimonials",
235
+ "field": "avatar",
236
+ "related_collection": "directus_files",
237
+ "meta": {
238
+ "many_collection": "testimonials",
239
+ "many_field": "avatar",
240
+ "one_collection": "directus_files",
241
+ "one_field": null
242
+ },
243
+ "schema": {
244
+ "on_delete": "SET NULL"
245
+ }
246
+ }
247
+ ]
248
+ }