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.
Files changed (78) hide show
  1. package/README.md +160 -160
  2. package/client/package-lock.json +8430 -8430
  3. package/client/src/APIInfo.jsx +1 -1
  4. package/client/src/App.jsx +2 -1
  5. package/client/src/App.scss +1635 -1626
  6. package/client/src/AssistantChat.jsx +1 -0
  7. package/client/src/CalendarView.jsx +1 -0
  8. package/client/src/ContentView.jsx +3 -3
  9. package/client/src/Dashboard.jsx +5 -2
  10. package/client/src/DashboardChart.jsx +1 -0
  11. package/client/src/DashboardFlexViewItem.jsx +1 -0
  12. package/client/src/DashboardHtmlViewItem.jsx +1 -0
  13. package/client/src/DashboardView.jsx +2 -0
  14. package/client/src/DataEditor.jsx +0 -1
  15. package/client/src/DataImporter.jsx +489 -468
  16. package/client/src/DataLayout.jsx +6 -3
  17. package/client/src/DataTable.jsx +4 -3
  18. package/client/src/Dialog.jsx +92 -90
  19. package/client/src/Dialog.scss +122 -116
  20. package/client/src/DisplayFlexNodeRenderer.jsx +1 -0
  21. package/client/src/FlexBuilderControls.jsx +1 -0
  22. package/client/src/FlexBuilderPreview.jsx +1 -1
  23. package/client/src/FlexNode.jsx +1 -1
  24. package/client/src/HistoryDialog.jsx +3 -2
  25. package/client/src/KPIWidget.jsx +1 -1
  26. package/client/src/KanbanView.jsx +1 -0
  27. package/client/src/ModelCreator.jsx +4 -0
  28. package/client/src/ModelList.jsx +1 -0
  29. package/client/src/PackGallery.jsx +5 -4
  30. package/client/src/RTETrans.jsx +1 -1
  31. package/client/src/RelationField.jsx +2 -0
  32. package/client/src/RelationSelectorWidget.jsx +2 -0
  33. package/client/src/RelationValue.jsx +1 -0
  34. package/client/src/RestoreDialog.jsx +1 -0
  35. package/client/src/WorkflowEditor.jsx +3 -0
  36. package/client/src/contexts/CommandContext.jsx +2 -1
  37. package/client/src/contexts/ModelContext.jsx +3 -3
  38. package/client/src/hooks/data.js +1 -0
  39. package/client/src/hooks/useValidation.js +1 -0
  40. package/client/src/translations.js +24 -24
  41. package/doc/AI-assistance.md +87 -63
  42. package/doc/Concepts.md +122 -0
  43. package/doc/Custom-Endpoints.md +31 -0
  44. package/doc/Event-system.md +13 -14
  45. package/doc/Home.md +33 -0
  46. package/doc/Modules.md +83 -0
  47. package/doc/Packs-gallery.md +8 -23
  48. package/doc/Workflows.md +32 -0
  49. package/doc/automation-workflows.md +141 -102
  50. package/doc/dashboards-kpis-charts.md +47 -49
  51. package/doc/data-management.md +126 -120
  52. package/doc/data-models.md +68 -75
  53. package/doc/roles-permissions.md +144 -43
  54. package/doc/sharding-replication.md +158 -0
  55. package/doc/users.md +54 -30
  56. package/package.json +1 -1
  57. package/server.js +37 -37
  58. package/src/constants.js +7 -8
  59. package/src/data.js +521 -520
  60. package/src/email.js +157 -154
  61. package/src/engine.js +117 -7
  62. package/src/gameObject.js +6 -0
  63. package/src/i18n.js +0 -1
  64. package/src/modules/auth-google/index.js +53 -50
  65. package/src/modules/bucket.js +346 -339
  66. package/src/modules/data/data.backup.js +400 -376
  67. package/src/modules/data/data.cluster.js +410 -42
  68. package/src/modules/data/data.operations.js +3666 -3635
  69. package/src/modules/data/data.replication.js +106 -64
  70. package/src/modules/data/data.routes.js +87 -64
  71. package/src/modules/data/data.scheduling.js +2 -1
  72. package/src/modules/file.js +248 -247
  73. package/src/modules/user.js +11 -1
  74. package/src/sso.js +91 -25
  75. package/test/cluster.test.js +221 -0
  76. package/test/core.test.js +0 -2
  77. package/test/replication.test.js +163 -0
  78. package/doc/core-concepts.md +0 -33
@@ -0,0 +1,122 @@
1
+ # Fundamental Concepts
2
+
3
+ `data-primals-engine` is built on a set of core concepts designed to provide maximum flexibility and power. Understanding these concepts is essential to getting the most out of the platform.
4
+
5
+ ---
6
+
7
+ ## 1. [Models](data-models)
8
+
9
+ A **model** represents a data entity in your application, similar to a table in an SQL database or a collection in MongoDB. Each model has a set of fields that define the structure of the data it contains.
10
+
11
+ - **Visual Definition**: Models can be created and modified directly from the user interface, without requiring manual database migrations.
12
+
13
+ - **Flexibility**: A model's structure can be updated at any time.
14
+ ### Model Generation
15
+ Models are the way to handle structured data. They organize data and they can be declared in JSON.
16
+
17
+ ```json
18
+ {
19
+ "name": "product",
20
+ "description": "E-commerce product schema",
21
+ "fields": [
22
+ { "name": "name", "type": "string", "required": true },
23
+ { "name": "price", "type": "number", "required": true },
24
+ { "name": "stock", "type": "number", "default": 0 },
25
+ { "name": "category", "type": "relation", "relation": "taxonomy",
26
+ "relationFilter": { "$eq": ["$type", "category"] }
27
+ },
28
+ { "name": "tags", "type": "relation", "relation": "taxonomy", "multiple": true,
29
+ "relationFilter": { "$eq": ["$type", "keyword"] }
30
+ }
31
+ ]
32
+ }
33
+ ```
34
+
35
+ #### Dynamic Index Management
36
+
37
+ 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.
38
+
39
+ 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.
40
+
41
+ You can enable indexing on any field by checking the `index` box in the model editor and choosing one of the following types:
42
+
43
+ | Index Type | `indexType` | Use Case & Behavior -|
44
+ |-----------------|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
45
+ | **Regular** | `regular` | **Purpose**: The standard index for most use cases. It dramatically speeds up queries, sorting, and filtering on a specific field. <br/> **Behavior**: Creates a standard ascending B-tree index on a single field. This is the default and most common index type. -|
46
+ | **Text Search** | `text` | **Purpose**: Enables powerful, language-aware full-text search across one or more fields. It's ideal for implementing search bars that need to query descriptions, titles, and other text-heavy content. <br/> **Behavior**: Creates a single, special **compound `text` index** for the entire model. All fields marked with `indexType: 'text'` are included in this single index. This allows you to use MongoDB's `$text` operator in your search queries. -|
47
+ | **Geospatial** | `2dsphere` | **Purpose**: Essential for location-based queries. It allows you to efficiently find documents within a certain radius, within a polygon, or sorted by distance. <br/> **Behavior**: Creates a `2dsphere` index on a single field. This index type should be used exclusively on fields of type `geolocation` which store data in GeoJSON format (e.g., `{ "type": "Point", "coordinates": [ -73.97, 40.77 ] }`). |
48
+
49
+ ### Model constraints
50
+ ```javascript
51
+ {
52
+ "name": "modelName",
53
+ "fields": [
54
+ { "name": "fieldName1", .... },
55
+ { "name": "fieldName2", .... }
56
+ ],
57
+ "constraints": [
58
+ // uniqueness
59
+ { "name": "uniqueConstraint", type: "unique", keys: ["fieldName1", "fieldName2"] }
60
+ ]
61
+ }
62
+ ```
63
+ ### Other model features
64
+ - Handles up to 1500 direct relations per document by default (can be customized). For larger datasets, use intermediate collections or maxRelationsPerData constant.
65
+ - Anonymizable fields (encrypted for API users)
66
+
67
+
68
+ ## 2. [Fields](data-models)
69
+
70
+ **Fields** are the attributes that make up a model. `data-primals-engine` supports a wide variety of field types to cover all needs:
71
+
72
+ ### Fields types
73
+
74
+ | Type | Description | Properties/Notes |
75
+ |:------------|:------------------------------------------------------------------------------------|:--------------------------------------------------------------------------|
76
+ | string | Character string. | minLength, maxLength |
77
+ | string_t | International character string ID. | same as string, translated in { key, value } |
78
+ | number | Numeric value (integer or float). | min, max |
79
+ | boolean | Boolean value (true/false). | – |
80
+ | date | Stores a ISO date. | – |
81
+ | datetime | Stores an ISO date and time. | – |
82
+ | richtext | Rich text field (HTML) for WYSIWYG editors. | |
83
+ | richtext_t | International rich text field (HTML) for WYSIWYG editors. | i18n |
84
+ | email | String validated as an email address. | – |
85
+ | password | String that will be automatically hashed. | – |
86
+ | enum | Allows selecting a value from a predefined list. | items: ["value1", "value2"] |
87
+ | relation | Creates a link to a document in another model. | relation: "target_model_name", multiple: true/false |
88
+ | file | For uploading a file (stored on S3 if configured). | allowedTypes:['image/jpeg', 'image/png', 'image/bmp'], maxSize: 1024*1000 |
89
+ | image | Specialized file type for images, with preview. | – |
90
+ | array | Stores a list of values. | itemsType: 'enum' // any type except relations |
91
+ | object | Stores a nested JSON object. – | |
92
+ | code | Stores language="*" as string, stores language="json" as arbitrary JSON structure. | language="json" conditionBuilder=true |
93
+ | color | Stores an hexadecimal value of an RGB color | '#FF0000' |
94
+ | model | Stores a model by name | – |
95
+ | modelField | Stores a model field path | – |
96
+
97
+
98
+ Each field can have specific validation rules to guarantee data integrity.
99
+
100
+ ## 3. [Permissions (RBAC)](roles-permissions)
101
+
102
+ Access management is handled by a **Role-Based Access Control (RBAC)** system.
103
+
104
+ - **Roles**: You can define roles (e.g., `Admin`, `Editor`, `Visitor`).
105
+
106
+ - **Granular Permissions**: For each model, you can assign CRUD (Create, Read, Update, Delete) permissions to each role. For example, an `Editor` can create and modify articles, but not delete them.
107
+
108
+ This system allows for granular security of access to your data.
109
+
110
+ ## 4. [User management](users)
111
+
112
+ The engine includes a robust authentication system based on **JWT (JSON Web Tokens)**.
113
+
114
+ - ****: A `User` model is typically used to manage user accounts.
115
+
116
+ - **Security**: `JWT_SECRET` ensures that tokens cannot be forged.
117
+
118
+ ## 5. Advanced Data Management
119
+
120
+ - **Complex Queries**: Leverage the power of MongoDB to perform complex queries and aggregations on your data.
121
+
122
+ - **Automatic Auditing**: The engine can automatically maintain a history of changes for each record, allowing you to know who did what and when.
@@ -0,0 +1,31 @@
1
+ # Custom API Endpoints
2
+
3
+ While `data-primals-engine` provides a full REST API for CRUD operations on your models, you may sometimes need to create API endpoints with specific business logic.
4
+
5
+ Custom API endpoints allow you to extend the engine's native API in a secure and controlled manner.
6
+
7
+ ---
8
+
9
+ ## Why Create a Custom API Endpoint?
10
+
11
+ - To execute complex logic that goes beyond simple CRUD operations (e.g., `POST /api/orders/{id}/processPayment`).
12
+
13
+ - To aggregate data from multiple models into a single response.
14
+
15
+ - To integrate with external services.
16
+
17
+ ## Creation and Configuration
18
+
19
+ Custom API endpoints can be created directly from the administration interface. During creation, you configure the following:
20
+
21
+ - **HTTP Route**: The URL path (e.g., `/my-custom-action`).
22
+
23
+ - **HTTP Method**: `GET`, `POST`, `PUT`, `DELETE`, etc.
24
+
25
+ - **Permissions**: Which role is authorized to call this API point.
26
+
27
+ - **Execution Code**: You write your logic in **JavaScript (Node.js)** directly in a secure (sandbox) environment.
28
+
29
+ ## Secure Execution Environment
30
+
31
+ The code you write for a custom API point runs in an isolated environment. You have controlled access to engine features (such as `searchData`, `insertData`) and certain Node.js libraries, which ensures that your custom code cannot compromise the security or stability of the main application.
@@ -63,17 +63,16 @@ When multiple listeners are registered for an event, their return values are mer
63
63
 
64
64
  Here is a list of the most important events you can listen to:
65
65
 
66
- | Event | Description | Scope | Triggered by | Arguments (Payload) |
67
- |:-------------------|:-----------------------------------------------------------------|:-------|:-----------------------------|:-----------------------------------------------------------------------------------|
68
- | `OnServerStart` | Triggered once the HTTP server is started and listening. | System | `engine.start()` | `engine` |
69
- | `OnDatabaseLoaded` | Triggered once the lient is ready | System | | `engine` |
70
- | `OnModelsLoaded` | Triggered after the initial models are loaded at startup. | System | `setupInitialModels()` | `engine`, `dbModels` |
71
- | `OnModelEdited` | Triggered after a model definition has been modified. | System | `editModel()` | `newModel` |
72
- | `OnDataAdded` | Triggered after new data has been inserted. | System | `insertData()` | `engine`, `insertedDocs` |
73
- | `OnDataEdited` | Triggered after data has been edited. | System | `editData()` / `patchData()` | `engine`, `{modelName, before, after}` |
74
- | `OnDataDeleted` | Triggered just after data is actually deleted. | System | `deleteData()` | `engine`, `{model, filter}` |
75
- | `OnDataSearched` | Triggered after a data search. | System | `searchData()` | `engine`, `{data, count}` |
76
- | `OnDataInsert` | Triggered just before data insertion. Allows modifying the data. | System | internal | `data` |
77
- | `OnDataValidate` | Triggered to override validation checks. | System | internal | `value`, `field`, `data` |
78
- | `OnChatAction` | Triggered when an AI assistant decides on an action. | User | `handleChatRequest` | `action`, `params`, `parsedResponse`, `command`, `llmOptions`, `user`, `reqParams` |
79
- | `OnSystemPrompt` | Triggered to override the AI assistant's system prompt. | User | `handleChatRequest` | `user` |
66
+ | Event | Description | Scope | Triggered by | Arguments (Payload) |
67
+ |:-----------------|:------------------------------------------------------------------------|:-------|:-------------------------|:---------------------------------------------------------------------|
68
+ | `OnServerStart` | Triggered once the HTTP server is started and listening. | System | `engine.start()` | `engine` |
69
+ | `OnModelsLoaded` | Triggered after the initial models are loaded at startup. | System | `setupInitialModels()` | `engine`, `dbModels` |
70
+ | `OnModelEdited` | Triggered after a model definition has been modified. | System | `editModel()` | `newModel` |
71
+ | `OnDataAdded` | Triggered after new data has been inserted. | System | `insertData()` | `engine`, `insertedDocs` |
72
+ | `OnDataEdited` | Triggered after data has been edited. | System | `editData()` / `patchData()` | `engine`, `{modelName, before, after}` |
73
+ | `OnDataDeleted` | Triggered just after data is actually deleted. | System | `deleteData()` | `engine`, `{model, filter}` |
74
+ | `OnDataSearched` | Triggered after a data search. | System | `searchData()` | `engine`, `{data, count}` |
75
+ | `OnDataInsert` | Triggered just before data insertion. Allows modifying the data. | System | internal | `data` |
76
+ | `OnDataValidate` | Triggered to override validation checks. | System | internal | `value`, `field`, `data` |
77
+ | `OnChatAction` | Triggered when an AI assistant decides on an action. | User | `handleChatRequest` | `action`, `params`, `parsedResponse`, `command`, `llmOptions`, `user`, `reqParams` |
78
+ | `OnSystemPrompt` | Triggered to override the AI assistant's system prompt. | User | `handleChatRequest` | `user` |
package/doc/Home.md ADDED
@@ -0,0 +1,33 @@
1
+ # Welcome to the data-primals-engine Wiki! 👋
2
+
3
+ This wiki is your central guide to using, integrating, and extending the platform.
4
+
5
+ ## 🧭 Explore the Platform
6
+ Discover the core features to get started building and managing your data.
7
+ Link to the official documentation: https://data.primals.net/en/documentation/
8
+
9
+ - 🧠 [Core Concepts](Concepts): Explore the fundamentals of data modeling.
10
+ - 🔌 [Custom API Endpoints](custom-api-endpoints): Create dynamic HTTP routes directly from the backend.
11
+ - 🏗️ [Data Models](data-models): Structure your information.
12
+ - 🗃️ [Data Management](data-management): Create, read, update, and delete your entries.
13
+ - 📈 [Dashboards, KPIs, and Charts](dashboards-kpis-charts): Track your key metrics.
14
+ - 👥 [Users](users): Manage access to the platform.
15
+ - 🔐 [Roles and Permissions](roles-permissions): Define who can see and do what.
16
+ - ⚙️ [Automation with Workflows](automation-workflows): Create automated processes.
17
+ - 🎁 [Pack Gallery](Packs-gallery): Discover ready-to-use configurations.
18
+ - 🤖 [AI Assistance](AI-assistance): Leverage artificial intelligence.
19
+
20
+ ## 🧩 Extend Capabilities
21
+ Go further by developing your own features and business logic.
22
+
23
+ - ⚡ [Event System](Event-system): React to events in real time.
24
+ - 🧠 [Advanced Workflows](Advanced-workflows): Create complex logic with custom scripts.
25
+ - 📦 [Modules](Modules): Package and share your developments.
26
+ - 🚀 [Sharding & Replication](sharding-replication): Scale horizontally and ensure high availability.
27
+ - ❤️ [Contribute to the project (CONTRIBUTING.md)](https://github.com/anonympins/data-primals-engine/blob/main/CONTRIBUTING.md): Join the developer community.
28
+
29
+ ## 💻 For Developers
30
+ Essential tools for a seamless development experience.
31
+
32
+ - 📖 [Explore the API with Swagger](https://data.primals.net/api-docs/): Test API access points directly from your browser.
33
+ - 📮 [Postman Collection](https://data.primals.net/doc/API.postman_collection.json): Import our collection to start querying in just a few clicks.
package/doc/Modules.md ADDED
@@ -0,0 +1,83 @@
1
+ # Modules: Packaging and Extending Features
2
+
3
+ The `data-primals-engine` is designed to be modular, allowing you to enable, disable, or create new features in a clean and organized way. A **Module** is a self-contained unit of functionality that plugs into the core engine at startup.
4
+
5
+ This approach keeps the core lightweight while allowing for powerful extensions like SSO authentication, payment gateway integrations, or custom API functionalities.
6
+
7
+ ## How Modules Work
8
+
9
+ 1. **Discovery**: The engine looks for modules in the `src/modules/` directory.
10
+ 2. **Activation**: You specify which modules to activate using the `Config` object.
11
+ 3. **Initialization**: For each active module, the engine calls its exported `onInit(engine)` function, passing the main engine instance. This is the module's entry point to interact with the system.
12
+
13
+ ## Enabling an Existing Module
14
+
15
+ The engine comes with several built-in modules, such as authentication providers. To enable one, you add its name to the `modules` array in your configuration **before** initializing the engine.
16
+
17
+ **Example: Enabling Google SSO and the Assistant**
18
+
19
+ ```javascript
20
+ import { Engine, Config } from 'data-primals-engine';
21
+
22
+ // Add modules to the list of modules to be loaded
23
+ Config.Set("modules", ["auth-google", "assistant"]);
24
+
25
+ const app = express();
26
+ const engine = await Engine.Create({ app });
27
+ ```
28
+
29
+ You may also need to install peer dependencies (`npm install passport-google-oauth20`) and set environment variables (`GOOGLE_CLIENT_ID`, etc.) as required by the module.
30
+
31
+ ## Creating a New Module
32
+
33
+ Creating a module is straightforward. It only requires a JavaScript file in the `src/modules/my-module/` directory that exports an `async` function named `onInit`.
34
+
35
+ ### Step 1: Create the Module File
36
+
37
+ Create a new file, for example: `src/modules/greeter/greeter.js`
38
+
39
+ ### Step 2: Write the `onInit` Function
40
+
41
+ In `greeter.js`, write your initialization logic. The `onInit` function gives you access to the entire engine.
42
+
43
+ ```javascript
44
+ // src/modules/greeter/greeter.js
45
+
46
+ export async function onInit(engine) {
47
+ // 1. Get components from the engine
48
+ const logger = engine.getComponent('Logger');
49
+ const Event = engine.getComponent('Event');
50
+
51
+ // 2. Register a new API endpoint
52
+ engine.get('/api/greet/:name', (req, res) => {
53
+ const { name } = req.params;
54
+ res.json({ message: `Hello, ${name}! Welcome to our custom module.` });
55
+ });
56
+
57
+ // 3. Listen to a core event
58
+ Event.Listen('OnDataAdded', (engine, insertedDocs) => {
59
+ if (insertedDocs?.[0]._model === 'user') {
60
+ logger.info(`A new user has signed up: ${insertedDocs[0].username}`);
61
+ }
62
+ }, 'event', 'system');
63
+
64
+ // 4. Log that the module has been loaded
65
+ logger.info("Module 'greeter' loaded successfully.");
66
+ }
67
+ ```
68
+
69
+ ### Step 3: Enable Your New Module
70
+
71
+ In your main server file, enable your module via the `Config` object.
72
+
73
+ ```javascript
74
+ Config.Set("modules", ["greeter"]); // Add your module's folder name
75
+
76
+ const engine = await Engine.Create({ app });
77
+ // When the server starts, you will see "Module 'greeter' loaded successfully." in your logs.
78
+ // You can now access http://localhost:7633/api/greet/World
79
+ ```
80
+
81
+ Modules are the preferred way to build reusable and maintainable extensions for `data-primals-engine`.
82
+
83
+ **[Next: Sharding / Replication](sharding-replication)**
@@ -1,4 +1,4 @@
1
- # Packs Gallery: Discover and Install Ready-to-Use Configurations
1
+ # Data Packs: Discover and Install Ready-to-Use Configurations
2
2
 
3
3
  **Packs** are pre-built configurations that allow you to quickly set up your `data-primals-engine` application with ready-to-use models, data, workflows, and more. They are designed to bootstrap common use cases like a CRM, an e-commerce backoffice, or a project management tool, saving you significant development time.
4
4
 
@@ -6,35 +6,17 @@ The **Pack Gallery** is the centralized place within the UI where you can discov
6
6
 
7
7
  ## What is a Pack?
8
8
 
9
- A pack is a JSON object that can contain:
9
+ A pack is a JSON object that can contain basically :
10
10
 
11
11
  - **`models`**: A list of model definitions (schemas) to be created.
12
12
  - **`data`**: Sample or initial data for the models in the pack. Data can be generic or language-specific.
13
13
  - **`workflows`**: Pre-configured automation workflows, including triggers, steps, and actions.
14
14
  - **`dashboards`** and **`kpis`**: Ready-to-use dashboards and KPIs for monitoring.
15
+ - ...
15
16
 
16
17
  ## Installing a Pack
17
18
 
18
- You can install a pack in two ways: by its ID from the gallery or by providing a custom JSON structure directly.
19
-
20
- ### 1. Installing from the Gallery
21
-
22
- Each pack in the gallery has a unique ID. You can use the `installPack` function with this ID to install it.
23
-
24
- ```javascript
25
- import { installPack } from 'data-primals-engine';
26
-
27
- // Assuming 'currentUser' is your authenticated user object
28
- const packId = "61d1f1a9e3f1a9e3f1a9e3f1"; // Example ID for an e-commerce pack
29
- const installationSummary = await installPack(packId, currentUser, "en");
30
-
31
- console.log(installationSummary);
32
- // Returns a summary of created models, inserted data, etc.
33
- ```
34
-
35
- ### 2. Installing a Custom Pack
36
-
37
- You can also define a pack on-the-fly and install it. This is useful for migrating configurations between environments or for programmatic setup.
19
+ You can define a pack on-the-fly and install it. This is useful for migrating configurations between environments or for programmatic setup.
38
20
 
39
21
  The `installPack` function accepts an array containing the pack's JSON definition.
40
22
 
@@ -70,4 +52,7 @@ const summary = await installPack(myCustomPack, currentUser, "en");
70
52
  console.log(summary);
71
53
  ```
72
54
 
73
- By using packs, you can dramatically accelerate your project setup and ensure consistency across different instances of your application.
55
+ By using packs, you can dramatically accelerate your project setup and ensure consistency across different instances of your application.
56
+
57
+
58
+ **[Next: AI assistance](AI-assistance)**
@@ -0,0 +1,32 @@
1
+ # Workflows and Automations
2
+
3
+ Workflows are one of the most powerful features of `data-primals-engine`. They allow you to automate complex business processes without writing code, by responding to data events or time-based schedules.
4
+
5
+ ---
6
+
7
+ ## Common Use Cases
8
+
9
+ - Send a welcome email when a new user signs up.
10
+
11
+ - Update inventory when an order is marked as "completed".
12
+
13
+ - Generate a PDF report every night at midnight.
14
+
15
+ - Call an external API when data is modified.
16
+
17
+ ## Trigger Types
18
+
19
+ A workflow is always initiated by a trigger. There are two main types:
20
+
21
+ ### 1. Data-Driven Triggers (Data Events)
22
+
23
+ These workflows are triggered automatically when an operation is performed on data:
24
+ - **After Create**: Triggers after a new record is created.
25
+
26
+ - **After Update**: Triggers after a record is modified.
27
+
28
+ - **Before Delete**: Triggers just before a record is deleted.
29
+
30
+ ### 2. Scheduled Triggers (Schedules)
31
+
32
+ These workflows run at specific times, using **cron** syntax. This is ideal for recurring tasks such as reports, database cleanups, or synchronizations.