@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,120 @@
1
+ import {
2
+ dkitQueryFailed,
3
+ getDirectus,
4
+ readItem,
5
+ readItems,
6
+ } from "@/lib/dkit/client";
7
+ import { collections } from "@/lib/dkit/config";
8
+ import { queryLimit, statusFilter } from "@/lib/dkit/helpers";
9
+ import {
10
+ isUsableTranslation,
11
+ pickTranslation,
12
+ requireLocaleTranslation,
13
+ resolveLocale,
14
+ translationsDeepFilter,
15
+ } from "@/lib/dkit/i18n";
16
+ import type { FaqItem, FaqItemTranslation, GetFaqItemsOptions } from "./types.multilocale";
17
+
18
+ export type { FaqItem, FaqItemTranslation, GetFaqItemsOptions } from "./types.multilocale";
19
+
20
+ function flattenFaqItem(row: Record<string, unknown>, locale: string): FaqItem | null {
21
+ const trans = pickTranslation(
22
+ row.translations as FaqItemTranslation[] | undefined,
23
+ locale,
24
+ );
25
+ if (!isUsableTranslation(trans, ["question", "answer"])) return null;
26
+
27
+ return {
28
+ id: row.id as string,
29
+ status: row.status as FaqItem["status"],
30
+ sort: (row.sort as number | null) ?? null,
31
+ question: trans!.question!,
32
+ answer: trans!.answer!,
33
+ category: trans?.category ?? null,
34
+ };
35
+ }
36
+
37
+ const FAQ_FIELDS = [
38
+ "id",
39
+ "status",
40
+ "sort",
41
+ { translations: ["id", "languages_code", "question", "answer", "category"] },
42
+ ] as const;
43
+
44
+ /** FAQ items, ordered by sort then question. Defaults to status=published. */
45
+ export async function getFaqItems(
46
+ options: GetFaqItemsOptions = {},
47
+ ): Promise<FaqItem[]> {
48
+ const client = getDirectus();
49
+ if (!client) return [];
50
+ if (!collections.faq_items) {
51
+ dkitQueryFailed(
52
+ 'collections.faq_items missing from lib/dkit/config — re-run `dkit add faq`',
53
+ );
54
+ return [];
55
+ }
56
+ const locale = await resolveLocale(options.locale);
57
+ const status = statusFilter(options.status);
58
+ const and: Record<string, unknown>[] = [
59
+ requireLocaleTranslation(locale, ["question", "answer"]),
60
+ ];
61
+ if (status) and.unshift(status);
62
+ if (options.category) {
63
+ and.push({
64
+ translations: {
65
+ _and: [
66
+ { languages_code: { _eq: locale } },
67
+ { category: { _eq: options.category } },
68
+ ],
69
+ },
70
+ });
71
+ }
72
+ const limit = queryLimit(options.limit);
73
+ try {
74
+ const rows = await client.request(
75
+ readItems(collections.faq_items, {
76
+ filter: { _and: and },
77
+ deep: translationsDeepFilter(locale),
78
+ fields: [...FAQ_FIELDS],
79
+ sort: options.sort ?? ["sort"],
80
+ ...(limit !== undefined ? { limit } : {}),
81
+ }),
82
+ );
83
+ return (rows as Record<string, unknown>[])
84
+ .map((r) => flattenFaqItem(r, locale))
85
+ .filter((f): f is FaqItem => f != null);
86
+ } catch (err) {
87
+ dkitQueryFailed(`getFaqItems failed (collection=${collections.faq_items})`, err);
88
+ return [];
89
+ }
90
+ }
91
+
92
+ export async function getFaqItemById(
93
+ id: string,
94
+ options: { locale?: string } = {},
95
+ ): Promise<FaqItem | null> {
96
+ const client = getDirectus();
97
+ if (!client) return null;
98
+ if (!collections.faq_items) return null;
99
+ const locale = await resolveLocale(options.locale);
100
+ try {
101
+ const rows = await client.request(
102
+ readItems(collections.faq_items, {
103
+ filter: {
104
+ _and: [
105
+ { id: { _eq: id } },
106
+ requireLocaleTranslation(locale, ["question", "answer"]),
107
+ ],
108
+ },
109
+ deep: translationsDeepFilter(locale),
110
+ fields: [...FAQ_FIELDS],
111
+ limit: 1,
112
+ }),
113
+ );
114
+ const row = (rows as Record<string, unknown>[])[0];
115
+ return row ? flattenFaqItem(row, locale) : null;
116
+ } catch (err) {
117
+ dkitQueryFailed(`getFaqItemById(${id}) failed`, err);
118
+ return null;
119
+ }
120
+ }
@@ -0,0 +1,73 @@
1
+ import {
2
+ dkitQueryFailed,
3
+ getDirectus,
4
+ readItem,
5
+ readItems,
6
+ } from "@/lib/dkit/client";
7
+ import { collections } from "@/lib/dkit/config";
8
+ import { queryLimit, statusFilter } from "@/lib/dkit/helpers";
9
+ import type { FaqItem, GetFaqItemsOptions } from "./types";
10
+
11
+ export type { FaqItem, GetFaqItemsOptions } from "./types";
12
+
13
+ const FAQ_FIELDS = [
14
+ "id",
15
+ "status",
16
+ "sort",
17
+ "question",
18
+ "answer",
19
+ "category",
20
+ ] as const;
21
+
22
+ /** FAQ items, ordered by sort then question. Defaults to status=published. */
23
+ export async function getFaqItems(
24
+ options: GetFaqItemsOptions = {},
25
+ ): Promise<FaqItem[]> {
26
+ const client = getDirectus();
27
+ if (!client) return [];
28
+ if (!collections.faq_items) {
29
+ dkitQueryFailed(
30
+ 'collections.faq_items missing from lib/dkit/config — re-run `dkit add faq`',
31
+ );
32
+ return [];
33
+ }
34
+ const status = statusFilter(options.status);
35
+ const and: Record<string, unknown>[] = [];
36
+ if (status) and.push(status);
37
+ if (options.category) {
38
+ and.push({ category: { _eq: options.category } });
39
+ }
40
+ const limit = queryLimit(options.limit);
41
+ try {
42
+ return await client.request(
43
+ readItems(collections.faq_items, {
44
+ filter: and.length ? { _and: and } : undefined,
45
+ fields: [...FAQ_FIELDS],
46
+ sort: options.sort ?? ["sort", "question"],
47
+ ...(limit !== undefined ? { limit } : {}),
48
+ }),
49
+ );
50
+ } catch (err) {
51
+ dkitQueryFailed(
52
+ `getFaqItems failed (collection=${collections.faq_items})`,
53
+ err,
54
+ );
55
+ return [];
56
+ }
57
+ }
58
+
59
+ export async function getFaqItemById(id: string): Promise<FaqItem | null> {
60
+ const client = getDirectus();
61
+ if (!client) return null;
62
+ if (!collections.faq_items) return null;
63
+ try {
64
+ return await client.request(
65
+ readItem(collections.faq_items, id, {
66
+ fields: [...FAQ_FIELDS],
67
+ }),
68
+ );
69
+ } catch (err) {
70
+ dkitQueryFailed(`getFaqItemById(${id}) failed`, err);
71
+ return null;
72
+ }
73
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "type": "dkit:module",
3
+ "id": "faq",
4
+ "title": "FAQ",
5
+ "description": "Frequently asked questions for public sites",
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
+ "faq-list"
21
+ ],
22
+ "collections": [
23
+ "help",
24
+ "faq_items"
25
+ ],
26
+ "defaultBasePath": "/faq",
27
+ "multilocale": {
28
+ "supported": true,
29
+ "mode": "translations"
30
+ }
31
+ }
@@ -0,0 +1,180 @@
1
+ {
2
+ "format": "dkit.rest",
3
+ "collections": [
4
+ {
5
+ "collection": "help",
6
+ "schema": null,
7
+ "meta": {
8
+ "icon": "help_outline",
9
+ "color": "#0F766E",
10
+ "collapse": "open",
11
+ "translations": [
12
+ {
13
+ "language": "en-US",
14
+ "translation": "Help",
15
+ "singular": "Help",
16
+ "plural": "Help"
17
+ }
18
+ ],
19
+ "note": "Help and support content — FAQ, knowledge base"
20
+ }
21
+ },
22
+ {
23
+ "collection": "faq_items",
24
+ "schema": {},
25
+ "meta": {
26
+ "icon": "quiz",
27
+ "color": "#0F766E",
28
+ "group": "help",
29
+ "display_template": "{{question}}",
30
+ "archive_field": "status",
31
+ "archive_value": "draft",
32
+ "unarchive_value": "published",
33
+ "archive_app_filter": true,
34
+ "sort_field": "sort",
35
+ "sort": 1,
36
+ "translations": [
37
+ {
38
+ "language": "en-US",
39
+ "translation": "FAQ items",
40
+ "singular": "FAQ item",
41
+ "plural": "FAQ items"
42
+ }
43
+ ],
44
+ "note": "Questions and answers displayed on the public site"
45
+ },
46
+ "fields": [
47
+ {
48
+ "field": "id",
49
+ "type": "uuid",
50
+ "meta": {
51
+ "hidden": true,
52
+ "readonly": true,
53
+ "interface": "input",
54
+ "special": ["uuid"],
55
+ "sort": 1,
56
+ "width": "full",
57
+ "translations": [{ "language": "en-US", "translation": "ID" }]
58
+ },
59
+ "schema": {
60
+ "is_primary_key": true,
61
+ "length": 36,
62
+ "has_auto_increment": false
63
+ }
64
+ },
65
+ {
66
+ "field": "status",
67
+ "type": "string",
68
+ "meta": {
69
+ "interface": "select-dropdown",
70
+ "display": "labels",
71
+ "width": "half",
72
+ "sort": 2,
73
+ "options": {
74
+ "choices": [
75
+ { "text": "Published", "value": "published" },
76
+ { "text": "Draft", "value": "draft" }
77
+ ]
78
+ },
79
+ "display_options": {
80
+ "choices": [
81
+ {
82
+ "text": "Published",
83
+ "value": "published",
84
+ "foreground": "#FFFFFF",
85
+ "background": "#0F766E"
86
+ },
87
+ {
88
+ "text": "Draft",
89
+ "value": "draft",
90
+ "foreground": "#44403C",
91
+ "background": "#E7E5E4"
92
+ }
93
+ ]
94
+ },
95
+ "translations": [{ "language": "en-US", "translation": "Status" }],
96
+ "note": "Only published items 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": "sort",
106
+ "type": "integer",
107
+ "meta": {
108
+ "interface": "input",
109
+ "hidden": true,
110
+ "width": "half",
111
+ "sort": 3,
112
+ "translations": [{ "language": "en-US", "translation": "Sort" }]
113
+ },
114
+ "schema": {}
115
+ },
116
+ {
117
+ "field": "question",
118
+ "type": "string",
119
+ "meta": {
120
+ "interface": "input",
121
+ "required": true,
122
+ "width": "full",
123
+ "sort": 4,
124
+ "options": { "trim": true },
125
+ "translations": [{ "language": "en-US", "translation": "Question" }],
126
+ "validation": {
127
+ "_and": [{ "question": { "_regex": "^.{1,300}$" } }]
128
+ },
129
+ "validation_message": "Question is required (max 300 characters)."
130
+ },
131
+ "schema": { "is_nullable": false, "max_length": 300 }
132
+ },
133
+ {
134
+ "field": "answer",
135
+ "type": "text",
136
+ "meta": {
137
+ "interface": "input-multiline",
138
+ "required": true,
139
+ "width": "full",
140
+ "sort": 5,
141
+ "options": { "trim": true },
142
+ "translations": [{ "language": "en-US", "translation": "Answer" }],
143
+ "note": "Plain-text answer shown in the accordion",
144
+ "validation": {
145
+ "_and": [{ "answer": { "_regex": "^[\\s\\S]{1,5000}$" } }]
146
+ },
147
+ "validation_message": "Answer is required (max 5000 characters)."
148
+ },
149
+ "schema": { "is_nullable": false }
150
+ },
151
+ {
152
+ "field": "category",
153
+ "type": "string",
154
+ "meta": {
155
+ "interface": "input",
156
+ "width": "half",
157
+ "sort": 6,
158
+ "options": { "trim": true },
159
+ "translations": [{ "language": "en-US", "translation": "Category" }],
160
+ "note": "Optional grouping label (e.g. General, Billing)",
161
+ "validation": {
162
+ "_and": [
163
+ {
164
+ "_or": [
165
+ { "category": { "_null": true } },
166
+ { "category": { "_empty": true } },
167
+ { "category": { "_regex": "^.{1,80}$" } }
168
+ ]
169
+ }
170
+ ]
171
+ },
172
+ "validation_message": "Category must be at most 80 characters."
173
+ },
174
+ "schema": { "max_length": 80 }
175
+ }
176
+ ]
177
+ }
178
+ ],
179
+ "relations": []
180
+ }
@@ -0,0 +1,116 @@
1
+ {
2
+ "format": "dkit.rest",
3
+ "collections": [
4
+ {
5
+ "collection": "help",
6
+ "schema": null,
7
+ "meta": {
8
+ "icon": "help_outline", "color": "#0F766E", "collapse": "open",
9
+ "translations": [{ "language": "en-US", "translation": "Help", "singular": "Help", "plural": "Help" }],
10
+ "note": "Help and support content — FAQ, knowledge base"
11
+ }
12
+ },
13
+ {
14
+ "collection": "faq_items",
15
+ "schema": {},
16
+ "meta": {
17
+ "icon": "quiz", "color": "#0F766E", "group": "help",
18
+ "display_template": "{{translations.question}}",
19
+ "archive_field": "status", "archive_value": "draft", "unarchive_value": "published", "archive_app_filter": true,
20
+ "sort_field": "sort", "sort": 1,
21
+ "translations": [{ "language": "en-US", "translation": "FAQ items", "singular": "FAQ item", "plural": "FAQ items" }],
22
+ "note": "Questions and answers displayed on the public site"
23
+ },
24
+ "fields": [
25
+ {
26
+ "field": "id", "type": "uuid",
27
+ "meta": { "hidden": true, "readonly": true, "interface": "input", "special": ["uuid"], "sort": 1, "width": "full", "translations": [{ "language": "en-US", "translation": "ID" }] },
28
+ "schema": { "is_primary_key": true, "length": 36, "has_auto_increment": false }
29
+ },
30
+ {
31
+ "field": "status", "type": "string",
32
+ "meta": {
33
+ "interface": "select-dropdown", "display": "labels", "width": "half", "sort": 2,
34
+ "options": { "choices": [{ "text": "Published", "value": "published" }, { "text": "Draft", "value": "draft" }] },
35
+ "display_options": { "choices": [
36
+ { "text": "Published", "value": "published", "foreground": "#FFFFFF", "background": "#0F766E" },
37
+ { "text": "Draft", "value": "draft", "foreground": "#44403C", "background": "#E7E5E4" }
38
+ ]},
39
+ "translations": [{ "language": "en-US", "translation": "Status" }],
40
+ "note": "Only published items appear on the public site",
41
+ "validation": { "_and": [{ "status": { "_in": ["published", "draft"] } }] },
42
+ "validation_message": "Choose Published or Draft."
43
+ },
44
+ "schema": { "default_value": "draft", "is_nullable": false }
45
+ },
46
+ {
47
+ "field": "sort", "type": "integer",
48
+ "meta": { "interface": "input", "hidden": true, "width": "half", "sort": 3, "translations": [{ "language": "en-US", "translation": "Sort" }] },
49
+ "schema": {}
50
+ },
51
+ {
52
+ "field": "translations", "type": "alias",
53
+ "meta": { "interface": "translations", "special": ["translations"], "width": "full", "sort": 4, "translations": [{ "language": "en-US", "translation": "Translations" }] },
54
+ "schema": null
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ "collection": "faq_items_translations",
60
+ "schema": {},
61
+ "meta": {
62
+ "hidden": true, "icon": "translate", "color": "#0F766E", "group": "help",
63
+ "translations": [{ "language": "en-US", "translation": "FAQ item translations", "singular": "FAQ item translation", "plural": "FAQ item translations" }]
64
+ },
65
+ "fields": [
66
+ { "field": "id", "type": "integer", "meta": { "hidden": true, "interface": "input", "sort": 1, "width": "full", "translations": [{ "language": "en-US", "translation": "ID" }] }, "schema": { "is_primary_key": true, "has_auto_increment": true } },
67
+ { "field": "faq_items_id", "type": "uuid", "meta": { "hidden": true, "sort": 2, "width": "half", "translations": [{ "language": "en-US", "translation": "FAQ item" }] }, "schema": {} },
68
+ { "field": "languages_code", "type": "string", "meta": { "hidden": true, "sort": 3, "width": "half", "translations": [{ "language": "en-US", "translation": "Language" }] }, "schema": {} },
69
+ {
70
+ "field": "question", "type": "string",
71
+ "meta": {
72
+ "interface": "input", "required": true, "width": "full", "sort": 4, "options": { "trim": true },
73
+ "translations": [{ "language": "en-US", "translation": "Question" }],
74
+ "validation": { "_and": [{ "question": { "_regex": "^.{1,300}$" } }] },
75
+ "validation_message": "Question is required (max 300 characters)."
76
+ },
77
+ "schema": { "is_nullable": false, "max_length": 300 }
78
+ },
79
+ {
80
+ "field": "answer", "type": "text",
81
+ "meta": {
82
+ "interface": "input-multiline", "required": true, "width": "full", "sort": 5, "options": { "trim": true },
83
+ "translations": [{ "language": "en-US", "translation": "Answer" }],
84
+ "note": "Plain-text answer shown in the accordion",
85
+ "validation": { "_and": [{ "answer": { "_regex": "^[\\s\\S]{1,5000}$" } }] },
86
+ "validation_message": "Answer is required (max 5000 characters)."
87
+ },
88
+ "schema": { "is_nullable": false }
89
+ },
90
+ {
91
+ "field": "category", "type": "string",
92
+ "meta": {
93
+ "interface": "input", "width": "half", "sort": 6, "options": { "trim": true },
94
+ "translations": [{ "language": "en-US", "translation": "Category" }],
95
+ "note": "Optional grouping label (e.g. General, Billing)",
96
+ "validation": { "_and": [{ "_or": [{ "category": { "_null": true } }, { "category": { "_empty": true } }, { "category": { "_regex": "^.{1,80}$" } }] }] },
97
+ "validation_message": "Category must be at most 80 characters."
98
+ },
99
+ "schema": { "max_length": 80 }
100
+ }
101
+ ]
102
+ }
103
+ ],
104
+ "relations": [
105
+ {
106
+ "collection": "faq_items_translations", "field": "faq_items_id", "related_collection": "faq_items",
107
+ "meta": { "many_collection": "faq_items_translations", "many_field": "faq_items_id", "one_collection": "faq_items", "one_field": "translations", "junction_field": "languages_code" },
108
+ "schema": { "on_delete": "CASCADE" }
109
+ },
110
+ {
111
+ "collection": "faq_items_translations", "field": "languages_code", "related_collection": "languages",
112
+ "meta": { "many_collection": "faq_items_translations", "many_field": "languages_code", "one_collection": "languages", "one_field": null, "junction_field": "faq_items_id" },
113
+ "schema": { "on_delete": "CASCADE" }
114
+ }
115
+ ]
116
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "items": {
3
+ "faq_items": [
4
+ {
5
+ "id": "f1000000-0000-4000-8000-000000000001",
6
+ "status": "published",
7
+ "sort": 1,
8
+ "question": "Sample: How do I request a quote?",
9
+ "answer": "Use the contact or booking form on this site. Include your project type, timeline, and location so we can respond with next steps. Replace this sample answer before launch.",
10
+ "category": "Getting started"
11
+ },
12
+ {
13
+ "id": "f1000000-0000-4000-8000-000000000002",
14
+ "status": "published",
15
+ "sort": 2,
16
+ "question": "Sample: What areas do you serve?",
17
+ "answer": "This sample FAQ item confirms category grouping on the list. Edit or delete it once you have verified the install.",
18
+ "category": "Getting started"
19
+ },
20
+ {
21
+ "id": "f1000000-0000-4000-8000-000000000003",
22
+ "status": "published",
23
+ "sort": 3,
24
+ "question": "Sample: How long does a typical project take?",
25
+ "answer": "Timelines vary by scope. Small renovations may take a few weeks; larger builds can run several months. Use this item to check sort order and accordion layout.",
26
+ "category": "Projects"
27
+ },
28
+ {
29
+ "id": "f1000000-0000-4000-8000-000000000004",
30
+ "status": "published",
31
+ "sort": 4,
32
+ "question": "Sample: Do you offer site visits?",
33
+ "answer": "Yes — site visits can be requested through the booking form. Safe to delete this sample once your own FAQ content is ready.",
34
+ "category": "Projects"
35
+ }
36
+ ]
37
+ }
38
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "items": {
3
+ "faq_items": [
4
+ {
5
+ "id": "f1000000-0000-4000-8000-000000000001",
6
+ "status": "published",
7
+ "sort": 1,
8
+ "translations": [
9
+ {
10
+ "languages_code": "en-US",
11
+ "question": "Sample: What is this FAQ module?",
12
+ "answer": "This is sample seed data from the FAQ module. Use it to verify the accordion component and API, then replace with your own Q&A content.",
13
+ "category": "General"
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ "id": "f1000000-0000-4000-8000-000000000002",
19
+ "status": "published",
20
+ "sort": 2,
21
+ "translations": [
22
+ {
23
+ "languages_code": "en-US",
24
+ "question": "Sample: How do I add more items?",
25
+ "answer": "Open Help → FAQ items in Directus, create a new item, and choose Published. The sort field controls display order.",
26
+ "category": "General"
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ }
32
+ }
@@ -0,0 +1,31 @@
1
+ /* ── Translation row type ── */
2
+
3
+ export type FaqItemTranslation = {
4
+ id: number;
5
+ faq_items_id?: string;
6
+ languages_code?: string | { code?: string };
7
+ question: string;
8
+ answer: string;
9
+ category?: string | null;
10
+ };
11
+
12
+ /* ── Public API type (flat) ── */
13
+
14
+ export type FaqItem = {
15
+ id: string;
16
+ status: "published" | "draft";
17
+ sort?: number | null;
18
+ question: string;
19
+ answer: string;
20
+ category?: string | null;
21
+ };
22
+
23
+ export type GetFaqItemsOptions = {
24
+ /** Directus status filter. Default `"published"`. Pass `null` to skip. */
25
+ status?: string | null;
26
+ limit?: number;
27
+ /** Filter by category label. */
28
+ category?: string;
29
+ sort?: string[];
30
+ locale?: string;
31
+ };
@@ -0,0 +1,17 @@
1
+ export type FaqItem = {
2
+ id: string;
3
+ status: "published" | "draft";
4
+ sort?: number | null;
5
+ question: string;
6
+ answer: string;
7
+ category?: string | null;
8
+ };
9
+
10
+ export type GetFaqItemsOptions = {
11
+ /** Directus status filter. Default `"published"`. Pass `null` to skip. */
12
+ status?: string | null;
13
+ limit?: number;
14
+ /** Filter by category label. */
15
+ category?: string;
16
+ sort?: string[];
17
+ };
@@ -0,0 +1,31 @@
1
+ {
2
+ "policies": [
3
+ {
4
+ "name": "dkit Navigation Public Read",
5
+ "icon": "public",
6
+ "description": "Public read for nav menus and items (flat rules — Core-compatible). UI filters published status.",
7
+ "admin_access": false,
8
+ "app_access": false
9
+ }
10
+ ],
11
+ "permissions": [
12
+ {
13
+ "policy": "dkit Navigation Public Read",
14
+ "collection": "nav_menus",
15
+ "action": "read",
16
+ "fields": ["*"]
17
+ },
18
+ {
19
+ "policy": "dkit Navigation Public Read",
20
+ "collection": "nav_items",
21
+ "action": "read",
22
+ "fields": ["*"]
23
+ }
24
+ ],
25
+ "access": [
26
+ {
27
+ "role": "$public",
28
+ "policy": "dkit Navigation Public Read"
29
+ }
30
+ ]
31
+ }