@byline/cli 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +23 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +72 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/doctor.d.ts +2 -0
  8. package/dist/commands/doctor.d.ts.map +1 -0
  9. package/dist/commands/doctor.js +36 -0
  10. package/dist/commands/doctor.js.map +1 -0
  11. package/dist/commands/init.d.ts +16 -0
  12. package/dist/commands/init.d.ts.map +1 -0
  13. package/dist/commands/init.js +76 -0
  14. package/dist/commands/init.js.map +1 -0
  15. package/dist/context.d.ts +38 -0
  16. package/dist/context.d.ts.map +1 -0
  17. package/dist/context.js +37 -0
  18. package/dist/context.js.map +1 -0
  19. package/dist/index.d.ts +5 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +4 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/lib/pg-url.d.ts +11 -0
  24. package/dist/lib/pg-url.d.ts.map +1 -0
  25. package/dist/lib/pg-url.js +22 -0
  26. package/dist/lib/pg-url.js.map +1 -0
  27. package/dist/manifest/deps.d.ts +29 -0
  28. package/dist/manifest/deps.d.ts.map +1 -0
  29. package/dist/manifest/deps.js +97 -0
  30. package/dist/manifest/deps.js.map +1 -0
  31. package/dist/manifest/env.d.ts +18 -0
  32. package/dist/manifest/env.d.ts.map +1 -0
  33. package/dist/manifest/env.js +38 -0
  34. package/dist/manifest/env.js.map +1 -0
  35. package/dist/phases/db-init.d.ts +3 -0
  36. package/dist/phases/db-init.d.ts.map +1 -0
  37. package/dist/phases/db-init.js +163 -0
  38. package/dist/phases/db-init.js.map +1 -0
  39. package/dist/phases/db.d.ts +11 -0
  40. package/dist/phases/db.d.ts.map +1 -0
  41. package/dist/phases/db.js +93 -0
  42. package/dist/phases/db.js.map +1 -0
  43. package/dist/phases/deps.d.ts +3 -0
  44. package/dist/phases/deps.d.ts.map +1 -0
  45. package/dist/phases/deps.js +115 -0
  46. package/dist/phases/deps.js.map +1 -0
  47. package/dist/phases/env.d.ts +3 -0
  48. package/dist/phases/env.d.ts.map +1 -0
  49. package/dist/phases/env.js +172 -0
  50. package/dist/phases/env.js.map +1 -0
  51. package/dist/phases/host.d.ts +3 -0
  52. package/dist/phases/host.d.ts.map +1 -0
  53. package/dist/phases/host.js +99 -0
  54. package/dist/phases/host.js.map +1 -0
  55. package/dist/phases/index.d.ts +7 -0
  56. package/dist/phases/index.d.ts.map +1 -0
  57. package/dist/phases/index.js +40 -0
  58. package/dist/phases/index.js.map +1 -0
  59. package/dist/phases/preflight.d.ts +4 -0
  60. package/dist/phases/preflight.d.ts.map +1 -0
  61. package/dist/phases/preflight.js +81 -0
  62. package/dist/phases/preflight.js.map +1 -0
  63. package/dist/phases/routes.d.ts +3 -0
  64. package/dist/phases/routes.d.ts.map +1 -0
  65. package/dist/phases/routes.js +145 -0
  66. package/dist/phases/routes.js.map +1 -0
  67. package/dist/phases/scaffold.d.ts +3 -0
  68. package/dist/phases/scaffold.d.ts.map +1 -0
  69. package/dist/phases/scaffold.js +113 -0
  70. package/dist/phases/scaffold.js.map +1 -0
  71. package/dist/phases/stub.d.ts +3 -0
  72. package/dist/phases/stub.d.ts.map +1 -0
  73. package/dist/phases/stub.js +25 -0
  74. package/dist/phases/stub.js.map +1 -0
  75. package/dist/phases/ui.d.ts +3 -0
  76. package/dist/phases/ui.d.ts.map +1 -0
  77. package/dist/phases/ui.js +93 -0
  78. package/dist/phases/ui.js.map +1 -0
  79. package/dist/phases/wire/index.d.ts +3 -0
  80. package/dist/phases/wire/index.d.ts.map +1 -0
  81. package/dist/phases/wire/index.js +67 -0
  82. package/dist/phases/wire/index.js.map +1 -0
  83. package/dist/phases/wire/root-tsx.d.ts +3 -0
  84. package/dist/phases/wire/root-tsx.d.ts.map +1 -0
  85. package/dist/phases/wire/root-tsx.js +57 -0
  86. package/dist/phases/wire/root-tsx.js.map +1 -0
  87. package/dist/phases/wire/server-ts.d.ts +3 -0
  88. package/dist/phases/wire/server-ts.d.ts.map +1 -0
  89. package/dist/phases/wire/server-ts.js +54 -0
  90. package/dist/phases/wire/server-ts.js.map +1 -0
  91. package/dist/phases/wire/shared.d.ts +34 -0
  92. package/dist/phases/wire/shared.d.ts.map +1 -0
  93. package/dist/phases/wire/shared.js +2 -0
  94. package/dist/phases/wire/shared.js.map +1 -0
  95. package/dist/phases/wire/start-ts.d.ts +3 -0
  96. package/dist/phases/wire/start-ts.d.ts.map +1 -0
  97. package/dist/phases/wire/start-ts.js +149 -0
  98. package/dist/phases/wire/start-ts.js.map +1 -0
  99. package/dist/phases/wire/tsconfig.d.ts +3 -0
  100. package/dist/phases/wire/tsconfig.d.ts.map +1 -0
  101. package/dist/phases/wire/tsconfig.js +105 -0
  102. package/dist/phases/wire/tsconfig.js.map +1 -0
  103. package/dist/phases/wire/vite-config.d.ts +3 -0
  104. package/dist/phases/wire/vite-config.d.ts.map +1 -0
  105. package/dist/phases/wire/vite-config.js +46 -0
  106. package/dist/phases/wire/vite-config.js.map +1 -0
  107. package/dist/prompts.d.ts +34 -0
  108. package/dist/prompts.d.ts.map +1 -0
  109. package/dist/prompts.js +49 -0
  110. package/dist/prompts.js.map +1 -0
  111. package/dist/runner.d.ts +5 -0
  112. package/dist/runner.d.ts.map +1 -0
  113. package/dist/runner.js +91 -0
  114. package/dist/runner.js.map +1 -0
  115. package/dist/state.d.ts +18 -0
  116. package/dist/state.d.ts.map +1 -0
  117. package/dist/state.js +68 -0
  118. package/dist/state.js.map +1 -0
  119. package/dist/templates/byline/admin.config.ts +41 -0
  120. package/dist/templates/byline/i18n.ts +47 -0
  121. package/dist/templates/byline/routes.ts +28 -0
  122. package/dist/templates/byline/seed.ts +19 -0
  123. package/dist/templates/byline/seeds/admin.ts +62 -0
  124. package/dist/templates/byline/server.config.ts +92 -0
  125. package/dist/templates/byline-examples/admin.config.ts +74 -0
  126. package/dist/templates/byline-examples/blocks/photo-block.ts +59 -0
  127. package/dist/templates/byline-examples/blocks/richtext-block.ts +35 -0
  128. package/dist/templates/byline-examples/collections/doc-example-flat-locale-all.ts +373 -0
  129. package/dist/templates/byline-examples/collections/doc-example-flat-locale-en.ts +283 -0
  130. package/dist/templates/byline-examples/collections/doc-example-tree-locale-all.ts +278 -0
  131. package/dist/templates/byline-examples/collections/doc-example-tree-locale-en.ts +205 -0
  132. package/dist/templates/byline-examples/collections/docs/admin.tsx +204 -0
  133. package/dist/templates/byline-examples/collections/docs/components/.gitkeep +0 -0
  134. package/dist/templates/byline-examples/collections/docs/components/feature-formatter.tsx +10 -0
  135. package/dist/templates/byline-examples/collections/docs/hooks/.gitkeep +0 -0
  136. package/dist/templates/byline-examples/collections/docs/index.ts +10 -0
  137. package/dist/templates/byline-examples/collections/docs/schema.ts +209 -0
  138. package/dist/templates/byline-examples/collections/docs-categories/admin.tsx +78 -0
  139. package/dist/templates/byline-examples/collections/docs-categories/components/.gitkeep +0 -0
  140. package/dist/templates/byline-examples/collections/docs-categories/hooks/.gitkeep +0 -0
  141. package/dist/templates/byline-examples/collections/docs-categories/index.ts +10 -0
  142. package/dist/templates/byline-examples/collections/docs-categories/schema.ts +33 -0
  143. package/dist/templates/byline-examples/collections/media/admin.tsx +188 -0
  144. package/dist/templates/byline-examples/collections/media/components/media-list-view.tsx +330 -0
  145. package/dist/templates/byline-examples/collections/media/components/media-thumbnail.tsx +63 -0
  146. package/dist/templates/byline-examples/collections/media/hooks/.gitkeep +0 -0
  147. package/dist/templates/byline-examples/collections/media/index.ts +10 -0
  148. package/dist/templates/byline-examples/collections/media/schema.ts +157 -0
  149. package/dist/templates/byline-examples/collections/news/admin.tsx +192 -0
  150. package/dist/templates/byline-examples/collections/news/components/.gitkeep +0 -0
  151. package/dist/templates/byline-examples/collections/news/hooks/.gitkeep +0 -0
  152. package/dist/templates/byline-examples/collections/news/index.ts +10 -0
  153. package/dist/templates/byline-examples/collections/news/schema.ts +91 -0
  154. package/dist/templates/byline-examples/collections/news-categories/admin.tsx +78 -0
  155. package/dist/templates/byline-examples/collections/news-categories/components/.gitkeep +0 -0
  156. package/dist/templates/byline-examples/collections/news-categories/hooks/.gitkeep +0 -0
  157. package/dist/templates/byline-examples/collections/news-categories/index.ts +10 -0
  158. package/dist/templates/byline-examples/collections/news-categories/schema.ts +33 -0
  159. package/dist/templates/byline-examples/collections/pages/admin.tsx +183 -0
  160. package/dist/templates/byline-examples/collections/pages/components/.gitkeep +0 -0
  161. package/dist/templates/byline-examples/collections/pages/hooks/.gitkeep +0 -0
  162. package/dist/templates/byline-examples/collections/pages/index.ts +10 -0
  163. package/dist/templates/byline-examples/collections/pages/schema.ts +96 -0
  164. package/dist/templates/byline-examples/components/length-indicator.tsx +138 -0
  165. package/dist/templates/byline-examples/components/pill.tsx +38 -0
  166. package/dist/templates/byline-examples/components/summary-length.tsx +39 -0
  167. package/dist/templates/byline-examples/fields/available-languages-field.ts +90 -0
  168. package/dist/templates/byline-examples/fields/lexical-richtext-compact.ts +88 -0
  169. package/dist/templates/byline-examples/i18n.ts +47 -0
  170. package/dist/templates/byline-examples/routes.ts +28 -0
  171. package/dist/templates/byline-examples/scripts/regenerate-media.ts +275 -0
  172. package/dist/templates/byline-examples/seed.ts +25 -0
  173. package/dist/templates/byline-examples/seeds/admin.ts +62 -0
  174. package/dist/templates/byline-examples/seeds/doc-categories.ts +71 -0
  175. package/dist/templates/byline-examples/seeds/docs.ts +293 -0
  176. package/dist/templates/byline-examples/seeds/news-categories.ts +71 -0
  177. package/dist/templates/byline-examples/server.config.ts +179 -0
  178. package/dist/templates/host/vite.config.ts +41 -0
  179. package/dist/templates/migrations/0000_condemned_kronos.sql +324 -0
  180. package/dist/templates/migrations/0001_sudden_phantom_reporter.sql +1 -0
  181. package/dist/templates/migrations/meta/0000_snapshot.json +2793 -0
  182. package/dist/templates/migrations/meta/0001_snapshot.json +2799 -0
  183. package/dist/templates/migrations/meta/_journal.json +20 -0
  184. package/dist/templates/routes/(byline)/admin/account/index.tsx +11 -0
  185. package/dist/templates/routes/(byline)/admin/collections/$collection/$id/api.tsx +16 -0
  186. package/dist/templates/routes/(byline)/admin/collections/$collection/$id/history.tsx +19 -0
  187. package/dist/templates/routes/(byline)/admin/collections/$collection/$id/index.tsx +16 -0
  188. package/dist/templates/routes/(byline)/admin/collections/$collection/create.tsx +11 -0
  189. package/dist/templates/routes/(byline)/admin/collections/$collection/index.tsx +11 -0
  190. package/dist/templates/routes/(byline)/admin/index.tsx +11 -0
  191. package/dist/templates/routes/(byline)/admin/permissions/index.tsx +11 -0
  192. package/dist/templates/routes/(byline)/admin/roles/$id/index.tsx +11 -0
  193. package/dist/templates/routes/(byline)/admin/roles/index.tsx +11 -0
  194. package/dist/templates/routes/(byline)/admin/route.tsx +11 -0
  195. package/dist/templates/routes/(byline)/admin/users/$id/index.tsx +11 -0
  196. package/dist/templates/routes/(byline)/admin/users/index.tsx +11 -0
  197. package/dist/templates/routes/(byline)/sign-in.tsx +11 -0
  198. package/dist/templates/ui-byline/blocks/photo-block/index.tsx +80 -0
  199. package/dist/templates/ui-byline/blocks/richtext-block/index.tsx +46 -0
  200. package/dist/templates/ui-byline/components/admonition/index.tsx +40 -0
  201. package/dist/templates/ui-byline/components/code/code-serializer.tsx +20 -0
  202. package/dist/templates/ui-byline/components/code/code.tsx +50 -0
  203. package/dist/templates/ui-byline/components/code/index.module.scss +137 -0
  204. package/dist/templates/ui-byline/components/code/index.ts +2 -0
  205. package/dist/templates/ui-byline/components/code/types.ts +5 -0
  206. package/dist/templates/ui-byline/components/code/utils.ts +20 -0
  207. package/dist/templates/ui-byline/components/heading-anchor/heading-anchor.tsx +69 -0
  208. package/dist/templates/ui-byline/components/heading-anchor/index.ts +1 -0
  209. package/dist/templates/ui-byline/components/heading-anchor/utils.ts +15 -0
  210. package/dist/templates/ui-byline/components/inline-image/index.tsx +109 -0
  211. package/dist/templates/ui-byline/components/layout/index.tsx +63 -0
  212. package/dist/templates/ui-byline/components/link/lang-link.tsx +70 -0
  213. package/dist/templates/ui-byline/components/link/link-field.tsx +298 -0
  214. package/dist/templates/ui-byline/components/link/link-lexical.tsx +191 -0
  215. package/dist/templates/ui-byline/components/list/index.ts +2 -0
  216. package/dist/templates/ui-byline/components/list/list-item.tsx +32 -0
  217. package/dist/templates/ui-byline/components/list/list.tsx +17 -0
  218. package/dist/templates/ui-byline/components/responsive-image/index.tsx +205 -0
  219. package/dist/templates/ui-byline/components/richtext-lexical/index.tsx +31 -0
  220. package/dist/templates/ui-byline/components/richtext-lexical/serialize/index.tsx +249 -0
  221. package/dist/templates/ui-byline/components/richtext-lexical/serialize/richtext-node-formats.ts +66 -0
  222. package/dist/templates/ui-byline/components/richtext-lexical/serialize/types.ts +48 -0
  223. package/dist/templates/ui-byline/components/richtext-lexical/serialize/utils.ts +15 -0
  224. package/dist/templates/ui-byline/components/table-cell/index.tsx +36 -0
  225. package/dist/templates/ui-byline/components/vimeo/index.tsx +21 -0
  226. package/dist/templates/ui-byline/components/youtube/index.tsx +22 -0
  227. package/dist/templates/ui-byline/render-blocks.tsx +71 -0
  228. package/dist/templates/ui-byline/types/i18n.ts +14 -0
  229. package/dist/templates/ui-byline/utils/image-sources.ts +102 -0
  230. package/dist/templates/ui-byline/utils/to-kebab-case.ts +5 -0
  231. package/dist/types.d.ts +54 -0
  232. package/dist/types.d.ts.map +1 -0
  233. package/dist/types.js +2 -0
  234. package/dist/types.js.map +1 -0
  235. package/dist/ui/diff.d.ts +4 -0
  236. package/dist/ui/diff.d.ts.map +1 -0
  237. package/dist/ui/diff.js +23 -0
  238. package/dist/ui/diff.js.map +1 -0
  239. package/dist/ui/grid.d.ts +7 -0
  240. package/dist/ui/grid.d.ts.map +1 -0
  241. package/dist/ui/grid.js +24 -0
  242. package/dist/ui/grid.js.map +1 -0
  243. package/dist/ui/logger.d.ts +14 -0
  244. package/dist/ui/logger.d.ts.map +1 -0
  245. package/dist/ui/logger.js +30 -0
  246. package/dist/ui/logger.js.map +1 -0
  247. package/dist/ui/snippet.d.ts +2 -0
  248. package/dist/ui/snippet.d.ts.map +1 -0
  249. package/dist/ui/snippet.js +7 -0
  250. package/dist/ui/snippet.js.map +1 -0
  251. package/package.json +69 -0
@@ -0,0 +1,209 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+
9
+ import type { CollectionFieldData } from '@byline/core'
10
+ import { defineCollection, defineWorkflow } from '@byline/core'
11
+
12
+ import { PhotoBlock } from '../../blocks/photo-block.js'
13
+ import { RichTextBlock } from '../../blocks/richtext-block.js'
14
+ import { availableLanguagesField } from '../../fields/available-languages-field.js'
15
+
16
+ // ---- Schema (server-safe, no UI concerns) ----
17
+
18
+ export const Docs = defineCollection({
19
+ path: 'docs',
20
+ labels: {
21
+ singular: 'Document',
22
+ plural: 'Documents',
23
+ },
24
+ // Workflow: defineWorkflow() guarantees draft, published, and archived are
25
+ // always present and correctly ordered. Any additional statuses specified in
26
+ // customStatuses are inserted between draft and published.
27
+ //
28
+ // Resulting order: [draft, needs_review, published, archived]
29
+ workflow: defineWorkflow({
30
+ draft: { label: 'Draft', verb: 'Revert to Draft' },
31
+ published: { label: 'Published', verb: 'Publish' },
32
+ archived: { label: 'Archived', verb: 'Archive' },
33
+ customStatuses: [{ name: 'needs_review', label: 'Needs Review', verb: 'Request Review' }],
34
+ }),
35
+ showStats: true,
36
+ search: { fields: ['title'] },
37
+ useAsTitle: 'title',
38
+ useAsPath: 'title',
39
+ linksInEditor: true, // See type definition for details.
40
+ // All hooks can be a single function or an array of functions.
41
+ // If an array is provided, the functions will be executed in sequence.
42
+ hooks: {
43
+ beforeCreate: async ({ data, collectionPath }) => {
44
+ // Example: beforeCreate hook
45
+ console.log(
46
+ `beforeCreate: Creating a new document in collection ${collectionPath} with data:`,
47
+ data
48
+ )
49
+ },
50
+ afterCreate: async ({ data, collectionPath, documentId, documentVersionId }) => {
51
+ // Example: log the creation of a new document.
52
+ console.log(
53
+ `afterCreate: Document created with ID ${documentId} and version ID ${documentVersionId} in collection ${collectionPath}`
54
+ )
55
+ },
56
+ beforeUpdate: async ({ data, originalData, collectionPath }) => {
57
+ // Example: prevent a document from being published if it doesn't have a title.
58
+ console.log(
59
+ `beforeUpdate: Updating a document in collection ${collectionPath} with data:`,
60
+ data
61
+ )
62
+ },
63
+ afterUpdate: async ({ data, originalData, collectionPath, documentId, documentVersionId }) => {
64
+ // Example: log the update of a document.
65
+ console.log(
66
+ `afterUpdate: Document with ID ${documentId} and version ID ${documentVersionId} in collection ${collectionPath} was updated`
67
+ )
68
+ },
69
+ beforeStatusChange: async ({
70
+ documentId,
71
+ documentVersionId,
72
+ collectionPath,
73
+ previousStatus,
74
+ nextStatus,
75
+ }) => {
76
+ console.log(
77
+ `beforeStatusChange: Changing status of document in collection ${collectionPath} from ${previousStatus} to ${nextStatus} with document ID ${documentId} and version ID ${documentVersionId}`
78
+ )
79
+ },
80
+ afterStatusChange: async ({
81
+ documentId,
82
+ documentVersionId,
83
+ collectionPath,
84
+ previousStatus,
85
+ nextStatus,
86
+ }) => {
87
+ console.log(
88
+ `afterStatusChange: Status of document in collection ${collectionPath} changed from ${previousStatus} to ${nextStatus} with document ID ${documentId} and version ID ${documentVersionId}`
89
+ )
90
+ },
91
+ beforeUnpublish: async ({ documentId, collectionPath }) => {
92
+ console.log(
93
+ `beforeUnpublish: Unpublishing document in collection ${collectionPath} with document ID ${documentId}.`
94
+ )
95
+ },
96
+ afterUnpublish: async ({ documentId, collectionPath }) => {
97
+ console.log(
98
+ `afterUnpublish: Document in collection ${collectionPath} with document ID ${documentId} unpublished.`
99
+ )
100
+ },
101
+ beforeDelete: async ({ documentId, collectionPath }) => {
102
+ console.log(
103
+ `beforeDelete: Deleting document in collection ${collectionPath} with document ID ${documentId}.`
104
+ )
105
+ },
106
+ afterDelete: async ({ documentId, collectionPath }) => {
107
+ console.log(
108
+ `afterDelete: Document in collection ${collectionPath} with document ID ${documentId} deleted.`
109
+ )
110
+ },
111
+ },
112
+ fields: [
113
+ {
114
+ name: 'title',
115
+ label: 'Title',
116
+ type: 'text',
117
+ localized: true,
118
+ hooks: {
119
+ // Advisory: flag leading whitespace without altering the value.
120
+ beforeValidate: ({ value }) => {
121
+ if (typeof value === 'string' && value !== value.trimStart()) {
122
+ return { error: 'Title should not start with whitespace' }
123
+ }
124
+ },
125
+ },
126
+ },
127
+ {
128
+ name: 'summary',
129
+ label: 'Summary',
130
+ type: 'textArea',
131
+ localized: true,
132
+ helpText:
133
+ 'Enter a short summary. The first 150 characters are used for social media meta descriptions. Aim for 100–300 characters.',
134
+ },
135
+ // Relation field demo. Points at the Media upload collection
136
+ // so editors can choose a feature image via the relation picker widget.
137
+ // Set `displayField: 'title'` so the picker's row label reads from the
138
+ // uploaded item's `title` field rather than falling back to its path.
139
+ // Will display the picker defined columns if present in the admin.tsx
140
+ // configuration.
141
+ {
142
+ name: 'featureImage',
143
+ label: 'Feature Image',
144
+ type: 'relation',
145
+ targetCollection: 'media',
146
+ displayField: 'title',
147
+ optional: true,
148
+ },
149
+ {
150
+ name: 'publishedOn',
151
+ label: 'Published On',
152
+ type: 'datetime',
153
+ mode: 'datetime',
154
+ },
155
+ {
156
+ name: 'category',
157
+ label: 'Category',
158
+ type: 'relation',
159
+ targetCollection: 'docs-categories',
160
+ displayField: 'name',
161
+ },
162
+ {
163
+ name: 'featured',
164
+ label: 'Featured',
165
+ type: 'checkbox',
166
+ optional: true,
167
+ helpText: 'Feature this document.',
168
+ },
169
+ {
170
+ name: 'content',
171
+ label: 'Content',
172
+ type: 'blocks',
173
+ optional: true,
174
+ blocks: [RichTextBlock, PhotoBlock],
175
+ },
176
+ {
177
+ name: 'reviews',
178
+ label: 'Reviews',
179
+ type: 'array',
180
+ optional: true,
181
+ fields: [
182
+ {
183
+ name: 'reviewItem',
184
+ label: 'Review Item',
185
+ type: 'group',
186
+ fields: [
187
+ { name: 'rating', label: 'Rating', type: 'integer' },
188
+ {
189
+ name: 'comment',
190
+ label: 'Comments',
191
+ type: 'richText',
192
+ localized: false,
193
+ },
194
+ ],
195
+ },
196
+ ],
197
+ },
198
+ {
199
+ name: 'links',
200
+ label: 'Links',
201
+ type: 'array',
202
+ optional: true,
203
+ fields: [{ name: 'link', label: 'Link', type: 'text' }],
204
+ },
205
+ availableLanguagesField(),
206
+ ],
207
+ })
208
+
209
+ export type DocFields = CollectionFieldData<typeof Docs>
@@ -0,0 +1,78 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+
9
+ import { type CollectionAdminConfig, type ColumnDefinition, defineAdmin } from '@byline/core'
10
+ import { DateTimeFormatter } from '@byline/ui/react/fields'
11
+
12
+ import { DocsCategories } from './schema.js'
13
+
14
+ // ---- Admin UI config (client-only, presentation concerns) ----
15
+
16
+ /**
17
+ * Column definitions for the default table-based list view.
18
+ *
19
+ * These are passed to the built-in `ListView` component and control which
20
+ * fields appear as columns, their labels, sort behaviour, and formatters.
21
+ *
22
+ * Note: when a custom `listView` component is registered on the
23
+ * `CollectionAdminConfig`, it receives the raw paginated data directly and
24
+ * is responsible for its own layout. These column definitions can still
25
+ * be used in a custom list view, but they are not automatically applied
26
+ * as they are with the default table-based `ListView`. You can import
27
+ * them if needed - for example if you wanted to create a toggled grid/table
28
+ * custom view.
29
+ */
30
+
31
+ const listViewColumns: ColumnDefinition[] = [
32
+ {
33
+ fieldName: 'name',
34
+ label: 'Name',
35
+ sortable: true,
36
+ align: 'left',
37
+ className: 'w-[25%]',
38
+ },
39
+ {
40
+ fieldName: 'status',
41
+ label: 'Status',
42
+ align: 'center',
43
+ className: 'w-[15%]',
44
+ },
45
+ {
46
+ fieldName: 'updatedAt',
47
+ label: 'Last Updated',
48
+ sortable: true,
49
+ align: 'right',
50
+ className: 'w-[20%]',
51
+ formatter: { component: DateTimeFormatter },
52
+ },
53
+ ]
54
+
55
+ /**
56
+ * Columns rendered per row when Media appears as the target of a relation
57
+ * picker (e.g. News → `heroImage` → Media). Narrower than the list view —
58
+ * just enough to identify the right media item at a glance.
59
+ */
60
+ const pickerViewColumns: ColumnDefinition[] = [
61
+ {
62
+ fieldName: 'name',
63
+ label: 'Name',
64
+ align: 'left',
65
+ className: 'flex-1',
66
+ },
67
+ {
68
+ fieldName: 'status',
69
+ label: 'Status',
70
+ align: 'right',
71
+ className: 'w-[80px] shrink-0 text-xs text-gray-500',
72
+ },
73
+ ]
74
+
75
+ export const DocsCategoriesAdmin: CollectionAdminConfig = defineAdmin(DocsCategories, {
76
+ columns: listViewColumns,
77
+ picker: pickerViewColumns,
78
+ })
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+
9
+ export { DocsCategoriesAdmin } from './admin.js'
10
+ export { DocsCategories } from './schema.js'
@@ -0,0 +1,33 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+
9
+ import type { CollectionFieldData } from '@byline/core'
10
+ import { defineCollection, SINGLE_STATUS_WORKFLOW } from '@byline/core'
11
+
12
+ // ---- Schema (server-safe, no UI concerns) ----
13
+
14
+ export const DocsCategories = defineCollection({
15
+ path: 'docs-categories',
16
+ labels: {
17
+ singular: 'Document Category',
18
+ plural: 'Document Categories',
19
+ },
20
+ // Lookup collection — no editorial lifecycle. Saves go straight to
21
+ // `published` and the form shows only Save / Close.
22
+ workflow: SINGLE_STATUS_WORKFLOW,
23
+ showStats: true,
24
+ search: { fields: ['name'] },
25
+ useAsTitle: 'name',
26
+ useAsPath: 'name',
27
+ fields: [
28
+ { name: 'name', label: 'Name', type: 'text', localized: true },
29
+ { name: 'description', label: 'Description', type: 'textArea', localized: true },
30
+ ],
31
+ })
32
+
33
+ export type DocsCategoryFields = CollectionFieldData<typeof DocsCategories>
@@ -0,0 +1,188 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+
9
+ import { type CollectionAdminConfig, type ColumnDefinition, defineAdmin } from '@byline/core'
10
+ import { DateTimeFormatter } from '@byline/ui/react/fields'
11
+
12
+ import { MediaListView } from './components/media-list-view.js'
13
+ import { MediaThumbnail } from './components/media-thumbnail.js'
14
+ import { Media } from './schema.js'
15
+
16
+ /**
17
+ * Column definitions for the default table-based list view.
18
+ *
19
+ * These are passed to the built-in `ListView` component and control which
20
+ * fields appear as columns, their labels, sort behaviour, and formatters.
21
+ *
22
+ * Note: when a custom `listView` component is registered on the
23
+ * `CollectionAdminConfig`, it receives the raw paginated data directly and
24
+ * is responsible for its own layout. These column definitions can still
25
+ * be used in a custom list view, but they are not automatically applied
26
+ * as they are with the default table-based `ListView`. You can import
27
+ * them if needed - for example if you wanted to create a toggled grid/table
28
+ * custom view.
29
+ */
30
+ const listViewColumns: ColumnDefinition[] = [
31
+ {
32
+ fieldName: 'image' as keyof any,
33
+ label: 'Preview',
34
+ align: 'left',
35
+ className: 'w-[5%]',
36
+ formatter: { component: MediaThumbnail },
37
+ },
38
+ {
39
+ fieldName: 'title',
40
+ label: 'Title',
41
+ sortable: true,
42
+ align: 'left',
43
+ className: 'w-[60%]',
44
+ },
45
+ {
46
+ fieldName: 'status',
47
+ label: 'Status',
48
+ align: 'center',
49
+ className: 'w-[15%]',
50
+ },
51
+ {
52
+ fieldName: 'updatedAt',
53
+ label: 'Last Updated',
54
+ sortable: true,
55
+ align: 'right',
56
+ className: 'w-[20%]',
57
+ formatter: { component: DateTimeFormatter },
58
+ },
59
+ ]
60
+
61
+ /**
62
+ * Columns rendered per row when Media appears as the target of a relation
63
+ * picker (e.g. News → `heroImage` → Media). Narrower than the list view —
64
+ * just enough to identify the right media item at a glance.
65
+ */
66
+ const pickerViewColumns: ColumnDefinition[] = [
67
+ {
68
+ fieldName: 'image' as keyof any,
69
+ label: 'Preview',
70
+ align: 'left',
71
+ className: 'w-[72px] shrink-0',
72
+ formatter: { component: MediaThumbnail },
73
+ },
74
+ {
75
+ fieldName: 'title',
76
+ label: 'Title',
77
+ align: 'left',
78
+ className: 'flex-1',
79
+ },
80
+ {
81
+ fieldName: 'status',
82
+ label: 'Status',
83
+ align: 'right',
84
+ className: 'w-[80px] shrink-0 text-xs text-gray-500',
85
+ },
86
+ ]
87
+
88
+ export const MediaAdmin: CollectionAdminConfig = defineAdmin(Media, {
89
+ /**
90
+ * Column definitions for the default table-based list view.
91
+ * Controls which fields appear as columns, their labels, sort behaviour, and formatters.
92
+ */
93
+ columns: listViewColumns,
94
+
95
+ /**
96
+ * Column definitions used when this collection appears as the target of a relation
97
+ * picker modal (opened from a `relation` field widget). Omit to fall back to a
98
+ * single-line render of `useAsTitle` + `path`.
99
+ *
100
+ * Shape matches `ColumnDefinition` so formatters can be reused across list and picker.
101
+ */
102
+ picker: pickerViewColumns,
103
+
104
+ /**
105
+ * Custom list-view component that completely replaces the default table-based `ListView`
106
+ * on the collection index route. Receives a `ListViewComponentProps` object and is
107
+ * responsible for rendering search, ordering, results, and pagination itself.
108
+ */
109
+ listView: MediaListView,
110
+
111
+ /**
112
+ * Group name for organising this collection in the admin sidebar navigation.
113
+ *
114
+ * @example
115
+ * group: 'Assets',
116
+ */
117
+ // group: undefined,
118
+
119
+ /**
120
+ * Per-field rendering overrides, keyed by field name. Use to supply custom
121
+ * UI component slots for a specific field without affecting placement.
122
+ * Placement is controlled exclusively through the layout primitives below.
123
+ *
124
+ * @example
125
+ * fields: { title: { components: { Input: MyCustomInput } } }
126
+ */
127
+ // fields: {},
128
+
129
+ /**
130
+ * Preview URL builder for live preview links. Receives the document and an
131
+ * optional locale and should return a fully-qualified URL string.
132
+ *
133
+ * @example
134
+ * preview: (doc, { locale }) => `https://example.com/media/${doc.fields.path}`
135
+ */
136
+ // preview: undefined,
137
+
138
+ // ---------------------------------------------------------------------------
139
+ // UI Layout
140
+ //
141
+ // Tab, row, and group containers control how fields are grouped and positioned
142
+ // in the document edit view. Field names must match those defined in the
143
+ // collection schema. Names for tabSets, rows, and groups must be unique and
144
+ // must not collide with any schema field name (a startup error is thrown if
145
+ // they do).
146
+ // ---------------------------------------------------------------------------
147
+
148
+ /**
149
+ * Named tab sets. Each entry creates a separate tabbed interface in the edit
150
+ * view. You can define more than one tab set, though a single set is sufficient
151
+ * for most collections. Tab sets may only appear in `layout.main`.
152
+ *
153
+ * Each tab's `fields` array accepts schema field names, row names, and group names.
154
+ * An optional `condition` function can show/hide a tab based on live form data.
155
+ */
156
+ // tabSets: [],
157
+
158
+ /**
159
+ * Named horizontal-row layouts. Fields listed inside a row are rendered
160
+ * side-by-side (flex row) on desktop and stack vertically below the `sm`
161
+ * breakpoint. Rows are leaf containers — they accept only schema field names.
162
+ *
163
+ * Reference a row by its `name` inside a tab's `fields`, a group's `fields`,
164
+ * or directly in `layout.main` / `layout.sidebar`.
165
+ */
166
+ // rows: [],
167
+
168
+ /**
169
+ * Named labelled-fieldset clusters. Groups accept schema field names and row
170
+ * names (not tabSets or nested groups). An optional `label` renders a heading
171
+ * above the cluster.
172
+ *
173
+ * Reference a group by its `name` inside a tab's `fields` or directly in
174
+ * `layout.main` / `layout.sidebar`.
175
+ */
176
+ // groups: [],
177
+
178
+ /**
179
+ * Composition of all layout primitives into the form's two render regions.
180
+ *
181
+ * - `main` — accepts tabSet names, group names, row names, and schema field names.
182
+ * - `sidebar` — accepts group names, row names, and schema field names (no tabSets).
183
+ *
184
+ * When omitted entirely, the renderer synthesises a default that places every
185
+ * schema field in `main` in declaration order.
186
+ */
187
+ // layout: { main: [], sidebar: [] },
188
+ })