@micro-cms/core 1.0.20 → 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 +48 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @micro-cms/core
|
|
2
|
+
|
|
3
|
+
The backbone of the Micro-CMS ecosystem. This package provides the runtime for loading and composing decoupled modules.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Module Loader:** Discovers and initializes modules with a standardized lifecycle.
|
|
8
|
+
- **Staged Event Bus:** Decoupled communication with support for validation, processing, and notification stages.
|
|
9
|
+
- **Shared State Manager:** Reactive, cross-module state management.
|
|
10
|
+
- **Capability Registry:** Allows modules to provide and consume specialized functionalities (e.g., `database-adapter`, `route-provider`).
|
|
11
|
+
- **Route Registry:** Framework-agnostic API endpoint registration.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @micro-cms/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Basic Usage
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import { createApp } from '@micro-cms/core';
|
|
23
|
+
import postgresModule from '@micro-cms/postgres';
|
|
24
|
+
import restApiModule from '@micro-cms/rest-api';
|
|
25
|
+
|
|
26
|
+
const app = createApp();
|
|
27
|
+
|
|
28
|
+
// Compose your stack
|
|
29
|
+
app.use(postgresModule, { connectionString: '...' });
|
|
30
|
+
app.use(restApiModule);
|
|
31
|
+
|
|
32
|
+
// Start the runtime
|
|
33
|
+
await app.start();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Core Concepts
|
|
37
|
+
|
|
38
|
+
### 1. Staged Events
|
|
39
|
+
The Event Bus supports deterministic execution order through stages:
|
|
40
|
+
1. `validation`: Ensure data integrity.
|
|
41
|
+
2. `processing`: Execute business logic (sequential or parallel).
|
|
42
|
+
3. `notification`: Trigger post-processing effects.
|
|
43
|
+
|
|
44
|
+
### 2. Capabilities
|
|
45
|
+
Modules can register "capabilities" that other modules can consume via `runtime.getCapability(name)`. This enables a "plug-and-play" architecture where you can swap a database or UI without changing other modules.
|
|
46
|
+
|
|
47
|
+
### 3. Shared Context
|
|
48
|
+
A global, reactive key-value store that allows modules to publish state (like `currentUser` or `currentSchema`) that others can subscribe to.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-cms/core",
|
|
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",
|