@zenith-open/zenithcms-types 0.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.
- package/dist/database.d.ts +111 -0
- package/dist/database.js +2 -0
- package/dist/database.js.map +1 -0
- package/dist/generated.d.ts +138 -0
- package/dist/generated.js +7 -0
- package/dist/generated.js.map +1 -0
- package/dist/index.d.ts +353 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -0
- package/src/database.d.ts +84 -0
- package/src/database.js +1 -0
- package/src/database.js.map +1 -0
- package/src/database.ts +164 -0
- package/src/generated.d.ts +274 -0
- package/src/generated.js +7 -0
- package/src/generated.js.map +1 -0
- package/src/generated.ts +143 -0
- package/src/index.d.ts +193 -0
- package/src/index.js +9 -0
- package/src/index.js.map +1 -0
- package/src/index.ts +378 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { CollectionConfig } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* Zenith Database Adapter Contract
|
|
4
|
+
* ────────────────────────────────
|
|
5
|
+
* Hardened interface for database agnostic operations.
|
|
6
|
+
* Use generics <T> to ensure type safety in higher level services.
|
|
7
|
+
*/
|
|
8
|
+
export interface DatabaseAdapter {
|
|
9
|
+
name: string;
|
|
10
|
+
connect(): Promise<void>;
|
|
11
|
+
disconnect(): Promise<void>;
|
|
12
|
+
getHealth(): 'ok' | 'connecting' | 'disconnected' | 'error';
|
|
13
|
+
/** Syncs the provided collection config with the physical DB schema */
|
|
14
|
+
registerCollection(config: CollectionConfig): Promise<void>;
|
|
15
|
+
/** Lists all existing collections/tables in the database */
|
|
16
|
+
getExistingCollections(): Promise<string[]>;
|
|
17
|
+
find<T = unknown>(collection: string, query: Record<string, unknown>, options?: FindOptions): Promise<T[]>;
|
|
18
|
+
findOne<T = unknown>(collection: string, query: Record<string, unknown>, options?: BaseOptions): Promise<T | null>;
|
|
19
|
+
create<T = unknown>(collection: string, data: Partial<T>, options?: BaseOptions): Promise<T>;
|
|
20
|
+
update<T = unknown>(collection: string, id: string, data: Partial<T>, options?: BaseOptions): Promise<T | null>;
|
|
21
|
+
updateMany(collection: string, query: Record<string, unknown>, data: unknown, options?: BaseOptions): Promise<number>;
|
|
22
|
+
delete(collection: string, id: string, options?: BaseOptions): Promise<boolean>;
|
|
23
|
+
deleteMany(collection: string, query: Record<string, unknown>, options?: BaseOptions): Promise<number>;
|
|
24
|
+
count(collection: string, query: Record<string, unknown>): Promise<number>;
|
|
25
|
+
aggregate<T = unknown>(collection: string, pipeline: unknown[], options?: BaseOptions): Promise<T[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Atomically finds a single document and updates it, returning either
|
|
28
|
+
* the original (returnDocument: 'before') or updated (returnDocument: 'after') document.
|
|
29
|
+
* Returns null if no document matches the query.
|
|
30
|
+
*/
|
|
31
|
+
findOneAndUpdate<T = unknown>(collection: string, query: Record<string, unknown>, update: Record<string, unknown>, options?: BaseOptions & {
|
|
32
|
+
returnDocument?: 'before' | 'after';
|
|
33
|
+
}): Promise<T | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Executes multiple operations in a transaction.
|
|
36
|
+
* If the adapter does not support transactions (e.g. standalone Mongo),
|
|
37
|
+
* this will execute the function without a transaction context.
|
|
38
|
+
*/
|
|
39
|
+
transaction<T>(fn: (session: unknown) => Promise<T>): Promise<T>;
|
|
40
|
+
createAuditLog(data: AuditLogData, options?: BaseOptions): Promise<void>;
|
|
41
|
+
createVersion(data: VersionData, options?: BaseOptions): Promise<void>;
|
|
42
|
+
getVersions(collection: string, documentId: string): Promise<VersionData[]>;
|
|
43
|
+
createWebhookDelivery(data: WebhookDeliveryData): Promise<void>;
|
|
44
|
+
getWebhookDeliveries(webhookId: string, limit?: number): Promise<WebhookDeliveryRecord[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Full-text / pattern search across specified fields in a collection.
|
|
47
|
+
* Each adapter translates this into its native search primitive
|
|
48
|
+
* (MongoDB $regex/$text, Postgres ILIKE/pg_trgm).
|
|
49
|
+
*/
|
|
50
|
+
search<T = unknown>(collection: string, query: string, fields: string[], limit?: number, options?: BaseOptions): Promise<T[]>;
|
|
51
|
+
}
|
|
52
|
+
export interface BaseOptions {
|
|
53
|
+
session?: unknown;
|
|
54
|
+
tenantId?: string;
|
|
55
|
+
siteId?: string;
|
|
56
|
+
expectedVersion?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface FindOptions extends BaseOptions {
|
|
59
|
+
sort?: string | Record<string, unknown>;
|
|
60
|
+
skip?: number;
|
|
61
|
+
limit?: number;
|
|
62
|
+
select?: string | string[];
|
|
63
|
+
populate?: string | string[];
|
|
64
|
+
}
|
|
65
|
+
export interface AuditLogData {
|
|
66
|
+
userId: string;
|
|
67
|
+
userEmail: string;
|
|
68
|
+
userName?: string;
|
|
69
|
+
action: string;
|
|
70
|
+
collectionName: string;
|
|
71
|
+
documentId?: string;
|
|
72
|
+
changes?: unknown;
|
|
73
|
+
ip?: string;
|
|
74
|
+
userAgent?: string;
|
|
75
|
+
timestamp?: Date;
|
|
76
|
+
status?: 'success' | 'failed';
|
|
77
|
+
resource?: string;
|
|
78
|
+
siteId?: string;
|
|
79
|
+
hash?: string;
|
|
80
|
+
previousHash?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface VersionData {
|
|
83
|
+
collectionName: string;
|
|
84
|
+
collectionSlug: string;
|
|
85
|
+
documentId: string;
|
|
86
|
+
snapshot: unknown;
|
|
87
|
+
delta?: unknown;
|
|
88
|
+
createdBy: string;
|
|
89
|
+
timestamp: Date;
|
|
90
|
+
}
|
|
91
|
+
export interface WebhookDeliveryData {
|
|
92
|
+
webhookId?: string;
|
|
93
|
+
collectionSlug?: string;
|
|
94
|
+
event: string;
|
|
95
|
+
url: string;
|
|
96
|
+
payload?: unknown;
|
|
97
|
+
success: boolean;
|
|
98
|
+
responseStatus?: number;
|
|
99
|
+
timestamp?: Date;
|
|
100
|
+
}
|
|
101
|
+
export interface WebhookDeliveryRecord {
|
|
102
|
+
id: string;
|
|
103
|
+
webhookId?: string;
|
|
104
|
+
collectionSlug?: string;
|
|
105
|
+
event: string;
|
|
106
|
+
url: string;
|
|
107
|
+
payload?: unknown;
|
|
108
|
+
success: boolean;
|
|
109
|
+
responseStatus?: number;
|
|
110
|
+
timestamp: Date | string;
|
|
111
|
+
}
|
package/dist/database.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zenith Auto-Generated TypeScript Definitions
|
|
3
|
+
* This file is automatically re-compiled on database register & boot.
|
|
4
|
+
* DO NOT MODIFY MANUALLY.
|
|
5
|
+
*/
|
|
6
|
+
export interface ZenithDocument {
|
|
7
|
+
_id: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
status?: 'draft' | 'published' | 'archived' | string;
|
|
11
|
+
}
|
|
12
|
+
export interface Authors extends ZenithDocument {
|
|
13
|
+
name: string;
|
|
14
|
+
avatar?: {
|
|
15
|
+
url: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
};
|
|
18
|
+
bio?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface Posts extends ZenithDocument {
|
|
21
|
+
title: string;
|
|
22
|
+
coverImage?: {
|
|
23
|
+
url: string;
|
|
24
|
+
alt?: string;
|
|
25
|
+
};
|
|
26
|
+
content?: string;
|
|
27
|
+
publishedAt?: string | Date;
|
|
28
|
+
author?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export interface Categories extends ZenithDocument {
|
|
31
|
+
title: string;
|
|
32
|
+
slug: string;
|
|
33
|
+
}
|
|
34
|
+
export interface Products extends ZenithDocument {
|
|
35
|
+
name: string;
|
|
36
|
+
slug: string;
|
|
37
|
+
price: number;
|
|
38
|
+
description?: string;
|
|
39
|
+
gallery?: {
|
|
40
|
+
image?: {
|
|
41
|
+
url: string;
|
|
42
|
+
alt?: string;
|
|
43
|
+
};
|
|
44
|
+
}[];
|
|
45
|
+
inStock?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface Pages extends ZenithDocument {
|
|
48
|
+
title: string;
|
|
49
|
+
slug: string;
|
|
50
|
+
layout?: ({
|
|
51
|
+
blockType: 'undefined';
|
|
52
|
+
} | {
|
|
53
|
+
blockType: 'undefined';
|
|
54
|
+
} | {
|
|
55
|
+
blockType: 'undefined';
|
|
56
|
+
} | {
|
|
57
|
+
blockType: 'undefined';
|
|
58
|
+
} | {
|
|
59
|
+
blockType: 'undefined';
|
|
60
|
+
} | {
|
|
61
|
+
blockType: 'undefined';
|
|
62
|
+
} | {
|
|
63
|
+
blockType: 'undefined';
|
|
64
|
+
} | {
|
|
65
|
+
blockType: 'undefined';
|
|
66
|
+
} | {
|
|
67
|
+
blockType: 'undefined';
|
|
68
|
+
} | {
|
|
69
|
+
blockType: 'undefined';
|
|
70
|
+
} | {
|
|
71
|
+
blockType: 'undefined';
|
|
72
|
+
})[];
|
|
73
|
+
}
|
|
74
|
+
export interface AuditTarget1781217670604 extends ZenithDocument {
|
|
75
|
+
title: string;
|
|
76
|
+
}
|
|
77
|
+
export interface Media extends ZenithDocument {
|
|
78
|
+
name?: string;
|
|
79
|
+
url?: string;
|
|
80
|
+
alt?: string;
|
|
81
|
+
folder?: string;
|
|
82
|
+
mimetype?: string;
|
|
83
|
+
size?: number;
|
|
84
|
+
}
|
|
85
|
+
export interface SiteSettings extends ZenithDocument {
|
|
86
|
+
siteName: string;
|
|
87
|
+
supportEmail?: string;
|
|
88
|
+
logo?: {
|
|
89
|
+
url: string;
|
|
90
|
+
alt?: string;
|
|
91
|
+
};
|
|
92
|
+
favicon?: {
|
|
93
|
+
url: string;
|
|
94
|
+
alt?: string;
|
|
95
|
+
};
|
|
96
|
+
primaryColor?: string;
|
|
97
|
+
metaTitle?: string;
|
|
98
|
+
metaDescription?: string;
|
|
99
|
+
ogImage?: {
|
|
100
|
+
url: string;
|
|
101
|
+
alt?: string;
|
|
102
|
+
};
|
|
103
|
+
socialLinks?: {
|
|
104
|
+
platform?: ('Twitter' | 'Instagram' | 'Facebook' | 'LinkedIn' | 'GitHub' | 'YouTube');
|
|
105
|
+
url?: string;
|
|
106
|
+
}[];
|
|
107
|
+
copyrightText?: string;
|
|
108
|
+
headerLinks?: {
|
|
109
|
+
label: string;
|
|
110
|
+
url: string;
|
|
111
|
+
}[];
|
|
112
|
+
footerLinks?: {
|
|
113
|
+
label: string;
|
|
114
|
+
url: string;
|
|
115
|
+
}[];
|
|
116
|
+
}
|
|
117
|
+
export interface ZenithCollections {
|
|
118
|
+
'authors': Authors;
|
|
119
|
+
'posts': Posts;
|
|
120
|
+
'categories': Categories;
|
|
121
|
+
'products': Products;
|
|
122
|
+
'pages': Pages;
|
|
123
|
+
'audit-target-1781217670604': AuditTarget1781217670604;
|
|
124
|
+
'media': Media;
|
|
125
|
+
'site-settings': SiteSettings;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Fully Typed React SDK Data Hook Mappings
|
|
129
|
+
*/
|
|
130
|
+
export type ZenithQuery<T> = {
|
|
131
|
+
where?: Record<string, any>;
|
|
132
|
+
sort?: string | Record<string, any>;
|
|
133
|
+
limit?: number;
|
|
134
|
+
skip?: number;
|
|
135
|
+
select?: string[];
|
|
136
|
+
populate?: string[];
|
|
137
|
+
locale?: string;
|
|
138
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated.js","sourceRoot":"","sources":["../src/generated.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zenith CMS — Core Type System
|
|
3
|
+
* ─────────────────────────────
|
|
4
|
+
* Strictly typed configuration schema for collections, fields, and plugins.
|
|
5
|
+
* Uses Discriminated Unions for robust field-level validation and IntelliSense.
|
|
6
|
+
*/
|
|
7
|
+
import type React from 'react';
|
|
8
|
+
export interface ZenithDocument {
|
|
9
|
+
_id?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
siteId?: string | null;
|
|
12
|
+
_status?: 'draft' | 'published' | string;
|
|
13
|
+
_version?: number;
|
|
14
|
+
workflowStatus?: string;
|
|
15
|
+
deletedAt?: Date | null;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
export type FieldType = 'text' | 'number' | 'email' | 'textarea' | 'checkbox' | 'date' | 'select' | 'media' | 'richtext' | 'json' | 'group' | 'tabs' | 'array' | 'relation' | 'blocks' | 'boolean' | 'code' | 'collapsible' | 'join' | 'point' | 'radio' | 'row' | 'ui' | 'dz';
|
|
19
|
+
export interface BlockDefinition {
|
|
20
|
+
slug: string;
|
|
21
|
+
labels?: {
|
|
22
|
+
singular: string;
|
|
23
|
+
plural: string;
|
|
24
|
+
};
|
|
25
|
+
fields: FieldConfig[];
|
|
26
|
+
admin?: {
|
|
27
|
+
description?: string;
|
|
28
|
+
icon?: string;
|
|
29
|
+
imageURL?: string;
|
|
30
|
+
category?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface FieldAdminConfig {
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
hidden?: boolean;
|
|
37
|
+
readOnly?: boolean;
|
|
38
|
+
width?: string;
|
|
39
|
+
condition?: (data: unknown, siblingData: unknown) => boolean;
|
|
40
|
+
readAccess?: string[];
|
|
41
|
+
writeAccess?: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface BaseFieldConfig {
|
|
44
|
+
name: string;
|
|
45
|
+
label?: string;
|
|
46
|
+
required?: boolean;
|
|
47
|
+
unique?: boolean;
|
|
48
|
+
localized?: boolean;
|
|
49
|
+
virtual?: boolean;
|
|
50
|
+
defaultValue?: unknown;
|
|
51
|
+
admin?: FieldAdminConfig;
|
|
52
|
+
hooks?: {
|
|
53
|
+
beforeChange?: (value: unknown) => unknown | Promise<unknown>;
|
|
54
|
+
afterRead?: (value: unknown) => unknown | Promise<unknown>;
|
|
55
|
+
validate?: (value: unknown, data: unknown) => boolean | string | Promise<boolean | string>;
|
|
56
|
+
};
|
|
57
|
+
access?: {
|
|
58
|
+
read?: (user: unknown) => boolean;
|
|
59
|
+
update?: (user: unknown) => boolean;
|
|
60
|
+
create?: (user: unknown) => boolean;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface TextFieldConfig extends BaseFieldConfig {
|
|
64
|
+
type: 'text' | 'email' | 'textarea' | 'password' | 'uid' | 'color';
|
|
65
|
+
minLength?: number;
|
|
66
|
+
maxLength?: number;
|
|
67
|
+
}
|
|
68
|
+
export interface NumberFieldConfig extends BaseFieldConfig {
|
|
69
|
+
type: 'number';
|
|
70
|
+
min?: number;
|
|
71
|
+
max?: number;
|
|
72
|
+
}
|
|
73
|
+
export interface CheckboxFieldConfig extends BaseFieldConfig {
|
|
74
|
+
type: 'checkbox' | 'boolean';
|
|
75
|
+
}
|
|
76
|
+
export interface SelectFieldConfig extends BaseFieldConfig {
|
|
77
|
+
type: 'select';
|
|
78
|
+
options: (string | {
|
|
79
|
+
label: string;
|
|
80
|
+
value: string;
|
|
81
|
+
})[];
|
|
82
|
+
hasMany?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export interface MediaFieldConfig extends BaseFieldConfig {
|
|
85
|
+
type: 'media';
|
|
86
|
+
hasMany?: boolean;
|
|
87
|
+
options?: {
|
|
88
|
+
focalPoint?: boolean;
|
|
89
|
+
blurhash?: boolean;
|
|
90
|
+
responsive?: boolean;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export type OnDeletePolicy = 'SET_NULL' | 'CASCADE' | 'RESTRICT' | 'NO_ACTION';
|
|
94
|
+
export interface RelationFieldConfig extends BaseFieldConfig {
|
|
95
|
+
type: 'relation';
|
|
96
|
+
relationTo: string | string[];
|
|
97
|
+
hasMany?: boolean;
|
|
98
|
+
junctionTable?: string;
|
|
99
|
+
pivotFields?: FieldConfig[];
|
|
100
|
+
onDelete?: OnDeletePolicy;
|
|
101
|
+
}
|
|
102
|
+
export interface ArrayFieldConfig extends BaseFieldConfig {
|
|
103
|
+
type: 'array';
|
|
104
|
+
fields: FieldConfig[];
|
|
105
|
+
minRows?: number;
|
|
106
|
+
maxRows?: number;
|
|
107
|
+
}
|
|
108
|
+
export interface GroupFieldConfig extends BaseFieldConfig {
|
|
109
|
+
type: 'group';
|
|
110
|
+
fields: FieldConfig[];
|
|
111
|
+
}
|
|
112
|
+
export interface BlocksFieldConfig extends BaseFieldConfig {
|
|
113
|
+
type: 'blocks';
|
|
114
|
+
blocks: BlockDefinition[];
|
|
115
|
+
}
|
|
116
|
+
export interface RichTextFieldConfig extends BaseFieldConfig {
|
|
117
|
+
type: 'richtext';
|
|
118
|
+
format?: 'html' | 'json';
|
|
119
|
+
}
|
|
120
|
+
export interface BasicFieldConfig extends BaseFieldConfig {
|
|
121
|
+
type: 'date' | 'json';
|
|
122
|
+
}
|
|
123
|
+
export interface CodeFieldConfig extends BaseFieldConfig {
|
|
124
|
+
type: 'code';
|
|
125
|
+
language?: string;
|
|
126
|
+
minLength?: number;
|
|
127
|
+
maxLength?: number;
|
|
128
|
+
}
|
|
129
|
+
export interface CollapsibleFieldConfig extends BaseFieldConfig {
|
|
130
|
+
type: 'collapsible';
|
|
131
|
+
fields: FieldConfig[];
|
|
132
|
+
initCollapsed?: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface JoinFieldConfig extends Omit<BaseFieldConfig, 'required'> {
|
|
135
|
+
type: 'join';
|
|
136
|
+
collection: string | string[];
|
|
137
|
+
on: string;
|
|
138
|
+
maxDepth?: number;
|
|
139
|
+
where?: Record<string, unknown>;
|
|
140
|
+
defaultLimit?: number;
|
|
141
|
+
defaultSort?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface PointFieldConfig extends BaseFieldConfig {
|
|
144
|
+
type: 'point';
|
|
145
|
+
}
|
|
146
|
+
export interface RadioFieldConfig extends BaseFieldConfig {
|
|
147
|
+
type: 'radio';
|
|
148
|
+
options: (string | {
|
|
149
|
+
label: string;
|
|
150
|
+
value: string;
|
|
151
|
+
})[];
|
|
152
|
+
layout?: 'horizontal' | 'vertical';
|
|
153
|
+
}
|
|
154
|
+
export interface RowFieldConfig extends Omit<BaseFieldConfig, 'required' | 'unique' | 'localized' | 'virtual' | 'defaultValue' | 'admin' | 'hooks' | 'access'> {
|
|
155
|
+
type: 'row';
|
|
156
|
+
fields: FieldConfig[];
|
|
157
|
+
admin?: {
|
|
158
|
+
className?: string;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export interface UIFieldConfig extends Omit<BaseFieldConfig, 'required' | 'unique' | 'localized' | 'virtual' | 'defaultValue' | 'hooks' | 'access'> {
|
|
162
|
+
type: 'ui';
|
|
163
|
+
admin?: {
|
|
164
|
+
components?: {
|
|
165
|
+
Field?: React.ComponentType<unknown>;
|
|
166
|
+
};
|
|
167
|
+
condition?: (data: unknown, siblingData: unknown) => boolean;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
export interface DZFieldConfig extends BaseFieldConfig {
|
|
171
|
+
type: 'dz';
|
|
172
|
+
/** List of available component types (block slugs) for this dynamic zone */
|
|
173
|
+
components?: string[];
|
|
174
|
+
}
|
|
175
|
+
export type FieldConfig = TextFieldConfig | NumberFieldConfig | CheckboxFieldConfig | SelectFieldConfig | MediaFieldConfig | RelationFieldConfig | ArrayFieldConfig | GroupFieldConfig | BlocksFieldConfig | RichTextFieldConfig | BasicFieldConfig | CodeFieldConfig | CollapsibleFieldConfig | JoinFieldConfig | PointFieldConfig | RadioFieldConfig | RowFieldConfig | UIFieldConfig | DZFieldConfig;
|
|
176
|
+
export interface CollectionConfig {
|
|
177
|
+
name: string;
|
|
178
|
+
slug: string;
|
|
179
|
+
labels?: {
|
|
180
|
+
singular: string;
|
|
181
|
+
plural: string;
|
|
182
|
+
};
|
|
183
|
+
fields: FieldConfig[];
|
|
184
|
+
drafts?: boolean;
|
|
185
|
+
seo?: boolean;
|
|
186
|
+
timestamps?: boolean;
|
|
187
|
+
singleton?: boolean;
|
|
188
|
+
versions?: boolean;
|
|
189
|
+
maxVersions?: number;
|
|
190
|
+
scheduling?: boolean;
|
|
191
|
+
publicRead?: boolean;
|
|
192
|
+
softDelete?: boolean;
|
|
193
|
+
hooks?: {
|
|
194
|
+
beforeValidate?: (data: unknown, user: unknown, context: {
|
|
195
|
+
hookType: string;
|
|
196
|
+
}) => unknown | Promise<unknown>;
|
|
197
|
+
beforeCreate?: (data: unknown, user: unknown, context: {
|
|
198
|
+
hookType: string;
|
|
199
|
+
}) => unknown | Promise<unknown>;
|
|
200
|
+
afterCreate?: (doc: unknown, user: unknown, context: {
|
|
201
|
+
hookType: string;
|
|
202
|
+
}) => void | Promise<void>;
|
|
203
|
+
beforeUpdate?: (data: unknown, user: unknown, context: {
|
|
204
|
+
hookType: string;
|
|
205
|
+
}) => unknown | Promise<unknown>;
|
|
206
|
+
afterUpdate?: (doc: unknown, user: unknown, context: {
|
|
207
|
+
hookType: string;
|
|
208
|
+
}) => void | Promise<void>;
|
|
209
|
+
beforeDelete?: (id: string, user: unknown, context: {
|
|
210
|
+
hookType: string;
|
|
211
|
+
}) => void | Promise<void>;
|
|
212
|
+
afterDelete?: (id: string, user: unknown, context: {
|
|
213
|
+
hookType: string;
|
|
214
|
+
}) => void | Promise<void>;
|
|
215
|
+
afterRead?: (doc: unknown, user: unknown, context: {
|
|
216
|
+
hookType: string;
|
|
217
|
+
}) => unknown | Promise<unknown>;
|
|
218
|
+
afterError?: (error: Error, data: unknown, user: unknown) => void | Promise<void>;
|
|
219
|
+
};
|
|
220
|
+
access?: {
|
|
221
|
+
/** Return false to deny, or an object to merge as query constraints (Row-Level Security). */
|
|
222
|
+
read?: (user: unknown, context?: {
|
|
223
|
+
req?: unknown;
|
|
224
|
+
}) => boolean | object;
|
|
225
|
+
/** Return false to deny, or an object to constrain which documents the user may create. */
|
|
226
|
+
create?: (user: unknown, context?: {
|
|
227
|
+
req?: unknown;
|
|
228
|
+
}) => boolean;
|
|
229
|
+
/** Return false to deny, or an object to constrain which documents the user may update. */
|
|
230
|
+
update?: (user: unknown, context?: {
|
|
231
|
+
req?: unknown;
|
|
232
|
+
}) => boolean | object;
|
|
233
|
+
/** Return false to deny, or an object to constrain which documents the user may delete. */
|
|
234
|
+
delete?: (user: unknown, context?: {
|
|
235
|
+
req?: unknown;
|
|
236
|
+
}) => boolean | object;
|
|
237
|
+
};
|
|
238
|
+
admin?: {
|
|
239
|
+
group?: string;
|
|
240
|
+
hidden?: boolean;
|
|
241
|
+
useAsTitle?: string;
|
|
242
|
+
displayTemplate?: string;
|
|
243
|
+
defaultColumns?: string[];
|
|
244
|
+
icon?: string;
|
|
245
|
+
previewUrl?: string | ((doc: unknown) => string);
|
|
246
|
+
};
|
|
247
|
+
endpoints?: {
|
|
248
|
+
path: string;
|
|
249
|
+
method: 'get' | 'post' | 'put' | 'delete' | 'patch';
|
|
250
|
+
handler: (req: unknown, res: unknown) => void | Promise<void>;
|
|
251
|
+
}[];
|
|
252
|
+
}
|
|
253
|
+
export type GlobalConfig = CollectionConfig;
|
|
254
|
+
export interface ZenithPlugin {
|
|
255
|
+
/** Unique identifier (slug). Use reverse-domain notation: `zenith-seo`, `acme-analytics` */
|
|
256
|
+
id: string;
|
|
257
|
+
/** Display name shown in admin UI */
|
|
258
|
+
name: string;
|
|
259
|
+
version?: string;
|
|
260
|
+
description?: string;
|
|
261
|
+
author?: string;
|
|
262
|
+
/** Plugin home page / documentation URL */
|
|
263
|
+
homepage?: string;
|
|
264
|
+
/** NPM package name if installable via package manager */
|
|
265
|
+
packageName?: string;
|
|
266
|
+
downloads?: number;
|
|
267
|
+
/** Minimum Zenith engine version required */
|
|
268
|
+
minEngineVersion?: string;
|
|
269
|
+
/** Other plugin IDs this plugin depends on */
|
|
270
|
+
dependencies?: string[];
|
|
271
|
+
/** Whether the plugin is active. Disabled plugins are not applied. */
|
|
272
|
+
enabled?: boolean;
|
|
273
|
+
/**
|
|
274
|
+
* JSON Schema for plugin configuration options.
|
|
275
|
+
* Used by the admin UI to render a settings form.
|
|
276
|
+
*/
|
|
277
|
+
configSchema?: Record<string, {
|
|
278
|
+
type: 'string' | 'number' | 'boolean' | 'select' | 'multiselect' | 'url' | 'secret';
|
|
279
|
+
label: string;
|
|
280
|
+
description?: string;
|
|
281
|
+
default?: unknown;
|
|
282
|
+
options?: Array<{
|
|
283
|
+
label: string;
|
|
284
|
+
value: string;
|
|
285
|
+
}>;
|
|
286
|
+
required?: boolean;
|
|
287
|
+
}>;
|
|
288
|
+
/** Runtime config values (set by admin UI) */
|
|
289
|
+
config?: Record<string, unknown>;
|
|
290
|
+
/**
|
|
291
|
+
* Transform the CMS config (add collections, fields, hooks, etc.).
|
|
292
|
+
* Called at engine bootstrap for each enabled plugin.
|
|
293
|
+
*/
|
|
294
|
+
apply: (config: CMSConfig, pluginConfig?: Record<string, unknown>) => CMSConfig | void;
|
|
295
|
+
/** Called after all plugins are applied, before routes are mounted */
|
|
296
|
+
onInit?: (ctx: PluginContext) => void | Promise<void>;
|
|
297
|
+
/** Called after the engine is fully started and listening */
|
|
298
|
+
onReady?: (ctx: PluginContext) => void | Promise<void>;
|
|
299
|
+
/** Called when the engine is shutting down */
|
|
300
|
+
onDestroy?: (ctx: PluginContext) => void | Promise<void>;
|
|
301
|
+
}
|
|
302
|
+
export interface PluginContext {
|
|
303
|
+
/** Express application instance */
|
|
304
|
+
app: unknown;
|
|
305
|
+
/** Active database adapter */
|
|
306
|
+
adapter: unknown;
|
|
307
|
+
/** Current CMS config (after all plugins applied) */
|
|
308
|
+
config: CMSConfig;
|
|
309
|
+
/** Hook registry — use to register lifecycle hooks */
|
|
310
|
+
hooks: {
|
|
311
|
+
on: <T = unknown>(hook: string, handler: (payload: T) => T | Promise<T> | void, priority?: number) => () => void;
|
|
312
|
+
emit: (hook: string, payload: unknown) => Promise<void>;
|
|
313
|
+
};
|
|
314
|
+
/** Register admin UI components */
|
|
315
|
+
admin: {
|
|
316
|
+
registerComponent: (slot: string, component: {
|
|
317
|
+
id: string;
|
|
318
|
+
label: string;
|
|
319
|
+
icon?: string;
|
|
320
|
+
}) => void;
|
|
321
|
+
};
|
|
322
|
+
/** Logger instance */
|
|
323
|
+
logger: {
|
|
324
|
+
info: (msg: string, meta?: Record<string, unknown>) => void;
|
|
325
|
+
warn: (msg: string, meta?: Record<string, unknown>) => void;
|
|
326
|
+
error: (msg: string, meta?: Record<string, unknown>) => void;
|
|
327
|
+
debug: (msg: string, meta?: Record<string, unknown>) => void;
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
export type DeploymentProvider = 'cloudflare' | 'netlify' | 'vercel' | 'custom';
|
|
331
|
+
export interface DeploymentConfig {
|
|
332
|
+
provider: DeploymentProvider;
|
|
333
|
+
hookUrl: string;
|
|
334
|
+
triggerOn?: string[];
|
|
335
|
+
autoTrigger?: boolean;
|
|
336
|
+
}
|
|
337
|
+
export interface WebhookTarget {
|
|
338
|
+
url: string;
|
|
339
|
+
events: string[];
|
|
340
|
+
secret?: string;
|
|
341
|
+
}
|
|
342
|
+
export interface CMSConfig {
|
|
343
|
+
collections: CollectionConfig[];
|
|
344
|
+
globals?: GlobalConfig[];
|
|
345
|
+
plugins?: ZenithPlugin[];
|
|
346
|
+
webhooks?: WebhookTarget[];
|
|
347
|
+
deployment?: DeploymentConfig;
|
|
348
|
+
cors?: {
|
|
349
|
+
origins: string[];
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
export * from './generated';
|
|
353
|
+
export * from './database';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zenith CMS — Core Type System
|
|
3
|
+
* ─────────────────────────────
|
|
4
|
+
* Strictly typed configuration schema for collections, fields, and plugins.
|
|
5
|
+
* Uses Discriminated Unions for robust field-level validation and IntelliSense.
|
|
6
|
+
*/
|
|
7
|
+
export * from './generated';
|
|
8
|
+
export * from './database';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmXH,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zenith-open/zenithcms-types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"lint": "echo 'Lint bypassed for types'"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"typescript": "^5.0.0"
|
|
15
|
+
}
|
|
16
|
+
}
|