@byline/cli 2.1.2 → 2.2.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 (34) hide show
  1. package/dist/manifest/deps.d.ts +5 -7
  2. package/dist/manifest/deps.d.ts.map +1 -1
  3. package/dist/manifest/deps.js +46 -8
  4. package/dist/manifest/deps.js.map +1 -1
  5. package/dist/templates/byline/i18n.ts +1 -1
  6. package/dist/templates/byline-examples/admin.config.ts +12 -0
  7. package/dist/templates/byline-examples/collections/media/components/media-list-view.module.css +1 -1
  8. package/dist/templates/byline-examples/collections/news/admin.tsx +7 -2
  9. package/dist/templates/byline-examples/collections/pages/admin.tsx +2 -1
  10. package/dist/templates/byline-examples/fields/ai-text.ts +47 -0
  11. package/dist/templates/byline-examples/fields/ai-textarea.ts +50 -0
  12. package/dist/templates/byline-examples/fields/ai-widgets/ai-field-label.tsx +48 -0
  13. package/dist/templates/byline-examples/fields/ai-widgets/ai-field-panel.tsx +42 -0
  14. package/dist/templates/byline-examples/fields/ai-widgets/ai-panel-store.ts +52 -0
  15. package/dist/templates/byline-examples/fields/lexical-richtext-ai.tsx +82 -0
  16. package/dist/templates/byline-examples/fields/lexical-richtext-compact.ts +8 -4
  17. package/dist/templates/byline-examples/i18n.ts +1 -1
  18. package/dist/templates/byline-examples/plugins/ai/ai-plugin-text.tsx +58 -0
  19. package/dist/templates/byline-examples/scripts/import-docs.ts +272 -0
  20. package/dist/templates/byline-examples/scripts/lib/frontmatter.ts +136 -0
  21. package/dist/templates/byline-examples/scripts/lib/mdast-to-lexical.ts +497 -0
  22. package/dist/templates/byline-examples/scripts/lib/strip-leading-h1.ts +31 -0
  23. package/dist/templates/host/vite.config.ts +33 -25
  24. package/dist/templates/migrations/{0000_slimy_lilandra.sql → 0000_cold_red_wolf.sql} +40 -34
  25. package/dist/templates/migrations/meta/0000_snapshot.json +100 -68
  26. package/dist/templates/migrations/meta/_journal.json +2 -2
  27. package/package.json +1 -1
  28. package/dist/templates/byline-examples/collections/docs/components/feature-formatter.tsx +0 -10
  29. package/dist/templates/byline-examples/collections/docs-categories/admin.tsx +0 -78
  30. package/dist/templates/byline-examples/collections/docs-categories/components/.gitkeep +0 -0
  31. package/dist/templates/byline-examples/collections/docs-categories/hooks/.gitkeep +0 -0
  32. package/dist/templates/byline-examples/collections/docs-categories/index.ts +0 -10
  33. package/dist/templates/byline-examples/collections/docs-categories/schema.ts +0 -33
  34. package/dist/templates/byline-examples/seeds/doc-categories.ts +0 -71
@@ -1,78 +0,0 @@
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'
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
- })
@@ -1,10 +0,0 @@
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'
@@ -1,33 +0,0 @@
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>
@@ -1,71 +0,0 @@
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 { getCollectionDefinition, getDefaultStatus, getServerConfig, slugify } from '@byline/core'
10
-
11
- const categories = [
12
- {
13
- name: { en: 'Whitepaper' },
14
- description: { en: 'In-depth articles and research papers.' },
15
- },
16
- {
17
- name: { en: 'Tutorial' },
18
- description: { en: 'Step-by-step guides and how-tos.' },
19
- },
20
- {
21
- name: { en: 'Framework' },
22
- description: { en: 'Libraries, frameworks, and toolkits.' },
23
- },
24
- ]
25
-
26
- export async function seedDocsCategories() {
27
- const db = getServerConfig().db
28
-
29
- const collectionDefinition = getCollectionDefinition('docs-categories')
30
-
31
- if (!collectionDefinition) {
32
- console.error('Collection definition not found for "docs-categories"')
33
- return
34
- }
35
-
36
- // `initBylineCore` already registered the collection row via
37
- // `ensureCollections()` when byline/server.config was imported, so we
38
- // look the row up rather than re-inserting (which would violate the
39
- // unique-path constraint).
40
- const existing = await db.queries.collections.getCollectionByPath('docs-categories')
41
- if (!existing) {
42
- throw new Error(
43
- "seedDocsCategories: expected the 'docs-categories' collection to be registered by initBylineCore()"
44
- )
45
- }
46
-
47
- const categoriesCollection = {
48
- id: existing.id as string,
49
- name: existing.path as string,
50
- version: (existing.version as number | undefined) ?? 1,
51
- }
52
-
53
- console.log(`Seeding into Docs Categories collection (${categoriesCollection.name})`)
54
-
55
- for (const category of categories) {
56
- const seedPath = slugify(category.name.en, {
57
- locale: 'en',
58
- collectionPath: 'docs-categories',
59
- })
60
- await db.commands.documents.createDocumentVersion({
61
- collectionId: categoriesCollection.id,
62
- collectionVersion: categoriesCollection.version,
63
- collectionConfig: collectionDefinition,
64
- action: 'create',
65
- documentData: category,
66
- path: seedPath,
67
- status: getDefaultStatus(collectionDefinition),
68
- })
69
- console.log(` - seeded category: ${category.name.en} (${seedPath})`)
70
- }
71
- }