@byline/cli 3.21.0 → 4.1.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 (183) hide show
  1. package/README.md +29 -3
  2. package/dist/cli.js +5 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/doctor.d.ts.map +1 -1
  5. package/dist/commands/doctor.js +1 -0
  6. package/dist/commands/doctor.js.map +1 -1
  7. package/dist/commands/init.d.ts +3 -0
  8. package/dist/commands/init.d.ts.map +1 -1
  9. package/dist/commands/init.js +10 -14
  10. package/dist/commands/init.js.map +1 -1
  11. package/dist/commands/setup-checks.d.ts +9 -0
  12. package/dist/commands/setup-checks.d.ts.map +1 -1
  13. package/dist/commands/setup-checks.js +43 -18
  14. package/dist/commands/setup-checks.js.map +1 -1
  15. package/dist/commands/setup.js +1 -1
  16. package/dist/commands/setup.js.map +1 -1
  17. package/dist/context.d.ts +2 -0
  18. package/dist/context.d.ts.map +1 -1
  19. package/dist/context.js +6 -0
  20. package/dist/context.js.map +1 -1
  21. package/dist/lib/dependency-version.d.ts +12 -0
  22. package/dist/lib/dependency-version.d.ts.map +1 -0
  23. package/dist/lib/dependency-version.js +101 -0
  24. package/dist/lib/dependency-version.js.map +1 -0
  25. package/dist/lib/planned-writes.d.ts +8 -0
  26. package/dist/lib/planned-writes.d.ts.map +1 -0
  27. package/dist/lib/planned-writes.js +177 -0
  28. package/dist/lib/planned-writes.js.map +1 -0
  29. package/dist/lib/planned-writes.test.d.ts +2 -0
  30. package/dist/lib/planned-writes.test.d.ts.map +1 -0
  31. package/dist/lib/planned-writes.test.js +113 -0
  32. package/dist/lib/planned-writes.test.js.map +1 -0
  33. package/dist/lib/release-policy.d.ts +12 -0
  34. package/dist/lib/release-policy.d.ts.map +1 -0
  35. package/dist/lib/release-policy.js +20 -0
  36. package/dist/lib/release-policy.js.map +1 -0
  37. package/dist/lib/release-policy.test.d.ts +2 -0
  38. package/dist/lib/release-policy.test.d.ts.map +1 -0
  39. package/dist/lib/release-policy.test.js +36 -0
  40. package/dist/lib/release-policy.test.js.map +1 -0
  41. package/dist/lib/route-config.d.ts +40 -0
  42. package/dist/lib/route-config.d.ts.map +1 -0
  43. package/dist/lib/route-config.js +322 -0
  44. package/dist/lib/route-config.js.map +1 -0
  45. package/dist/lib/static-config.d.ts +20 -0
  46. package/dist/lib/static-config.d.ts.map +1 -0
  47. package/dist/lib/static-config.js +444 -0
  48. package/dist/lib/static-config.js.map +1 -0
  49. package/dist/lib/static-config.test.d.ts +2 -0
  50. package/dist/lib/static-config.test.d.ts.map +1 -0
  51. package/dist/lib/static-config.test.js +105 -0
  52. package/dist/lib/static-config.test.js.map +1 -0
  53. package/dist/lib/template-hook-boundary.test.node.d.ts +2 -0
  54. package/dist/lib/template-hook-boundary.test.node.d.ts.map +1 -0
  55. package/dist/lib/template-hook-boundary.test.node.js +30 -0
  56. package/dist/lib/template-hook-boundary.test.node.js.map +1 -0
  57. package/dist/lib/template-path.d.ts +5 -0
  58. package/dist/lib/template-path.d.ts.map +1 -0
  59. package/dist/lib/template-path.js +9 -0
  60. package/dist/lib/template-path.js.map +1 -0
  61. package/dist/lib/workspace-root.d.ts +28 -0
  62. package/dist/lib/workspace-root.d.ts.map +1 -0
  63. package/dist/lib/workspace-root.js +205 -0
  64. package/dist/lib/workspace-root.js.map +1 -0
  65. package/dist/manifest/deps.d.ts +1 -1
  66. package/dist/manifest/deps.d.ts.map +1 -1
  67. package/dist/manifest/deps.js +24 -8
  68. package/dist/manifest/deps.js.map +1 -1
  69. package/dist/phases/deps.d.ts +14 -1
  70. package/dist/phases/deps.d.ts.map +1 -1
  71. package/dist/phases/deps.js +312 -137
  72. package/dist/phases/deps.js.map +1 -1
  73. package/dist/phases/deps.test.d.ts +2 -0
  74. package/dist/phases/deps.test.d.ts.map +1 -0
  75. package/dist/phases/deps.test.js +343 -0
  76. package/dist/phases/deps.test.js.map +1 -0
  77. package/dist/phases/preflight.d.ts.map +1 -1
  78. package/dist/phases/preflight.js +59 -11
  79. package/dist/phases/preflight.js.map +1 -1
  80. package/dist/phases/prompts.d.ts +2 -0
  81. package/dist/phases/prompts.d.ts.map +1 -1
  82. package/dist/phases/prompts.js +51 -2
  83. package/dist/phases/prompts.js.map +1 -1
  84. package/dist/phases/routes-ui.test.d.ts +2 -0
  85. package/dist/phases/routes-ui.test.d.ts.map +1 -0
  86. package/dist/phases/routes-ui.test.js +766 -0
  87. package/dist/phases/routes-ui.test.js.map +1 -0
  88. package/dist/phases/routes.d.ts +4 -1
  89. package/dist/phases/routes.d.ts.map +1 -1
  90. package/dist/phases/routes.js +610 -122
  91. package/dist/phases/routes.js.map +1 -1
  92. package/dist/phases/scaffold-smoke.test.d.ts +2 -0
  93. package/dist/phases/scaffold-smoke.test.d.ts.map +1 -0
  94. package/dist/phases/scaffold-smoke.test.js +175 -0
  95. package/dist/phases/scaffold-smoke.test.js.map +1 -0
  96. package/dist/phases/scaffold.d.ts +3 -2
  97. package/dist/phases/scaffold.d.ts.map +1 -1
  98. package/dist/phases/scaffold.js +268 -91
  99. package/dist/phases/scaffold.js.map +1 -1
  100. package/dist/phases/scaffold.test.js +171 -22
  101. package/dist/phases/scaffold.test.js.map +1 -1
  102. package/dist/phases/ui.d.ts +4 -1
  103. package/dist/phases/ui.d.ts.map +1 -1
  104. package/dist/phases/ui.js +51 -59
  105. package/dist/phases/ui.js.map +1 -1
  106. package/dist/phases/wire/index.d.ts.map +1 -1
  107. package/dist/phases/wire/index.js +10 -6
  108. package/dist/phases/wire/index.js.map +1 -1
  109. package/dist/phases/wire/shared.d.ts +4 -1
  110. package/dist/phases/wire/shared.d.ts.map +1 -1
  111. package/dist/phases/wire/vite-config.d.ts.map +1 -1
  112. package/dist/phases/wire/vite-config.js +69 -20
  113. package/dist/phases/wire/vite-config.js.map +1 -1
  114. package/dist/phases/wire/vite-config.test.d.ts +2 -0
  115. package/dist/phases/wire/vite-config.test.d.ts.map +1 -0
  116. package/dist/phases/wire/vite-config.test.js +97 -0
  117. package/dist/phases/wire/vite-config.test.js.map +1 -0
  118. package/dist/prompts.d.ts +1 -0
  119. package/dist/prompts.d.ts.map +1 -1
  120. package/dist/prompts.js +7 -2
  121. package/dist/prompts.js.map +1 -1
  122. package/dist/runner.js +1 -1
  123. package/dist/runner.js.map +1 -1
  124. package/dist/templates/byline/collection-types.contract.ts +26 -1
  125. package/dist/templates/byline/collections/index.ts +1 -1
  126. package/dist/templates/byline/collections/server-hooks.ts +7 -0
  127. package/dist/templates/byline/generated/collection-types.ts +14 -6
  128. package/dist/templates/byline/routes.ts +7 -6
  129. package/dist/templates/byline/server.config.ts +10 -1
  130. package/dist/templates/byline-examples/admin.config.ts +7 -12
  131. package/dist/templates/byline-examples/blocks/photo-block.ts +3 -2
  132. package/dist/templates/byline-examples/collection-types.contract.ts +26 -1
  133. package/dist/templates/byline-examples/collections/docs/hooks.ts +23 -13
  134. package/dist/templates/byline-examples/collections/docs/schema.ts +2 -11
  135. package/dist/templates/byline-examples/collections/index.ts +1 -1
  136. package/dist/templates/byline-examples/collections/media/components/media-list-view.tsx +11 -6
  137. package/dist/templates/byline-examples/collections/media/schema.ts +3 -0
  138. package/dist/templates/byline-examples/collections/news/schema.ts +4 -3
  139. package/dist/templates/byline-examples/collections/server-hooks.ts +8 -0
  140. package/dist/templates/byline-examples/fields/ai-text.ts +1 -1
  141. package/dist/templates/byline-examples/fields/ai-textarea.ts +1 -1
  142. package/dist/templates/byline-examples/fields/lexical-richtext-ai.tsx +3 -3
  143. package/dist/templates/byline-examples/generated/collection-types.ts +138 -130
  144. package/dist/templates/byline-examples/routes.ts +7 -6
  145. package/dist/templates/byline-examples/scripts/backfill-version-locales.ts +1 -1
  146. package/dist/templates/byline-examples/scripts/import-docs.ts +10 -11
  147. package/dist/templates/byline-examples/scripts/lib/mdast-to-lexical.test.node.ts +93 -233
  148. package/dist/templates/byline-examples/scripts/lib/mdast-to-lexical.ts +2 -2
  149. package/dist/templates/byline-examples/scripts/lib/strip-leading-h1.test.node.ts +0 -4
  150. package/dist/templates/byline-examples/scripts/re-anchor.ts +3 -3
  151. package/dist/templates/byline-examples/scripts/regenerate-media-operation.ts +112 -0
  152. package/dist/templates/byline-examples/scripts/regenerate-media.ts +129 -92
  153. package/dist/templates/byline-examples/server.config.ts +14 -6
  154. package/dist/templates/host/vite.config.ts +2 -0
  155. package/dist/templates/routes/_byline/route.lazy.tsx +1 -2
  156. package/dist/templates/routes/_byline/route.tsx +1 -1
  157. package/dist/templates/ui-byline/blocks/photo-block/index.tsx +18 -22
  158. package/dist/templates/ui-byline/blocks/richtext-block/index.tsx +1 -1
  159. package/dist/templates/ui-byline/components/admonition/index.tsx +11 -8
  160. package/dist/templates/ui-byline/components/code/code.tsx +6 -4
  161. package/dist/templates/ui-byline/components/link/lang-link.tsx +4 -8
  162. package/dist/templates/ui-byline/components/link/link-field.tsx +3 -2
  163. package/dist/templates/ui-byline/components/link/link-lexical.tsx +9 -8
  164. package/dist/templates/ui-byline/render-blocks.tsx +38 -34
  165. package/dist/templates/ui-byline/types/content.ts +25 -0
  166. package/dist/templates/ui-byline/types/i18n.ts +4 -8
  167. package/dist/test-helpers.d.ts +5 -0
  168. package/dist/test-helpers.d.ts.map +1 -0
  169. package/dist/test-helpers.js +52 -0
  170. package/dist/test-helpers.js.map +1 -0
  171. package/dist/types.d.ts +21 -1
  172. package/dist/types.d.ts.map +1 -1
  173. package/dist/ui-template-contract.test.d.ts +2 -0
  174. package/dist/ui-template-contract.test.d.ts.map +1 -0
  175. package/dist/ui-template-contract.test.js +150 -0
  176. package/dist/ui-template-contract.test.js.map +1 -0
  177. package/dist/workspace-root.test.d.ts +2 -0
  178. package/dist/workspace-root.test.d.ts.map +1 -0
  179. package/dist/workspace-root.test.js +311 -0
  180. package/dist/workspace-root.test.js.map +1 -0
  181. package/package.json +9 -1
  182. package/dist/templates/byline/client.server.ts +0 -32
  183. package/dist/templates/byline-examples/client.server.ts +0 -32
@@ -1,6 +1,6 @@
1
1
  // Generated by @byline/core/codegen
2
- // Format version: 1
3
- // Hash: a32bba417302b4e2c90703e47a1f326d4db64cabd11194f8eed816e78442178e
2
+ // Format version: 2
3
+ // Hash: 7c42f9892f94559081c07b01952f1149e7c4cc112569bbed5861c0a32d735448
4
4
 
5
5
  import type {
6
6
  JsonValue,
@@ -8,132 +8,140 @@ import type {
8
8
  StoredFileValue,
9
9
  } from '@byline/core'
10
10
 
11
- export type PhotoBlockData = {
12
- _id: string
13
- _type: 'photoBlock'
14
- display?: 'default' | 'wide' | 'full_width' | undefined
15
- photo?: RelatedDocumentValue | undefined
16
- alt: string
17
- caption?: JsonValue | undefined
11
+ declare module '@byline/generated-types' {
12
+ export type PhotoBlockData = {
13
+ _id: string
14
+ _type: 'photoBlock'
15
+ display?: 'default' | 'wide' | 'full_width' | undefined
16
+ photo?: RelatedDocumentValue | undefined
17
+ alt: string
18
+ caption?: JsonValue | undefined
19
+ }
20
+
21
+ export type PhotoBlockDataAllLocales = {
22
+ _id: string
23
+ _type: 'photoBlock'
24
+ display?: 'default' | 'wide' | 'full_width' | undefined
25
+ photo?: RelatedDocumentValue | undefined
26
+ alt: string
27
+ caption?: { [locale: string]: JsonValue } | undefined
28
+ }
29
+
30
+ export type RichTextBlockData = {
31
+ _id: string
32
+ _type: 'richTextBlock'
33
+ richText: JsonValue
34
+ constrainedWidth?: boolean | undefined
35
+ }
36
+
37
+ export type RichTextBlockDataAllLocales = {
38
+ _id: string
39
+ _type: 'richTextBlock'
40
+ richText: { [locale: string]: JsonValue }
41
+ constrainedWidth?: boolean | undefined
42
+ }
43
+
44
+ export type DocsFields = {
45
+ title: string
46
+ summary: string
47
+ featureImage?: RelatedDocumentValue | undefined
48
+ publishedOn: Date
49
+ content?: Array<RichTextBlockData | PhotoBlockData> | undefined
50
+ }
51
+
52
+ export type DocsFieldsAllLocales = {
53
+ title: { [locale: string]: string }
54
+ summary: { [locale: string]: string }
55
+ featureImage?: RelatedDocumentValue | undefined
56
+ publishedOn: Date
57
+ content?: Array<RichTextBlockDataAllLocales | PhotoBlockDataAllLocales> | undefined
58
+ }
59
+
60
+ export type MediaFields = {
61
+ image: StoredFileValue
62
+ title: string
63
+ altText: string
64
+ caption?: string | undefined
65
+ credit?: string | undefined
66
+ }
67
+
68
+ export type MediaFieldsAllLocales = {
69
+ image: StoredFileValue
70
+ title: string
71
+ altText: string
72
+ caption?: string | undefined
73
+ credit?: string | undefined
74
+ }
75
+
76
+ export type NewsCategoriesFields = {
77
+ name: string
78
+ description: string
79
+ }
80
+
81
+ export type NewsCategoriesFieldsAllLocales = {
82
+ name: { [locale: string]: string }
83
+ description: { [locale: string]: string }
84
+ }
85
+
86
+ export type NewsFields = {
87
+ title: string
88
+ summary: string
89
+ category: RelatedDocumentValue
90
+ featureImage?: RelatedDocumentValue | undefined
91
+ featured?: boolean | undefined
92
+ content: JsonValue
93
+ publishedOn: Date
94
+ }
95
+
96
+ export type NewsFieldsAllLocales = {
97
+ title: { [locale: string]: string }
98
+ summary: { [locale: string]: string }
99
+ category: RelatedDocumentValue
100
+ featureImage?: RelatedDocumentValue | undefined
101
+ featured?: boolean | undefined
102
+ content: { [locale: string]: JsonValue }
103
+ publishedOn: Date
104
+ }
105
+
106
+ export type PagesFields = {
107
+ title: string
108
+ summary: string
109
+ featureImage?: RelatedDocumentValue | undefined
110
+ area: 'root' | 'about' | 'legal'
111
+ content?: Array<RichTextBlockData | PhotoBlockData> | undefined
112
+ publishedOn: Date
113
+ }
114
+
115
+ export type PagesFieldsAllLocales = {
116
+ title: { [locale: string]: string }
117
+ summary: { [locale: string]: string }
118
+ featureImage?: RelatedDocumentValue | undefined
119
+ area: 'root' | 'about' | 'legal'
120
+ content?: Array<RichTextBlockDataAllLocales | PhotoBlockDataAllLocales> | undefined
121
+ publishedOn: Date
122
+ }
123
+
124
+ export type CollectionFieldsByPath = {
125
+ docs: DocsFields
126
+ media: MediaFields
127
+ news: NewsFields
128
+ 'news-categories': NewsCategoriesFields
129
+ pages: PagesFields
130
+ }
131
+
132
+ export type CollectionFieldsAllLocalesByPath = {
133
+ docs: DocsFieldsAllLocales
134
+ media: MediaFieldsAllLocales
135
+ news: NewsFieldsAllLocales
136
+ 'news-categories': NewsCategoriesFieldsAllLocales
137
+ pages: PagesFieldsAllLocales
138
+ }
139
+
140
+ export type CollectionPath = keyof CollectionFieldsByPath
141
+ }
142
+
143
+ declare module '@byline/client' {
144
+ interface Register {
145
+ collections: import('@byline/generated-types').CollectionFieldsByPath
146
+ }
18
147
  }
19
-
20
- export type PhotoBlockDataAllLocales = {
21
- _id: string
22
- _type: 'photoBlock'
23
- display?: 'default' | 'wide' | 'full_width' | undefined
24
- photo?: RelatedDocumentValue | undefined
25
- alt: string
26
- caption?: { [locale: string]: JsonValue } | undefined
27
- }
28
-
29
- export type RichTextBlockData = {
30
- _id: string
31
- _type: 'richTextBlock'
32
- richText: JsonValue
33
- constrainedWidth?: boolean | undefined
34
- }
35
-
36
- export type RichTextBlockDataAllLocales = {
37
- _id: string
38
- _type: 'richTextBlock'
39
- richText: { [locale: string]: JsonValue }
40
- constrainedWidth?: boolean | undefined
41
- }
42
-
43
- export type DocsFields = {
44
- title: string
45
- summary: string
46
- featureImage?: RelatedDocumentValue | undefined
47
- publishedOn: Date
48
- content?: Array<RichTextBlockData | PhotoBlockData> | undefined
49
- }
50
-
51
- export type DocsFieldsAllLocales = {
52
- title: { [locale: string]: string }
53
- summary: { [locale: string]: string }
54
- featureImage?: RelatedDocumentValue | undefined
55
- publishedOn: Date
56
- content?: Array<RichTextBlockDataAllLocales | PhotoBlockDataAllLocales> | undefined
57
- }
58
-
59
- export type MediaFields = {
60
- image: StoredFileValue
61
- title: string
62
- altText: string
63
- caption?: string | undefined
64
- credit?: string | undefined
65
- }
66
-
67
- export type MediaFieldsAllLocales = {
68
- image: StoredFileValue
69
- title: string
70
- altText: string
71
- caption?: string | undefined
72
- credit?: string | undefined
73
- }
74
-
75
- export type NewsCategoriesFields = {
76
- name: string
77
- description: string
78
- }
79
-
80
- export type NewsCategoriesFieldsAllLocales = {
81
- name: { [locale: string]: string }
82
- description: { [locale: string]: string }
83
- }
84
-
85
- export type NewsFields = {
86
- title: string
87
- summary: string
88
- category: RelatedDocumentValue
89
- featureImage?: RelatedDocumentValue | undefined
90
- featured?: boolean | undefined
91
- content: JsonValue
92
- publishedOn: Date
93
- }
94
-
95
- export type NewsFieldsAllLocales = {
96
- title: { [locale: string]: string }
97
- summary: { [locale: string]: string }
98
- category: RelatedDocumentValue
99
- featureImage?: RelatedDocumentValue | undefined
100
- featured?: boolean | undefined
101
- content: { [locale: string]: JsonValue }
102
- publishedOn: Date
103
- }
104
-
105
- export type PagesFields = {
106
- title: string
107
- summary: string
108
- featureImage?: RelatedDocumentValue | undefined
109
- area: 'root' | 'about' | 'legal'
110
- content?: Array<RichTextBlockData | PhotoBlockData> | undefined
111
- publishedOn: Date
112
- }
113
-
114
- export type PagesFieldsAllLocales = {
115
- title: { [locale: string]: string }
116
- summary: { [locale: string]: string }
117
- featureImage?: RelatedDocumentValue | undefined
118
- area: 'root' | 'about' | 'legal'
119
- content?: Array<RichTextBlockDataAllLocales | PhotoBlockDataAllLocales> | undefined
120
- publishedOn: Date
121
- }
122
-
123
- export type CollectionFieldsByPath = {
124
- docs: DocsFields
125
- media: MediaFields
126
- news: NewsFields
127
- 'news-categories': NewsCategoriesFields
128
- pages: PagesFields
129
- }
130
-
131
- export type CollectionFieldsAllLocalesByPath = {
132
- docs: DocsFieldsAllLocales
133
- media: MediaFieldsAllLocales
134
- news: NewsFieldsAllLocales
135
- 'news-categories': NewsCategoriesFieldsAllLocales
136
- pages: PagesFieldsAllLocales
137
- }
138
-
139
- export type CollectionPath = keyof CollectionFieldsByPath
@@ -7,17 +7,18 @@
7
7
  */
8
8
 
9
9
  /**
10
- * URL segments for admin and (future) public API routes. Defaults of
11
- * `/admin` and `/api` are applied automatically by `resolveRoutes()` —
12
- * keys only need to be set here when overriding either default.
10
+ * Client-safe URL paths for admin, sign-in, and the future public API.
11
+ * Resolve once at this client-safe configuration boundary so consumers only
12
+ * read canonical paths.
13
13
  */
14
14
 
15
- import type { RoutesConfig } from '@byline/core'
15
+ import { resolveRoutes } from '@byline/core'
16
16
 
17
- export const routes: Partial<RoutesConfig> = {
17
+ export const routes = resolveRoutes({
18
18
  admin: '/admin',
19
19
  api: '/api',
20
- }
20
+ signIn: '/sign-in',
21
+ })
21
22
 
22
23
  /**
23
24
  * Fallback used by both server and admin entry points when no
@@ -16,7 +16,7 @@
16
16
  * Idempotent — safe to re-run. Uses the installation's configured default
17
17
  * content locale (resolved from byline/i18n.ts via the server config).
18
18
  *
19
- * cd apps/webapp && pnpm tsx byline/scripts/backfill-version-locales.ts
19
+ * pnpm tsx byline/scripts/backfill-version-locales.ts
20
20
  *
21
21
  * See docs/07-internationalization/index.md.
22
22
  */
@@ -12,11 +12,6 @@
12
12
  // pnpm tsx byline/scripts/import-docs.ts ../../docs/**/*.md --verbose
13
13
  // pnpm tsx byline/scripts/import-docs.ts '../../docs/*.md' --dry-run --verbose
14
14
  // pnpm tsx byline/scripts/import-docs.ts ../../docs/**/*.md
15
- //
16
- // Run tests...
17
- //
18
- // pnpm vitest run --mode=node byline/scripts/lib/
19
-
20
15
  /**
21
16
  * Import markdown files into the `docs` collection.
22
17
  *
@@ -59,7 +54,7 @@ import { glob } from 'node:fs/promises'
59
54
  import { basename, dirname, join, resolve } from 'node:path'
60
55
 
61
56
  import { createSuperAdminContext } from '@byline/auth'
62
- import { type CollectionHandle, createBylineClient } from '@byline/client'
57
+ import { type BylineClient, type CollectionHandle, createBylineClient } from '@byline/client'
63
58
  import { getCollectionDefinition, getServerConfig, slugify } from '@byline/core'
64
59
 
65
60
  import { type DocFrontmatter, parseDocFile } from './lib/frontmatter.js'
@@ -67,12 +62,16 @@ import { type MdastToLexicalWarning, mdastToLexical } from './lib/mdast-to-lexic
67
62
  import { parseBodyToMdast } from './lib/parse-markdown.js'
68
63
  import { type DocLinkRewriteWarning, rewriteDocLinks } from './lib/rewrite-doc-links.js'
69
64
  import { stripLeadingH1IfMatches } from './lib/strip-leading-h1.js'
65
+ import type { DocsFields } from '@byline/generated-types'
70
66
 
71
67
  const DOCS_COLLECTION = 'docs'
72
68
  const MEDIA_COLLECTION = 'media'
73
69
  const DOCS_URL_PREFIX = '/docs'
74
70
  const DEFAULT_IMPORT_STATUS = 'published'
75
71
 
72
+ type AppBylineClient = BylineClient
73
+ type DocsHandle = CollectionHandle<DocsFields>
74
+
76
75
  interface Flags {
77
76
  dryRun: boolean
78
77
  verbose: boolean
@@ -135,7 +134,7 @@ interface ResolvedFeatureImage {
135
134
  }
136
135
 
137
136
  async function resolveFeatureImage(
138
- client: ReturnType<typeof createBylineClient>,
137
+ client: AppBylineClient,
139
138
  path: string
140
139
  ): Promise<ResolvedFeatureImage | null> {
141
140
  const mediaCollectionId = await client.resolveCollectionId(MEDIA_COLLECTION)
@@ -186,7 +185,7 @@ function derivePath(frontmatter: DocFrontmatter, locale: string): string {
186
185
  * workflow doesn't include the target or when already at/past it.
187
186
  */
188
187
  async function walkToStatus(
189
- handle: CollectionHandle,
188
+ handle: DocsHandle,
190
189
  documentId: string,
191
190
  workflowStatuses: readonly { name: string }[],
192
191
  currentStatus: string,
@@ -230,8 +229,8 @@ function buildSourcePathMap(files: string[], defaultLocale: string): Map<string,
230
229
 
231
230
  async function processFile(
232
231
  filePath: string,
233
- client: ReturnType<typeof createBylineClient>,
234
- handle: CollectionHandle,
232
+ client: AppBylineClient,
233
+ handle: DocsHandle,
235
234
  flags: Flags,
236
235
  pathMap: Map<string, string>
237
236
  ): Promise<ProcessResult> {
@@ -340,7 +339,7 @@ function parentIndexFile(filePath: string): string {
340
339
  * processed in sorted order, so prefix order carries straight through.
341
340
  */
342
341
  async function placeTreeFromDirectories(
343
- handle: CollectionHandle,
342
+ handle: DocsHandle,
344
343
  results: ProcessResult[]
345
344
  ): Promise<void> {
346
345
  const placeable = results.filter(