data-primals-engine 1.4.2 → 1.4.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.
@@ -482,6 +482,7 @@ const CheckboxField = forwardRef(
482
482
  minlength,
483
483
  maxlength,
484
484
  checked,
485
+ checkbox=false,
485
486
  ...rest
486
487
  },
487
488
  ref,
@@ -531,16 +532,19 @@ const CheckboxField = forwardRef(
531
532
  </label>
532
533
  )}
533
534
  {help && <div className="flex help">{help}</div>}
534
- <Switch
535
+ {!checkbox && (<Switch
535
536
  id={id}
536
537
  onChange={handleChange}
537
- checked={value} />
538
+ checked={value} />)}
539
+ {checkbox && (
540
+ <input type={"checkbox"} id={id} onChange={handleChange} checked={value} />
541
+ )}
538
542
  </div>
539
543
  {errors.length > 0 && (
540
544
  <ul className="error">
541
545
  {errors.map((e, key) => (
542
546
  <li key={key} aria-live="assertive" role="alert">
543
- {e}
547
+ {JSON.stringify(e, null, 2)}
544
548
  </li>
545
549
  ))}
546
550
  </ul>
@@ -0,0 +1,94 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { MapContainer, TileLayer, Marker, useMapEvents, Popup } from 'react-leaflet';
3
+ import 'leaflet/dist/leaflet.css';
4
+ import L from 'leaflet';
5
+
6
+ // Fix for default marker icon issue with webpack/parcel
7
+ delete L.Icon.Default.prototype._getIconUrl;
8
+
9
+ L.Icon.Default.mergeOptions({
10
+ iconRetinaUrl: 'https://unpkg.com/leaflet@1.7.1/dist/images/marker-icon-2x.png',
11
+ iconUrl: 'https://unpkg.com/leaflet@1.7.1/dist/images/marker-icon.png',
12
+ shadowUrl: 'https://unpkg.com/leaflet@1.7.1/dist/images/marker-shadow.png'
13
+ });
14
+
15
+
16
+ const LocationMarker = ({ position, setPosition, name, onChange, value }) => {
17
+ const map = useMapEvents({
18
+ click(e) {
19
+ const { lat, lng } = e.latlng;
20
+ const newPos = [lat, lng];
21
+ setPosition(newPos);
22
+ map.flyTo(newPos, map.getZoom());
23
+ onChange({
24
+ name: name,
25
+ value: {
26
+ type: 'Point',
27
+ coordinates: [lng, lat]
28
+ }
29
+ });
30
+ },
31
+ locationfound(e) {
32
+ const { lat, lng } = e.latlng;
33
+ const newPos = [lat, lng];
34
+ setPosition(newPos);
35
+ map.flyTo(newPos, map.getZoom());
36
+ onChange({
37
+ name: name,
38
+ value: {
39
+ type: 'Point',
40
+ coordinates: [lng, lat]
41
+ }
42
+ });
43
+ },
44
+ });
45
+
46
+ useEffect(() => {
47
+ // If there's no value, try to locate user
48
+ if (!value) {
49
+ map.locate();
50
+ }
51
+ }, [map, value]);
52
+
53
+
54
+ return position === null ? null : (
55
+ <Marker position={position}>
56
+ <Popup>Selected location</Popup>
57
+ </Marker>
58
+ );
59
+ }
60
+
61
+ const GeolocationField = ({ value, onChange, name }) => {
62
+ // Default to a central location if no value is provided, e.g., Paris
63
+ const initialPosition = (value && value.coordinates && value.coordinates.length === 2)
64
+ ? [value.coordinates[1], value.coordinates[0]] // Leaflet uses [lat, lng], GeoJSON uses [lng, lat]
65
+ : [48.8566, 2.3522]; // Default to Paris
66
+
67
+ const [position, setPosition] = useState(initialPosition);
68
+
69
+ useEffect(() => {
70
+ if (value && value.coordinates && value.coordinates.length === 2) {
71
+ const newPos = [value.coordinates[1], value.coordinates[0]];
72
+ if (position[0] !== newPos[0] || position[1] !== newPos[1]) {
73
+ setPosition(newPos);
74
+ }
75
+ } else {
76
+ // If value is cleared, reset to default. The map.locate() will try to find the user.
77
+ setPosition([48.8566, 2.3522]);
78
+ }
79
+ }, [value]);
80
+
81
+ return (
82
+ <div style={{ height: '300px', width: '100%' }}>
83
+ <MapContainer center={position} zoom={13} scrollWheelZoom={true} style={{ height: '100%', width: '100%' }}>
84
+ <TileLayer
85
+ attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
86
+ url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
87
+ />
88
+ <LocationMarker position={position} setPosition={setPosition} name={name} onChange={onChange} value={value} />
89
+ </MapContainer>
90
+ </div>
91
+ );
92
+ };
93
+
94
+ export default GeolocationField;
@@ -117,6 +117,7 @@ const ModelCreatorField = ({model, handleRenameField, handleRemoveField, handleU
117
117
  {label: t("field.array"), value: "array"},
118
118
  {label: t("field.relation"), value: "relation"},
119
119
  {label: t("field.file"), value: "file"},
120
+ {label: t("field.geolocation"), value: "geolocation"},
120
121
  {label: t("field.code"), value: "code"},
121
122
  {label: t("field.calculated", "calculated data"), value: "calculated"},
122
123
  {label: t("field.cronSchedule", "task schedule"), value: "cronSchedule"},
@@ -43,14 +43,14 @@ const RelationField = ({ field, help, onFocus, onBlur, onChange, value = null })
43
43
  // Recherche sur les champs principaux (asMain)
44
44
  model.fields.forEach(f => {
45
45
  if (f.asMain && mainFieldsTypes.includes(f.type)) {
46
- orConditions.push({ [f.name]: { "$regex": searchValue, "$options": "i" } });
46
+ orConditions.push({"$regexMatch": {input: "$" + f.name, regex: searchValue}});
47
47
  }
48
48
  });
49
49
  // Si aucun champ principal, recherche sur les champs texte
50
50
  if (orConditions.length === 0) {
51
51
  model.fields.forEach(f => {
52
52
  if (["string", "string_t", "richtext", "url"].includes(f.type)) {
53
- orConditions.push({ [f.name]: { "$regex": searchValue, "$options": "i" } });
53
+ orConditions.push({"$regexMatch": {input: "$" + f.name, regex: searchValue}});
54
54
  }
55
55
  });
56
56
  }
@@ -60,11 +60,11 @@ export const profiles = {
60
60
  "models": ['alert','endpoint','request','webpage', 'content', 'taxonomy', 'resource', 'translation', 'contact', 'location', 'channel', 'lang', 'token', 'message', 'ticket', 'user', 'permission', 'role']
61
61
  },
62
62
  'company': {
63
- "packs": ["E-commerce Starter Kit"],
63
+ "packs": ["Multilingual starter pack", "E-commerce Starter Kit"],
64
64
  "models": ['alert','request','location', 'order', 'currency', 'product', 'cart', 'cartItem', 'invoice', 'message', 'user', 'role', 'permission', 'token','translation', 'lang', 'webpage', 'content', 'taxonomy', 'contact', 'resource', 'accountingExercise', 'accountingLineItem', 'accountingEntry', 'employee', 'kpi', 'dashboard']
65
65
  },
66
66
  'engineer': {
67
- "packs": ["AI Content Generation - Starter Pack"],
67
+ "packs": ["Multilingual starter pack", "AI Content Generation - Starter Pack"],
68
68
  "models":['alert','endpoint','request','dashboard', 'kpi', 'user', 'role', 'token', 'permission', 'workflow', 'workflowRun', 'workflowStep', "channel", "message", 'workflowAction', 'workflowTrigger']
69
69
  }
70
70
  }
@@ -1,159 +1,4 @@
1
1
 
2
- export const MONGO_CALC_OPERATORS = {
3
- $find: {
4
- label: 'Find in relation',
5
- description: 'Recherche dans une relation/tableau',
6
- supportsNesting: true,
7
- multi: false,
8
- isFindOperator: true // Nouvelle propriété pour identifier les opérateurs $find
9
- },
10
- '$regexMatch': {
11
- label: 'Find by regex',
12
- description: 'Find a string matching a regular expression (Ecmascript)',
13
- args: 2, // input et regex
14
- specialStructure: true // Indique une structure spéciale
15
- },
16
- $and: { label: 'Et (and)', description: 'Renvoie vrai si toutes les conditions sont vérifiées', args: 1, multi: true },
17
- $or: { label: 'Ou (or)', description: 'Renvoie vrai si au moins une des conditions est vérifiée.', args: 1, multi: true },
18
- $not: { label: 'Non (not)', description: 'Inverse la condition (ex: non égal à).', args: 1, multi: true },
19
- $nor: { label: 'Ou Non (nor)', description: 'Renvoie vrai si aucune des conditions n\'est vérifiée', args: 1, multi: true },
20
- $eq: { label: '=', multi: false, args: 2 },
21
- $ne: { label: '!=', multi: false, args: 2 },
22
- $gt: { label: '>', multi: false, args: 2 },
23
- $gte: { label: '>=', multi: false, args: 2 },
24
- $lt: { label: '<', multi: false, args: 2 },
25
- $lte: { label: '<=', multi: false, args: 2 },
26
- $in: { label: 'in', multi: true, args: 2 },
27
- $nin: { label: 'nin', multi: true, args: 2 },
28
- $all: { label: 'afll', multi: true },
29
- $size: {
30
- label: 'size',
31
- multi: false,
32
- description: 'Renvoie le nombre d\'éléments dans un tableau',
33
- disableAdvancedValue: true
34
- },
35
- $elemMatch: { label: 'elemMatch', multi: true },
36
- $type: {
37
- label: 'type',
38
- description: 'Renvoie le type BSON de l\'élément',
39
- multi: false,
40
- disableAdvancedValue: true
41
- },
42
- $add: { label: '+', multi: true },
43
- $subtract: { label: '-', multi: false, args: 2 },
44
- $multiply: { label: '*', multi: true },
45
- $divide: { label: '/', multi: false, args: 2 },
46
- $mod: { label: '%', multi: false, args: 2 },
47
- $pow: { label: 'pow', multi: false },
48
- $sqrt: { label: 'sqrt', multi: false },
49
- $exp: { label: 'exp', multi: false },
50
- $abs: { label: 'abs', multi: false },
51
- $ceil: { label: 'ceil', multi: false },
52
- $floor: { label: 'floor', multi: false },
53
- $ln: { label: 'ln', multi: false },
54
- $log10: { label: 'log', multi: false },
55
- $concat: { label: 'concat', multi: true },
56
-
57
- // Date-specific
58
- $year: { label: 'year', multi: false, isDate: true },
59
- $month: { label: 'month', multi: false, isDate: true },
60
- $dayOfMonth: { label: 'dayOfMonth', multi: false, isDate: true },
61
- $hour: { label: 'hour', multi: false, isDate: true },
62
- $minute: { label: 'minute', multi: false, isDate: true },
63
- $second: { label: 'second', multi: false, isDate: true },
64
- $millisecond: { label: 'ms', multi: false, isDate: true },
65
- // Date operators
66
- $dateAdd: {
67
- label: 'Add to date',
68
- description: 'Adds a duration to a date',
69
- isDate: true,
70
- specialStructure: true,
71
- args: [
72
- { name: 'startDate', label: 'Start Date', type: 'date' },
73
- { name: 'unit', label: 'Unit', type: 'select', options: ['year', 'month', 'day', 'hour', 'minute', 'second'] },
74
- { name: 'amount', label: 'Amount', type: 'number' },
75
- { name: 'timezone', label: 'Timezone', type: 'text', optional: true }
76
- ]
77
- },
78
- $dateSubtract: {
79
- label: 'Subtract from date',
80
- description: 'Subtracts a duration from a date',
81
- isDate: true,
82
- specialStructure: true,
83
- args: [
84
- { name: 'startDate', label: 'Start Date', type: 'date' },
85
- { name: 'unit', label: 'Unit', type: 'select', options: ['year', 'month', 'day', 'hour', 'minute', 'second'] },
86
- { name: 'amount', label: 'Amount', type: 'number' },
87
- { name: 'timezone', label: 'Timezone', type: 'text', optional: true }
88
- ]
89
- },
90
- $dateDiff: {
91
- label: 'Date Difference',
92
- description: 'Calculates the difference between two dates in specified units',
93
- isDate: true,
94
- specialStructure: true,
95
- args: [
96
- {
97
- name: 'startDate',
98
- label: 'Start Date',
99
- type: 'date',
100
- description: 'The starting date (inclusive)'
101
- },
102
- {
103
- name: 'endDate',
104
- label: 'End Date',
105
- type: 'date',
106
- description: 'The ending date (exclusive)'
107
- },
108
- {
109
- name: 'unit',
110
- label: 'Unit',
111
- type: 'select',
112
- options: ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'],
113
- description: 'The unit for the result'
114
- },
115
- {
116
- name: 'timezone',
117
- label: 'Timezone',
118
- type: 'text',
119
- optional: true,
120
- description: 'The timezone (e.g. "Europe/Paris")'
121
- }
122
- ]
123
- },
124
- $dateToString: {
125
- label: 'Format date as string',
126
- description: 'Formats a date as a string',
127
- isDate: true,
128
- specialStructure: true,
129
- args: [
130
- {
131
- name: 'date',
132
- label: 'Date',
133
- type: 'date'
134
- },
135
- {
136
- name: 'format',
137
- label: 'Format',
138
- optional: true,
139
- type: 'text'
140
- },
141
- {
142
- name: 'timezone',
143
- label: 'Timezone',
144
- type: 'text',
145
- optional: true,
146
- description: 'The timezone (e.g. "Europe/Paris")'
147
- }
148
- ]
149
- },
150
-
151
- // Converters
152
- $toBool: { label: 'toBool', multi: false, converter: true },
153
- $toString: { label: 'toString', multi: false, converter: true },
154
- $toInt: { label: 'toInt', multi: false, converter: true },
155
- $toDouble: { label: 'toDouble', multi: false, converter: true }
156
- };
157
2
 
158
3
  export const convertInputValue = (value) => {
159
4
  if (typeof value !== 'string') return value;
@@ -2,6 +2,7 @@
2
2
  export const websiteTranslations = {
3
3
  fr: {
4
4
  translation: {
5
+ "field.geolocation": "Géolocalisation",
5
6
  "time.minute": "Minute",
6
7
  "time.hour": "Heure",
7
8
  "time.day": "Jour",
@@ -55,8 +56,6 @@ export const websiteTranslations = {
55
56
  "history.revertSuccess": "Document restauré avec succès. L'historique va maintenant être mis à jour.",
56
57
  "history.revertError": "Erreur lors de la restauration : {{error}}",
57
58
 
58
- "field_endpoint_isPublic": "Accès public",
59
- "field_endpoint_isPublic_hint": "Si coché, ce point d'accès sera accessible sans authentification. Le script s'exécutera avec les droits du propriétaire du point d'accès.",
60
59
 
61
60
  "packs.manualInstall": "Importer",
62
61
  "packs.manualInstall.title": "Installation manuelle de pack",
@@ -606,6 +605,7 @@ export const websiteTranslations = {
606
605
  },
607
606
  en: {
608
607
  translation: {
608
+ "field.geolocation": "Geolocation",
609
609
  "time.minute":"Minute",
610
610
  "time.hour":"Hour",
611
611
  "time.day":"Day",
@@ -2084,6 +2084,7 @@ export const websiteTranslations = {
2084
2084
  },
2085
2085
  es: {
2086
2086
  translation: {
2087
+ "field.geolocation": "Geolocalización",
2087
2088
  "time.minute": "Minuto",
2088
2089
  "time.hour": "Hora",
2089
2090
  "time.day": "Día",
@@ -3564,6 +3565,7 @@ export const websiteTranslations = {
3564
3565
  },
3565
3566
  pt: {
3566
3567
  translation: {
3568
+ "field.geolocation": "Geolocalização",
3567
3569
  "time.minute":"Minuto",
3568
3570
  "time.hour":"Hora",
3569
3571
  "time.day":"Dia",
@@ -5039,6 +5041,7 @@ export const websiteTranslations = {
5039
5041
  },
5040
5042
  de: {
5041
5043
  translation: {
5044
+ "field.geolocation": "Geolokalisierung",
5042
5045
  "time.minute":"Minute",
5043
5046
  "time.hour":"Stunde",
5044
5047
  "time.day":"Tag",
@@ -6499,6 +6502,7 @@ export const websiteTranslations = {
6499
6502
  },
6500
6503
  it: {
6501
6504
  translation: {
6505
+ "field.geolocation": "Geolocalizzazione",
6502
6506
  "time.minute":"Minuto",
6503
6507
  "time.hour":"Ora",
6504
6508
  "time.day":"Giorno",
@@ -7972,6 +7976,7 @@ export const websiteTranslations = {
7972
7976
  },
7973
7977
  cs: {
7974
7978
  translation: {
7979
+ "field.geolocation": "Geolokace",
7975
7980
  "time.minute":"Minuta",
7976
7981
  "time.hour":"Hodina",
7977
7982
  "time.day":"Den",
@@ -9439,6 +9444,7 @@ export const websiteTranslations = {
9439
9444
  },
9440
9445
  ru: {
9441
9446
  translation: {
9447
+ "field.geolocation": "Геолокация",
9442
9448
  "time.minute":"Минута",
9443
9449
  "time.hour":"Час",
9444
9450
  "time.day":"День",
@@ -10918,6 +10924,7 @@ export const websiteTranslations = {
10918
10924
  },
10919
10925
  ar: {
10920
10926
  translation: {
10927
+ "field.geolocation": "تحديد الموقع الجغرافي",
10921
10928
  "الدقيقة الزمنية": "الدقيقة", "الساعة الزمنية": "الساعة", "اليوم الزمني": "اليوم", "الأسبوع الزمني": "الأسبوع", "الشهر الزمني": "الشهر", "السنة الزمنية": "السنة",
10922
10929
  "packs.myPack": "حزمتي",
10923
10930
  "packs.public": "عامة",
@@ -12407,6 +12414,7 @@ export const websiteTranslations = {
12407
12414
  },
12408
12415
  sv: {
12409
12416
  translation: {
12417
+ "field.geolocation": "Geolocation",
12410
12418
  "time.minute":"Minut",
12411
12419
  "time.hour":"Timme",
12412
12420
  "time.day":"Dag",
@@ -13874,6 +13882,7 @@ export const websiteTranslations = {
13874
13882
  },
13875
13883
  el: {
13876
13884
  translation: {
13885
+ "field.geolocation": "Γεωγραφική τοποθεσία",
13877
13886
  "time.minute":"Λεπτό",
13878
13887
  "time.hour":"Ώρα",
13879
13888
  "time.day":"Ημέρα",
@@ -15350,6 +15359,7 @@ export const websiteTranslations = {
15350
15359
  },
15351
15360
  fa: {
15352
15361
  "translation": {
15362
+ "field.geolocation": "موقعیت جغرافیایی",
15353
15363
  "time.minute":"دقیقه",
15354
15364
  "time.hour":"ساعت",
15355
15365
  "time.day":"روز",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-primals-engine",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "data-primals-engine is a package responsible from handling large amount of data using MongoDB in a practical and performant way. It can also get workflow models working (for automation), and fully supports internationalisation. It also has integrated AI assistant.",
5
5
  "main": "src/engine.js",
6
6
  "type": "module",