data-primals-engine 1.7.2 → 1.7.3
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 +160 -160
- package/client/package-lock.json +8430 -8430
- package/client/src/APIInfo.jsx +1 -1
- package/client/src/App.jsx +2 -1
- package/client/src/App.scss +1635 -1626
- package/client/src/AssistantChat.jsx +1 -0
- package/client/src/CalendarView.jsx +1 -0
- package/client/src/ContentView.jsx +3 -3
- package/client/src/Dashboard.jsx +5 -2
- package/client/src/DashboardChart.jsx +1 -0
- package/client/src/DashboardFlexViewItem.jsx +1 -0
- package/client/src/DashboardHtmlViewItem.jsx +1 -0
- package/client/src/DashboardView.jsx +2 -0
- package/client/src/DataEditor.jsx +0 -1
- package/client/src/DataImporter.jsx +489 -468
- package/client/src/DataLayout.jsx +6 -3
- package/client/src/DataTable.jsx +4 -3
- package/client/src/Dialog.jsx +92 -90
- package/client/src/Dialog.scss +122 -116
- package/client/src/DisplayFlexNodeRenderer.jsx +1 -0
- package/client/src/FlexBuilderControls.jsx +1 -0
- package/client/src/FlexBuilderPreview.jsx +1 -1
- package/client/src/FlexNode.jsx +1 -1
- package/client/src/HistoryDialog.jsx +3 -2
- package/client/src/KPIWidget.jsx +1 -1
- package/client/src/KanbanView.jsx +1 -0
- package/client/src/ModelCreator.jsx +4 -0
- package/client/src/ModelList.jsx +1 -0
- package/client/src/PackGallery.jsx +5 -4
- package/client/src/RTETrans.jsx +1 -1
- package/client/src/RelationField.jsx +2 -0
- package/client/src/RelationSelectorWidget.jsx +2 -0
- package/client/src/RelationValue.jsx +1 -0
- package/client/src/RestoreDialog.jsx +1 -0
- package/client/src/WorkflowEditor.jsx +3 -0
- package/client/src/contexts/CommandContext.jsx +2 -1
- package/client/src/contexts/ModelContext.jsx +3 -3
- package/client/src/hooks/data.js +1 -0
- package/client/src/hooks/useValidation.js +1 -0
- package/client/src/translations.js +24 -24
- package/doc/AI-assistance.md +87 -63
- package/doc/Concepts.md +122 -0
- package/doc/Custom-Endpoints.md +31 -0
- package/doc/Event-system.md +13 -14
- package/doc/Home.md +33 -0
- package/doc/Modules.md +83 -0
- package/doc/Packs-gallery.md +8 -23
- package/doc/Workflows.md +32 -0
- package/doc/automation-workflows.md +141 -102
- package/doc/dashboards-kpis-charts.md +47 -49
- package/doc/data-management.md +126 -120
- package/doc/data-models.md +68 -75
- package/doc/roles-permissions.md +144 -43
- package/doc/sharding-replication.md +158 -0
- package/doc/users.md +54 -30
- package/package.json +1 -1
- package/server.js +37 -37
- package/src/constants.js +7 -8
- package/src/data.js +521 -520
- package/src/email.js +157 -154
- package/src/engine.js +117 -7
- package/src/gameObject.js +6 -0
- package/src/i18n.js +0 -1
- package/src/modules/auth-google/index.js +53 -50
- package/src/modules/bucket.js +346 -339
- package/src/modules/data/data.backup.js +400 -376
- package/src/modules/data/data.cluster.js +410 -42
- package/src/modules/data/data.operations.js +3666 -3635
- package/src/modules/data/data.replication.js +106 -64
- package/src/modules/data/data.routes.js +87 -64
- package/src/modules/data/data.scheduling.js +2 -1
- package/src/modules/file.js +248 -247
- package/src/modules/user.js +11 -1
- package/src/sso.js +91 -25
- package/test/cluster.test.js +221 -0
- package/test/core.test.js +0 -2
- package/test/replication.test.js +163 -0
- package/doc/core-concepts.md +0 -33
package/doc/data-management.md
CHANGED
|
@@ -1,120 +1,126 @@
|
|
|
1
|
-
# Data Management: Create, Read, Update, and Delete Entries
|
|
2
|
-
|
|
3
|
-
The `data-primals-engine` provides a powerful and flexible API for performing standard CRUD (Create, Read, Update, Delete) operations on all defined data models. These generic endpoints
|
|
4
|
-
|
|
5
|
-
## Authentication
|
|
6
|
-
|
|
7
|
-
All data management operations require authentication. You must provide a valid `_user` query parameter (your username) and a `Bearer` token in the `Authorization` header for most operations.
|
|
8
|
-
|
|
9
|
-
## API Endpoints Overview
|
|
10
|
-
|
|
11
|
-
The following endpoints are available for generic data management:
|
|
12
|
-
|
|
13
|
-
### 1. Create Data: `POST /api/data`
|
|
14
|
-
|
|
15
|
-
This endpoint allows you to create one or more new documents within a specified model.
|
|
16
|
-
|
|
17
|
-
- **Method**: `POST`
|
|
18
|
-
- **Summary**: Create one or more documents
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
-
|
|
22
|
-
- `
|
|
23
|
-
- `
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- **
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- **
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- **
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
- **
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
- **
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
- **
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
- **
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
1
|
+
# Data Management: Create, Read, Update, and Delete Entries
|
|
2
|
+
|
|
3
|
+
The `data-primals-engine` provides a powerful and flexible REST API for performing standard CRUD (Create, Read, Update, Delete) operations on all defined data models. These generic endpoints are the primary way to interact with your data programmatically.
|
|
4
|
+
|
|
5
|
+
## Authentication
|
|
6
|
+
|
|
7
|
+
All data management operations require authentication. You must provide a valid `_user` query parameter (your username) and a `Bearer` token in the `Authorization` header for most operations.
|
|
8
|
+
|
|
9
|
+
## API Endpoints Overview
|
|
10
|
+
|
|
11
|
+
The following endpoints are available for generic data management:
|
|
12
|
+
|
|
13
|
+
### 1. Create Data: `POST /api/data`
|
|
14
|
+
|
|
15
|
+
This endpoint allows you to create one or more new documents within a specified model. It's optimized for both single and bulk insertions.
|
|
16
|
+
|
|
17
|
+
- **Method**: `POST`
|
|
18
|
+
- **Summary**: Create one or more documents.
|
|
19
|
+
- **Security**: `BearerAuth`
|
|
20
|
+
- **Parameters**:
|
|
21
|
+
- `_user` (query, required): Your username for authentication.
|
|
22
|
+
- `model` (body, required): The name of the model in which to create the documents (e.g., 'user', 'product').
|
|
23
|
+
- `data` (body, required): The data to insert. Can be a single object or an array of objects for bulk creation.
|
|
24
|
+
- **Example (Single Document)**:
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"model": "product",
|
|
28
|
+
"data": {
|
|
29
|
+
"name": "New Product",
|
|
30
|
+
"price": 99.99,
|
|
31
|
+
"currency": { "$find": { "code": "USD" } }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
> **💡 Best Practice**: For `relation` fields, use the `$find` operator instead of a hardcoded `_id`. This makes your code more readable and resilient to changes.
|
|
36
|
+
|
|
37
|
+
- **Example (Bulk Creation)**:
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"model": "product",
|
|
41
|
+
"data": [
|
|
42
|
+
{ "name": "Laptop", "price": 1200, "currency": { "$find": { "code": "USD" } } },
|
|
43
|
+
{ "name": "Mouse", "price": 25, "currency": { "$find": { "code": "USD" } } }
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
- **Responses**: `201` (Document(s) successfully created), `400` (Invalid data), `401` (Unauthorized).
|
|
48
|
+
|
|
49
|
+
### 2. Search Data: `POST /api/data/search`
|
|
50
|
+
|
|
51
|
+
This endpoint allows you to search and retrieve documents from a specified model. It supports powerful filtering, sorting, pagination, and relation population.
|
|
52
|
+
|
|
53
|
+
- **Method**: `POST`
|
|
54
|
+
- **Summary**: Search among data
|
|
55
|
+
- **Security**: `BearerAuth`
|
|
56
|
+
- **Parameters**:
|
|
57
|
+
- `_user` (query, required): Your username for authentication.
|
|
58
|
+
- `model` (body, required): The name of the data model (e.g., 'user', 'product').
|
|
59
|
+
- `filter` (body, optional): MongoDB filter JSON object for the search.
|
|
60
|
+
- `sort` (body, optional): Sort object (e.g., `{ "createdAt": -1 }`).
|
|
61
|
+
- `limit` (query, optional, default: 1000): Maximum number of documents to return.
|
|
62
|
+
- `offset` (query, optional, default: 0): Number of documents to skip (for pagination).
|
|
63
|
+
- `depth` (query, optional, default: 1): Population depth for 'relation' type fields.
|
|
64
|
+
- **Example Request Body**:
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"model": "product",
|
|
68
|
+
"filter": {
|
|
69
|
+
"price": { "$gt": 50 },
|
|
70
|
+
"category": { "$find": { "name": "Electronics" } }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
- **Responses**: `200` (Success with returned data), `401` (Unauthorized).
|
|
75
|
+
|
|
76
|
+
### 3. Update Data: `PUT /api/data/{id}` or `PUT /api/data` (Bulk)
|
|
77
|
+
|
|
78
|
+
You can update a single document by its ID or perform bulk updates using a filter.
|
|
79
|
+
|
|
80
|
+
- **Method**: `PUT`
|
|
81
|
+
- **Summary**: Update a document (by ID) or Bulk update documents
|
|
82
|
+
- **Security**: `BearerAuth`
|
|
83
|
+
- **Parameters**:
|
|
84
|
+
- `_user` (query, required): Your username for authentication.
|
|
85
|
+
- `id` (path, required for single update): The unique identifier (`_id`) of the document to update.
|
|
86
|
+
- `model` (body, required): The name of the data model.
|
|
87
|
+
- `data` (body, required): The data to edit. For bulk updates, this object will contain the fields to update.
|
|
88
|
+
- `filter` (body, optional, for bulk update): MongoDB filter JSON object to select documents for bulk update.
|
|
89
|
+
- **Example Request Body (Single Update)**:
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"model": "product",
|
|
93
|
+
"data": {
|
|
94
|
+
"price": 120.00,
|
|
95
|
+
"status": "published"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
- **Responses**: `200` (Document successfully updated), `400` (Invalid data), `401` (Unauthorized), `404` (Document not found).
|
|
100
|
+
|
|
101
|
+
### 4. Delete Data: `DELETE /api/data`
|
|
102
|
+
|
|
103
|
+
This endpoint allows you to permanently delete one or more documents.
|
|
104
|
+
|
|
105
|
+
- **Method**: `DELETE`
|
|
106
|
+
- **Summary**: Delete one or more document(s)
|
|
107
|
+
- **Security**: `BearerAuth`
|
|
108
|
+
- **Parameters**:
|
|
109
|
+
- `_user` (query, required): Your username for authentication.
|
|
110
|
+
- `model` (body, required): The name of the data model.
|
|
111
|
+
- `ids` (body, optional): An array of identifiers of the documents to delete.
|
|
112
|
+
- `filter` (body, optional): The MongoDB JSON filter to apply for bulk deletion.
|
|
113
|
+
- **Example Request Body (Bulk Delete)**:
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"model": "product",
|
|
117
|
+
"filter": {
|
|
118
|
+
"stock": 0
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
- **Responses**: `200` (Document successfully deleted), `401` (Unauthorized), `404` (Document not found).
|
|
123
|
+
|
|
124
|
+
These generic CRUD endpoints provide a consistent and powerful way to interact with all your data models within the `data-primals-engine`.
|
|
125
|
+
|
|
126
|
+
**[Next: Dashboards, KPI, and charts](dashboards-kpis-charts)**
|