data-primals-engine 1.0.0 → 1.0.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/.idea/data-primals-engine.iml +9 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +128 -67
- package/package.json +7 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/.idea/misc.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/data-primals-engine.iml" filepath="$PROJECT_DIR$/.idea/data-primals-engine.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/README.md
CHANGED
|
@@ -1,68 +1,67 @@
|
|
|
1
1
|
# Data Primals Engine
|
|
2
2
|
|
|
3
|
-
**data-primals-engine**
|
|
3
|
+
**data-primals-engine** is a powerful and flexible **Node.js** backend framework designed to accelerate development of complex data-driven applications. Built on **Express.js** and **MongoDB**, it offers dynamic data modeling, automation workflows, advanced user management, and more.
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Whether you're building a CRM, e-commerce site, CMS, or SaaS platform, **data-primals-engine** provides the strong foundations so you can focus on what makes your application unique.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
## 🚀
|
|
9
|
+
## 🚀 Key Features
|
|
10
10
|
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
-
|
|
17
|
-
- **🧠
|
|
18
|
-
-
|
|
19
|
-
- **📄 Documentation
|
|
11
|
+
- **Dynamic data modeling**: Define and update schemas using JSON, no migrations required.
|
|
12
|
+
- **Robust REST API**: Advanced CRUD operations, filtering, and querying.
|
|
13
|
+
- **Modular architecture**: Load or extend modules dynamically.
|
|
14
|
+
- **Automation workflows**: Trigger actions on events or schedules.
|
|
15
|
+
- **Authentication & authorization**: Role-based access control, pluggable providers.
|
|
16
|
+
- **📦 Starter Packs**: CRM, e-commerce, showcase websites, etc.
|
|
17
|
+
- **🧠 AI Integration**: Supports OpenAI, Google Gemini via LangChain.
|
|
18
|
+
- **🌐 i18n support**: Multilingual interfaces, translated validations.
|
|
19
|
+
- **📄 Auto Documentation**: Swagger available at `/api-docs`.
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## ⚙️ Requirements
|
|
24
24
|
|
|
25
25
|
- Node.js ≥ 18
|
|
26
|
-
- MongoDB
|
|
27
|
-
- NPM
|
|
26
|
+
- MongoDB (local or remote)
|
|
27
|
+
- NPM or Yarn
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
## ⚡
|
|
31
|
+
## ⚡ Quick Start
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
git clone https://
|
|
34
|
+
git clone https://your-repo/data-primals-engine.git
|
|
35
35
|
cd data-primals-engine
|
|
36
36
|
npm install
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Create a `.env` file:
|
|
40
40
|
```env
|
|
41
41
|
MONGO_DB_URL=mongodb://127.0.0.1:27017
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
Start the server:
|
|
45
45
|
```bash
|
|
46
|
-
#
|
|
47
|
-
|
|
46
|
+
# Development mode
|
|
47
|
+
npm run devserver
|
|
48
48
|
|
|
49
|
-
#
|
|
49
|
+
# Production mode
|
|
50
50
|
npm run server
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
By default, the app runs on port **7633**.
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
57
|
-
##
|
|
58
|
-
|
|
59
|
-
### 1. 📂 Modèles
|
|
60
|
-
Définis en JSON, les modèles structurent vos données.
|
|
57
|
+
## 🧠 Concepts
|
|
61
58
|
|
|
59
|
+
### 1. Models
|
|
60
|
+
Define schemas using JSON:
|
|
62
61
|
```json
|
|
63
62
|
{
|
|
64
63
|
"name": "product",
|
|
65
|
-
"description": "
|
|
64
|
+
"description": "E-commerce product schema",
|
|
66
65
|
"fields": [
|
|
67
66
|
{ "name": "name", "type": "string", "required": true },
|
|
68
67
|
{ "name": "price", "type": "number", "required": true },
|
|
@@ -72,33 +71,72 @@ Définis en JSON, les modèles structurent vos données.
|
|
|
72
71
|
}
|
|
73
72
|
```
|
|
74
73
|
|
|
75
|
-
### 2.
|
|
76
|
-
|
|
74
|
+
### 2. Modules
|
|
75
|
+
Activatable features:
|
|
77
76
|
- `mongodb`, `data`, `user`, `workflow`, `file`, `assistant`, `swagger`
|
|
78
77
|
|
|
79
|
-
### 3.
|
|
80
|
-
- **E-commerce
|
|
81
|
-
- **CRM
|
|
82
|
-
- **
|
|
78
|
+
### 3. Starter Packs
|
|
79
|
+
- **E-commerce**: Products, orders, KPIs
|
|
80
|
+
- **CRM**: Contacts, leads, interactions
|
|
81
|
+
- **Website/blog**: Pages, posts, i18n
|
|
83
82
|
|
|
84
|
-
### 4.
|
|
85
|
-
|
|
86
|
-
- **Triggers
|
|
87
|
-
- **Actions
|
|
83
|
+
### 4. Workflows
|
|
84
|
+
Automate business processes:
|
|
85
|
+
- **Triggers**: `DataAdded`, `DataUpdated`, `Scheduled`, `Manual`
|
|
86
|
+
- **Actions**: `CreateData`, `UpdateData`, `SendEmail`, `ApiCall`
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
>
|
|
88
|
+
Example:
|
|
89
|
+
> When a new order is created, email the customer, update stock, and notify logistics.
|
|
91
90
|
|
|
92
91
|
---
|
|
93
92
|
|
|
94
|
-
##
|
|
93
|
+
## 🔌 API Examples (using `curl`)
|
|
94
|
+
|
|
95
|
+
### 📁 Model Management
|
|
95
96
|
|
|
96
|
-
|
|
97
|
+
#### Create a model
|
|
97
98
|
```bash
|
|
98
|
-
curl -X POST http://localhost:7633/api/
|
|
99
|
+
curl -X POST http://localhost:7633/api/model?_user=demouser \
|
|
100
|
+
-H "Authorization: Bearer demotoken" \
|
|
99
101
|
-H "Content-Type: application/json" \
|
|
100
|
-
-
|
|
102
|
+
-d '{
|
|
103
|
+
"name": "newModel",
|
|
104
|
+
"description": "A test model.",
|
|
105
|
+
"fields": [
|
|
106
|
+
{"name": "title", "type": "string", "required": true},
|
|
107
|
+
{"name": "price", "type": "number"}
|
|
108
|
+
]
|
|
109
|
+
}'
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Update a model
|
|
113
|
+
```bash
|
|
114
|
+
curl -X PUT http://localhost:7633/api/model/60d0fe4f5311236168a109ca?_user=demouser \
|
|
115
|
+
-H "Authorization: Bearer demotoken" \
|
|
116
|
+
-H "Content-Type: application/json" \
|
|
117
|
+
-d '{
|
|
118
|
+
"name": "updatedModel",
|
|
119
|
+
"description": "Updated description.",
|
|
120
|
+
"fields": [
|
|
121
|
+
{"name": "title", "type": "string", "required": true},
|
|
122
|
+
{"name": "status", "type": "enum", "items": ["active", "inactive"]}
|
|
123
|
+
]
|
|
124
|
+
}'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Delete a model
|
|
128
|
+
```bash
|
|
129
|
+
curl -X DELETE "http://localhost:7633/api/model?_user=demouser&name=newModel" \
|
|
130
|
+
-H "Authorization: Bearer demotoken"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 🗂️ Data Management
|
|
134
|
+
|
|
135
|
+
#### Create a document
|
|
136
|
+
```bash
|
|
137
|
+
curl -X POST http://localhost:7633/api/data?_user=demouser \
|
|
101
138
|
-H "Authorization: Bearer demotoken" \
|
|
139
|
+
-H "Content-Type: application/json" \
|
|
102
140
|
-d '{
|
|
103
141
|
"model": "product",
|
|
104
142
|
"data": {
|
|
@@ -110,29 +148,52 @@ curl -X POST http://localhost:7633/api/data \
|
|
|
110
148
|
}'
|
|
111
149
|
```
|
|
112
150
|
|
|
113
|
-
|
|
151
|
+
#### Search documents
|
|
152
|
+
```bash
|
|
153
|
+
curl -X POST http://localhost:7633/api/data/search?_user=demouser \
|
|
154
|
+
-H "Authorization: Bearer demotoken" \
|
|
155
|
+
-H "Content-Type: application/json" \
|
|
156
|
+
-d '{
|
|
157
|
+
"model": "product",
|
|
158
|
+
"filter": { "price": { "$gt": 50 } }
|
|
159
|
+
}'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Update a document by ID
|
|
114
163
|
```bash
|
|
115
|
-
curl -X
|
|
164
|
+
curl -X PUT http://localhost:7633/api/data/64a31c123ef59d4c8d55aa99?_user=demouser \
|
|
165
|
+
-H "Authorization: Bearer demotoken" \
|
|
116
166
|
-H "Content-Type: application/json" \
|
|
117
|
-
-
|
|
167
|
+
-d '{
|
|
168
|
+
"model": "product",
|
|
169
|
+
"data": { "price": 109.99 }
|
|
170
|
+
}'
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### Bulk update
|
|
174
|
+
```bash
|
|
175
|
+
curl -X PUT http://localhost:7633/api/data?_user=demouser \
|
|
118
176
|
-H "Authorization: Bearer demotoken" \
|
|
177
|
+
-H "Content-Type: application/json" \
|
|
119
178
|
-d '{
|
|
120
179
|
"model": "product",
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
180
|
+
"data": { "stock": 999 }
|
|
181
|
+
}'
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Delete documents
|
|
185
|
+
```bash
|
|
186
|
+
curl -X DELETE http://localhost:7633/api/data?_user=demouser \
|
|
187
|
+
-H "Authorization: Bearer demotoken" \
|
|
188
|
+
-H "Content-Type: application/json" \
|
|
189
|
+
-d '{
|
|
190
|
+
"ids": ["64a31c123ef59d4c8d55aa99"]
|
|
130
191
|
}'
|
|
131
192
|
```
|
|
132
193
|
|
|
133
194
|
---
|
|
134
195
|
|
|
135
|
-
## 📁 Structure
|
|
196
|
+
## 📁 Project Structure
|
|
136
197
|
```
|
|
137
198
|
data-primals-engine/
|
|
138
199
|
├── src/
|
|
@@ -149,21 +210,21 @@ data-primals-engine/
|
|
|
149
210
|
|
|
150
211
|
---
|
|
151
212
|
|
|
152
|
-
##
|
|
213
|
+
## 🤝 Contributing
|
|
153
214
|
|
|
154
|
-
1.
|
|
155
|
-
2.
|
|
156
|
-
3.
|
|
157
|
-
4. Push : `git push origin feature/
|
|
158
|
-
5.
|
|
215
|
+
1. Fork the repo
|
|
216
|
+
2. Create your feature branch: `git checkout -b feature/your-feature`
|
|
217
|
+
3. Commit changes: `git commit -m "Add new feature"`
|
|
218
|
+
4. Push to your branch: `git push origin feature/your-feature`
|
|
219
|
+
5. Open a pull request
|
|
159
220
|
|
|
160
|
-
|
|
221
|
+
Star ⭐ the repo if you find it useful!
|
|
161
222
|
|
|
162
223
|
---
|
|
163
224
|
|
|
164
|
-
##
|
|
165
|
-
|
|
225
|
+
## 📄 License
|
|
226
|
+
Distributed under the **MIT License**. See `LICENSE` file.
|
|
166
227
|
|
|
167
228
|
---
|
|
168
229
|
|
|
169
|
-
## 🔼
|
|
230
|
+
## 🔼 Back to Top
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-primals-engine",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
|
|
5
|
+
"description": "data-primals-engine is the package responsible from handling large amount of data in a practical and performant way. It can handle large amount of data in a practical and performant way. It can also get workflow models working (for automation), and fully supports internationalisation.",
|
|
5
6
|
"main": "src/engine.js",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"scripts": {
|
|
@@ -13,6 +14,10 @@
|
|
|
13
14
|
"migrate:revert": "node src/migrate.js revert",
|
|
14
15
|
"migrate:status": "node src/migrate.js status"
|
|
15
16
|
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/anonympins/data-primals-engine.git"
|
|
20
|
+
},
|
|
16
21
|
"exports": {
|
|
17
22
|
".": "./src/index.js",
|
|
18
23
|
"./modules/*": "./src/modules/*.js",
|