data-primals-engine 1.5.2 → 1.6.0

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 (63) hide show
  1. package/README.md +924 -915
  2. package/client/README.md +136 -136
  3. package/client/index.js +0 -1
  4. package/client/public/doc/API.postman_collection.json +213 -213
  5. package/client/public/react.svg +9 -9
  6. package/client/src/AddWidgetTypeModal.jsx +47 -47
  7. package/client/src/App.css +42 -42
  8. package/client/src/App.jsx +92 -150
  9. package/client/src/App.scss +6 -0
  10. package/client/src/AssistantChat.jsx +362 -363
  11. package/client/src/Button.jsx +12 -12
  12. package/client/src/Dashboard.jsx +480 -480
  13. package/client/src/DashboardHtmlViewItem.jsx +146 -146
  14. package/client/src/DashboardView.jsx +654 -654
  15. package/client/src/DataEditor.jsx +383 -383
  16. package/client/src/DataLayout.jsx +779 -808
  17. package/client/src/DataTable.jsx +782 -822
  18. package/client/src/DataTable.scss +186 -186
  19. package/client/src/GeolocationField.jsx +93 -93
  20. package/client/src/HistoryDialog.jsx +307 -307
  21. package/client/src/HistoryDialog.scss +319 -319
  22. package/client/src/HtmlViewBuilderModal.jsx +90 -90
  23. package/client/src/HtmlViewBuilderModal.scss +17 -17
  24. package/client/src/HtmlViewCard.jsx +43 -43
  25. package/client/src/ModelCreatorField.jsx +950 -950
  26. package/client/src/ModelList.jsx +280 -280
  27. package/client/src/Notification.jsx +136 -136
  28. package/client/src/PackGallery.jsx +391 -391
  29. package/client/src/PackGallery.scss +231 -231
  30. package/client/src/Pagination.jsx +143 -143
  31. package/client/src/RelationField.jsx +354 -354
  32. package/client/src/RelationSelectorWidget.jsx +172 -172
  33. package/client/src/RelationValue.jsx +2 -1
  34. package/client/src/contexts/CommandContext.jsx +260 -0
  35. package/client/src/contexts/ModelContext.jsx +4 -1
  36. package/client/src/contexts/UIContext.jsx +72 -72
  37. package/client/src/filter.js +263 -263
  38. package/client/src/index.css +90 -90
  39. package/package.json +6 -5
  40. package/perf/artillery-hooks.js +37 -37
  41. package/perf/setup.yml +25 -25
  42. package/src/constants.js +4 -0
  43. package/src/engine.js +335 -335
  44. package/src/events.js +232 -137
  45. package/src/filter.js +274 -274
  46. package/src/modules/assistant/assistant.js +225 -83
  47. package/src/modules/auth-google/index.js +50 -50
  48. package/src/modules/auth-microsoft/index.js +81 -81
  49. package/src/modules/data/data.core.js +118 -118
  50. package/src/modules/data/data.history.js +555 -555
  51. package/src/modules/data/data.operations.js +3401 -3381
  52. package/src/modules/data/data.relations.js +686 -686
  53. package/src/modules/data/data.routes.js +1879 -1879
  54. package/src/modules/data/data.validation.js +2 -2
  55. package/src/modules/file.js +247 -247
  56. package/src/packs.js +2 -2
  57. package/src/providers.js +2 -2
  58. package/src/services/stripe.js +196 -196
  59. package/src/sso.js +193 -193
  60. package/test/data.history.integration.test.js +264 -264
  61. package/test/data.integration.test.js +1206 -1206
  62. package/test/events.test.js +108 -10
  63. package/test/model.integration.test.js +377 -377
@@ -1,91 +1,91 @@
1
- import React, { useState, useEffect, useMemo } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { Dialog } from './Dialog.jsx';
4
- import {TextField, SelectField, NumberField, CodeField, ModelField} from './Field.jsx';
5
- import Button from './Button.jsx';
6
- import { FaSave, FaTimes } from 'react-icons/fa';
7
- import './HtmlViewBuilderModal.scss';
8
-
9
- const HtmlViewBuilderModal = ({ isOpen, onClose, onSave, models, initialConfig }) => {
10
- const { t } = useTranslation();
11
- const [config, setConfig] = useState({});
12
- const [jsonError, setJsonError] = useState('');
13
-
14
- useEffect(() => {
15
- if (isOpen) {
16
- setConfig(initialConfig || {
17
- title: '',
18
- model: '',
19
- limit: 10,
20
- filter: {},
21
- template: '',
22
- css: '',
23
- ...initialConfig
24
- });
25
- setJsonError('');
26
- }
27
- }, [isOpen, initialConfig]);
28
-
29
- const modelOptions = useMemo(() => {
30
- return (models || []).map(m => ({ label: m.name, value: m.name }));
31
- }, [models]);
32
-
33
- const handleChange = (e) => {
34
- const { name, value } = e.target || e;
35
- setConfig(prev => ({ ...prev, [name]: value }));
36
- };
37
-
38
- const handleCodeChange = (name, value) => {
39
- setConfig(prev => ({ ...prev, [name]: value }));
40
- };
41
-
42
- const handleFilterChange = (codeValue) => {
43
- try {
44
- const parsed = JSON.parse(codeValue);
45
- setConfig(prev => ({ ...prev, filter: parsed }));
46
- setJsonError('');
47
- } catch (e) {
48
- setJsonError(t('dashboards.invalidJson', 'JSON invalide'));
49
- }
50
- };
51
-
52
- const handleSave = () => {
53
- if (!config.model || !config.template) {
54
- console.error("Model and template are required.");
55
- return;
56
- }
57
- if (jsonError) return;
58
- onSave(config);
59
- };
60
-
61
- if (!isOpen) return null;
62
-
63
- return (
64
- <Dialog
65
- isModal={true}
66
- isClosable={true}
67
- onClose={onClose}
68
- title={initialConfig?.id ? t('dashboards.editHtmlViewTitle', 'Modifier la Vue HTML') : t('dashboards.addHtmlViewTitle', 'Ajouter une Vue HTML')}
69
- className="html-view-builder-modal"
70
- >
71
- <div className="form-grid">
72
- <TextField name="title" label={t('dashboards.widgetTitle', 'Titre du widget')} value={config.title || ''} onChange={handleChange} />
73
- <ModelField name="model" label={t('model', 'Modèle')} value={config.model || ''} onChange={(option) => handleChange({ name: 'model', value: option?.value })} required />
74
- <NumberField name="limit" label={t('dashboards.dataLimit', 'Limite de données')} value={config.limit ?? 10} onChange={handleChange} min={1} max={100} />
75
- <CodeField name="filter" label={t('filter', 'Filtre (JSON)')} value={typeof config.filter === 'string' ? config.filter : JSON.stringify(config.filter || {}, null, 2)} language="json" onChange={(e) => handleFilterChange(e.value)} error={jsonError} />
76
- <CodeField name="template" label={t('dashboards.htmlTemplate', 'Template HTML')} value={config.template || ''} language="html" onChange={(e) => handleCodeChange('template', e.value)} required height="200px" />
77
- <CodeField name="css" label={t('dashboards.cssStyles', 'Styles CSS')} value={config.css || ''} language="css" onChange={(e) => handleCodeChange('css', e.value)} height="150px" />
78
- </div>
79
- <div className="flex actions right">
80
- <Button onClick={onClose} className="btn-secondary">
81
- <FaTimes /> {t('btns.cancel', 'Annuler')}
82
- </Button>
83
- <Button onClick={handleSave} className="btn-primary" disabled={!!jsonError}>
84
- <FaSave /> {t('btns.save', 'Enregistrer')}
85
- </Button>
86
- </div>
87
- </Dialog>
88
- );
89
- };
90
-
1
+ import React, { useState, useEffect, useMemo } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Dialog } from './Dialog.jsx';
4
+ import {TextField, SelectField, NumberField, CodeField, ModelField} from './Field.jsx';
5
+ import Button from './Button.jsx';
6
+ import { FaSave, FaTimes } from 'react-icons/fa';
7
+ import './HtmlViewBuilderModal.scss';
8
+
9
+ const HtmlViewBuilderModal = ({ isOpen, onClose, onSave, models, initialConfig }) => {
10
+ const { t } = useTranslation();
11
+ const [config, setConfig] = useState({});
12
+ const [jsonError, setJsonError] = useState('');
13
+
14
+ useEffect(() => {
15
+ if (isOpen) {
16
+ setConfig(initialConfig || {
17
+ title: '',
18
+ model: '',
19
+ limit: 10,
20
+ filter: {},
21
+ template: '',
22
+ css: '',
23
+ ...initialConfig
24
+ });
25
+ setJsonError('');
26
+ }
27
+ }, [isOpen, initialConfig]);
28
+
29
+ const modelOptions = useMemo(() => {
30
+ return (models || []).map(m => ({ label: m.name, value: m.name }));
31
+ }, [models]);
32
+
33
+ const handleChange = (e) => {
34
+ const { name, value } = e.target || e;
35
+ setConfig(prev => ({ ...prev, [name]: value }));
36
+ };
37
+
38
+ const handleCodeChange = (name, value) => {
39
+ setConfig(prev => ({ ...prev, [name]: value }));
40
+ };
41
+
42
+ const handleFilterChange = (codeValue) => {
43
+ try {
44
+ const parsed = JSON.parse(codeValue);
45
+ setConfig(prev => ({ ...prev, filter: parsed }));
46
+ setJsonError('');
47
+ } catch (e) {
48
+ setJsonError(t('dashboards.invalidJson', 'JSON invalide'));
49
+ }
50
+ };
51
+
52
+ const handleSave = () => {
53
+ if (!config.model || !config.template) {
54
+ console.error("Model and template are required.");
55
+ return;
56
+ }
57
+ if (jsonError) return;
58
+ onSave(config);
59
+ };
60
+
61
+ if (!isOpen) return null;
62
+
63
+ return (
64
+ <Dialog
65
+ isModal={true}
66
+ isClosable={true}
67
+ onClose={onClose}
68
+ title={initialConfig?.id ? t('dashboards.editHtmlViewTitle', 'Modifier la Vue HTML') : t('dashboards.addHtmlViewTitle', 'Ajouter une Vue HTML')}
69
+ className="html-view-builder-modal"
70
+ >
71
+ <div className="form-grid">
72
+ <TextField name="title" label={t('dashboards.widgetTitle', 'Titre du widget')} value={config.title || ''} onChange={handleChange} />
73
+ <ModelField name="model" label={t('model', 'Modèle')} value={config.model || ''} onChange={(option) => handleChange({ name: 'model', value: option?.value })} required />
74
+ <NumberField name="limit" label={t('dashboards.dataLimit', 'Limite de données')} value={config.limit ?? 10} onChange={handleChange} min={1} max={100} />
75
+ <CodeField name="filter" label={t('filter', 'Filtre (JSON)')} value={typeof config.filter === 'string' ? config.filter : JSON.stringify(config.filter || {}, null, 2)} language="json" onChange={(e) => handleFilterChange(e.value)} error={jsonError} />
76
+ <CodeField name="template" label={t('dashboards.htmlTemplate', 'Template HTML')} value={config.template || ''} language="html" onChange={(e) => handleCodeChange('template', e.value)} required height="200px" />
77
+ <CodeField name="css" label={t('dashboards.cssStyles', 'Styles CSS')} value={config.css || ''} language="css" onChange={(e) => handleCodeChange('css', e.value)} height="150px" />
78
+ </div>
79
+ <div className="flex actions right">
80
+ <Button onClick={onClose} className="btn-secondary">
81
+ <FaTimes /> {t('btns.cancel', 'Annuler')}
82
+ </Button>
83
+ <Button onClick={handleSave} className="btn-primary" disabled={!!jsonError}>
84
+ <FaSave /> {t('btns.save', 'Enregistrer')}
85
+ </Button>
86
+ </div>
87
+ </Dialog>
88
+ );
89
+ };
90
+
91
91
  export default HtmlViewBuilderModal;
@@ -1,18 +1,18 @@
1
- .html-view-builder-modal {
2
- .form-grid {
3
- display: grid;
4
- grid-template-columns: 1fr;
5
- gap: 1rem;
6
- padding-bottom: 1rem;
7
-
8
- .code-editor-container {
9
- grid-column: 1 / -1;
10
- }
11
- }
12
-
13
- .actions {
14
- margin-top: 1rem;
15
- padding-top: 1rem;
16
- border-top: 1px solid var(--border-color);
17
- }
1
+ .html-view-builder-modal {
2
+ .form-grid {
3
+ display: grid;
4
+ grid-template-columns: 1fr;
5
+ gap: 1rem;
6
+ padding-bottom: 1rem;
7
+
8
+ .code-editor-container {
9
+ grid-column: 1 / -1;
10
+ }
11
+ }
12
+
13
+ .actions {
14
+ margin-top: 1rem;
15
+ padding-top: 1rem;
16
+ border-top: 1px solid var(--border-color);
17
+ }
18
18
  }
@@ -1,44 +1,44 @@
1
- import React, {useEffect, useMemo} from 'react';
2
- import './HtmlViewCard.scss';
3
- import {renderHtmlTemplate} from "./DashboardHtmlViewItem.jsx";
4
-
5
- /**
6
- * Affiche une vue HTML personnalisée, généralement générée par l'assistant IA.
7
- * @param {object} props
8
- * @param {object} props.config - La configuration de la vue.
9
- * @param {string} props.config.title - Le titre de la carte.
10
- * @param {string} props.config.template - La chaîne de template HTML Handlebars.
11
- * @param {Array<object>} props.config.data - Le tableau d'enregistrements de données à afficher.
12
- */
13
- const HtmlViewCard = ({ config }) => {
14
- const { title, template, data, css } = config;
15
-
16
- // Génère un ID unique et stable pour ce composant
17
- const containerId = useMemo(() => `html-view-${Math.random().toString(36).substring(2, 9)}`, []);
18
-
19
- // Effet pour injecter et nettoyer le CSS
20
- useEffect(() => {
21
- if (!css) return;
22
-
23
- const styleElement = document.createElement('style');
24
- // Remplace le placeholder par notre ID unique pour scoper le CSS
25
- styleElement.innerHTML = css.replace(/\{\{containerId\}\}/g, containerId);
26
- document.head.appendChild(styleElement);
27
-
28
- // Fonction de nettoyage : retire le style quand le composant est démonté
29
- return () => {
30
- document.head.removeChild(styleElement);
31
- };
32
- }, [css, containerId]);
33
-
34
- const renderedHtml = renderHtmlTemplate(template, data);
35
-
36
- return (
37
- <div id={containerId} className="html-view-card">
38
- {title && <h4>{title}</h4>}
39
- <div className="html-view-content" dangerouslySetInnerHTML={{ __html: renderedHtml }} />
40
- </div>
41
- );
42
- };
43
-
1
+ import React, {useEffect, useMemo} from 'react';
2
+ import './HtmlViewCard.scss';
3
+ import {renderHtmlTemplate} from "./DashboardHtmlViewItem.jsx";
4
+
5
+ /**
6
+ * Affiche une vue HTML personnalisée, généralement générée par l'assistant IA.
7
+ * @param {object} props
8
+ * @param {object} props.config - La configuration de la vue.
9
+ * @param {string} props.config.title - Le titre de la carte.
10
+ * @param {string} props.config.template - La chaîne de template HTML Handlebars.
11
+ * @param {Array<object>} props.config.data - Le tableau d'enregistrements de données à afficher.
12
+ */
13
+ const HtmlViewCard = ({ config }) => {
14
+ const { title, template, data, css } = config;
15
+
16
+ // Génère un ID unique et stable pour ce composant
17
+ const containerId = useMemo(() => `html-view-${Math.random().toString(36).substring(2, 9)}`, []);
18
+
19
+ // Effet pour injecter et nettoyer le CSS
20
+ useEffect(() => {
21
+ if (!css) return;
22
+
23
+ const styleElement = document.createElement('style');
24
+ // Remplace le placeholder par notre ID unique pour scoper le CSS
25
+ styleElement.innerHTML = css.replace(/\{\{containerId\}\}/g, containerId);
26
+ document.head.appendChild(styleElement);
27
+
28
+ // Fonction de nettoyage : retire le style quand le composant est démonté
29
+ return () => {
30
+ document.head.removeChild(styleElement);
31
+ };
32
+ }, [css, containerId]);
33
+
34
+ const renderedHtml = renderHtmlTemplate(template, data);
35
+
36
+ return (
37
+ <div id={containerId} className="html-view-card">
38
+ {title && <h4>{title}</h4>}
39
+ <div className="html-view-content" dangerouslySetInnerHTML={{ __html: renderedHtml }} />
40
+ </div>
41
+ );
42
+ };
43
+
44
44
  export default HtmlViewCard;