@michaelthielemann/kestrel 4.0.2 → 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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The consumer-facing authoring API, registered as Nuxt/Nitro auto-imports so a site built on Kestrel
3
+ * can write `defineCollection({...})` without importing it. Every name here is also importable
4
+ * explicitly from its package; the auto-import is a convenience, not the only path.
5
+ */
6
+ export interface AutoImportEntry {
7
+ name: string
8
+ from: string
9
+ }
10
+
11
+ const CORE = '@michaelthielemann/kestrel-core'
12
+ const FIELDS = '@michaelthielemann/kestrel-fields'
13
+ const ACCESS = '@michaelthielemann/kestrel-access'
14
+
15
+ const entries = (from: string, names: string[]): AutoImportEntry[] => names.map((name) => ({ name, from }))
16
+
17
+ /** Server-only (Nitro) authoring API: collections, pipelines, revisions, field populators, access. */
18
+ export const serverAutoImports: AutoImportEntry[] = [
19
+ ...entries(CORE, [
20
+ 'defineCollection',
21
+ 'buildCollection',
22
+ 'definePipeline',
23
+ 'registerPipeline',
24
+ 'registerAfterStep',
25
+ 'syncStep',
26
+ 'asyncStep',
27
+ 'eventsOf',
28
+ 'getFieldPopulator',
29
+ 'readRevisions',
30
+ 'registerRevisionUpcast',
31
+ 'useDb',
32
+ ]),
33
+ ...entries(FIELDS, ['defineFieldType', 'constrain', 'opt']),
34
+ ...entries(ACCESS, ['registerAccessGrant']),
35
+ ]
36
+
37
+ /** App-side (Vue) authoring API: block definitions live next to their components. */
38
+ export const appAutoImports: AutoImportEntry[] = entries(`${FIELDS}/client`, ['defineBlock'])
@@ -2,6 +2,7 @@ import { readFileSync } from 'node:fs'
2
2
  import { defineNuxtModule } from '@nuxt/kit'
3
3
  import { resolveKestrel, type KestrelConfig } from '@michaelthielemann/kestrel-core'
4
4
  import { diagnoseAppShell } from './app-shell'
5
+ import { appAutoImports, serverAutoImports } from './auto-imports'
5
6
 
6
7
  /**
7
8
  * The `kestrel` config namespace (`kestrel: { … }` in nuxt.config, sourced from `kestrel.config.ts`).
@@ -15,6 +16,17 @@ export default defineNuxtModule<KestrelConfig>({
15
16
  setup(options, nuxt) {
16
17
  const c = resolveKestrel(options, process.env, nuxt.options.rootDir)
17
18
 
19
+ // Registered through hooks rather than `addImports`/`addServerImports`, which need an active Kit
20
+ // instance (`useNuxt()`) that plain `setup()` callers (tests) do not provide.
21
+ nuxt.hook('imports:extend', (imports) => {
22
+ imports.push(...appAutoImports)
23
+ })
24
+ nuxt.hook('nitro:config', (config) => {
25
+ config.imports ||= {}
26
+ config.imports.imports ||= []
27
+ config.imports.imports.push(...serverAutoImports)
28
+ })
29
+
18
30
  // `app:resolve` is the first hook where `mainComponent` is settled across all layers. In dev it fires
19
31
  // on every watched change, so an unfixed problem would repaint the whole message on each keystroke.
20
32
  const reported = new Set<string>()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michaelthielemann/kestrel",
3
- "version": "4.0.2",
3
+ "version": "4.1.0",
4
4
  "description": "A slim, collection-driven Nuxt 4 CMS meta-layer with a runtime schema engine. Add `extends: ['@michaelthielemann/kestrel']`, define collections, and the database migrates itself.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Michael Thielemann <283621694+MichaelThielemann@users.noreply.github.com>",
@@ -76,16 +76,16 @@
76
76
  "thumbhash": "^0.1.1",
77
77
  "typescript": "^6.0.3",
78
78
  "zod": "^4.4.3",
79
- "@michaelthielemann/kestrel-access": "0.1.0",
80
- "@michaelthielemann/kestrel-collections": "0.1.0",
79
+ "@michaelthielemann/kestrel-auth": "0.1.0",
81
80
  "@michaelthielemann/kestrel-contracts": "0.1.0",
81
+ "@michaelthielemann/kestrel-collections": "0.1.0",
82
82
  "@michaelthielemann/kestrel-core": "0.1.0",
83
- "@michaelthielemann/kestrel-auth": "0.1.0",
83
+ "@michaelthielemann/kestrel-access": "0.1.0",
84
84
  "@michaelthielemann/kestrel-delivery-live": "0.1.0",
85
85
  "@michaelthielemann/kestrel-fields": "0.1.0",
86
- "@michaelthielemann/kestrel-media": "0.1.0",
87
86
  "@michaelthielemann/kestrel-publishing": "0.1.0",
88
- "@michaelthielemann/kestrel-delivery-static": "0.1.0"
87
+ "@michaelthielemann/kestrel-delivery-static": "0.1.0",
88
+ "@michaelthielemann/kestrel-media": "0.1.0"
89
89
  },
90
90
  "//peers": "Framework singletons the layer sources import by bare specifier. Peers, not dependencies: a second copy breaks identity (two Vue instances; an h3 v1 `createError` handed to an h3 v2 error handler, which surfaces our 400/404/409 as bare 500s). All optional, because kestrel's own `nuxt` dependency already supplies them transitively — the entry pins identity where a copy exists rather than demanding one, and a required peer would ERESOLVE-fail npm installs on any Nuxt whose bundled range we did not anticipate. Each is also a devDependency so this repo resolves it without auto-install-peers writing a phantom root dependency into the lockfile.",
91
91
  "peerDependencies": {