@zenith-open/zenithcms-types 1.0.0-beta.5 → 1.0.0-beta.8

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.
@@ -18,22 +18,22 @@ export interface DatabaseAdapter {
18
18
  getNativeClient<T = any>(): T;
19
19
  /** Escape hatch for executing raw DDL/SQL queries directly */
20
20
  executeRaw(query: string, params?: any[]): Promise<any>;
21
- find<T = any>(collection: string, query: Record<string, any>, options?: FindOptions): Promise<T[]>;
22
- findOne<T = any>(collection: string, query: Record<string, any>, options?: BaseOptions): Promise<T | null>;
21
+ find<T = any>(collection: string, query: ZenithQueryAST, options?: FindOptions): Promise<T[]>;
22
+ findOne<T = any>(collection: string, query: ZenithQueryAST, options?: BaseOptions): Promise<T | null>;
23
23
  findMany<T = any>(collection: string, ids: string[], options?: BaseOptions): Promise<T[]>;
24
24
  create<T = any>(collection: string, data: Partial<T>, options?: BaseOptions): Promise<T>;
25
25
  update<T = any>(collection: string, id: string, data: Partial<T>, options?: BaseOptions): Promise<T | null>;
26
- updateMany(collection: string, query: Record<string, any>, data: any, options?: BaseOptions): Promise<number>;
26
+ updateMany(collection: string, query: ZenithQueryAST, data: any, options?: BaseOptions): Promise<number>;
27
27
  delete(collection: string, id: string, options?: BaseOptions): Promise<boolean>;
28
- deleteMany(collection: string, query: Record<string, any>, options?: BaseOptions): Promise<number>;
29
- count(collection: string, query: Record<string, any>): Promise<number>;
28
+ deleteMany(collection: string, query: ZenithQueryAST, options?: BaseOptions): Promise<number>;
29
+ count(collection: string, query: ZenithQueryAST): Promise<number>;
30
30
  aggregate<T = any>(collection: string, pipeline: any[], options?: BaseOptions): Promise<T[]>;
31
31
  /**
32
32
  * Atomically finds a single document and updates it, returning either
33
33
  * the original (returnDocument: 'before') or updated (returnDocument: 'after') document.
34
34
  * Returns null if no document matches the query.
35
35
  */
36
- findOneAndUpdate<T = any>(collection: string, query: Record<string, any>, update: Record<string, any>, options?: BaseOptions & {
36
+ findOneAndUpdate<T = any>(collection: string, query: ZenithQueryAST, update: Record<string, any>, options?: BaseOptions & {
37
37
  returnDocument?: 'before' | 'after';
38
38
  }): Promise<T | null>;
39
39
  /**
@@ -115,3 +115,27 @@ export interface WebhookDeliveryRecord {
115
115
  responseStatus?: number;
116
116
  timestamp: Date | string;
117
117
  }
118
+ /**
119
+ * ZenithQueryAST Formal Specification
120
+ * ───────────────────────────────────
121
+ * Standardized cross-database query language.
122
+ * Currently mimics MongoDB syntax due to historical reasons,
123
+ * but formally documents it so adapters (e.g. Postgres) know exactly what to parse.
124
+ */
125
+ export type ZenithQueryAST = {
126
+ $and?: ZenithQueryAST[];
127
+ $or?: ZenithQueryAST[];
128
+ [field: string]: any | {
129
+ $eq?: any;
130
+ $ne?: any;
131
+ $in?: any[];
132
+ $nin?: any[];
133
+ $gt?: number | Date | string;
134
+ $gte?: number | Date | string;
135
+ $lt?: number | Date | string;
136
+ $lte?: number | Date | string;
137
+ $exists?: boolean;
138
+ $regex?: string | RegExp;
139
+ $options?: string;
140
+ };
141
+ };
@@ -4,11 +4,20 @@
4
4
  * DO NOT MODIFY MANUALLY.
5
5
  */
6
6
  export interface ZenithDocument {
7
- _id: string;
7
+ id: string;
8
8
  createdAt: string;
9
9
  updatedAt: string;
10
10
  status?: 'draft' | 'published' | 'archived' | string;
11
11
  }
12
+ export interface ExternalUsers extends ZenithDocument {
13
+ name?: string;
14
+ email?: string;
15
+ phone?: string;
16
+ }
17
+ export interface Media extends ZenithDocument {
18
+ alt: string;
19
+ url: string;
20
+ }
12
21
  export interface Authors extends ZenithDocument {
13
22
  name: string;
14
23
  avatar?: {
@@ -19,17 +28,16 @@ export interface Authors extends ZenithDocument {
19
28
  }
20
29
  export interface Posts extends ZenithDocument {
21
30
  title: string;
22
- coverImage?: {
23
- url: string;
24
- alt?: string;
25
- };
26
- content?: string;
31
+ slug: string;
32
+ content: string;
27
33
  publishedAt?: string | Date;
28
- author?: Record<string, any>;
34
+ authors?: Users | null;
35
+ categories?: Categories | null;
36
+ status?: ('draft' | 'published');
29
37
  }
30
38
  export interface Categories extends ZenithDocument {
31
39
  title: string;
32
- slug: string;
40
+ description?: string;
33
41
  }
34
42
  export interface Products extends ZenithDocument {
35
43
  name: string;
@@ -88,27 +96,8 @@ export interface ZApiKeys extends ZenithDocument {
88
96
  allowedCollections?: Record<string, any>;
89
97
  }
90
98
  export interface Users extends ZenithDocument {
91
- email: string;
92
- username?: string;
93
- displayName?: string;
94
- password: string;
95
- role?: ('admin' | 'editor' | 'viewer');
96
- failedLoginAttempts?: number;
97
- lockUntil?: string | Date;
98
- emailVerified?: boolean;
99
- verificationToken?: string;
100
- verificationTokenExpiry?: string | Date;
101
- twoFactorSecret?: string;
102
- twoFactorEnabled?: boolean;
103
- oauthProviders?: Record<string, any>;
104
- }
105
- export interface Media extends ZenithDocument {
106
- name?: string;
107
- url?: string;
108
- alt?: string;
109
- folder?: string;
110
- mimetype?: string;
111
- size?: number;
99
+ name: string;
100
+ role: ('admin' | 'editor' | 'user');
112
101
  }
113
102
  export interface SiteSettings extends ZenithDocument {
114
103
  siteName: string;
@@ -143,6 +132,8 @@ export interface SiteSettings extends ZenithDocument {
143
132
  }[];
144
133
  }
145
134
  export interface ZenithCollections {
135
+ 'external_users': ExternalUsers;
136
+ 'media': Media;
146
137
  'authors': Authors;
147
138
  'posts': Posts;
148
139
  'categories': Categories;
@@ -151,7 +142,6 @@ export interface ZenithCollections {
151
142
  'z_roles': ZRoles;
152
143
  'z_api_keys': ZApiKeys;
153
144
  'users': Users;
154
- 'media': Media;
155
145
  'site-settings': SiteSettings;
156
146
  }
157
147
  /**
package/dist/index.d.ts CHANGED
@@ -182,6 +182,24 @@ export interface CollectionConfig {
182
182
  plural: string;
183
183
  };
184
184
  fields: FieldConfig[];
185
+ federation?: {
186
+ enabled: boolean;
187
+ provider: 'rest' | 'graphql' | 'custom';
188
+ endpoint: string;
189
+ headers?: Record<string, string>;
190
+ methods?: {
191
+ find?: string;
192
+ findById?: string;
193
+ create?: string;
194
+ update?: string;
195
+ delete?: string;
196
+ };
197
+ mapping?: {
198
+ id?: string;
199
+ results?: string;
200
+ total?: string;
201
+ };
202
+ };
185
203
  drafts?: boolean;
186
204
  seo?: boolean;
187
205
  timestamps?: boolean;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,aAAa,CAAA;AAgY3B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,aAAa,CAAA;AAkZ3B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenith-open/zenithcms-types",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },