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 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 2,000 direct relations by default (can be customized). For larger datasets, use intermediate collections
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
- - Install ecommerce-starter pack
236
- - Add products via API/UI
237
- - Customize order workflows
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
- ### 🎫 Support Ticket System
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
- ### 🤖 AI Chatbot
245
- - Define your model
246
- - Set up workflow: "When new entry generate AI content"
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
- The "Marketing & Campaigning" starter pack provides a powerful solution for sending large-scale email campaigns without overloading your server.
284
+ > “Send 10,000 emails without crashing your VPS”
285
+
286
+ **Pain**: for loop + SMTP = blacklist + 100% CPU usage.
250
287
 
251
- - **Install the Pack**: A single command installs the necessary models (`campaign`, `audience`) and a sophisticated workflow.
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
- This use case demonstrates how starter packs and workflows can automate complex, performance-critical business logic right out of the box.
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 | Triggered by | Arguments (Payload) |
872
- |:-----------------|:------------------------------------------------------------------------|:--------------|:---------------------|:-----------------------------------------------------------------------------------------------------------------------------------------|
873
- | OnServerStart | Triggered once the HTTP server is started and listening. | System | engine.start() | engine |
874
- | OnServerStop | Triggered right after the HTTP server is stopped. | System | engine.stop() | engine |
875
- | OnModelsLoaded | Triggered after the initial models are loaded and validated at startup. | System | setupInitialModels() | engine, dbModels |
876
- | OnModelsDeleted | Triggered after all models are deleted via the reset function. | System | engine.resetModels() | engine |
877
- | OnUserDataDumped | Triggered after a user's data has been backed up (dumped). | System | jobDumpUserData() | engine |
878
- | OnDataRestored | Triggered after a user's data has been restored from a backup. | System | loadFromDump() | (none) |
879
- | OnPackInstalled | Triggered after a data pack has been successfully installed. | System | installPack() | pack |
880
- | OnModelEdited | Triggered after a model definition has been modified. | System & User | editModel() | System: engine, newModel (Pipeline*)<br>User: newModel (or the version modified by the system) |
881
- | OnDataAdded | Triggered after new data has been inserted. | System & User | insertData() | System: engine, insertedIds (Pipeline*)<br>User: insertedIds (or the version modified by the system) |
882
- | OnDataDeleted | Triggered just after data is actually deleted. | System & User | deleteData() | System: engine, {model, filter} (Pipeline*)<br>User: {model, filter} |
883
- | OnDataSearched | Triggered after a data search. | System & User | searchData() | System: engine, {data, count} (Pipeline*)<br>User: {data, count} (or the version modified by the system) |
884
- | OnDataExported | Triggered after a data export. | System & User | exportData() | System: engine, exportResults, modelsToExport (Pipeline*)<br>User: exportResults, modelsToExport (or the version modified by the system) |
885
- | OnDataInsert | Triggered just before data insertion. It will use the overrided data. | System | internal | (data) |
886
- | OnDataValidate | Triggered to override validation check. | System | internal | (value, field, data) |
887
- | OnDataFilter | Triggered to override data filtering operation. | System | internal | (filteredValue, field, data) |
888
- | OnEmailTemplate | Triggered to override custom email templates | System | internal | (templateData, lang) |
889
- | OnSystemPrompt | Triggered to override assistant system prompt | User | handleChatRequest | (user) |
890
- | OnChatAction | Triggered when an action is created by the AI | User | handleChatRequest | (action, params, parsedResponse, user) |
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