data-primals-engine 1.7.1 → 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 (99) hide show
  1. package/README.md +9 -9
  2. package/client/package-lock.json +8430 -8121
  3. package/client/package.json +7 -4
  4. package/client/src/APIInfo.jsx +1 -1
  5. package/client/src/App.jsx +2 -1
  6. package/client/src/App.scss +1635 -1626
  7. package/client/src/AssistantChat.jsx +2 -3
  8. package/client/src/CalendarView.jsx +1 -0
  9. package/client/src/ContentView.jsx +3 -3
  10. package/client/src/Dashboard.jsx +5 -2
  11. package/client/src/DashboardChart.jsx +1 -0
  12. package/client/src/DashboardFlexViewItem.jsx +1 -0
  13. package/client/src/DashboardHtmlViewItem.jsx +1 -0
  14. package/client/src/DashboardView.jsx +2 -0
  15. package/client/src/DataEditor.jsx +0 -1
  16. package/client/src/DataImporter.jsx +489 -468
  17. package/client/src/DataLayout.jsx +25 -23
  18. package/client/src/DataTable.jsx +6 -5
  19. package/client/src/Dialog.jsx +92 -90
  20. package/client/src/Dialog.scss +122 -116
  21. package/client/src/DisplayFlexNodeRenderer.jsx +1 -0
  22. package/client/src/DocumentationPageLayout.scss +1 -1
  23. package/client/src/FlexBuilderControls.jsx +1 -0
  24. package/client/src/FlexBuilderPreview.jsx +1 -1
  25. package/client/src/FlexNode.jsx +1 -1
  26. package/client/src/HistoryDialog.jsx +3 -2
  27. package/client/src/KPIWidget.jsx +1 -1
  28. package/client/src/KanbanView.jsx +1 -0
  29. package/client/src/ModelCreator.jsx +4 -0
  30. package/client/src/ModelList.jsx +1 -0
  31. package/client/src/PackGallery.jsx +5 -4
  32. package/client/src/RTETrans.jsx +1 -1
  33. package/client/src/RelationField.jsx +2 -0
  34. package/client/src/RelationSelectorWidget.jsx +2 -0
  35. package/client/src/RelationValue.jsx +1 -0
  36. package/client/src/RestoreDialog.jsx +1 -0
  37. package/client/src/ViewSwitcher.jsx +1 -1
  38. package/client/src/WorkflowEditor.jsx +3 -0
  39. package/client/src/contexts/CommandContext.jsx +2 -1
  40. package/client/src/contexts/ModelContext.jsx +3 -3
  41. package/client/src/hooks/data.js +1 -0
  42. package/client/src/hooks/useValidation.js +1 -0
  43. package/client/src/translations.js +24 -24
  44. package/client/vite.config.js +31 -30
  45. package/doc/AI-assistance.md +87 -63
  46. package/doc/Concepts.md +122 -0
  47. package/doc/Custom-Endpoints.md +31 -0
  48. package/doc/Event-system.md +13 -14
  49. package/doc/Home.md +33 -0
  50. package/doc/Modules.md +83 -0
  51. package/doc/Packs-gallery.md +8 -23
  52. package/doc/Workflows.md +32 -0
  53. package/doc/automation-workflows.md +141 -102
  54. package/doc/dashboards-kpis-charts.md +47 -49
  55. package/doc/data-management.md +126 -120
  56. package/doc/data-models.md +68 -75
  57. package/doc/roles-permissions.md +144 -43
  58. package/doc/sharding-replication.md +158 -0
  59. package/doc/users.md +54 -30
  60. package/package.json +27 -17
  61. package/server.js +37 -37
  62. package/src/ai.jobs.js +135 -0
  63. package/src/constants.js +560 -545
  64. package/src/data.js +521 -518
  65. package/src/email.js +157 -154
  66. package/src/engine.js +167 -49
  67. package/src/gameObject.js +6 -0
  68. package/src/i18n.js +0 -1
  69. package/src/modules/assistant/assistant.js +782 -763
  70. package/src/modules/assistant/constants.js +23 -16
  71. package/src/modules/assistant/providers.js +77 -37
  72. package/src/modules/auth-google/index.js +53 -50
  73. package/src/modules/bucket.js +346 -335
  74. package/src/modules/data/data.backup.js +400 -376
  75. package/src/modules/data/data.cluster.js +559 -0
  76. package/src/modules/data/data.core.js +11 -8
  77. package/src/modules/data/data.js +311 -311
  78. package/src/modules/data/data.operations.js +3666 -3555
  79. package/src/modules/data/data.relations.js +1 -0
  80. package/src/modules/data/data.replication.js +125 -0
  81. package/src/modules/data/data.routes.js +2206 -1879
  82. package/src/modules/data/data.scheduling.js +2 -1
  83. package/src/modules/file.js +248 -247
  84. package/src/modules/mongodb.js +76 -73
  85. package/src/modules/user.js +18 -2
  86. package/src/modules/worker-script-runner.js +97 -0
  87. package/src/modules/workflow.js +177 -52
  88. package/src/packs.js +5701 -5701
  89. package/src/providers.js +298 -297
  90. package/src/sso.js +91 -25
  91. package/test/assistant.test.js +207 -206
  92. package/test/cluster.test.js +221 -0
  93. package/test/core.test.js +0 -2
  94. package/test/data.integration.test.js +1425 -1416
  95. package/test/import_export.integration.test.js +210 -210
  96. package/test/replication.test.js +163 -0
  97. package/test/workflow.actions.integration.test.js +487 -475
  98. package/test/workflow.integration.test.js +332 -329
  99. package/doc/core-concepts.md +0 -33
@@ -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 allow you 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.
16
-
17
- - **Method**: `POST`
18
- - **Summary**: Create one or more documents
19
- - **Description**: Creates one or more new documents in a specified model.
20
- - **Security**: `BearerAuth`
21
- - **Parameters**:
22
- - `_user` (query, required): Your username for authentication.
23
- - `model` (body, required): The name of the model in which to create the documents (e.g., 'user', 'product').
24
- - `data` (body, required): The data to insert. Can be a single object or an array of objects. Using the `$find` operator is recommended for relational data.
25
- - `lang` (query, optional, default: 'en'): Language used for error messages.
26
- - **Example Request Body**:
27
- ```json
28
- {
29
- "model": "product",
30
- "data": {
31
- "name": "New Product",
32
- "price": 99.99,
33
- "currency": "60d0fe4f5311236168a109cb"
34
- }
35
- }
36
- ```
37
- - **Responses**: `201` (Document(s) successfully created), `400` (Invalid data), `401` (Unauthorized).
38
-
39
- ### 2. Search Data: `POST /api/data/search`
40
-
41
- This endpoint allows you to search and retrieve documents from a specified model. It supports powerful filtering, sorting, pagination, and relation population.
42
-
43
- - **Method**: `POST`
44
- - **Summary**: Search among data
45
- - **Description**: Search across all data of the specified model.
46
- - **Security**: `BearerAuth`
47
- - **Parameters**:
48
- - `_user` (query, required): Your username for authentication.
49
- - `model` (body, required): The name of the data model (e.g., 'user', 'product').
50
- - `filter` (body, optional): MongoDB filter JSON object for the search.
51
- - `sort` (query, optional): Sort parameter by field (e.g., `fieldName:ASC;fieldName2:DESC`).
52
- - `limit` (query, optional, default: 1000): Maximum number of documents to return.
53
- - `offset` (query, optional, default: 0): Number of documents to skip (for pagination).
54
- - `depth` (query, optional, default: 1): Population depth for 'relation' type fields.
55
- - `lang` (query, optional, default: 'en'): Language used for error messages.
56
- - **Example Request Body (Filter)**:
57
- ```json
58
- {
59
- "model": "product",
60
- "filter": {
61
- "price": { "$gt": 50 },
62
- "category": "60d0fe4f5311236168a109cc"
63
- }
64
- }
65
- ```
66
- - **Responses**: `200` (Success with returned data), `401` (Unauthorized).
67
-
68
- ### 3. Update Data: `PUT /api/data/{id}` or `PUT /api/data` (Bulk)
69
-
70
- You can update a single document by its ID or perform bulk updates using a filter.
71
-
72
- - **Method**: `PUT`
73
- - **Summary**: Update a document (by ID) or Bulk update documents
74
- - **Description**: Updates an existing document using its ID, or multiple documents using a filter.
75
- - **Security**: `BearerAuth`
76
- - **Parameters**:
77
- - `_user` (query, required): Your username for authentication.
78
- - `id` (path, required for single update): The unique identifier (`_id`) of the document to update.
79
- - `model` (body, required): The name of the data model.
80
- - `data` (body, required): The data to edit. For bulk updates, this object will contain the fields to update.
81
- - `filter` (body, optional, for bulk update): MongoDB filter JSON object to select documents for bulk update.
82
- - `lang` (query, optional, default: 'en'): Language used for error messages.
83
- - **Example Request Body (Single Update)**:
84
- ```json
85
- {
86
- "model": "product",
87
- "data": {
88
- "price": 120.00
89
- }
90
- }
91
- ```
92
- - **Responses**: `200` (Document successfully updated), `400` (Invalid data), `401` (Unauthorized), `404` (Document not found).
93
-
94
- ### 4. Delete Data: `DELETE /api/data`
95
-
96
- This endpoint allows you to permanently delete one or more documents.
97
-
98
- - **Method**: `DELETE`
99
- - **Summary**: Delete one or more document(s)
100
- - **Description**: Permanently deletes a document using its ID, or multiple documents using a filter.
101
- - **Security**: `BearerAuth`
102
- - **Parameters**:
103
- - `_user` (query, required): Your username for authentication.
104
- - `ids` (body, optional): An array of identifiers of the documents to delete.
105
- - `filter` (body, optional): The MongoDB JSON filter to apply for bulk deletion.
106
- - `lang` (query, optional, default: 'en'): Language used for error messages.
107
- - **Example Request Body (Bulk Delete)**:
108
- ```json
109
- {
110
- "model": "product",
111
- "filter": {
112
- "status": "draft"
113
- }
114
- }
115
- ```
116
- - **Responses**: `200` (Document successfully deleted), `401` (Unauthorized), `404` (Document not found).
117
-
118
- These generic CRUD endpoints provide a flexible and powerful way to interact with all your data models within the `data-primals-engine`.
119
-
120
- **Next: Dashboards, KPIs, and Charts**
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)**