@azlib/cms 0.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.
@@ -0,0 +1,851 @@
1
+ //#region src/core/types.d.ts
2
+ /**
3
+ * @azlib/cms - Universal Domain Types & Interfaces
4
+ */
5
+ type ContentStatus = "draft" | "pending_review" | "scheduled" | "published" | "private" | "trash";
6
+ type FieldType = "text" | "slug" | "richText" | "number" | "boolean" | "select" | "image" | "taxonomy" | "relationship" | "date" | "json" | "repeater";
7
+ interface SelectOption {
8
+ readonly label: string;
9
+ readonly value: string | number;
10
+ }
11
+ interface FieldDefinition<TValue = any> {
12
+ readonly name: string;
13
+ readonly type: FieldType;
14
+ readonly label?: string;
15
+ readonly description?: string;
16
+ readonly required?: boolean;
17
+ readonly defaultValue?: TValue;
18
+ readonly unique?: boolean;
19
+ readonly options?: readonly (string | SelectOption)[];
20
+ readonly taxonomy?: string;
21
+ readonly targetCollection?: string;
22
+ readonly fromField?: string;
23
+ readonly fields?: readonly FieldDefinition[];
24
+ readonly min?: number;
25
+ readonly max?: number;
26
+ readonly pattern?: string;
27
+ readonly validate?: (value: any, data: Record<string, unknown>) => string | null | boolean;
28
+ }
29
+ interface CollectionConfig {
30
+ readonly slug: string;
31
+ readonly label: string;
32
+ readonly singularLabel?: string;
33
+ readonly description?: string;
34
+ readonly hierarchical?: boolean;
35
+ readonly timestamps?: boolean;
36
+ readonly revisions?: boolean;
37
+ readonly draftable?: boolean;
38
+ readonly fields: readonly FieldDefinition[];
39
+ readonly taxonomies?: readonly string[];
40
+ readonly defaultSort?: {
41
+ readonly field: string;
42
+ readonly direction: "asc" | "desc";
43
+ };
44
+ }
45
+ interface ContentItem<TData extends Record<string, unknown> = Record<string, unknown>> {
46
+ id: string;
47
+ collection: string;
48
+ slug: string;
49
+ status: ContentStatus;
50
+ title?: string;
51
+ parentId?: string | null;
52
+ authorId?: string | null;
53
+ publishedAt?: string | null;
54
+ scheduledAt?: string | null;
55
+ createdAt: string;
56
+ updatedAt: string;
57
+ version: number;
58
+ data: TData;
59
+ terms?: Record<string, string[]>;
60
+ }
61
+ interface ContentQueryOptions {
62
+ status?: ContentStatus | ContentStatus[];
63
+ authorId?: string;
64
+ parentId?: string | null;
65
+ termIds?: string[];
66
+ search?: string;
67
+ where?: Record<string, unknown>;
68
+ orderBy?: string;
69
+ orderDirection?: "asc" | "desc";
70
+ limit?: number;
71
+ offset?: number;
72
+ includeRevisions?: boolean;
73
+ includeTerms?: boolean;
74
+ }
75
+ interface PaginatedResult<T> {
76
+ items: T[];
77
+ total: number;
78
+ limit: number;
79
+ offset: number;
80
+ hasMore: boolean;
81
+ }
82
+ interface RevisionRecord {
83
+ id: string;
84
+ contentId: string;
85
+ collection: string;
86
+ version: number;
87
+ snapshot: ContentItem;
88
+ authorId?: string | null;
89
+ note?: string;
90
+ createdAt: string;
91
+ }
92
+ interface RevisionDiffField {
93
+ field: string;
94
+ oldValue: unknown;
95
+ newValue: unknown;
96
+ }
97
+ interface RevisionDiff {
98
+ contentId: string;
99
+ fromVersion: number;
100
+ toVersion: number;
101
+ changes: RevisionDiffField[];
102
+ }
103
+ interface TaxonomyConfig {
104
+ readonly slug: string;
105
+ readonly label: string;
106
+ readonly singularLabel?: string;
107
+ readonly hierarchical?: boolean;
108
+ readonly postTypes?: readonly string[];
109
+ readonly description?: string;
110
+ }
111
+ interface TermItem {
112
+ id: string;
113
+ taxonomy: string;
114
+ name: string;
115
+ slug: string;
116
+ description?: string;
117
+ parentId?: string | null;
118
+ count: number;
119
+ meta?: Record<string, unknown>;
120
+ createdAt: string;
121
+ updatedAt: string;
122
+ }
123
+ interface TermTreeItem extends TermItem {
124
+ children: TermTreeItem[];
125
+ }
126
+ interface MediaItem {
127
+ id: string;
128
+ filename: string;
129
+ originalName: string;
130
+ mimeType: string;
131
+ sizeBytes: number;
132
+ url: string;
133
+ path?: string;
134
+ width?: number;
135
+ height?: number;
136
+ altText?: string;
137
+ caption?: string;
138
+ authorId?: string | null;
139
+ variants?: Record<string, string>;
140
+ createdAt: string;
141
+ updatedAt: string;
142
+ }
143
+ interface OptionItem<T = unknown> {
144
+ key: string;
145
+ value: T;
146
+ autoload: boolean;
147
+ namespace?: string;
148
+ updatedAt: string;
149
+ }
150
+ type UserRole = "admin" | "editor" | "author" | "contributor" | "subscriber" | (string & {});
151
+ type CMSCapability = "manage_options" | "manage_taxonomies" | "upload_files" | "delete_files" | "edit_posts" | "edit_others_posts" | "publish_posts" | "delete_posts" | "delete_others_posts" | "read_private_posts" | (string & {});
152
+ interface CMSUser {
153
+ id: string;
154
+ username: string;
155
+ email: string;
156
+ displayName: string;
157
+ role: UserRole;
158
+ capabilities?: string[];
159
+ active?: boolean;
160
+ }
161
+ interface SiteConfig {
162
+ name: string;
163
+ description?: string;
164
+ url?: string;
165
+ logo?: string;
166
+ locale?: string;
167
+ timezone?: string;
168
+ }
169
+ interface CMSConfig {
170
+ site?: SiteConfig;
171
+ collections: readonly CollectionConfig[];
172
+ taxonomies?: readonly TaxonomyConfig[];
173
+ admin?: {
174
+ route?: string;
175
+ enableRegistration?: boolean;
176
+ };
177
+ }
178
+ //#endregion
179
+ //#region src/core/config.d.ts
180
+ /**
181
+ * Default standard collections provided when not explicitly specified.
182
+ */
183
+ declare const DEFAULT_COLLECTIONS: CollectionConfig[];
184
+ /**
185
+ * Type-safe configuration helper function for azlib.config.ts.
186
+ */
187
+ declare function defineConfig(config: CMSConfig): CMSConfig;
188
+ /**
189
+ * Normalize and merge user config with CMS defaults.
190
+ */
191
+ declare function normalizeConfig(config: Partial<CMSConfig>): CMSConfig;
192
+ //#endregion
193
+ //#region src/core/hooks.d.ts
194
+ /**
195
+ * @azlib/cms - WordPress-style Action and Filter Hook System
196
+ */
197
+ type ActionCallback = (...args: unknown[]) => void | Promise<void>;
198
+ type FilterCallback<T = unknown> = (value: T, ...args: unknown[]) => T | Promise<T>;
199
+ type SyncFilterCallback<T = unknown> = (value: T, ...args: unknown[]) => T;
200
+ interface HookEntry<TCallback> {
201
+ readonly callback: TCallback;
202
+ readonly priority: number;
203
+ }
204
+ declare class HooksManager {
205
+ private actions;
206
+ private filters;
207
+ /**
208
+ * Register an action callback.
209
+ * Lower priority numbers execute first (default: 10).
210
+ */
211
+ addAction(tag: string, callback: ActionCallback, priority?: number): this;
212
+ /**
213
+ * Execute all callbacks registered for the specified action asynchronously.
214
+ */
215
+ doAction(tag: string, ...args: unknown[]): Promise<void>;
216
+ /**
217
+ * Execute all callbacks registered for the specified action synchronously.
218
+ */
219
+ doActionSync(tag: string, ...args: unknown[]): void;
220
+ /**
221
+ * Register a filter callback.
222
+ * Filter callbacks receive a value and return the modified value.
223
+ */
224
+ addFilter<T = unknown>(tag: string, callback: FilterCallback<T>, priority?: number): this;
225
+ /**
226
+ * Apply all filters registered for the specified tag sequentially.
227
+ */
228
+ applyFilters<T = unknown>(tag: string, initialValue: T, ...args: unknown[]): Promise<T>;
229
+ /**
230
+ * Apply all filters registered for the specified tag synchronously.
231
+ */
232
+ applyFiltersSync<T = unknown>(tag: string, initialValue: T, ...args: unknown[]): T;
233
+ /**
234
+ * Remove a registered action callback.
235
+ */
236
+ removeAction(tag: string, callback: ActionCallback): boolean;
237
+ /**
238
+ * Remove a registered filter callback.
239
+ */
240
+ removeFilter<T = unknown>(tag: string, callback: FilterCallback<T>): boolean;
241
+ /**
242
+ * Check if any callbacks are registered for an action.
243
+ */
244
+ hasAction(tag: string): boolean;
245
+ /**
246
+ * Check if any callbacks are registered for a filter.
247
+ */
248
+ hasFilter(tag: string): boolean;
249
+ /**
250
+ * Remove all registered actions and filters.
251
+ */
252
+ removeAll(tag?: string): void;
253
+ }
254
+ declare const defaultHooks: HooksManager;
255
+ //#endregion
256
+ //#region src/storage/storage-contract.d.ts
257
+ interface CMSStorageAdapter {
258
+ init(): Promise<void>;
259
+ close(): Promise<void>;
260
+ createContent<T extends Record<string, unknown>>(item: Omit<ContentItem<T>, "id" | "createdAt" | "updatedAt" | "version">): Promise<ContentItem<T>>;
261
+ getContent<T extends Record<string, unknown>>(collection: string, id: string): Promise<ContentItem<T> | null>;
262
+ getContentBySlug<T extends Record<string, unknown>>(collection: string, slug: string): Promise<ContentItem<T> | null>;
263
+ findContent<T extends Record<string, unknown>>(collection: string, options?: ContentQueryOptions): Promise<PaginatedResult<ContentItem<T>>>;
264
+ updateContent<T extends Record<string, unknown>>(collection: string, id: string, updates: Partial<Omit<ContentItem<T>, "id" | "collection" | "createdAt">>): Promise<ContentItem<T> | null>;
265
+ deleteContent(collection: string, id: string): Promise<boolean>;
266
+ countContent(collection: string, options?: ContentQueryOptions): Promise<number>;
267
+ createRevision(contentId: string, collection: string, version: number, snapshot: ContentItem, authorId?: string | null, note?: string): Promise<RevisionRecord>;
268
+ getRevisions(contentId: string): Promise<RevisionRecord[]>;
269
+ getRevision(revisionId: string): Promise<RevisionRecord | null>;
270
+ deleteRevisionsByContentId(contentId: string): Promise<number>;
271
+ createTerm(term: Omit<TermItem, "id" | "count" | "createdAt" | "updatedAt">): Promise<TermItem>;
272
+ getTermById(id: string): Promise<TermItem | null>;
273
+ getTermBySlug(taxonomy: string, slug: string): Promise<TermItem | null>;
274
+ getTerms(taxonomy: string, options?: {
275
+ parentId?: string | null;
276
+ }): Promise<TermItem[]>;
277
+ updateTerm(id: string, updates: Partial<Omit<TermItem, "id" | "taxonomy" | "createdAt">>): Promise<TermItem | null>;
278
+ deleteTerm(id: string): Promise<boolean>;
279
+ assignTermsToContent(contentId: string, termIds: string[]): Promise<void>;
280
+ getContentTerms(contentId: string, taxonomy?: string): Promise<TermItem[]>;
281
+ removeTermsFromContent(contentId: string, termIds: string[]): Promise<void>;
282
+ createMedia(item: Omit<MediaItem, "id" | "createdAt" | "updatedAt">): Promise<MediaItem>;
283
+ getMedia(id: string): Promise<MediaItem | null>;
284
+ findMedia(options?: {
285
+ search?: string;
286
+ mimeType?: string;
287
+ authorId?: string;
288
+ limit?: number;
289
+ offset?: number;
290
+ }): Promise<PaginatedResult<MediaItem>>;
291
+ updateMedia(id: string, updates: Partial<Omit<MediaItem, "id" | "createdAt">>): Promise<MediaItem | null>;
292
+ deleteMedia(id: string): Promise<boolean>;
293
+ getOption<T = unknown>(key: string): Promise<OptionItem<T> | null>;
294
+ setOption<T = unknown>(item: OptionItem<T>): Promise<void>;
295
+ deleteOption(key: string): Promise<boolean>;
296
+ getOptions(namespace?: string): Promise<OptionItem[]>;
297
+ }
298
+ //#endregion
299
+ //#region src/core/options.d.ts
300
+ declare class OptionsManager {
301
+ private storage;
302
+ private hooks?;
303
+ constructor(storage: CMSStorageAdapter, hooks?: HooksManager | undefined);
304
+ /**
305
+ * Retrieve an option by key. Returns defaultValue if option does not exist.
306
+ */
307
+ get<T = unknown>(key: string, defaultValue?: T): Promise<T | undefined>;
308
+ /**
309
+ * Set or update an option value.
310
+ */
311
+ set<T = unknown>(key: string, value: T, options?: {
312
+ autoload?: boolean;
313
+ namespace?: string;
314
+ }): Promise<OptionItem<T>>;
315
+ /**
316
+ * Delete an option by key.
317
+ */
318
+ delete(key: string): Promise<boolean>;
319
+ /**
320
+ * Check if an option exists.
321
+ */
322
+ has(key: string): Promise<boolean>;
323
+ /**
324
+ * Get all options, optionally filtered by namespace.
325
+ */
326
+ getAll(namespace?: string): Promise<Record<string, unknown>>;
327
+ }
328
+ //#endregion
329
+ //#region src/content/lifecycle.d.ts
330
+ declare const VALID_STATUS_TRANSITIONS: Record<ContentStatus, readonly ContentStatus[]>;
331
+ declare class ContentLifecycle {
332
+ private storage;
333
+ private hooks?;
334
+ constructor(storage: CMSStorageAdapter, hooks?: HooksManager | undefined);
335
+ /**
336
+ * Validate whether a status transition is permitted.
337
+ */
338
+ canTransition(currentStatus: ContentStatus, nextStatus: ContentStatus): boolean;
339
+ /**
340
+ * Process all scheduled content across a collection (or all collections) and publish mature items.
341
+ */
342
+ processScheduledContent(collection: string, now?: Date): Promise<ContentItem[]>;
343
+ }
344
+ //#endregion
345
+ //#region src/content/revisions.d.ts
346
+ declare class RevisionManager {
347
+ private storage;
348
+ private hooks?;
349
+ constructor(storage: CMSStorageAdapter, hooks?: HooksManager | undefined);
350
+ /**
351
+ * Save a revision snapshot for a content item.
352
+ */
353
+ createRevision(item: ContentItem, authorId?: string | null, note?: string): Promise<RevisionRecord>;
354
+ /**
355
+ * Get all revisions for a content item.
356
+ */
357
+ getRevisions(contentId: string): Promise<RevisionRecord[]>;
358
+ /**
359
+ * Get a specific revision by ID.
360
+ */
361
+ getRevision(revisionId: string): Promise<RevisionRecord | null>;
362
+ /**
363
+ * Compute differences between two content snapshots.
364
+ */
365
+ computeDiff(oldSnapshot: ContentItem, newSnapshot: ContentItem): RevisionDiff;
366
+ /**
367
+ * Restore a content item to a previous revision snapshot.
368
+ */
369
+ restoreRevision(collection: string, revisionId: string, authorId?: string): Promise<ContentItem | null>;
370
+ }
371
+ //#endregion
372
+ //#region src/taxonomy/taxonomy.d.ts
373
+ declare class TaxonomyManager {
374
+ private storage;
375
+ private hooks?;
376
+ private registeredTaxonomies;
377
+ constructor(storage: CMSStorageAdapter, hooks?: HooksManager | undefined);
378
+ /**
379
+ * Register a taxonomy definition.
380
+ */
381
+ registerTaxonomy(config: TaxonomyConfig): void;
382
+ /**
383
+ * Get all registered taxonomies.
384
+ */
385
+ getTaxonomies(): TaxonomyConfig[];
386
+ /**
387
+ * Get a single taxonomy configuration by slug.
388
+ */
389
+ getTaxonomy(slug: string): TaxonomyConfig | undefined;
390
+ /**
391
+ * Create a new term (e.g. category or tag).
392
+ */
393
+ createTerm(taxonomy: string, data: {
394
+ name: string;
395
+ slug?: string;
396
+ description?: string;
397
+ parentId?: string | null;
398
+ meta?: Record<string, unknown>;
399
+ }): Promise<TermItem>;
400
+ /**
401
+ * Get a term by ID.
402
+ */
403
+ getTermById(id: string): Promise<TermItem | null>;
404
+ /**
405
+ * Get a term by slug within a taxonomy.
406
+ */
407
+ getTermBySlug(taxonomy: string, slug: string): Promise<TermItem | null>;
408
+ /**
409
+ * Get terms for a taxonomy.
410
+ */
411
+ getTerms(taxonomy: string, options?: {
412
+ parentId?: string | null;
413
+ }): Promise<TermItem[]>;
414
+ /**
415
+ * Build a hierarchical tree of terms for a taxonomy (parent -> children).
416
+ */
417
+ getTermTree(taxonomy: string): Promise<TermTreeItem[]>;
418
+ /**
419
+ * Update a term.
420
+ */
421
+ updateTerm(id: string, updates: {
422
+ name?: string;
423
+ slug?: string;
424
+ description?: string;
425
+ parentId?: string | null;
426
+ meta?: Record<string, unknown>;
427
+ }): Promise<TermItem | null>;
428
+ /**
429
+ * Delete a term.
430
+ */
431
+ deleteTerm(id: string): Promise<boolean>;
432
+ /**
433
+ * Assign term IDs to a content item.
434
+ */
435
+ assignTerms(contentId: string, termIds: string[]): Promise<void>;
436
+ /**
437
+ * Get all terms assigned to a content item.
438
+ */
439
+ getContentTerms(contentId: string, taxonomy?: string): Promise<TermItem[]>;
440
+ /**
441
+ * Remove terms from a content item.
442
+ */
443
+ removeTerms(contentId: string, termIds: string[]): Promise<void>;
444
+ }
445
+ //#endregion
446
+ //#region src/media/media-manager.d.ts
447
+ interface MediaUploadInput {
448
+ filename: string;
449
+ mimeType: string;
450
+ sizeBytes: number;
451
+ url?: string;
452
+ width?: number;
453
+ height?: number;
454
+ altText?: string;
455
+ caption?: string;
456
+ variants?: Record<string, string>;
457
+ }
458
+ declare class MediaManager {
459
+ private storage;
460
+ private hooks?;
461
+ private publicBaseUrl;
462
+ private allowedMimePrefixes;
463
+ constructor(storage: CMSStorageAdapter, hooks?: HooksManager | undefined, publicBaseUrl?: string);
464
+ /**
465
+ * Upload / register a new media item.
466
+ */
467
+ upload(input: MediaUploadInput, authorId?: string | null): Promise<MediaItem>;
468
+ /**
469
+ * Get a media item by ID.
470
+ */
471
+ get(id: string): Promise<MediaItem | null>;
472
+ /**
473
+ * Find media items.
474
+ */
475
+ find(options?: {
476
+ search?: string;
477
+ mimeType?: string;
478
+ authorId?: string;
479
+ limit?: number;
480
+ offset?: number;
481
+ }): Promise<PaginatedResult<MediaItem>>;
482
+ /**
483
+ * Update media metadata (alt text, caption, dimensions).
484
+ */
485
+ updateMetadata(id: string, updates: {
486
+ altText?: string;
487
+ caption?: string;
488
+ width?: number;
489
+ height?: number;
490
+ }): Promise<MediaItem | null>;
491
+ /**
492
+ * Delete a media item.
493
+ */
494
+ delete(id: string): Promise<boolean>;
495
+ }
496
+ //#endregion
497
+ //#region src/auth/rbac.d.ts
498
+ declare const DEFAULT_ROLE_CAPABILITIES: Record<string, string[]>;
499
+ declare class RBACManager {
500
+ private roleCapabilities;
501
+ constructor();
502
+ /**
503
+ * Register a custom role with its capabilities.
504
+ */
505
+ registerRole(role: string, capabilities: string[]): void;
506
+ /**
507
+ * Add a capability to an existing role.
508
+ */
509
+ addCapabilityToRole(role: string, capability: string): void;
510
+ /**
511
+ * Get all capabilities assigned to a role.
512
+ */
513
+ getRoleCapabilities(role: string): string[];
514
+ /**
515
+ * Check if a user possesses a specific capability.
516
+ * If a target content item context is provided, checks object ownership rules.
517
+ */
518
+ can(user: CMSUser | null | undefined, capability: CMSCapability, context?: {
519
+ contentItem?: ContentItem;
520
+ }): boolean;
521
+ }
522
+ //#endregion
523
+ //#region src/core/engine.d.ts
524
+ interface CreateContentInput {
525
+ title?: string;
526
+ slug?: string;
527
+ status?: ContentItem["status"];
528
+ parentId?: string | null;
529
+ scheduledAt?: string | null;
530
+ data?: Record<string, unknown>;
531
+ terms?: Record<string, string[]>;
532
+ }
533
+ interface UpdateContentInput {
534
+ title?: string;
535
+ slug?: string;
536
+ status?: ContentItem["status"];
537
+ parentId?: string | null;
538
+ scheduledAt?: string | null;
539
+ data?: Record<string, unknown>;
540
+ terms?: Record<string, string[]>;
541
+ }
542
+ interface CollectionService<TData extends Record<string, unknown> = Record<string, unknown>> {
543
+ readonly config: CollectionConfig;
544
+ create(input: CreateContentInput, authorId?: string | null): Promise<ContentItem<TData>>;
545
+ findById(id: string): Promise<ContentItem<TData> | null>;
546
+ findBySlug(slug: string): Promise<ContentItem<TData> | null>;
547
+ find(options?: ContentQueryOptions): Promise<PaginatedResult<ContentItem<TData>>>;
548
+ update(id: string, input: UpdateContentInput, authorId?: string | null, revisionNote?: string): Promise<ContentItem<TData> | null>;
549
+ delete(id: string): Promise<boolean>;
550
+ publish(id: string, authorId?: string | null): Promise<ContentItem<TData> | null>;
551
+ schedule(id: string, scheduledAt: Date | string, authorId?: string | null): Promise<ContentItem<TData> | null>;
552
+ getRevisions(id: string): Promise<RevisionRecord[]>;
553
+ getRevision(revisionId: string): Promise<RevisionRecord | null>;
554
+ restoreRevision(id: string, revisionId: string, authorId?: string): Promise<ContentItem<TData> | null>;
555
+ getDiff(oldVersion: ContentItem<TData>, newVersion: ContentItem<TData>): RevisionDiff;
556
+ }
557
+ declare class CMSEngine {
558
+ readonly config: CMSConfig;
559
+ readonly hooks: HooksManager;
560
+ readonly storage: CMSStorageAdapter;
561
+ readonly options: OptionsManager;
562
+ readonly taxonomies: TaxonomyManager;
563
+ readonly media: MediaManager;
564
+ readonly rbac: RBACManager;
565
+ readonly revisions: RevisionManager;
566
+ readonly lifecycle: ContentLifecycle;
567
+ private collections;
568
+ constructor(config?: Partial<CMSConfig>, storage?: CMSStorageAdapter, hooks?: HooksManager);
569
+ /**
570
+ * Initialize storage and trigger bootstrap hooks.
571
+ */
572
+ init(): Promise<void>;
573
+ /**
574
+ * Close storage connections.
575
+ */
576
+ close(): Promise<void>;
577
+ /**
578
+ * Get all registered collection configurations.
579
+ */
580
+ getCollections(): CollectionConfig[];
581
+ /**
582
+ * Get a single collection configuration.
583
+ */
584
+ getCollectionConfig(slug: string): CollectionConfig | undefined;
585
+ /**
586
+ * Access high-level CRUD service for a collection.
587
+ */
588
+ collection<TData extends Record<string, unknown> = Record<string, unknown>>(slug: string): CollectionService<TData>;
589
+ /**
590
+ * Run scheduled content publisher for all registered collections.
591
+ */
592
+ processScheduledContent(now?: Date): Promise<ContentItem[]>;
593
+ }
594
+ /**
595
+ * Factory helper to create a configured CMSEngine instance.
596
+ */
597
+ declare function createCMSEngine(config?: Partial<CMSConfig>, storage?: CMSStorageAdapter, hooks?: HooksManager): CMSEngine;
598
+ //#endregion
599
+ //#region src/content/schema.d.ts
600
+ interface TextFieldOptions {
601
+ name: string;
602
+ label?: string;
603
+ description?: string;
604
+ required?: boolean;
605
+ defaultValue?: string;
606
+ unique?: boolean;
607
+ min?: number;
608
+ max?: number;
609
+ pattern?: string;
610
+ validate?: (value: string, data: Record<string, unknown>) => string | null | boolean;
611
+ }
612
+ interface SlugFieldOptions {
613
+ name?: string;
614
+ label?: string;
615
+ from?: string;
616
+ required?: boolean;
617
+ unique?: boolean;
618
+ }
619
+ interface RichTextFieldOptions {
620
+ name: string;
621
+ label?: string;
622
+ description?: string;
623
+ required?: boolean;
624
+ defaultValue?: string;
625
+ }
626
+ interface NumberFieldOptions {
627
+ name: string;
628
+ label?: string;
629
+ description?: string;
630
+ required?: boolean;
631
+ defaultValue?: number;
632
+ min?: number;
633
+ max?: number;
634
+ }
635
+ interface BooleanFieldOptions {
636
+ name: string;
637
+ label?: string;
638
+ description?: string;
639
+ defaultValue?: boolean;
640
+ }
641
+ interface SelectFieldOptions {
642
+ name: string;
643
+ label?: string;
644
+ description?: string;
645
+ required?: boolean;
646
+ options: readonly (string | SelectOption)[];
647
+ defaultValue?: string | number;
648
+ }
649
+ interface ImageFieldOptions {
650
+ name: string;
651
+ label?: string;
652
+ description?: string;
653
+ required?: boolean;
654
+ }
655
+ interface TaxonomyFieldOptions {
656
+ name: string;
657
+ taxonomy: string;
658
+ label?: string;
659
+ required?: boolean;
660
+ }
661
+ interface RelationshipFieldOptions {
662
+ name: string;
663
+ targetCollection: string;
664
+ label?: string;
665
+ description?: string;
666
+ required?: boolean;
667
+ }
668
+ interface DateFieldOptions {
669
+ name: string;
670
+ label?: string;
671
+ description?: string;
672
+ required?: boolean;
673
+ defaultValue?: string;
674
+ }
675
+ interface JsonFieldOptions {
676
+ name: string;
677
+ label?: string;
678
+ description?: string;
679
+ required?: boolean;
680
+ defaultValue?: unknown;
681
+ }
682
+ interface RepeaterFieldOptions {
683
+ name: string;
684
+ label?: string;
685
+ description?: string;
686
+ fields: readonly FieldDefinition[];
687
+ min?: number;
688
+ max?: number;
689
+ }
690
+ declare const fields: {
691
+ text(options: TextFieldOptions): FieldDefinition<string>;
692
+ slug(options?: SlugFieldOptions): FieldDefinition<string>;
693
+ richText(options: RichTextFieldOptions): FieldDefinition<string>;
694
+ number(options: NumberFieldOptions): FieldDefinition<number>;
695
+ boolean(options: BooleanFieldOptions): FieldDefinition<boolean>;
696
+ select(options: SelectFieldOptions): FieldDefinition<string | number>;
697
+ image(options: ImageFieldOptions): FieldDefinition<string>;
698
+ taxonomy(options: TaxonomyFieldOptions): FieldDefinition<string | string[]>;
699
+ relationship(options: RelationshipFieldOptions): FieldDefinition<string | string[]>;
700
+ date(options: DateFieldOptions): FieldDefinition<string>;
701
+ json(options: JsonFieldOptions): FieldDefinition<unknown>;
702
+ repeater(options: RepeaterFieldOptions): FieldDefinition<Record<string, unknown>[]>;
703
+ };
704
+ interface CollectionOptions {
705
+ slug: string;
706
+ label: string;
707
+ singularLabel?: string;
708
+ description?: string;
709
+ hierarchical?: boolean;
710
+ timestamps?: boolean;
711
+ revisions?: boolean;
712
+ draftable?: boolean;
713
+ fields: readonly FieldDefinition[];
714
+ taxonomies?: readonly string[];
715
+ defaultSort?: {
716
+ field: string;
717
+ direction: "asc" | "desc";
718
+ };
719
+ }
720
+ /**
721
+ * Define a CMS Collection with field schemas and lifecycle rules.
722
+ */
723
+ declare function collection(options: CollectionOptions): CollectionConfig;
724
+ /**
725
+ * Validate and apply default values to input data for a collection.
726
+ */
727
+ declare function validateAndNormalizeData(fieldsList: readonly FieldDefinition[], inputData: Record<string, unknown>): {
728
+ data: Record<string, unknown>;
729
+ errors: Record<string, string>;
730
+ };
731
+ //#endregion
732
+ //#region src/content/slug.d.ts
733
+ /**
734
+ * @azlib/cms - Slug generation and normalization utility
735
+ */
736
+ /**
737
+ * Generate a clean, URL-safe slug from any input string.
738
+ */
739
+ declare function slugify(input: string): string;
740
+ /**
741
+ * Create a unique slug given an existing set of slugs or a check function.
742
+ */
743
+ declare function resolveUniqueSlug(baseSlug: string, isSlugTaken: (slug: string) => Promise<boolean> | boolean, currentId?: string): Promise<string>;
744
+ //#endregion
745
+ //#region src/storage/memory-adapter.d.ts
746
+ declare class MemoryStorageAdapter implements CMSStorageAdapter {
747
+ private content;
748
+ private revisions;
749
+ private terms;
750
+ private contentTerms;
751
+ private media;
752
+ private options;
753
+ init(): Promise<void>;
754
+ close(): Promise<void>;
755
+ createContent<T extends Record<string, unknown>>(item: Omit<ContentItem<T>, "id" | "createdAt" | "updatedAt" | "version">): Promise<ContentItem<T>>;
756
+ getContent<T extends Record<string, unknown>>(collection: string, id: string): Promise<ContentItem<T> | null>;
757
+ getContentBySlug<T extends Record<string, unknown>>(collection: string, slug: string): Promise<ContentItem<T> | null>;
758
+ findContent<T extends Record<string, unknown>>(collection: string, options?: ContentQueryOptions): Promise<PaginatedResult<ContentItem<T>>>;
759
+ updateContent<T extends Record<string, unknown>>(collection: string, id: string, updates: Partial<Omit<ContentItem<T>, "id" | "collection" | "createdAt">>): Promise<ContentItem<T> | null>;
760
+ deleteContent(collection: string, id: string): Promise<boolean>;
761
+ countContent(collection: string, options?: ContentQueryOptions): Promise<number>;
762
+ createRevision(contentId: string, collection: string, version: number, snapshot: ContentItem, authorId?: string | null, note?: string): Promise<RevisionRecord>;
763
+ getRevisions(contentId: string): Promise<RevisionRecord[]>;
764
+ getRevision(revisionId: string): Promise<RevisionRecord | null>;
765
+ deleteRevisionsByContentId(contentId: string): Promise<number>;
766
+ createTerm(term: Omit<TermItem, "id" | "count" | "createdAt" | "updatedAt">): Promise<TermItem>;
767
+ getTermById(id: string): Promise<TermItem | null>;
768
+ getTermBySlug(taxonomy: string, slug: string): Promise<TermItem | null>;
769
+ getTerms(taxonomy: string, options?: {
770
+ parentId?: string | null;
771
+ }): Promise<TermItem[]>;
772
+ updateTerm(id: string, updates: Partial<Omit<TermItem, "id" | "taxonomy" | "createdAt">>): Promise<TermItem | null>;
773
+ deleteTerm(id: string): Promise<boolean>;
774
+ assignTermsToContent(contentId: string, termIds: string[]): Promise<void>;
775
+ getContentTerms(contentId: string, taxonomy?: string): Promise<TermItem[]>;
776
+ removeTermsFromContent(contentId: string, termIds: string[]): Promise<void>;
777
+ private recalculateTermCounts;
778
+ createMedia(item: Omit<MediaItem, "id" | "createdAt" | "updatedAt">): Promise<MediaItem>;
779
+ getMedia(id: string): Promise<MediaItem | null>;
780
+ findMedia(options?: {
781
+ search?: string;
782
+ mimeType?: string;
783
+ authorId?: string;
784
+ limit?: number;
785
+ offset?: number;
786
+ }): Promise<PaginatedResult<MediaItem>>;
787
+ updateMedia(id: string, updates: Partial<Omit<MediaItem, "id" | "createdAt">>): Promise<MediaItem | null>;
788
+ deleteMedia(id: string): Promise<boolean>;
789
+ getOption<T = unknown>(key: string): Promise<OptionItem<T> | null>;
790
+ setOption<T = unknown>(item: OptionItem<T>): Promise<void>;
791
+ deleteOption(key: string): Promise<boolean>;
792
+ getOptions(namespace?: string): Promise<OptionItem[]>;
793
+ }
794
+ //#endregion
795
+ //#region src/api/router.d.ts
796
+ declare class CMSRouter {
797
+ private engine;
798
+ constructor(engine: CMSEngine);
799
+ /**
800
+ * Universal Web Standards request handler.
801
+ */
802
+ handle(request: Request): Promise<Response>;
803
+ private handleContent;
804
+ private handleTaxonomies;
805
+ private handleMedia;
806
+ private handleOptions;
807
+ }
808
+ declare function createCMSRouter(engine: CMSEngine): CMSRouter;
809
+ //#endregion
810
+ //#region src/client/cms-client.d.ts
811
+ interface CMSClientOptions {
812
+ engine?: CMSEngine;
813
+ baseUrl?: string;
814
+ fetch?: typeof globalThis.fetch;
815
+ headers?: Record<string, string>;
816
+ }
817
+ interface ClientCollectionApi<TData extends Record<string, unknown> = Record<string, unknown>> {
818
+ find(options?: ContentQueryOptions): Promise<PaginatedResult<ContentItem<TData>>>;
819
+ findById(id: string): Promise<ContentItem<TData> | null>;
820
+ findBySlug(slug: string): Promise<ContentItem<TData> | null>;
821
+ create(data: Record<string, unknown>): Promise<ContentItem<TData>>;
822
+ update(id: string, data: Record<string, unknown>): Promise<ContentItem<TData> | null>;
823
+ delete(id: string): Promise<boolean>;
824
+ }
825
+ declare class CMSClient {
826
+ private engine?;
827
+ private baseUrl?;
828
+ private fetchFn;
829
+ private headers;
830
+ constructor(options: CMSClientOptions);
831
+ collection<TData extends Record<string, unknown> = Record<string, unknown>>(slug: string): ClientCollectionApi<TData>;
832
+ readonly taxonomies: {
833
+ getTerms: (taxonomy: string) => Promise<TermItem[]>;
834
+ getTree: (taxonomy: string) => Promise<TermTreeItem[]>;
835
+ };
836
+ readonly media: {
837
+ find: (options?: {
838
+ search?: string;
839
+ limit?: number;
840
+ }) => Promise<PaginatedResult<MediaItem>>;
841
+ get: (id: string) => Promise<MediaItem | null>;
842
+ };
843
+ readonly options: {
844
+ get: <T = unknown>(key: string, defaultValue?: T) => Promise<T | undefined>;
845
+ };
846
+ private request;
847
+ }
848
+ declare function createCmsClient(options: CMSClientOptions): CMSClient;
849
+ //#endregion
850
+ export { type ActionCallback, type BooleanFieldOptions, CMSCapability, CMSClient, type CMSClientOptions, CMSConfig, CMSEngine, CMSRouter, type CMSStorageAdapter, CMSUser, type ClientCollectionApi, CollectionConfig, type CollectionOptions, type CollectionService, ContentItem, ContentLifecycle, ContentQueryOptions, ContentStatus, type CreateContentInput, DEFAULT_COLLECTIONS, DEFAULT_ROLE_CAPABILITIES, type DateFieldOptions, FieldDefinition, FieldType, type FilterCallback, type HookEntry, HooksManager, type ImageFieldOptions, type JsonFieldOptions, MediaItem, MediaManager, type MediaUploadInput, MemoryStorageAdapter, type NumberFieldOptions, OptionItem, OptionsManager, PaginatedResult, RBACManager, type RelationshipFieldOptions, type RepeaterFieldOptions, RevisionDiff, RevisionDiffField, RevisionManager, RevisionRecord, type RichTextFieldOptions, type SelectFieldOptions, SelectOption, SiteConfig, type SlugFieldOptions, type SyncFilterCallback, TaxonomyConfig, type TaxonomyFieldOptions, TaxonomyManager, TermItem, TermTreeItem, type TextFieldOptions, type UpdateContentInput, UserRole, VALID_STATUS_TRANSITIONS, collection, createCMSEngine, createCMSRouter, createCmsClient, defaultHooks, defineConfig, fields, normalizeConfig, resolveUniqueSlug, slugify, validateAndNormalizeData };
851
+ //# sourceMappingURL=index.d.mts.map