data-primals-engine 1.6.1 → 1.6.2
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 +73 -42
- package/client/package-lock.json +524 -5
- package/client/package.json +2 -1
- package/client/src/App.scss +14 -1
- package/client/src/Dashboard.jsx +4 -0
- package/client/src/DataLayout.jsx +85 -20
- package/client/src/DataLayout.scss +32 -6
- package/client/src/DataTable.jsx +18 -11
- package/client/src/ModelCreator.jsx +686 -683
- package/client/src/ModelImporter.jsx +1 -1
- package/client/src/ViewSwitcher.jsx +1 -1
- package/client/src/WorkflowEditor.jsx +317 -0
- package/client/src/WorkflowEditor.scss +16 -0
- package/package.json +22 -19
- package/src/client.js +4 -0
- package/src/defaultModels.js +5 -2
- package/src/i18n.js +35 -3
- package/src/modules/assistant/assistant.js +38 -56
- package/src/modules/assistant/providers.js +38 -0
- package/src/modules/data/data.history.js +2 -5
- package/src/modules/data/data.operations.js +3496 -3484
- package/src/modules/workflow.js +3 -6
- package/src/packs.js +239 -24
- package/test/assistant.test.js +207 -0
- package/test/config.test.js +41 -0
- package/test/data.history.integration.test.js +4 -4
package/README.md
CHANGED
|
@@ -200,7 +200,7 @@ Models are the way to handle structured data. They organize data and they can be
|
|
|
200
200
|
| modelField | Stores a model field path | – |
|
|
201
201
|
|
|
202
202
|
### Other model features
|
|
203
|
-
- Handles up to
|
|
203
|
+
- Handles up to 1500 direct relations per document by default (can be customized). For larger datasets, use intermediate collections or maxRelationsPerData constant.
|
|
204
204
|
- Anonymizable fields (encrypted for API users)
|
|
205
205
|
- **Dynamic Index Management**: The engine features a sophisticated system for managing database indexes directly from the model editor UI. This eliminates the need for manual database administration or migration scripts for indexing, significantly speeding up development and reducing errors. Indexes are created, updated, and removed automatically when you save a model's structure. All created indexes are **partial indexes**, meaning they only include documents for the specific model and user, which optimizes storage and performance.
|
|
206
206
|
|
|
@@ -231,33 +231,63 @@ You can enable indexing on any field by checking the `index` box in the model ed
|
|
|
231
231
|
|
|
232
232
|
## 🏗️ Use Case Examples
|
|
233
233
|
|
|
234
|
-
### 🛒 E-Commerce Backoffice
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
### 🛒 E-Commerce Backoffice
|
|
235
|
+
> “Sell in 15 min, not 15 days”
|
|
236
|
+
>
|
|
237
|
+
**Pain**: You're struggling to sync your catalog, inventory, orders, refunds…
|
|
238
|
+
|
|
239
|
+
**Promise**: Install the "E-commerce Starter Kit" to get all the models you need for products, orders, and payments, plus a pre-configured workflow to process new orders.
|
|
240
|
+
|
|
241
|
+
**Proof**: After installing the pack, a single API call creates the order, which can then automatically trigger the "Order Fulfillment" workflow to update its status and create a shipment record.
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
curl -X POST "http://localhost:7633/api/data?_user=demo" \
|
|
245
|
+
-H "Content-Type: application/json" \
|
|
246
|
+
-d '{
|
|
247
|
+
"model": "order",
|
|
248
|
+
"data": { "orderId": "ORDER-12345", "totalAmount": 99.98, "status": "pending" }
|
|
249
|
+
}'
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### 🎫 Support Ticket System
|
|
253
|
+
> "Transform Gmail into Zendesk in 10 minutes"
|
|
254
|
+
|
|
255
|
+
**Pain**: Tickets flood a shared inbox → delayed responses, broken SLAs.
|
|
256
|
+
|
|
257
|
+
**Promise**: Create a `ticket` model (with statuses, priority, etc.). Then, build a workflow that triggers on new high-priority tickets. This workflow can use the built-in **`HttpRequest`** action to send a message to a Discord or Slack webhook URL, and the **`SendEmail`** action to alert a manager.
|
|
258
|
+
|
|
259
|
+
**Proof**: A single API call to create a ticket instantly triggers the notification workflow. The following `curl` command demonstrates how to create a new high-priority ticket, which would immediately fire the pre-configured alerts.
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
curl -X POST "http://localhost:7633/api/data?_user=demo" \
|
|
263
|
+
-H "Content-Type: application/json" \
|
|
264
|
+
-d '{
|
|
265
|
+
"model": "ticket",
|
|
266
|
+
"data": {
|
|
267
|
+
"subject": "Critical: Payment Gateway Down",
|
|
268
|
+
"priority": "high",
|
|
269
|
+
"description": "No payments have been processed in the last hour."
|
|
270
|
+
}
|
|
271
|
+
}'
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### 🤖 AI Chatbot
|
|
275
|
+
> "Adds an assistant that answers instead of support."
|
|
238
276
|
|
|
239
|
-
|
|
240
|
-
- Create ticket model with [open, pending, resolved] statuses
|
|
241
|
-
- Configure notification workflows
|
|
242
|
-
- Add custom endpoints or dashboards/kpi for analytics
|
|
277
|
+
**Pain**: 70% of questions are "Where is my order?" → overloaded team.
|
|
243
278
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
279
|
+
**Promise**: One line in the workflow `OnDataAdded/ticket`: `GenerateAIContent(prompt="Summarize the order {triggerData.orderId} and provide the tracking link").`
|
|
280
|
+
|
|
281
|
+
**Proof**: The ticket is created, the AI responds in 3 seconds, the status changes to "automatically resolved" → saves 30 hours/month of support.
|
|
247
282
|
|
|
248
283
|
### 📧 Email Campaign Management
|
|
249
|
-
|
|
284
|
+
> “Send 10,000 emails without crashing your VPS”
|
|
285
|
+
|
|
286
|
+
**Pain**: for loop + SMTP = blacklist + 100% CPU usage.
|
|
250
287
|
|
|
251
|
-
|
|
252
|
-
- **Dynamic Audiences**: Create target audiences with MongoDB filters. For example, select all contacts with the "newsletter" tag or located in a specific country.
|
|
253
|
-
- **Personalized Content**: Use variables like `{recipient.firstName}` in the subject and body of your emails for a personal touch.
|
|
254
|
-
- **Automated & Scalable Sending**: When you schedule a campaign, a pre-configured workflow takes over:
|
|
255
|
-
- It processes your audience in small batches (e.g., 10 recipients at a time).
|
|
256
|
-
- It sends emails to each batch and waits before processing the next, ensuring stability.
|
|
257
|
-
- It tracks processed recipients to avoid duplicates and allow the campaign to be safely paused and resumed.
|
|
258
|
-
- Once all emails are sent, the campaign is automatically marked as "completed".
|
|
288
|
+
**Promise**: Install the "Marketing & Campaigning" pack, configure your SMTP credentials in the 'env' model, create a campaign: the workflow sends emails in efficient batches of 10.
|
|
259
289
|
|
|
260
|
-
|
|
290
|
+
**Proof**: Simply edit a campaign and set its status to "scheduled". A background workflow is immediately triggered, processing your entire mailing list in small, manageable batches. This offloads your server and allows you to continue working while the campaign runs securely in the background.
|
|
261
291
|
|
|
262
292
|
---
|
|
263
293
|
|
|
@@ -868,26 +898,27 @@ Event.Listen("OnDataAdded", (engine, data) => {
|
|
|
868
898
|
}, "event", "system");
|
|
869
899
|
```
|
|
870
900
|
|
|
871
|
-
| Event | Description | Scope
|
|
872
|
-
|
|
873
|
-
| OnServerStart | Triggered once the HTTP server is started and listening. | System
|
|
874
|
-
| OnServerStop | Triggered right after the HTTP server is stopped. | System
|
|
875
|
-
| OnModelsLoaded | Triggered after the initial models are loaded and validated at startup. | System
|
|
876
|
-
| OnModelsDeleted | Triggered after all models are deleted via the reset function. | System
|
|
877
|
-
| OnUserDataDumped | Triggered after a user's data has been backed up (dumped). | System
|
|
878
|
-
| OnDataRestored | Triggered after a user's data has been restored from a backup. | System
|
|
879
|
-
| OnPackInstalled | Triggered after a data pack has been successfully installed. | System
|
|
880
|
-
| OnModelEdited | Triggered after a model definition has been modified. | System
|
|
881
|
-
| OnDataAdded | Triggered after new data has been inserted. | System
|
|
882
|
-
|
|
|
883
|
-
|
|
|
884
|
-
|
|
|
885
|
-
|
|
|
886
|
-
|
|
|
887
|
-
|
|
|
888
|
-
|
|
|
889
|
-
|
|
|
890
|
-
|
|
|
901
|
+
| Event | Description | Scope | Triggered by | Arguments (Payload) |
|
|
902
|
+
|:-----------------|:------------------------------------------------------------------------|:-------|:-------------------------|:---------------------------------------------------------------------|
|
|
903
|
+
| OnServerStart | Triggered once the HTTP server is started and listening. | System | engine.start() | engine |
|
|
904
|
+
| OnServerStop | Triggered right after the HTTP server is stopped. | System | engine.stop() | engine |
|
|
905
|
+
| OnModelsLoaded | Triggered after the initial models are loaded and validated at startup. | System | setupInitialModels() | engine, dbModels |
|
|
906
|
+
| OnModelsDeleted | Triggered after all models are deleted via the reset function. | System | engine.resetModels() | engine |
|
|
907
|
+
| OnUserDataDumped | Triggered after a user's data has been backed up (dumped). | System | jobDumpUserData() | engine |
|
|
908
|
+
| OnDataRestored | Triggered after a user's data has been restored from a backup. | System | loadFromDump() | (none) |
|
|
909
|
+
| OnPackInstalled | Triggered after a data pack has been successfully installed. | System | installPack() | pack |
|
|
910
|
+
| OnModelEdited | Triggered after a model definition has been modified. | System | editModel() | newModel |
|
|
911
|
+
| OnDataAdded | Triggered after new data has been inserted. | System | insertData() | engine, insertedDocs |
|
|
912
|
+
| OnDataEdited | Triggered after data has been edited. | System | editData() / patchData() | engine, {modelName, before, after} |
|
|
913
|
+
| OnDataDeleted | Triggered just after data is actually deleted. | System | deleteData() | engine, {model, filter} |
|
|
914
|
+
| OnDataSearched | Triggered after a data search. | System | searchData() | engine, {data, count} |
|
|
915
|
+
| OnDataExported | Triggered after a data export. | User | exportData() | exportResults, modelsToExport |
|
|
916
|
+
| OnDataInsert | Triggered just before data insertion. It will use the overrided data. | System | internal | data |
|
|
917
|
+
| OnDataValidate | Triggered to override validation check. | System | internal | value, field, data |
|
|
918
|
+
| OnDataFilter | Triggered to override data filtering operation. | System | internal | filteredValue, field, data |
|
|
919
|
+
| OnEmailTemplate | Triggered to override custom email templates | System | internal | templateData, lang |
|
|
920
|
+
| OnSystemPrompt | Triggered to override assistant system prompt | User | handleChatRequest | user |
|
|
921
|
+
| OnChatAction | Triggered when an action is created by the AI | User | handleChatRequest | action, params, parsedResponse, command, llmOptions, user, reqParams |
|
|
891
922
|
|
|
892
923
|
### Triggering events
|
|
893
924
|
|