@nuasite/cms 0.42.1 → 0.43.0-beta.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.
@@ -1,55 +1,11 @@
1
- export interface MediaItem {
2
- id: string
3
- url: string
4
- filename: string
5
- annotation?: string
6
- contentType: string
7
- width?: number
8
- height?: number
9
- uploadedAt?: string
10
- /** Folder path relative to media root (e.g. 'photos') */
11
- folder?: string
12
- }
13
-
14
- export interface MediaFolderItem {
15
- /** Folder name (last segment) */
16
- name: string
17
- /** Full relative path from media root (e.g. 'photos/vacation') */
18
- path: string
19
- }
20
-
21
- export type MediaTypeFilter = 'all' | 'photo' | 'graphic' | 'video' | 'document'
22
-
23
- export interface MediaListOptions {
24
- limit?: number
25
- cursor?: string
26
- /** List contents of this subfolder (relative to media root) */
27
- folder?: string
28
- }
29
-
30
- export interface MediaListResult {
31
- items: MediaItem[]
32
- /** Subfolders in the current directory */
33
- folders: MediaFolderItem[]
34
- hasMore: boolean
35
- cursor?: string
36
- }
37
-
38
- export interface MediaUploadResult {
39
- success: boolean
40
- url?: string
41
- filename?: string
42
- annotation?: string
43
- id?: string
44
- error?: string
45
- }
46
-
47
- export interface MediaStorageAdapter {
48
- list(options?: MediaListOptions): Promise<MediaListResult>
49
- upload(file: Buffer, filename: string, contentType: string, options?: { folder?: string }): Promise<MediaUploadResult>
50
- delete(id: string): Promise<{ success: boolean; error?: string }>
51
- /** Create an empty folder. Folders are also created implicitly on upload. */
52
- createFolder?(folder: string): Promise<{ success: boolean; error?: string }>
53
- /** Local filesystem info for direct file serving in dev (bypasses Vite's public dir cache) */
54
- staticFiles?: { urlPrefix: string; dir: string }
55
- }
1
+ // Media storage adapter types now live in @nuasite/cms-types (the shared wire model).
2
+ // Re-exported here so existing `../media/types` imports keep working unchanged.
3
+ export type {
4
+ MediaFolderItem,
5
+ MediaItem,
6
+ MediaListOptions,
7
+ MediaListResult,
8
+ MediaStorageAdapter,
9
+ MediaTypeFilter,
10
+ MediaUploadResult,
11
+ } from '@nuasite/cms-types'
package/src/tsconfig.json CHANGED
@@ -19,5 +19,9 @@
19
19
  "react-dom": ["../../../node_modules/preact/compat/"],
20
20
  "react-dom/*": ["../../../node_modules/preact/compat/*"]
21
21
  }
22
- }
22
+ },
23
+ "references": [
24
+ { "path": "../../cms-core/src" },
25
+ { "path": "../../cms-types/src" }
26
+ ]
23
27
  }
package/src/types.ts CHANGED
@@ -1,3 +1,32 @@
1
+ import type { CollectionDefinition, CollectionEntry, ComponentDefinition } from '@nuasite/cms-types'
2
+
3
+ // Structural contract types live in @nuasite/cms-types (the shared wire model).
4
+ // Re-exported here so existing `@nuasite/cms` imports keep working unchanged.
5
+ export type {
6
+ CollectionDefinition,
7
+ CollectionEntry,
8
+ CollectionEntryInfo,
9
+ ComponentDefinition,
10
+ ComponentProp,
11
+ FieldDefinition,
12
+ FieldHints,
13
+ FieldType,
14
+ MutationResult,
15
+ } from '@nuasite/cms-types'
16
+ export type {
17
+ AddRedirectRequest,
18
+ CreatePageRequest,
19
+ DeletePageRequest,
20
+ DeleteRedirectRequest,
21
+ DuplicatePageRequest,
22
+ GetRedirectsResponse,
23
+ LayoutInfo,
24
+ PageOperationResponse,
25
+ RedirectOperationResponse,
26
+ RedirectRule,
27
+ UpdateRedirectRequest,
28
+ } from '@nuasite/cms-types'
29
+
1
30
  /** SEO tracking options */
2
31
  export interface SeoOptions {
3
32
  /** Whether to track SEO elements (default: true) */
@@ -23,25 +52,6 @@ export interface CmsMarkerOptions {
23
52
  seo?: SeoOptions
24
53
  }
25
54
 
26
- export interface ComponentProp {
27
- name: string
28
- type: string
29
- required: boolean
30
- defaultValue?: string
31
- description?: string
32
- }
33
-
34
- export interface ComponentDefinition {
35
- name: string
36
- file: string
37
- props: ComponentProp[]
38
- description?: string
39
- slots?: string[]
40
- previewUrl?: string
41
- /** Viewport width (in px) used to render the preview iframe (default: 1280) */
42
- previewWidth?: number
43
- }
44
-
45
55
  /** Background image metadata for elements using bg-[url()] */
46
56
  export interface BackgroundImageMetadata {
47
57
  /** Full Tailwind class, e.g. bg-[url('/path.png')] */
@@ -219,140 +229,6 @@ export interface ComponentInstance {
219
229
  isInlineArray?: boolean
220
230
  }
221
231
 
222
- /** Represents a content collection entry (markdown file) */
223
- export interface CollectionEntry {
224
- /** Collection name (e.g., 'services', 'blog') */
225
- collectionName: string
226
- /** Entry slug (e.g., '3d-tisk') */
227
- collectionSlug: string
228
- /** Path to the markdown file relative to project root */
229
- sourcePath: string
230
- /** Frontmatter fields with their values and line numbers */
231
- frontmatter: Record<string, { value: string; line: number }>
232
- /** Full markdown body content */
233
- body: string
234
- /** Line number where body starts (1-indexed) */
235
- bodyStartLine: number
236
- /** ID of the wrapper element containing the rendered markdown */
237
- wrapperId?: string
238
- }
239
-
240
- /** Field types for collection schema inference */
241
- export type FieldType =
242
- | 'text'
243
- | 'textarea'
244
- | 'date'
245
- | 'datetime'
246
- | 'time'
247
- | 'year'
248
- | 'month'
249
- | 'boolean'
250
- | 'number'
251
- | 'image'
252
- | 'file'
253
- | 'url'
254
- | 'email'
255
- | 'tel'
256
- | 'color'
257
- | 'select'
258
- | 'array'
259
- | 'object'
260
- | 'reference'
261
-
262
- /** Editor hints for enhanced field rendering (extracted from `n.*()` options in content config) */
263
- export interface FieldHints {
264
- min?: number | string
265
- max?: number | string
266
- step?: number
267
- placeholder?: string
268
- maxLength?: number
269
- minLength?: number
270
- rows?: number
271
- accept?: string
272
- }
273
-
274
- /** Definition of a single field in a collection's schema */
275
- export interface FieldDefinition {
276
- /** Field name as it appears in frontmatter */
277
- name: string
278
- /** Inferred or specified field type */
279
- type: FieldType
280
- /** Whether the field is required (present in all entries) */
281
- required: boolean
282
- /** Default value for the field */
283
- defaultValue?: unknown
284
- /** Options for 'select' type fields */
285
- options?: string[]
286
- /** Item type for 'array' fields */
287
- itemType?: FieldType
288
- /** Nested fields for 'object' type */
289
- fields?: FieldDefinition[]
290
- /** Sample values seen across entries */
291
- examples?: unknown[]
292
- /** Where the field renders in the editor UI */
293
- position?: 'sidebar' | 'header'
294
- /** Group name for visual grouping with section headers */
295
- group?: string
296
- /** Referenced collection name for 'reference' type fields */
297
- collection?: string
298
- /** Hide from the editor UI (e.g. derived/computed fields) */
299
- hidden?: boolean
300
- /** Source field name this field is derived from (e.g. categoryHref derived from category) */
301
- derivedFrom?: string
302
- /** Editor hints for enhanced field rendering */
303
- hints?: FieldHints
304
- /** True when the field uses Astro's `image()` schema (entry-relative paths through astro:assets). */
305
- astroImage?: boolean
306
- /** Semantic role used by the editor UI to position special fields without name matching.
307
- * - `publish-toggle`: boolean controlling whether the entry is published (e.g. `draft`, `isDraft`, `published`).
308
- * - `publish-date`: the publish/release date field (e.g. `date`, `publishDate`, `publishedAt`). */
309
- role?: 'publish-toggle' | 'publish-date'
310
- }
311
-
312
- /** Per-entry metadata for collection browsing */
313
- export interface CollectionEntryInfo {
314
- slug: string
315
- title?: string
316
- sourcePath: string
317
- draft?: boolean
318
- /** URL pathname of the rendered page for this entry */
319
- pathname?: string
320
- /** Full entry data for data collections (JSON/YAML) */
321
- data?: Record<string, unknown>
322
- }
323
-
324
- /** Definition of a content collection with inferred schema */
325
- export interface CollectionDefinition {
326
- /** Collection identifier (directory name) */
327
- name: string
328
- /** Human-readable label for the collection */
329
- label: string
330
- /** Path to the collection directory */
331
- path: string
332
- /** Number of entries in the collection */
333
- entryCount: number
334
- /** Inferred field definitions */
335
- fields: FieldDefinition[]
336
- /** Whether the collection has draft support */
337
- supportsDraft?: boolean
338
- /** Collection type: 'content' for markdown, 'data' for JSON/YAML */
339
- type?: 'content' | 'data'
340
- /** File extension used by entries */
341
- fileExtension: 'md' | 'mdx' | 'json' | 'yaml' | 'yml'
342
- /** Per-entry metadata for browsing */
343
- entries?: CollectionEntryInfo[]
344
- /** Frontmatter field name to sort entries by (detected from `.orderBy()` in content config) */
345
- orderBy?: string
346
- /** Sort direction for orderBy field */
347
- orderDirection?: 'asc' | 'desc'
348
- /**
349
- * Name of the collection this one is nested under in the CMS browser, when it shares a base
350
- * directory with another collection (e.g. a nested `*​/otazky/*` collection grouped under the
351
- * `*​/index.md` collection at the same base). Purely presentational grouping.
352
- */
353
- parentCollection?: string
354
- }
355
-
356
232
  /** Manifest metadata for versioning and conflict detection */
357
233
  export interface ManifestMetadata {
358
234
  /** Manifest schema version */
@@ -670,75 +546,5 @@ export interface CmsSetFeaturesMessage {
670
546
  /** All possible CMS postMessage types sent from the parent to the editor iframe */
671
547
  export type CmsInboundMessage = CmsDeselectElementMessage | CmsSetFeaturesMessage
672
548
 
673
- // ============================================================================
674
- // Page Operations (shared between server handlers and editor UI)
675
- // ============================================================================
676
-
677
- export interface CreatePageRequest {
678
- title: string
679
- slug: string
680
- layoutPath?: string
681
- }
682
-
683
- export interface DuplicatePageRequest {
684
- sourcePagePath: string
685
- slug: string
686
- title?: string
687
- createRedirect?: boolean
688
- }
689
-
690
- export interface DeletePageRequest {
691
- pagePath: string
692
- createRedirect?: boolean
693
- redirectTo?: string
694
- }
695
-
696
- export interface PageOperationResponse {
697
- success: boolean
698
- filePath?: string
699
- slug?: string
700
- url?: string
701
- error?: string
702
- }
703
-
704
- export interface LayoutInfo {
705
- name: string
706
- path: string
707
- }
708
-
709
- // ============================================================================
710
- // Redirect Operations (shared between server handlers and editor UI)
711
- // ============================================================================
712
-
713
- export interface RedirectRule {
714
- source: string
715
- destination: string
716
- statusCode: number
717
- lineIndex: number
718
- }
719
-
720
- export interface AddRedirectRequest {
721
- source: string
722
- destination: string
723
- statusCode?: number
724
- }
725
-
726
- export interface UpdateRedirectRequest {
727
- lineIndex: number
728
- source: string
729
- destination: string
730
- statusCode?: number
731
- }
732
-
733
- export interface DeleteRedirectRequest {
734
- lineIndex: number
735
- }
736
-
737
- export interface RedirectOperationResponse {
738
- success: boolean
739
- error?: string
740
- }
741
-
742
- export interface GetRedirectsResponse {
743
- rules: RedirectRule[]
744
- }
549
+ // Page & Redirect operation request/response types now live in @nuasite/cms-types
550
+ // and are re-exported at the top of this file.