data-primals-engine 1.6.3 → 1.6.5

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.
@@ -7,6 +7,7 @@
7
7
  "": {
8
8
  "name": "client",
9
9
  "version": "0.0.0",
10
+ "hasInstallScript": true,
10
11
  "dependencies": {
11
12
  "@babel/runtime": "^7.28.3",
12
13
  "@codeium/react-code-editor": "^1.0.12",
@@ -1134,7 +1135,7 @@
1134
1135
  "globals": "^14.0.0",
1135
1136
  "ignore": "^5.2.0",
1136
1137
  "import-fresh": "^3.2.1",
1137
- "js-yaml": "^4.1.0",
1138
+ "js-yaml": ">=4.1.1",
1138
1139
  "minimatch": "^3.1.2",
1139
1140
  "strip-json-comments": "^3.1.1"
1140
1141
  },
@@ -3223,23 +3224,28 @@
3223
3224
  }
3224
3225
  },
3225
3226
  "node_modules/body-parser": {
3226
- "version": "2.2.0",
3227
- "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz",
3228
- "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==",
3227
+ "version": "2.2.1",
3228
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.1.tgz",
3229
+ "integrity": "sha512-nfDwkulwiZYQIGwxdy0RUmowMhKcFVcYXUU7m4QlKYim1rUtg83xm2yjZ40QjDuc291AJjjeSc9b++AWHSgSHw==",
3230
+ "license": "MIT",
3229
3231
  "peer": true,
3230
3232
  "dependencies": {
3231
3233
  "bytes": "^3.1.2",
3232
3234
  "content-type": "^1.0.5",
3233
- "debug": "^4.4.0",
3235
+ "debug": "^4.4.3",
3234
3236
  "http-errors": "^2.0.0",
3235
- "iconv-lite": "^0.6.3",
3237
+ "iconv-lite": "^0.7.0",
3236
3238
  "on-finished": "^2.4.1",
3237
3239
  "qs": "^6.14.0",
3238
- "raw-body": "^3.0.0",
3239
- "type-is": "^2.0.0"
3240
+ "raw-body": "^3.0.1",
3241
+ "type-is": "^2.0.1"
3240
3242
  },
3241
3243
  "engines": {
3242
3244
  "node": ">=18"
3245
+ },
3246
+ "funding": {
3247
+ "type": "opencollective",
3248
+ "url": "https://opencollective.com/express"
3243
3249
  }
3244
3250
  },
3245
3251
  "node_modules/brace-expansion": {
@@ -3323,6 +3329,7 @@
3323
3329
  "version": "3.1.2",
3324
3330
  "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
3325
3331
  "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
3332
+ "license": "MIT",
3326
3333
  "peer": true,
3327
3334
  "engines": {
3328
3335
  "node": ">= 0.8"
@@ -3766,9 +3773,10 @@
3766
3773
  "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg=="
3767
3774
  },
3768
3775
  "node_modules/debug": {
3769
- "version": "4.4.1",
3770
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
3771
- "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
3776
+ "version": "4.4.3",
3777
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
3778
+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
3779
+ "license": "MIT",
3772
3780
  "dependencies": {
3773
3781
  "ms": "^2.1.3"
3774
3782
  },
@@ -4440,7 +4448,7 @@
4440
4448
  "peer": true,
4441
4449
  "dependencies": {
4442
4450
  "accepts": "^2.0.0",
4443
- "body-parser": "^2.2.0",
4451
+ "body-parser": ">=2.2.1",
4444
4452
  "content-disposition": "^1.0.0",
4445
4453
  "content-type": "^1.0.5",
4446
4454
  "cookie": "^0.7.1",
@@ -5020,19 +5028,24 @@
5020
5028
  }
5021
5029
  },
5022
5030
  "node_modules/http-errors": {
5023
- "version": "2.0.0",
5024
- "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
5025
- "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
5031
+ "version": "2.0.1",
5032
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
5033
+ "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
5034
+ "license": "MIT",
5026
5035
  "peer": true,
5027
5036
  "dependencies": {
5028
- "depd": "2.0.0",
5029
- "inherits": "2.0.4",
5030
- "setprototypeof": "1.2.0",
5031
- "statuses": "2.0.1",
5032
- "toidentifier": "1.0.1"
5037
+ "depd": "~2.0.0",
5038
+ "inherits": "~2.0.4",
5039
+ "setprototypeof": "~1.2.0",
5040
+ "statuses": "~2.0.2",
5041
+ "toidentifier": "~1.0.1"
5033
5042
  },
5034
5043
  "engines": {
5035
5044
  "node": ">= 0.8"
5045
+ },
5046
+ "funding": {
5047
+ "type": "opencollective",
5048
+ "url": "https://opencollective.com/express"
5036
5049
  }
5037
5050
  },
5038
5051
  "node_modules/i18next": {
@@ -5067,15 +5080,20 @@
5067
5080
  }
5068
5081
  },
5069
5082
  "node_modules/iconv-lite": {
5070
- "version": "0.6.3",
5071
- "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
5072
- "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
5083
+ "version": "0.7.0",
5084
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz",
5085
+ "integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==",
5086
+ "license": "MIT",
5073
5087
  "peer": true,
5074
5088
  "dependencies": {
5075
5089
  "safer-buffer": ">= 2.1.2 < 3.0.0"
5076
5090
  },
5077
5091
  "engines": {
5078
5092
  "node": ">=0.10.0"
5093
+ },
5094
+ "funding": {
5095
+ "type": "opencollective",
5096
+ "url": "https://opencollective.com/express"
5079
5097
  }
5080
5098
  },
5081
5099
  "node_modules/ignore": {
@@ -5575,15 +5593,16 @@
5575
5593
  "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
5576
5594
  },
5577
5595
  "node_modules/js-yaml": {
5578
- "version": "4.1.0",
5579
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
5580
- "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
5596
+ "version": "4.1.1",
5597
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
5598
+ "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
5581
5599
  "dev": true,
5600
+ "license": "MIT",
5582
5601
  "dependencies": {
5583
5602
  "argparse": "^2.0.1"
5584
5603
  },
5585
5604
  "bin": {
5586
- "js-yaml": "bin/js-yaml.js"
5605
+ "js-yaml": ">=4.1.1"
5587
5606
  }
5588
5607
  },
5589
5608
  "node_modules/jsesc": {
@@ -6559,18 +6578,19 @@
6559
6578
  }
6560
6579
  },
6561
6580
  "node_modules/raw-body": {
6562
- "version": "3.0.0",
6563
- "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.0.tgz",
6564
- "integrity": "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g==",
6581
+ "version": "3.0.2",
6582
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz",
6583
+ "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==",
6584
+ "license": "MIT",
6565
6585
  "peer": true,
6566
6586
  "dependencies": {
6567
- "bytes": "3.1.2",
6568
- "http-errors": "2.0.0",
6569
- "iconv-lite": "0.6.3",
6570
- "unpipe": "1.0.0"
6587
+ "bytes": "~3.1.2",
6588
+ "http-errors": "~2.0.1",
6589
+ "iconv-lite": "~0.7.0",
6590
+ "unpipe": "~1.0.0"
6571
6591
  },
6572
6592
  "engines": {
6573
- "node": ">= 0.8"
6593
+ "node": ">= 0.10"
6574
6594
  }
6575
6595
  },
6576
6596
  "node_modules/react": {
@@ -6952,7 +6972,7 @@
6952
6972
  "highlight.js": "^10.4.1",
6953
6973
  "highlightjs-vue": "^1.0.0",
6954
6974
  "lowlight": "^1.17.0",
6955
- "prismjs": "^1.27.0",
6975
+ "prismjs": ">=1.30.0",
6956
6976
  "refractor": "^3.6.0"
6957
6977
  },
6958
6978
  "peerDependencies": {
@@ -7068,7 +7088,7 @@
7068
7088
  "dependencies": {
7069
7089
  "hastscript": "^6.0.0",
7070
7090
  "parse-entities": "^2.0.0",
7071
- "prismjs": "~1.27.0"
7091
+ "prismjs": ">=1.30.0"
7072
7092
  },
7073
7093
  "funding": {
7074
7094
  "type": "github",
@@ -7167,15 +7187,6 @@
7167
7187
  "url": "https://github.com/sponsors/wooorm"
7168
7188
  }
7169
7189
  },
7170
- "node_modules/refractor/node_modules/prismjs": {
7171
- "version": "1.27.0",
7172
- "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz",
7173
- "integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==",
7174
- "peer": true,
7175
- "engines": {
7176
- "node": ">=6"
7177
- }
7178
- },
7179
7190
  "node_modules/regexp.prototype.flags": {
7180
7191
  "version": "1.5.4",
7181
7192
  "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz",
@@ -7422,6 +7433,7 @@
7422
7433
  "version": "2.1.2",
7423
7434
  "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
7424
7435
  "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
7436
+ "license": "MIT",
7425
7437
  "peer": true
7426
7438
  },
7427
7439
  "node_modules/sass": {
@@ -8021,9 +8033,10 @@
8021
8033
  "integrity": "sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w=="
8022
8034
  },
8023
8035
  "node_modules/statuses": {
8024
- "version": "2.0.1",
8025
- "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
8026
- "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
8036
+ "version": "2.0.2",
8037
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
8038
+ "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
8039
+ "license": "MIT",
8027
8040
  "peer": true,
8028
8041
  "engines": {
8029
8042
  "node": ">= 0.8"
@@ -8440,6 +8453,7 @@
8440
8453
  "version": "1.0.0",
8441
8454
  "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
8442
8455
  "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
8456
+ "license": "MIT",
8443
8457
  "peer": true,
8444
8458
  "engines": {
8445
8459
  "node": ">= 0.8"
@@ -8808,4 +8822,4 @@
8808
8822
  }
8809
8823
  }
8810
8824
  }
8811
- }
8825
+ }
@@ -4,6 +4,7 @@
4
4
  "version": "0.0.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
+ "preinstall": "npx force-resolutions",
7
8
  "dev": "vite",
8
9
  "build": "vite build --mode development",
9
10
  "build:ssr-client": "vite build --ssrManifest --outDir dist/client --mode development",
@@ -11,6 +12,11 @@
11
12
  "lint": "eslint .",
12
13
  "preview": "vite preview"
13
14
  },
15
+ "resolutions": {
16
+ "body-parser": ">=2.2.1",
17
+ "js-yaml": ">=4.1.1",
18
+ "prismjs": ">=1.30.0"
19
+ },
14
20
  "peerDependencies": {
15
21
  "@tiptap/react": "^2.26.1",
16
22
  "react-chartjs-2": "^5.3.0",
@@ -5,6 +5,35 @@ img {
5
5
  width: auto;
6
6
  }
7
7
 
8
+ /*
9
+ * Style global pour les barres de défilement (scrollbars)
10
+ * S'applique à toute l'application, y compris les blocs de code.
11
+ */
12
+
13
+ /* Pour les navigateurs WebKit (Chrome, Safari, Edge, etc.) */
14
+ ::-webkit-scrollbar {
15
+ width: 8px; /* Largeur de la scrollbar verticale */
16
+ height: 8px; /* Hauteur de la scrollbar horizontale */
17
+ }
18
+
19
+ /* La piste (le fond de la scrollbar) */
20
+ ::-webkit-scrollbar-track {
21
+ background: $scrollbar-track-color;
22
+ border-radius: 10px;
23
+ }
24
+
25
+ /* La poignée (la partie mobile de la scrollbar) */
26
+ ::-webkit-scrollbar-thumb {
27
+ background-color: $scrollbar-thumb-color;
28
+ border-radius: 10px;
29
+ border: 2px solid $scrollbar-track-color; /* Crée un petit espacement autour de la poignée */
30
+ }
31
+
32
+ /* La poignée au survol de la souris */
33
+ ::-webkit-scrollbar-thumb:hover {
34
+ background-color: $scrollbar-thumb-hover-color;
35
+ }
36
+
8
37
  body {
9
38
  font-family: "Nunito Sans", sans-serif;
10
39
  line-height: 1.6; // Améliore la lisibilité
@@ -17,5 +17,8 @@ $danger-color: #ff1e00;
17
17
  $shadow-color: rgba(0, 0, 0, 0.15);
18
18
  $shadow-color-hover: rgba(0, 0, 0, 0.25);
19
19
 
20
+ $scrollbar-track-color: #f1f1f1; // Couleur de fond de la scrollbar (très clair)
21
+ $scrollbar-thumb-color: #c1c1c1; // Couleur de la barre de défilement
22
+ $scrollbar-thumb-hover-color: #a8a8a8; // Couleur au survol
20
23
 
21
24
  // Appliquer cette palette aux différents éléments
@@ -0,0 +1,102 @@
1
+ # Automation with Workflows: Create Automated Processes
2
+
3
+ The `data-primals-engine` features a powerful **Workflow** system that enables you to define and automate complex business processes. Workflows are sequences of steps and actions that can be triggered by various events or on a schedule, allowing for sophisticated automation directly within your backend.
4
+
5
+ ## Core Workflow Models
6
+
7
+ The workflow system is composed of several interconnected data models:
8
+
9
+ ### 1. `workflow`
10
+
11
+ The `workflow` model is the top-level definition of an automated process. It outlines the overall flow and its starting point.
12
+
13
+ - **`name`** (string, required): A unique, descriptive name for the workflow (e.g., "Order Validation", "Low Stock Notification").
14
+ - **`description`** (richtext, optional): A detailed explanation of the workflow's purpose.
15
+ - **`startStep`** (relation to `workflowStep`, optional): The first step to execute when the workflow is initiated.
16
+
17
+ ### 2. `workflowTrigger`
18
+
19
+ A `workflowTrigger` defines an event or schedule that initiates a workflow.
20
+
21
+ - **`workflow`** (relation to `workflow`, required): The workflow that this trigger belongs to.
22
+ - **`name`** (string, required, unique): A descriptive name for the trigger (e.g., "New Order Created", "Stock < 5", "Monday 9 AM Report").
23
+ - **`type`** (enum, required): How the workflow is initiated:
24
+ - `manual`: Triggered by a data event.
25
+ - `scheduled`: Triggered by a cron schedule.
26
+ - **`onEvent`** (enum, for `manual` type): The data event that triggers the workflow: `DataAdded`, `DataEdited`, `DataDeleted`, `ModelAdded`, `ModelEdited`, `ModelDeleted`.
27
+ - **`targetModel`** (string, for `manual` type): The name of the model targeted by the `onEvent`.
28
+ - **`dataFilter`** (code - JSON, optional, for `manual` type): Optional MongoDB filter conditions checked against the `triggerData` before executing the workflow.
29
+ - **`cronExpression`** (string, for `scheduled` type): A cron expression (e.g., `'0 9 * * 1'` for Monday 9 AM) to schedule the workflow.
30
+ - **`isActive`** (boolean): Whether the trigger is currently active.
31
+ - **`env`** (code - JSON, optional): Environment variables (JSON key/value pairs) specific to this trigger.
32
+
33
+ ### 3. `workflowStep`
34
+
35
+ A `workflowStep` represents a single stage within a workflow process. It can contain conditions, actions, and define the next steps based on success or failure.
36
+
37
+ - **`workflow`** (relation to `workflow`, required): The workflow this step belongs to.
38
+ - **`name`** (string, optional): A descriptive name for the step (e.g., "Check Inventory", "Send Confirmation Email").
39
+ - **`conditions`** (code - JSON, optional): Optional conditions (MongoDB filter syntax) that must be met before the step's actions are executed. These can reference `contextData`.
40
+ - **`actions`** (multiple relation to `workflowAction`, required): The main operations performed by this step.
41
+ - **`onSuccessStep`** (relation to `workflowStep`, optional): The next step to execute if this step's conditions are met and actions succeed.
42
+ - **`onFailureStep`** (relation to `workflowStep`, optional): The next step if conditions fail or any action within this step fails.
43
+ - **`isTerminal`** (boolean, default: `false`): Indicates if this step marks the end of a workflow path.
44
+
45
+ ### 4. `workflowAction`
46
+
47
+ A `workflowAction` defines a specific operation to be performed by a `workflowStep`. This is where the actual work of the workflow happens.
48
+
49
+ - **`name`** (string, required): Name of the action (e.g., "Update Order Status", "Send Email", "Call Payment API").
50
+ - **`type`** (enum, required): The type of operation to perform:
51
+ - `UpdateData`: Modify existing data in a `targetModel`.
52
+ - `CreateData`: Add new data to a `targetModel`.
53
+ - `DeleteData`: Remove data from a `targetModel`.
54
+ - `ExecuteScript`: Run custom JavaScript code.
55
+ - `HttpRequest`: Make an HTTP request to an external service.
56
+ - `SendEmail`: Send an email.
57
+ - `Wait`: Pause the workflow for a specified duration.
58
+ - `GenerateAIContent`: Generate content using an AI model (e.g., OpenAI, Google Gemini).
59
+ - `ExecuteServiceFunction`: Call a function from a registered internal service (e.g., 'stripe').
60
+ - **`targetModel`** (string, for data operations): The model to target.
61
+ - **`targetSelector`** (code - JSON, for `UpdateData`/`DeleteData`): Expression to filter the target document(s).
62
+ - **`fieldsToUpdate`** (code - JSON, for `UpdateData`): Key-value pairs of fields to update.
63
+ - **`dataToCreate`** (code - JSON, for `CreateData`): Object template for the new document.
64
+ - **`script`** (code - JavaScript, for `ExecuteScript`): The JavaScript code to execute.
65
+ - **`url`, `method`, `headers`, `body`** (for `HttpRequest`): Details for the HTTP request.
66
+ - **`emailRecipients`, `emailSubject`, `emailContent`** (for `SendEmail`): Email details.
67
+ - **`duration`, `durationUnit`** (for `Wait`): How long to pause.
68
+ - **`aiProvider`, `aiModel`, `prompt`** (for `GenerateAIContent`): AI model and prompt details.
69
+ - **`serviceName`, `functionName`, `args`** (for `ExecuteServiceFunction`): Service call details.
70
+
71
+ ## Workflow Execution (`workflowRun`)
72
+
73
+ Each time a workflow is triggered, a `workflowRun` document is created to track its execution.
74
+
75
+ - **`workflow`** (relation to `workflow`): The workflow definition that was executed.
76
+ - **`contextData`** (code - JSON): A snapshot of the data or event that triggered this run, and any data generated during execution.
77
+ - **`status`** (enum): The current status (`pending`, `running`, `completed`, `failed`, `waiting`, `cancelled`).
78
+ - **`history`** (array of objects): Detailed execution history of each step and action.
79
+ - **`startedAt`, `completedAt`**: Timestamps for the run.
80
+ - **`error`**: Error message if the workflow run failed.
81
+
82
+ ## Example Workflow Scenario
83
+
84
+ Consider a workflow to "Send a Welcome Email to New Users":
85
+
86
+ 1. **`workflow`**: "New User Onboarding"
87
+ 2. **`workflowTrigger`**:
88
+ - `name`: "On New User Added"
89
+ - `type`: `manual`
90
+ - `onEvent`: `DataAdded`
91
+ - `targetModel`: `user`
92
+ 3. **`workflowStep`**: "Send Welcome Email"
93
+ - `workflow`: "New User Onboarding"
94
+ - `actions`: [ID of "Send Welcome Email Action"]
95
+ - `onSuccessStep`: (optional) "Create Onboarding Task"
96
+ 4. **`workflowAction`**: "Send Welcome Email Action"
97
+ - `type`: `SendEmail`
98
+ - `emailRecipients`: `{triggerData.contact.email}`
99
+ - `emailSubject`: "Welcome to Our Platform, {triggerData.contact.firstName}!"
100
+ - `emailContent`: "Hello {triggerData.contact.firstName}, welcome aboard..."
101
+
102
+ This powerful system allows you to automate virtually any process, from simple notifications to complex data transformations and integrations with external services.
@@ -0,0 +1,33 @@
1
+ # Core Concepts: Data Modeling Fundamentals
2
+
3
+ The `data-primals-engine` is built around a flexible and powerful data modeling system that allows you to define and manage your application's data structures without complex migrations. This section introduces the fundamental concepts of data modeling within the engine.
4
+
5
+ ## Dynamic and Schema-less Nature
6
+
7
+ At its core, `data-primals-engine` leverages **MongoDB**, a NoSQL database. This provides inherent flexibility, allowing for a schema-less approach. You can define and update your data models either through a user interface or by providing JSON definitions, and the system adapts dynamically without requiring traditional database migrations. This significantly accelerates development and iteration cycles.
8
+
9
+ ## Models
10
+
11
+ A **Model** is the blueprint for a collection of data. It defines the structure and characteristics of the documents you store. For example, a `User` model would define what properties a user object has (e.g., `username`, `email`, `roles`).
12
+
13
+ Models are defined by a `name`, an optional `description`, an `icon`, and a list of `fields`. The engine comes with a set of default models for common entities like `user`, `product`, `workflow`, and more.
14
+
15
+ ## Fields
16
+
17
+ **Fields** are the individual attributes that make up a model. Each field has a `name`, a `type`, and various optional properties that define its behavior and constraints.
18
+
19
+ Common field types include:
20
+ - `string`: For text data.
21
+ - `number`: For numerical data.
22
+ - `boolean`: For true/false values.
23
+ - `datetime`: For date and time values.
24
+ - `relation`: To establish relationships between different models (e.g., a `product` model having a `category` field that relates to a `taxonomy` model).
25
+ - `enum`: For fields with a predefined set of allowed values.
26
+ - `file`: For handling file uploads (e.g., `profilePicture` in the `user` model).
27
+ - `code`: For storing code snippets (e.g., `script` in an `endpoint` model).
28
+
29
+ Fields can also have properties like `required`, `unique`, `min`, `max`, `default` values, and `hint` for user guidance.
30
+
31
+ This dynamic and field-based approach to data modeling provides the flexibility needed for rapidly building complex data-driven applications.
32
+
33
+ **Next: Data Models**
@@ -0,0 +1,40 @@
1
+ # Custom API Endpoints: Create Dynamic HTTP Routes
2
+
3
+ The `data-primals-engine` allows you to extend its API by defining **Custom API Endpoints**. These endpoints are dynamic HTTP routes that execute server-side JavaScript code directly from the backend, providing immense flexibility for custom logic and integrations.
4
+
5
+ ## The `endpoint` Model
6
+
7
+ Custom API Endpoints are managed through the built-in `endpoint` data model. Each document in this model represents a unique API route.
8
+
9
+ ### Key Fields of the `endpoint` Model:
10
+
11
+ - **`name`** (string, required): A human-readable name for the endpoint.
12
+ - **`path`** (string, required, unique): The URL path segment that comes after `/api/actions/`. For example, if `path` is `send-welcome-email`, the full endpoint URL would be `/api/actions/send-welcome-email`.
13
+ - **`method`** (enum, required): The HTTP method (GET, POST, PUT, PATCH, DELETE) that this endpoint responds to.
14
+ - **`code`** (code, required): The JavaScript script that will be executed when this endpoint is called. This script has access to various utilities and the request context.
15
+ - **`isActive`** (boolean, default: `true`): If checked, the endpoint is active and can be called.
16
+ - **`isPublic`** (boolean, default: `false`): If checked, this endpoint will be accessible without authentication. Use with caution.
17
+
18
+ ### Script Execution Environment
19
+
20
+ The JavaScript `code` field provides a powerful environment for your custom logic:
21
+
22
+ - **`db`**: An object providing methods for interacting with the database (e.g., `db.find`, `db.create`, `db.update`, `db.delete`).
23
+ - **`logger`**: A logging utility (e.g., `logger.info`, `logger.error`).
24
+ - **`env`**: Access to environment variables defined in the `env` model.
25
+ - **`request`**: The incoming HTTP request object, containing `body`, `query`, `params`, and `headers`.
26
+ - **`user`**: The authenticated user object (if `isPublic` is false).
27
+
28
+ The script's return value will be sent as the JSON response to the client.
29
+
30
+ ### Example `endpoint` Definition (from `defaultModels.js`):
31
+
32
+ ```javascript
33
+ // The default code for a new endpoint
34
+ logger.info('Custom endpoint executed with body:', request.body);
35
+ return { success: true, message: 'Endpoint executed!', received: request.body };
36
+ ```
37
+
38
+ This feature allows developers to build highly customized backend logic directly within the `data-primals-engine`, making it a versatile tool for various application needs.
39
+
40
+ **Next: Data Models**
@@ -0,0 +1,49 @@
1
+ # Dashboards, KPIs, and Charts: Track Your Key Metrics
2
+
3
+ The `data-primals-engine` provides robust features for visualizing and tracking your application's performance and key metrics through customizable Dashboards and Key Performance Indicators (KPIs).
4
+
5
+ ## Dashboards
6
+
7
+ A **Dashboard** serves as a personalized overview, allowing users to arrange and display various KPIs and charts relevant to their needs.
8
+
9
+ ### Key Fields of the `dashboard` Model:
10
+
11
+ - **`name`** (string, required): The customizable display name of the dashboard.
12
+ - **`description`** (string, optional): Provides additional context for the dashboard.
13
+ - **`layout`** (code - JSON, required): A JSON structure describing the organization of KPIs and charts. This defines how elements are arranged (e.g., in columns).
14
+ - **Example Layout**: `"{ \"type\": \"columns\", \"columns\": [ [\"kpi_id_1\"], [\"kpi_id_2\", \"kpi_id_3\"] ] }"`
15
+ - **`settings`** (code - JSON, optional): JSON settings for the dashboard, such as a `defaultTimeRange` (e.g., 'last_7_days') or a `refreshInterval` in seconds.
16
+ - **`isDefault`** (boolean, default: `false`): If `true`, this dashboard is displayed by default for the user.
17
+
18
+ ## Key Performance Indicators (KPIs)
19
+
20
+ **KPIs** are quantifiable measures used to evaluate the success of an organization, employee, etc., in meeting objectives. In `data-primals-engine`, KPIs are highly configurable to extract meaningful insights from your data.
21
+
22
+ ### Key Fields of the `kpi` Model:
23
+
24
+ - **`name`** (string, required): The display name of the KPI (e.g., "Total Revenue", "Active Users").
25
+ - **`description`** (string, optional): Additional information about the KPI.
26
+ - **`targetModel`** (string, required): The name of the data model on which to calculate the KPI (e.g., `order`, `user`).
27
+ - **`aggregationType`** (enum, required): The type of calculation to perform:
28
+ - `count`: Count the number of documents.
29
+ - `sum`: Sum a numeric field.
30
+ - `avg`: Calculate the average of a numeric field.
31
+ - `min`: Find the minimum value of a numeric field.
32
+ - `max`: Find the maximum value of a numeric field.
33
+ - **`aggregationField`** (string, optional): The name of the numeric field to apply the aggregation to (e.g., `totalAmount`). Not required for `count` type.
34
+ - **`matchFormula`** (code - JSON, optional): A MongoDB `$match` JSON filter to apply before aggregation (e.g., `{ "status": "delivered" }`). This allows you to filter the data used for the KPI calculation.
35
+ - **`showTotal`** (boolean): Whether to display a grand total alongside the KPI.
36
+ - **`showPercentTotal`** (boolean): Whether to display the KPI value as a percentage of a total.
37
+ - **`totalMatchFormula`** (code - JSON, optional): A MongoDB `$match` JSON filter for calculating the total when `showPercentTotal` is enabled.
38
+ - **`unit`** (string, optional): The unit to display with the KPI value (e.g., "€", "$", "users").
39
+ - **`icon`** (string, optional): An icon name (e.g., `FaUsers`, `FaShoppingCart`) to visually represent the KPI.
40
+ - **`order`** (number, optional): The display order of the KPI on a dashboard.
41
+ - **`color`** (string, optional): A color associated with the KPI for visual distinction.
42
+
43
+ ## Charts
44
+
45
+ While the `kpi` model focuses on single aggregated values, the engine also supports the integration of charts to visualize data trends and distributions over time or across categories. These are typically rendered based on underlying KPI data or direct queries, offering a richer analytical experience.
46
+
47
+ By combining Dashboards, configurable KPIs, and charting capabilities, `data-primals-engine` empowers users to effectively monitor and understand their key business metrics.
48
+
49
+ **Next: Users**