@micro-cms/mock-db 1.0.19 → 1.0.21
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/README.md +43 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @micro-cms/mock-db
|
|
2
|
+
|
|
3
|
+
A development utility that provides an in-memory database and simulated blockchain payment provider. This allows you to build and test your CMS logic without needing a running PostgreSQL instance or a real blockchain wallet.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Standardized Data Provider:** Implements the `DataProvider` interface with support for CRUD, pagination, sorting, and searching.
|
|
8
|
+
- **Mock Introspection:** Returns a rich, predefined schema (`users`, `posts`, `orders`) to drive the Admin UI.
|
|
9
|
+
- **Mock Payment Provider:** Simulates the crypto payment handshake (`initiate` and `verify`) for testing checkout flows.
|
|
10
|
+
- **Auto-Sync:** Automatically publishes its schema to the global CMS context on load.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @micro-cms/mock-db
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
import { createApp } from '@micro-cms/core';
|
|
22
|
+
import mockDbModule from '@micro-cms/mock-db';
|
|
23
|
+
import adminUiModule from '@micro-cms/admin-ui';
|
|
24
|
+
|
|
25
|
+
const app = createApp();
|
|
26
|
+
|
|
27
|
+
// Use the mock database
|
|
28
|
+
app.use(mockDbModule);
|
|
29
|
+
|
|
30
|
+
// The Admin UI will automatically discover the schema from the mock DB
|
|
31
|
+
app.use(adminUiModule);
|
|
32
|
+
|
|
33
|
+
await app.start();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## How It Works
|
|
37
|
+
|
|
38
|
+
The module registers implementation for three core CMS capabilities:
|
|
39
|
+
1. `database-adapter`: Handles data persistence (in-memory).
|
|
40
|
+
2. `introspection`: Provides the schema metadata.
|
|
41
|
+
3. `payment-provider`: Simulates blockchain interactions.
|
|
42
|
+
|
|
43
|
+
This makes it the perfect "companion" module for front-end development before the real back-end is ready.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-cms/mock-db",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@micro-cms/types": "^1.0.
|
|
19
|
+
"@micro-cms/types": "^1.0.21"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|