@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.
- package/LICENSE +373 -0
- package/README.md +23 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +72 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +36 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +16 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +76 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/context.d.ts +38 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +37 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/pg-url.d.ts +11 -0
- package/dist/lib/pg-url.d.ts.map +1 -0
- package/dist/lib/pg-url.js +22 -0
- package/dist/lib/pg-url.js.map +1 -0
- package/dist/manifest/deps.d.ts +29 -0
- package/dist/manifest/deps.d.ts.map +1 -0
- package/dist/manifest/deps.js +97 -0
- package/dist/manifest/deps.js.map +1 -0
- package/dist/manifest/env.d.ts +18 -0
- package/dist/manifest/env.d.ts.map +1 -0
- package/dist/manifest/env.js +38 -0
- package/dist/manifest/env.js.map +1 -0
- package/dist/phases/db-init.d.ts +3 -0
- package/dist/phases/db-init.d.ts.map +1 -0
- package/dist/phases/db-init.js +163 -0
- package/dist/phases/db-init.js.map +1 -0
- package/dist/phases/db.d.ts +11 -0
- package/dist/phases/db.d.ts.map +1 -0
- package/dist/phases/db.js +93 -0
- package/dist/phases/db.js.map +1 -0
- package/dist/phases/deps.d.ts +3 -0
- package/dist/phases/deps.d.ts.map +1 -0
- package/dist/phases/deps.js +115 -0
- package/dist/phases/deps.js.map +1 -0
- package/dist/phases/env.d.ts +3 -0
- package/dist/phases/env.d.ts.map +1 -0
- package/dist/phases/env.js +172 -0
- package/dist/phases/env.js.map +1 -0
- package/dist/phases/host.d.ts +3 -0
- package/dist/phases/host.d.ts.map +1 -0
- package/dist/phases/host.js +99 -0
- package/dist/phases/host.js.map +1 -0
- package/dist/phases/index.d.ts +7 -0
- package/dist/phases/index.d.ts.map +1 -0
- package/dist/phases/index.js +40 -0
- package/dist/phases/index.js.map +1 -0
- package/dist/phases/preflight.d.ts +4 -0
- package/dist/phases/preflight.d.ts.map +1 -0
- package/dist/phases/preflight.js +81 -0
- package/dist/phases/preflight.js.map +1 -0
- package/dist/phases/routes.d.ts +3 -0
- package/dist/phases/routes.d.ts.map +1 -0
- package/dist/phases/routes.js +145 -0
- package/dist/phases/routes.js.map +1 -0
- package/dist/phases/scaffold.d.ts +3 -0
- package/dist/phases/scaffold.d.ts.map +1 -0
- package/dist/phases/scaffold.js +113 -0
- package/dist/phases/scaffold.js.map +1 -0
- package/dist/phases/stub.d.ts +3 -0
- package/dist/phases/stub.d.ts.map +1 -0
- package/dist/phases/stub.js +25 -0
- package/dist/phases/stub.js.map +1 -0
- package/dist/phases/ui.d.ts +3 -0
- package/dist/phases/ui.d.ts.map +1 -0
- package/dist/phases/ui.js +93 -0
- package/dist/phases/ui.js.map +1 -0
- package/dist/phases/wire/index.d.ts +3 -0
- package/dist/phases/wire/index.d.ts.map +1 -0
- package/dist/phases/wire/index.js +67 -0
- package/dist/phases/wire/index.js.map +1 -0
- package/dist/phases/wire/root-tsx.d.ts +3 -0
- package/dist/phases/wire/root-tsx.d.ts.map +1 -0
- package/dist/phases/wire/root-tsx.js +57 -0
- package/dist/phases/wire/root-tsx.js.map +1 -0
- package/dist/phases/wire/server-ts.d.ts +3 -0
- package/dist/phases/wire/server-ts.d.ts.map +1 -0
- package/dist/phases/wire/server-ts.js +54 -0
- package/dist/phases/wire/server-ts.js.map +1 -0
- package/dist/phases/wire/shared.d.ts +34 -0
- package/dist/phases/wire/shared.d.ts.map +1 -0
- package/dist/phases/wire/shared.js +2 -0
- package/dist/phases/wire/shared.js.map +1 -0
- package/dist/phases/wire/start-ts.d.ts +3 -0
- package/dist/phases/wire/start-ts.d.ts.map +1 -0
- package/dist/phases/wire/start-ts.js +149 -0
- package/dist/phases/wire/start-ts.js.map +1 -0
- package/dist/phases/wire/tsconfig.d.ts +3 -0
- package/dist/phases/wire/tsconfig.d.ts.map +1 -0
- package/dist/phases/wire/tsconfig.js +105 -0
- package/dist/phases/wire/tsconfig.js.map +1 -0
- package/dist/phases/wire/vite-config.d.ts +3 -0
- package/dist/phases/wire/vite-config.d.ts.map +1 -0
- package/dist/phases/wire/vite-config.js +46 -0
- package/dist/phases/wire/vite-config.js.map +1 -0
- package/dist/prompts.d.ts +34 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +49 -0
- package/dist/prompts.js.map +1 -0
- package/dist/runner.d.ts +5 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +91 -0
- package/dist/runner.js.map +1 -0
- package/dist/state.d.ts +18 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +68 -0
- package/dist/state.js.map +1 -0
- package/dist/templates/byline/admin.config.ts +41 -0
- package/dist/templates/byline/i18n.ts +47 -0
- package/dist/templates/byline/routes.ts +28 -0
- package/dist/templates/byline/seed.ts +19 -0
- package/dist/templates/byline/seeds/admin.ts +62 -0
- package/dist/templates/byline/server.config.ts +92 -0
- package/dist/templates/byline-examples/admin.config.ts +74 -0
- package/dist/templates/byline-examples/blocks/photo-block.ts +59 -0
- package/dist/templates/byline-examples/blocks/richtext-block.ts +35 -0
- package/dist/templates/byline-examples/collections/doc-example-flat-locale-all.ts +373 -0
- package/dist/templates/byline-examples/collections/doc-example-flat-locale-en.ts +283 -0
- package/dist/templates/byline-examples/collections/doc-example-tree-locale-all.ts +278 -0
- package/dist/templates/byline-examples/collections/doc-example-tree-locale-en.ts +205 -0
- package/dist/templates/byline-examples/collections/docs/admin.tsx +204 -0
- package/dist/templates/byline-examples/collections/docs/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/docs/components/feature-formatter.tsx +10 -0
- package/dist/templates/byline-examples/collections/docs/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/docs/index.ts +10 -0
- package/dist/templates/byline-examples/collections/docs/schema.ts +209 -0
- package/dist/templates/byline-examples/collections/docs-categories/admin.tsx +78 -0
- package/dist/templates/byline-examples/collections/docs-categories/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/docs-categories/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/docs-categories/index.ts +10 -0
- package/dist/templates/byline-examples/collections/docs-categories/schema.ts +33 -0
- package/dist/templates/byline-examples/collections/media/admin.tsx +188 -0
- package/dist/templates/byline-examples/collections/media/components/media-list-view.tsx +330 -0
- package/dist/templates/byline-examples/collections/media/components/media-thumbnail.tsx +63 -0
- package/dist/templates/byline-examples/collections/media/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/media/index.ts +10 -0
- package/dist/templates/byline-examples/collections/media/schema.ts +157 -0
- package/dist/templates/byline-examples/collections/news/admin.tsx +192 -0
- package/dist/templates/byline-examples/collections/news/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/news/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/news/index.ts +10 -0
- package/dist/templates/byline-examples/collections/news/schema.ts +91 -0
- package/dist/templates/byline-examples/collections/news-categories/admin.tsx +78 -0
- package/dist/templates/byline-examples/collections/news-categories/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/news-categories/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/news-categories/index.ts +10 -0
- package/dist/templates/byline-examples/collections/news-categories/schema.ts +33 -0
- package/dist/templates/byline-examples/collections/pages/admin.tsx +183 -0
- package/dist/templates/byline-examples/collections/pages/components/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/pages/hooks/.gitkeep +0 -0
- package/dist/templates/byline-examples/collections/pages/index.ts +10 -0
- package/dist/templates/byline-examples/collections/pages/schema.ts +96 -0
- package/dist/templates/byline-examples/components/length-indicator.tsx +138 -0
- package/dist/templates/byline-examples/components/pill.tsx +38 -0
- package/dist/templates/byline-examples/components/summary-length.tsx +39 -0
- package/dist/templates/byline-examples/fields/available-languages-field.ts +90 -0
- package/dist/templates/byline-examples/fields/lexical-richtext-compact.ts +88 -0
- package/dist/templates/byline-examples/i18n.ts +47 -0
- package/dist/templates/byline-examples/routes.ts +28 -0
- package/dist/templates/byline-examples/scripts/regenerate-media.ts +275 -0
- package/dist/templates/byline-examples/seed.ts +25 -0
- package/dist/templates/byline-examples/seeds/admin.ts +62 -0
- package/dist/templates/byline-examples/seeds/doc-categories.ts +71 -0
- package/dist/templates/byline-examples/seeds/docs.ts +293 -0
- package/dist/templates/byline-examples/seeds/news-categories.ts +71 -0
- package/dist/templates/byline-examples/server.config.ts +179 -0
- package/dist/templates/host/vite.config.ts +41 -0
- package/dist/templates/migrations/0000_condemned_kronos.sql +324 -0
- package/dist/templates/migrations/0001_sudden_phantom_reporter.sql +1 -0
- package/dist/templates/migrations/meta/0000_snapshot.json +2793 -0
- package/dist/templates/migrations/meta/0001_snapshot.json +2799 -0
- package/dist/templates/migrations/meta/_journal.json +20 -0
- package/dist/templates/routes/(byline)/admin/account/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/$id/api.tsx +16 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/$id/history.tsx +19 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/$id/index.tsx +16 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/create.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/collections/$collection/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/permissions/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/roles/$id/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/roles/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/route.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/users/$id/index.tsx +11 -0
- package/dist/templates/routes/(byline)/admin/users/index.tsx +11 -0
- package/dist/templates/routes/(byline)/sign-in.tsx +11 -0
- package/dist/templates/ui-byline/blocks/photo-block/index.tsx +80 -0
- package/dist/templates/ui-byline/blocks/richtext-block/index.tsx +46 -0
- package/dist/templates/ui-byline/components/admonition/index.tsx +40 -0
- package/dist/templates/ui-byline/components/code/code-serializer.tsx +20 -0
- package/dist/templates/ui-byline/components/code/code.tsx +50 -0
- package/dist/templates/ui-byline/components/code/index.module.scss +137 -0
- package/dist/templates/ui-byline/components/code/index.ts +2 -0
- package/dist/templates/ui-byline/components/code/types.ts +5 -0
- package/dist/templates/ui-byline/components/code/utils.ts +20 -0
- package/dist/templates/ui-byline/components/heading-anchor/heading-anchor.tsx +69 -0
- package/dist/templates/ui-byline/components/heading-anchor/index.ts +1 -0
- package/dist/templates/ui-byline/components/heading-anchor/utils.ts +15 -0
- package/dist/templates/ui-byline/components/inline-image/index.tsx +109 -0
- package/dist/templates/ui-byline/components/layout/index.tsx +63 -0
- package/dist/templates/ui-byline/components/link/lang-link.tsx +70 -0
- package/dist/templates/ui-byline/components/link/link-field.tsx +298 -0
- package/dist/templates/ui-byline/components/link/link-lexical.tsx +191 -0
- package/dist/templates/ui-byline/components/list/index.ts +2 -0
- package/dist/templates/ui-byline/components/list/list-item.tsx +32 -0
- package/dist/templates/ui-byline/components/list/list.tsx +17 -0
- package/dist/templates/ui-byline/components/responsive-image/index.tsx +205 -0
- package/dist/templates/ui-byline/components/richtext-lexical/index.tsx +31 -0
- package/dist/templates/ui-byline/components/richtext-lexical/serialize/index.tsx +249 -0
- package/dist/templates/ui-byline/components/richtext-lexical/serialize/richtext-node-formats.ts +66 -0
- package/dist/templates/ui-byline/components/richtext-lexical/serialize/types.ts +48 -0
- package/dist/templates/ui-byline/components/richtext-lexical/serialize/utils.ts +15 -0
- package/dist/templates/ui-byline/components/table-cell/index.tsx +36 -0
- package/dist/templates/ui-byline/components/vimeo/index.tsx +21 -0
- package/dist/templates/ui-byline/components/youtube/index.tsx +22 -0
- package/dist/templates/ui-byline/render-blocks.tsx +71 -0
- package/dist/templates/ui-byline/types/i18n.ts +14 -0
- package/dist/templates/ui-byline/utils/image-sources.ts +102 -0
- package/dist/templates/ui-byline/utils/to-kebab-case.ts +5 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/diff.d.ts +4 -0
- package/dist/ui/diff.d.ts.map +1 -0
- package/dist/ui/diff.js +23 -0
- package/dist/ui/diff.js.map +1 -0
- package/dist/ui/grid.d.ts +7 -0
- package/dist/ui/grid.d.ts.map +1 -0
- package/dist/ui/grid.js +24 -0
- package/dist/ui/grid.js.map +1 -0
- package/dist/ui/logger.d.ts +14 -0
- package/dist/ui/logger.d.ts.map +1 -0
- package/dist/ui/logger.js +30 -0
- package/dist/ui/logger.js.map +1 -0
- package/dist/ui/snippet.d.ts +2 -0
- package/dist/ui/snippet.d.ts.map +1 -0
- package/dist/ui/snippet.js +7 -0
- package/dist/ui/snippet.js.map +1 -0
- 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
|
+
})
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
+
})
|