@zenith-open/zenithcms-db-postgres 0.1.0 → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/PostgresDrizzleAdapter.d.ts +4 -20
- package/dist/PostgresDrizzleAdapter.js +118 -520
- package/dist/PostgresDrizzleAdapter.js.map +1 -1
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -0
- package/package.json +12 -9
- package/eslint.config.mjs +0 -26
- package/src/PostgresDrizzleAdapter.ts +0 -2239
- package/src/index.ts +0 -2
- package/src/query-ast.ts +0 -117
- package/tsconfig.eslint.json +0 -8
- package/tsconfig.json +0 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aman T Shekar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @zenith-open/zenithcms-db-postgres
|
|
2
|
+
|
|
3
|
+
The officially supported PostgreSQL persistence adapter for Zenith CMS, utilizing the Drizzle ORM layer.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Zenith CMS decouples business logic from database interactions via the `DatabaseAdapter` interface. This package implements that interface using Drizzle ORM, automatically mapping your `cms.config.ts` into strongly typed, highly optimized PostgreSQL tables.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @zenith-open/zenithcms-db-postgres
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
When booting the `ZenithEngine`, pass an instance of the `PostgresAdapter`.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { ZenithEngine } from '@zenith-open/zenithcms-core'
|
|
21
|
+
import { PostgresAdapter } from '@zenith-open/zenithcms-db-postgres'
|
|
22
|
+
import config from './cms.config'
|
|
23
|
+
|
|
24
|
+
const engine = new ZenithEngine({
|
|
25
|
+
config,
|
|
26
|
+
adapter: new PostgresAdapter({ uri: process.env.POSTGRES_URI }),
|
|
27
|
+
port: 3000
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
engine.start()
|
|
31
|
+
```
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
import { CollectionConfig, DatabaseAdapter, FindOptions, BaseOptions, AuditLogData, VersionData, WebhookDeliveryData, WebhookDeliveryRecord } from '@zenith-open/zenithcms-types';
|
|
2
|
-
export interface CacheLayer {
|
|
3
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
4
|
-
set<T>(key: string, value: T, collection: string): Promise<void>;
|
|
5
|
-
invalidate(collection: string): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export declare class LocalCacheLayer implements CacheLayer {
|
|
8
|
-
private cache;
|
|
9
|
-
constructor();
|
|
10
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
11
|
-
set<T>(key: string, value: T, collection: string): Promise<void>;
|
|
12
|
-
invalidate(collection: string): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export declare class RedisCacheLayer implements CacheLayer {
|
|
15
|
-
private redis;
|
|
16
|
-
constructor(redisUrl: string);
|
|
17
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
18
|
-
set<T>(key: string, value: T, collection: string): Promise<void>;
|
|
19
|
-
invalidate(collection: string): Promise<void>;
|
|
20
|
-
}
|
|
21
2
|
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
|
22
3
|
/**
|
|
23
4
|
* PostgreSQL Database Adapter with Drizzle ORM
|
|
@@ -47,6 +28,8 @@ export declare class PostgresDrizzleAdapter implements DatabaseAdapter {
|
|
|
47
28
|
*/
|
|
48
29
|
runWithTenantContext<T>(siteId: string | undefined, operation: (tx: any) => Promise<T>): Promise<T>;
|
|
49
30
|
registerTenant(tenantId: string, tenantConnectionString: string): Promise<void>;
|
|
31
|
+
getNativeClient<T = any>(): T;
|
|
32
|
+
executeRaw(query: string, params?: any[]): Promise<any>;
|
|
50
33
|
private getDbClient;
|
|
51
34
|
connect(): Promise<void>;
|
|
52
35
|
disconnect(): Promise<void>;
|
|
@@ -66,6 +49,7 @@ export declare class PostgresDrizzleAdapter implements DatabaseAdapter {
|
|
|
66
49
|
private mapAstToDrizzle;
|
|
67
50
|
find<T = unknown>(collection: string, query: Record<string, unknown>, options?: FindOptions): Promise<T[]>;
|
|
68
51
|
findOne<T = unknown>(collection: string, query: Record<string, unknown>, options?: FindOptions): Promise<T | null>;
|
|
52
|
+
findMany<T = unknown>(collection: string, ids: string[], options?: FindOptions): Promise<T[]>;
|
|
69
53
|
/**
|
|
70
54
|
* Builds a Drizzle select query, optionally scoped to a subset of columns.
|
|
71
55
|
* When options.select is populated, only those columns are fetched (plus
|
|
@@ -86,7 +70,7 @@ export declare class PostgresDrizzleAdapter implements DatabaseAdapter {
|
|
|
86
70
|
delete(collection: string, id: string, options?: BaseOptions): Promise<boolean>;
|
|
87
71
|
deleteMany(collection: string, query: Record<string, unknown>, options?: BaseOptions): Promise<number>;
|
|
88
72
|
count(collection: string, query: Record<string, unknown>, options?: BaseOptions): Promise<number>;
|
|
89
|
-
aggregate
|
|
73
|
+
aggregate(_collection: string, _pipeline: any[], _options?: BaseOptions): Promise<any[]>;
|
|
90
74
|
transaction<T>(fn: (session: unknown) => Promise<T>): Promise<T>;
|
|
91
75
|
createAuditLog(data: AuditLogData, options?: BaseOptions): Promise<void>;
|
|
92
76
|
createVersion(data: VersionData, options?: BaseOptions): Promise<void>;
|