@limetech/lime-crm-building-blocks 1.96.0 → 1.98.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.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/{_MapCache-2e84a981.js → _MapCache-8b125fbb.js} +0 -26
- package/dist/cjs/{_Uint8Array-1e99726d.js → _Uint8Array-95263550.js} +1 -12
- package/dist/cjs/_baseIsEqual-cb7951b0.js +496 -0
- package/dist/cjs/_defineProperty-40a6ad5d.js +15 -0
- package/dist/cjs/{get-1acf79ce.js → get-932b213e.js} +5 -4
- package/dist/cjs/isEqual-e77cce75.js +37 -0
- package/dist/cjs/isSymbol-5b36aeee.js +30 -0
- package/dist/cjs/lime-crm-building-blocks.cjs.js +1 -1
- package/dist/cjs/lime-query.types-bcb63a22.js +61 -0
- package/dist/cjs/limebb-component-config.cjs.entry.js +3 -2
- package/dist/cjs/limebb-lime-query-builder.cjs.entry.js +378 -150
- package/dist/cjs/limebb-lime-query-filter-and_5.cjs.entry.js +278 -0
- package/dist/cjs/limebb-lime-query-value-input.cjs.entry.js +239 -0
- package/dist/cjs/limebb-limetype-field_2.cjs.entry.js +406 -0
- package/dist/cjs/limebb-live-docs-info.cjs.entry.js +2 -2
- package/dist/cjs/limebb-locale-picker.cjs.entry.js +13 -498
- package/dist/cjs/limebb-mention-group-counter.cjs.entry.js +2 -2
- package/dist/cjs/limebb-navigation-button_2.cjs.entry.js +3 -3
- package/dist/cjs/limebb-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/limebb-percentage-visualizer.cjs.entry.js +2 -2
- package/dist/cjs/limebb-property-selector.cjs.entry.js +234 -0
- package/dist/cjs/limebb-response-format-item.cjs.entry.js +80 -0
- package/dist/cjs/limebb-text-editor.cjs.entry.js +20 -61
- package/dist/cjs/limebb-trend-indicator.cjs.entry.js +1 -1
- package/dist/cjs/limetype-1fe0207f.js +90 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/property-resolution-fb42a46b.js +66 -0
- package/dist/collection/collection-manifest.json +10 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-and.css +121 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-and.js +257 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-comparison.css +39 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-comparison.js +246 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-expression.css +104 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-expression.js +220 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-not.css +107 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-not.js +212 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-or.css +123 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-or.js +237 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-value-input.css +48 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-value-input.js +457 -0
- package/dist/collection/components/lime-query-builder/filter-conversion.js +118 -21
- package/dist/collection/components/lime-query-builder/lime-query-builder.css +30 -17
- package/dist/collection/components/lime-query-builder/lime-query-builder.js +253 -27
- package/dist/collection/components/lime-query-builder/limetype-field/limetype-field.js +435 -0
- package/dist/collection/components/lime-query-builder/property-selection-format.js +158 -0
- package/dist/collection/components/lime-query-builder/property-selector/property-selector.css +8 -0
- package/dist/collection/components/lime-query-builder/property-selector/property-selector.js +422 -0
- package/dist/collection/components/lime-query-builder/response-format-editor.css +72 -0
- package/dist/collection/components/lime-query-builder/response-format-editor.js +249 -0
- package/dist/collection/components/lime-query-builder/response-format-item.css +61 -0
- package/dist/collection/components/lime-query-builder/response-format-item.js +208 -0
- package/dist/collection/components/limeobject/file-viewer/live-docs-info.js +2 -2
- package/dist/collection/components/locale-picker/locale-picker.js +1 -1
- package/dist/collection/components/notification-list/notification-item/notification-item.js +1 -1
- package/dist/collection/components/percentage-visualizer/percentage-visualizer.js +2 -2
- package/dist/collection/components/summary-popover/summary-popover.js +3 -3
- package/dist/collection/components/text-editor/mention-group-counter.js +2 -2
- package/dist/collection/components/text-editor/text-editor.js +1 -1
- package/dist/collection/components/trend-indicator/trend-indicator.js +1 -1
- package/dist/components/_MapCache.js +2 -27
- package/dist/components/_Uint8Array.js +2 -12
- package/dist/components/_baseIsEqual.js +494 -0
- package/dist/components/_defineProperty.js +13 -0
- package/dist/components/get.js +2 -1
- package/dist/components/isEqual.js +35 -0
- package/dist/components/isSymbol.js +28 -0
- package/dist/components/lime-query-filter-and.js +408 -0
- package/dist/components/lime-query-filter-comparison.js +152 -0
- package/dist/components/lime-query-value-input.js +266 -0
- package/dist/components/limebb-lime-query-builder.js +437 -149
- package/dist/components/limebb-lime-query-filter-and.d.ts +11 -0
- package/dist/components/limebb-lime-query-filter-and.js +6 -0
- package/dist/components/limebb-lime-query-filter-comparison.d.ts +11 -0
- package/dist/components/limebb-lime-query-filter-comparison.js +6 -0
- package/dist/components/limebb-lime-query-filter-expression.d.ts +11 -0
- package/dist/components/limebb-lime-query-filter-expression.js +6 -0
- package/dist/components/limebb-lime-query-filter-not.d.ts +11 -0
- package/dist/components/limebb-lime-query-filter-not.js +6 -0
- package/dist/components/limebb-lime-query-filter-or.d.ts +11 -0
- package/dist/components/limebb-lime-query-filter-or.js +6 -0
- package/dist/components/limebb-lime-query-value-input.d.ts +11 -0
- package/dist/components/limebb-lime-query-value-input.js +6 -0
- package/dist/components/limebb-limetype-field.d.ts +11 -0
- package/dist/components/limebb-limetype-field.js +6 -0
- package/dist/components/limebb-locale-picker.js +8 -493
- package/dist/components/limebb-mention-group-counter.js +2 -2
- package/dist/components/limebb-percentage-visualizer.js +2 -2
- package/dist/components/limebb-property-selector.d.ts +11 -0
- package/dist/components/limebb-property-selector.js +6 -0
- package/dist/components/limebb-response-format-editor.d.ts +11 -0
- package/dist/components/limebb-response-format-editor.js +6 -0
- package/dist/components/limebb-response-format-item.d.ts +11 -0
- package/dist/components/limebb-response-format-item.js +6 -0
- package/dist/components/limebb-text-editor.js +7 -48
- package/dist/components/limebb-trend-indicator.js +1 -1
- package/dist/components/limetype-field.js +184 -0
- package/dist/components/limetype.js +85 -0
- package/dist/components/live-docs-info.js +2 -2
- package/dist/components/notification-item.js +1 -1
- package/dist/components/property-selector.js +317 -0
- package/dist/components/response-format-editor.js +278 -0
- package/dist/components/response-format-item.js +104 -0
- package/dist/components/summary-popover.js +3 -3
- package/dist/esm/{_MapCache-6484495d.js → _MapCache-af496e9d.js} +2 -27
- package/dist/esm/{_Uint8Array-e5cac922.js → _Uint8Array-d6ebd526.js} +3 -13
- package/dist/esm/_baseIsEqual-28053b81.js +494 -0
- package/dist/esm/_defineProperty-e6a185c3.js +13 -0
- package/dist/esm/{get-f9e0b2e1.js → get-3e42932b.js} +2 -1
- package/dist/esm/isEqual-57d0c223.js +35 -0
- package/dist/esm/isSymbol-1c5f65cc.js +28 -0
- package/dist/esm/lime-crm-building-blocks.js +1 -1
- package/dist/esm/lime-query.types-f72355e1.js +59 -0
- package/dist/esm/limebb-component-config.entry.js +3 -2
- package/dist/esm/limebb-lime-query-builder.entry.js +375 -147
- package/dist/esm/limebb-lime-query-filter-and_5.entry.js +270 -0
- package/dist/esm/limebb-lime-query-value-input.entry.js +235 -0
- package/dist/esm/limebb-limetype-field_2.entry.js +401 -0
- package/dist/esm/limebb-live-docs-info.entry.js +2 -2
- package/dist/esm/limebb-locale-picker.entry.js +9 -494
- package/dist/esm/limebb-mention-group-counter.entry.js +2 -2
- package/dist/esm/limebb-navigation-button_2.entry.js +3 -3
- package/dist/esm/limebb-notification-item.entry.js +1 -1
- package/dist/esm/limebb-percentage-visualizer.entry.js +2 -2
- package/dist/esm/limebb-property-selector.entry.js +230 -0
- package/dist/esm/limebb-response-format-item.entry.js +76 -0
- package/dist/esm/limebb-text-editor.entry.js +7 -48
- package/dist/esm/limebb-trend-indicator.entry.js +1 -1
- package/dist/esm/limetype-6e7552a7.js +85 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/property-resolution-fde2375e.js +63 -0
- package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
- package/dist/lime-crm-building-blocks/{p-88c64360.entry.js → p-00da9b24.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/p-02c0cc04.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-0957b2a6.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-123190c3.js +1 -0
- package/dist/lime-crm-building-blocks/p-244ee55b.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-35897ec3.js +1 -0
- package/dist/lime-crm-building-blocks/{p-85b7291c.entry.js → p-3932077b.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/p-3b0a15ec.js +1 -0
- package/dist/lime-crm-building-blocks/p-5a6d2e7f.js +1 -0
- package/dist/lime-crm-building-blocks/p-60971d64.js +1 -0
- package/dist/lime-crm-building-blocks/p-6c1146ca.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-70a28b93.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-7e6fb4af.js +1 -0
- package/dist/lime-crm-building-blocks/{p-8664381a.entry.js → p-8c4eb49f.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/p-96beaabc.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-a659d55a.js +1 -0
- package/dist/lime-crm-building-blocks/p-baf4e428.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-d298b34e.js +1 -0
- package/dist/lime-crm-building-blocks/{p-7c4bdc1b.entry.js → p-d89c44ad.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/p-e0ab1554.js +1 -0
- package/dist/lime-crm-building-blocks/{p-8064cbfb.entry.js → p-e9d23ef7.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/p-ef8a5266.entry.js +1 -0
- package/dist/lime-crm-building-blocks/{p-c9126885.entry.js → p-f52125a0.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/p-f99c611d.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-fe2b91d9.js +1 -0
- package/dist/types/components/lime-query-builder/expressions/lime-query-filter-and.d.ts +56 -0
- package/dist/types/components/lime-query-builder/expressions/lime-query-filter-comparison.d.ts +64 -0
- package/dist/types/components/lime-query-builder/expressions/lime-query-filter-expression.d.ts +53 -0
- package/dist/types/components/lime-query-builder/expressions/lime-query-filter-not.d.ts +54 -0
- package/dist/types/components/lime-query-builder/expressions/lime-query-filter-or.d.ts +55 -0
- package/dist/types/components/lime-query-builder/expressions/lime-query-value-input.d.ts +92 -0
- package/dist/types/components/lime-query-builder/filter-conversion.d.ts +18 -0
- package/dist/types/components/lime-query-builder/lime-query-builder.d.ts +40 -7
- package/dist/types/components/lime-query-builder/limetype-field/limetype-field.d.ts +96 -0
- package/dist/types/components/lime-query-builder/property-selection-format.d.ts +23 -0
- package/dist/types/components/lime-query-builder/property-selector/property-selector.d.ts +71 -0
- package/dist/types/components/lime-query-builder/response-format-editor.d.ts +57 -0
- package/dist/types/components/lime-query-builder/response-format-item.d.ts +46 -0
- package/dist/types/components.d.ts +1587 -114
- package/package.json +1 -1
- package/dist/lime-crm-building-blocks/p-00e7e0d4.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-11ac105b.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-5abe3fff.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-8044ffbd.js +0 -1
- package/dist/lime-crm-building-blocks/p-92ec9205.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-bcc23575.js +0 -1
- package/dist/lime-crm-building-blocks/p-c40a3f4b.js +0 -1
|
@@ -1,146 +1,63 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h } from './index-96dd111f.js';
|
|
2
2
|
import { T as Te } from './index.esm-d8fdeb18.js';
|
|
3
|
+
import { L as LIME_QUERY_OPERATORS } from './lime-query.types-f72355e1.js';
|
|
4
|
+
import { g as getNormalizedProperties, a as getPropertyFromPath } from './property-resolution-fde2375e.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param limetype The limetype to normalize
|
|
8
|
-
* @returns Normalized properties with system properties prefixed with underscore
|
|
9
|
-
*/
|
|
10
|
-
function getNormalizedProperties(limetype) {
|
|
11
|
-
if (!(limetype === null || limetype === void 0 ? void 0 : limetype.properties)) {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
const properties = Object.assign({}, limetype.properties);
|
|
15
|
-
// System properties that are exposed by the backend
|
|
16
|
-
// Map from internal property name to API property name
|
|
17
|
-
const systemProperties = {
|
|
18
|
-
id: '_id',
|
|
19
|
-
timestamp: '_timestamp',
|
|
20
|
-
descriptive: '_descriptive',
|
|
21
|
-
createduser: '_createduser',
|
|
22
|
-
createdtime: '_createdtime',
|
|
23
|
-
updateduser: '_updateduser',
|
|
24
|
-
};
|
|
25
|
-
// Find and normalize system properties by name
|
|
26
|
-
for (const [propName, systemPropName] of Object.entries(systemProperties)) {
|
|
27
|
-
const property = properties[propName];
|
|
28
|
-
if (property) {
|
|
29
|
-
properties[systemPropName] = property;
|
|
30
|
-
delete properties[propName];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return properties;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get property from limetype by path (e.g., "company.name")
|
|
37
|
-
* Supports relation traversal with dot-notation
|
|
38
|
-
* @param limetypes
|
|
39
|
-
* @param limetype
|
|
40
|
-
* @param path
|
|
7
|
+
* Convert UI filter representation to Lime Query filter format
|
|
8
|
+
* @param filter
|
|
41
9
|
*/
|
|
42
|
-
function
|
|
43
|
-
if (
|
|
10
|
+
function guiFilterToLimeQuery(filter) {
|
|
11
|
+
if (filter.filter_type === '') {
|
|
44
12
|
return undefined;
|
|
45
13
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
14
|
+
if (filter.filter_type === 'comparison') {
|
|
15
|
+
return {
|
|
16
|
+
key: filter.property,
|
|
17
|
+
op: filter.operator,
|
|
18
|
+
exp: filter.value,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (filter.filter_type === 'AND') {
|
|
22
|
+
const expressions = filter.expressions
|
|
23
|
+
.map(guiFilterToLimeQuery)
|
|
24
|
+
.filter((f) => f !== undefined);
|
|
25
|
+
if (expressions.length === 0) {
|
|
51
26
|
return undefined;
|
|
52
27
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
28
|
+
if (expressions.length === 1) {
|
|
29
|
+
return expressions[0];
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
op: 'AND',
|
|
33
|
+
exp: expressions,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (filter.filter_type === 'OR') {
|
|
37
|
+
const expressions = filter.expressions
|
|
38
|
+
.map(guiFilterToLimeQuery)
|
|
39
|
+
.filter((f) => f !== undefined);
|
|
40
|
+
if (expressions.length === 0) {
|
|
56
41
|
return undefined;
|
|
57
42
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
currentType = property.relation.getLimetype();
|
|
43
|
+
if (expressions.length === 1) {
|
|
44
|
+
return expressions[0];
|
|
61
45
|
}
|
|
62
|
-
}
|
|
63
|
-
return property;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* TypeScript type definitions for Lime Query DSL
|
|
68
|
-
*
|
|
69
|
-
* These types represent the structure of Lime Query as defined in:
|
|
70
|
-
* - lime-core/lime_query/schema.py
|
|
71
|
-
* - lime-core/lime_filter/schema.py
|
|
72
|
-
*/
|
|
73
|
-
/**
|
|
74
|
-
* Available operators with display metadata
|
|
75
|
-
*/
|
|
76
|
-
const LIME_QUERY_OPERATORS = [
|
|
77
|
-
{ value: '=', label: 'Equals', icon: 'equals' },
|
|
78
|
-
{ value: '!=', label: 'Not Equals', icon: 'not-equal' },
|
|
79
|
-
{
|
|
80
|
-
value: '>',
|
|
81
|
-
label: 'Greater Than',
|
|
82
|
-
icon: 'greater-than',
|
|
83
|
-
applicableTypes: ['integer', 'decimal', 'date', 'time'],
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
value: '>=',
|
|
87
|
-
label: 'Greater or Equal',
|
|
88
|
-
icon: 'greater-or-equal',
|
|
89
|
-
applicableTypes: ['integer', 'decimal', 'date', 'time'],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
value: '<',
|
|
93
|
-
label: 'Less Than',
|
|
94
|
-
icon: 'less-than',
|
|
95
|
-
applicableTypes: ['integer', 'decimal', 'date', 'time'],
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
value: '<=',
|
|
99
|
-
label: 'Less or Equal',
|
|
100
|
-
icon: 'less-or-equal',
|
|
101
|
-
applicableTypes: ['integer', 'decimal', 'date', 'time'],
|
|
102
|
-
},
|
|
103
|
-
{ value: 'IN', label: 'In List', icon: 'list' },
|
|
104
|
-
{
|
|
105
|
-
value: '?',
|
|
106
|
-
label: 'Contains',
|
|
107
|
-
icon: '-lime-filter-contain',
|
|
108
|
-
applicableTypes: ['string', 'text'],
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
value: '=?',
|
|
112
|
-
label: 'Begins With',
|
|
113
|
-
icon: '-lime-filter-begin',
|
|
114
|
-
applicableTypes: ['string', 'text'],
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
value: '=$',
|
|
118
|
-
label: 'Ends With',
|
|
119
|
-
icon: '-lime-filter-end',
|
|
120
|
-
applicableTypes: ['string', 'text'],
|
|
121
|
-
},
|
|
122
|
-
];
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Convert Lime Query filter to UI filter representation
|
|
126
|
-
* Throws errors for unsupported filter structures
|
|
127
|
-
* @param filter
|
|
128
|
-
*/
|
|
129
|
-
function limeQueryToGuiFilter(filter) {
|
|
130
|
-
if (!filter) {
|
|
131
|
-
// Return empty AND instead of missing expression
|
|
132
|
-
// This ensures users see the "Add a condition" button
|
|
133
46
|
return {
|
|
134
|
-
|
|
135
|
-
|
|
47
|
+
op: 'OR',
|
|
48
|
+
exp: expressions,
|
|
136
49
|
};
|
|
137
50
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
51
|
+
if (filter.filter_type === 'NOT') {
|
|
52
|
+
const innerFilter = guiFilterToLimeQuery(filter.expression);
|
|
53
|
+
if (innerFilter) {
|
|
54
|
+
return {
|
|
55
|
+
op: '!',
|
|
56
|
+
exp: innerFilter,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
141
59
|
}
|
|
142
|
-
|
|
143
|
-
return validateAndConvertFilterGroup(filter);
|
|
60
|
+
return undefined;
|
|
144
61
|
}
|
|
145
62
|
/**
|
|
146
63
|
* Validate and convert a FilterExpression (comparison filter)
|
|
@@ -222,6 +139,124 @@ function validateAndConvertFilterGroup(filter) {
|
|
|
222
139
|
// If we reach here, the operator is unsupported
|
|
223
140
|
throw new Error(`Unsupported filter operator: ${filter.op}`);
|
|
224
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Convert Lime Query filter to UI filter representation
|
|
144
|
+
* Throws errors for unsupported filter structures
|
|
145
|
+
* @param filter
|
|
146
|
+
*/
|
|
147
|
+
function limeQueryToGuiFilter(filter) {
|
|
148
|
+
if (!filter) {
|
|
149
|
+
// Return empty AND instead of missing expression
|
|
150
|
+
// This ensures users see the "Add a condition" button
|
|
151
|
+
return {
|
|
152
|
+
filter_type: 'AND',
|
|
153
|
+
expressions: [],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Check if it's a FilterExpression (has 'key' property)
|
|
157
|
+
if ('key' in filter) {
|
|
158
|
+
return validateAndConvertFilterExpression(filter);
|
|
159
|
+
}
|
|
160
|
+
// It's a FilterGroup
|
|
161
|
+
return validateAndConvertFilterGroup(filter);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Normalize filter for GUI mode by ensuring proper AND/OR wrapper structure.
|
|
165
|
+
* GUI mode requires filters to be wrapped in AND([OR(...)]) so users have
|
|
166
|
+
* access to add/remove buttons on the AND and OR components.
|
|
167
|
+
*
|
|
168
|
+
* This function ensures that:
|
|
169
|
+
* - Single comparisons are wrapped in AND([OR([comparison])])
|
|
170
|
+
* - OR groups are wrapped in AND([OR group])
|
|
171
|
+
* - AND groups have their comparison children wrapped in OR
|
|
172
|
+
* - Empty/undefined filters become AND([])
|
|
173
|
+
*
|
|
174
|
+
* When converting back to Lime Query JSON, limeQueryFilterToLimeQuery()
|
|
175
|
+
* automatically unwraps single-item AND/OR groups.
|
|
176
|
+
*
|
|
177
|
+
* @param filter The filter expression from limeQueryToLimeQueryFilter
|
|
178
|
+
* @returns Normalized filter suitable for GUI editing
|
|
179
|
+
*/
|
|
180
|
+
function normalizeLimeQueryFilterForGui(filter) {
|
|
181
|
+
// Empty AND is already correct for GUI
|
|
182
|
+
if (filter.filter_type === 'AND' && filter.expressions.length === 0) {
|
|
183
|
+
return filter;
|
|
184
|
+
}
|
|
185
|
+
// Single comparison needs wrapping
|
|
186
|
+
if (filter.filter_type === 'comparison') {
|
|
187
|
+
return {
|
|
188
|
+
filter_type: 'AND',
|
|
189
|
+
expressions: [
|
|
190
|
+
{
|
|
191
|
+
filter_type: 'OR',
|
|
192
|
+
expressions: [filter],
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
// OR needs wrapping in AND
|
|
198
|
+
if (filter.filter_type === 'OR') {
|
|
199
|
+
return {
|
|
200
|
+
filter_type: 'AND',
|
|
201
|
+
expressions: [filter],
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// NOT needs wrapping
|
|
205
|
+
if (filter.filter_type === 'NOT') {
|
|
206
|
+
return {
|
|
207
|
+
filter_type: 'AND',
|
|
208
|
+
expressions: [
|
|
209
|
+
{
|
|
210
|
+
filter_type: 'OR',
|
|
211
|
+
expressions: [filter],
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
// AND group - check if children need OR wrappers
|
|
217
|
+
if (filter.filter_type === 'AND') {
|
|
218
|
+
const normalizedChildren = filter.expressions.map((child) => {
|
|
219
|
+
// If child is already OR, keep it
|
|
220
|
+
if (child.filter_type === 'OR') {
|
|
221
|
+
return child;
|
|
222
|
+
}
|
|
223
|
+
// If child is NOT, keep it (NOT can be a direct child of AND)
|
|
224
|
+
if (child.filter_type === 'NOT') {
|
|
225
|
+
return child;
|
|
226
|
+
}
|
|
227
|
+
// If child is comparison, wrap in OR
|
|
228
|
+
if (child.filter_type === 'comparison') {
|
|
229
|
+
return {
|
|
230
|
+
filter_type: 'OR',
|
|
231
|
+
expressions: [child],
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
// If child is nested AND, recursively normalize and wrap in OR
|
|
235
|
+
if (child.filter_type === 'AND') {
|
|
236
|
+
return {
|
|
237
|
+
filter_type: 'OR',
|
|
238
|
+
expressions: [normalizeLimeQueryFilterForGui(child)],
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
// Unknown filter type, keep as is
|
|
242
|
+
return child;
|
|
243
|
+
});
|
|
244
|
+
return {
|
|
245
|
+
filter_type: 'AND',
|
|
246
|
+
expressions: normalizedChildren,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
// Fallback: wrap in AND/OR structure
|
|
250
|
+
return {
|
|
251
|
+
filter_type: 'AND',
|
|
252
|
+
expressions: [
|
|
253
|
+
{
|
|
254
|
+
filter_type: 'OR',
|
|
255
|
+
expressions: [filter],
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
};
|
|
259
|
+
}
|
|
225
260
|
|
|
226
261
|
/**
|
|
227
262
|
* Dynamic filter values and placeholders that are valid in Lime Query
|
|
@@ -600,7 +635,7 @@ function isLimeQuerySupported(limeQuery, limetypes, activeLimetype, guiModeEnabl
|
|
|
600
635
|
};
|
|
601
636
|
}
|
|
602
637
|
|
|
603
|
-
const limeQueryBuilderCss = ":host(limebb-lime-query-builder){display:block;width:100%}.lime-query-builder{display:flex;flex-direction:column;gap:2rem}.mode-controls{display:flex;align-items:center;gap:0.5rem;padding:0.5rem
|
|
638
|
+
const limeQueryBuilderCss = ":host(limebb-lime-lime-query-builder){display:block;width:100%}.lime-query-builder{display:flex;flex-direction:column;gap:2rem}.mode-controls{display:flex;align-items:center;gap:0.5rem;padding:0.5rem}.mode-switch{display:flex;align-items:center;gap:0.5rem}.mode-switch limel-button{min-width:5rem}.mode-switch limel-helper-text{margin-left:1rem;color:rgb(var(--color-red-default))}.gui-mode,.code-mode{display:block}.code-editor-container{--code-editor-max-height:70vh;display:flex;flex-direction:column;gap:1rem}.code-editor-container .validation-errors{padding:0.75rem 1rem;color:rgb(var(--color-red-default));background-color:rgb(var(--color-red-lighter));border-left:0.25rem solid rgb(var(--color-red-default));border-radius:0.25rem;font-size:0.875rem}.code-editor-container .validation-errors strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-editor-container .validation-errors ul{margin:0;padding-left:1.5rem}.code-editor-container .validation-errors li{margin:0.25rem 0}.code-editor-container .gui-limitations{padding:0.75rem 1rem;color:rgb(var(--color-blue-dark));background-color:rgb(var(--color-blue-lighter));border-left:0.25rem solid rgb(var(--color-blue-default));border-radius:0.25rem;font-size:0.875rem}.code-editor-container .gui-limitations strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-editor-container .gui-limitations ul{margin:0;padding-left:1.5rem}.code-editor-container .gui-limitations li{margin:0.25rem 0}.lime-query-builder-label{margin:0;font-size:1.5rem;font-weight:600;color:rgb(var(--contrast-1100))}.limetype-section{display:flex;flex-direction:column}.filter-section,.query-options-section{display:flex;flex-direction:column;gap:1rem}.section-label{margin:0;font-size:1.125rem;font-weight:600;color:rgb(var(--contrast-1000))}.query-options-controls{display:grid;grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));gap:1rem}@media (max-width: 768px){.lime-query-builder{gap:1.5rem}.query-options-controls{grid-template-columns:1fr}}";
|
|
604
639
|
const LimebbLimeQueryBuilderStyle0 = limeQueryBuilderCss;
|
|
605
640
|
|
|
606
641
|
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -619,10 +654,76 @@ const LimeQueryBuilder = class {
|
|
|
619
654
|
this.change = createEvent(this, "change", 7);
|
|
620
655
|
this.mode = 'gui';
|
|
621
656
|
this.codeValue = '';
|
|
657
|
+
this.limetype = '';
|
|
658
|
+
this.filter = {
|
|
659
|
+
filter_type: 'AND',
|
|
660
|
+
expressions: [],
|
|
661
|
+
};
|
|
662
|
+
this.handleLimetypeChange = (event) => {
|
|
663
|
+
event.stopPropagation();
|
|
664
|
+
this.limetype = event.detail;
|
|
665
|
+
// Reset filter when limetype changes
|
|
666
|
+
this.filter = {
|
|
667
|
+
filter_type: 'AND',
|
|
668
|
+
expressions: [],
|
|
669
|
+
};
|
|
670
|
+
// Reset response format when limetype changes
|
|
671
|
+
this.internalResponseFormat = {
|
|
672
|
+
object: {
|
|
673
|
+
_id: null,
|
|
674
|
+
},
|
|
675
|
+
};
|
|
676
|
+
this.emitChange();
|
|
677
|
+
};
|
|
678
|
+
this.handleFilterChange = (event) => {
|
|
679
|
+
event.stopPropagation();
|
|
680
|
+
// Convert missing expression back to empty AND to keep the UI consistent
|
|
681
|
+
if (event.detail.filter_type === '') {
|
|
682
|
+
this.filter = {
|
|
683
|
+
filter_type: 'AND',
|
|
684
|
+
expressions: [],
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
this.filter = event.detail;
|
|
689
|
+
}
|
|
690
|
+
this.emitChange();
|
|
691
|
+
};
|
|
692
|
+
this.handleResponseFormatChange = (event) => {
|
|
693
|
+
event.stopPropagation();
|
|
694
|
+
this.internalResponseFormat = event.detail;
|
|
695
|
+
this.emitChange();
|
|
696
|
+
};
|
|
697
|
+
this.handleLimitChange = (event) => {
|
|
698
|
+
event.stopPropagation();
|
|
699
|
+
const value = event.detail;
|
|
700
|
+
this.limit = value ? Number.parseInt(value, 10) : undefined;
|
|
701
|
+
this.emitChange();
|
|
702
|
+
};
|
|
622
703
|
this.switchToGui = () => {
|
|
623
|
-
|
|
704
|
+
// Validate JSON before switching
|
|
705
|
+
try {
|
|
706
|
+
const parsed = JSON.parse(this.codeValue);
|
|
707
|
+
// Check if it's supported in GUI
|
|
708
|
+
const support = this.checkGuiSupport();
|
|
709
|
+
if (!support.guiSupported) {
|
|
710
|
+
// Don't switch if GUI can't render this query
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
// Update internal state from parsed query
|
|
714
|
+
this.limetype = parsed.limetype || '';
|
|
715
|
+
this.filter = normalizeLimeQueryFilterForGui(limeQueryToGuiFilter(parsed.filter));
|
|
716
|
+
this.internalResponseFormat = parsed.responseFormat;
|
|
717
|
+
this.limit = parsed.limit;
|
|
718
|
+
this.mode = 'gui';
|
|
719
|
+
this.change.emit(parsed);
|
|
720
|
+
}
|
|
721
|
+
catch (_a) {
|
|
722
|
+
// Don't switch if JSON is invalid (linter will show the error)
|
|
723
|
+
}
|
|
624
724
|
};
|
|
625
725
|
this.switchToCode = () => {
|
|
726
|
+
this.updateCodeValue();
|
|
626
727
|
this.mode = 'code';
|
|
627
728
|
};
|
|
628
729
|
this.handleCodeChange = (event) => {
|
|
@@ -643,43 +744,130 @@ const LimeQueryBuilder = class {
|
|
|
643
744
|
return ((_c = (_b = (_a = this.platform) === null || _a === void 0 ? void 0 : _a.isFeatureEnabled) === null || _b === void 0 ? void 0 : _b.call(_a, 'useLimeQueryBuilderGuiMode')) !== null && _c !== void 0 ? _c : false);
|
|
644
745
|
}
|
|
645
746
|
componentWillLoad() {
|
|
646
|
-
// Initialize code value from input prop
|
|
647
|
-
this.codeValue = JSON.stringify(this.value || {}, null, 2);
|
|
648
747
|
// Force code mode if GUI is disabled
|
|
649
748
|
if (!this.guiModeEnabled) {
|
|
650
749
|
this.mode = 'code';
|
|
750
|
+
// Initialize code value from prop
|
|
751
|
+
this.updateCodeValue();
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
if (this.value) {
|
|
755
|
+
this.limetype = this.value.limetype || '';
|
|
756
|
+
this.filter = normalizeLimeQueryFilterForGui(limeQueryToGuiFilter(this.value.filter));
|
|
757
|
+
this.internalResponseFormat = this.value.responseFormat;
|
|
758
|
+
this.limit = this.value.limit;
|
|
759
|
+
}
|
|
760
|
+
// Initialize code value from prop
|
|
761
|
+
this.updateCodeValue();
|
|
762
|
+
// Check if GUI mode is supported
|
|
763
|
+
const support = this.checkGuiSupport();
|
|
764
|
+
if (!support.guiSupported) {
|
|
765
|
+
this.mode = 'code';
|
|
651
766
|
}
|
|
652
767
|
}
|
|
653
768
|
render() {
|
|
654
769
|
const guiSupported = this.checkGuiSupport();
|
|
655
|
-
|
|
770
|
+
const showCodeMode = !this.guiModeEnabled || this.mode === 'code';
|
|
771
|
+
return (h("div", { key: '96d1a933f699404c3806af3742e9ad30d53562aa', class: "lime-query-builder" }, this.renderLabel(), this.renderModeControls(guiSupported), showCodeMode
|
|
772
|
+
? this.renderCodeMode(guiSupported)
|
|
773
|
+
: this.renderGuiMode()));
|
|
774
|
+
}
|
|
775
|
+
emitChange() {
|
|
776
|
+
// Only emit in GUI mode
|
|
777
|
+
if (this.mode === 'code') {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
if (!this.limetype) {
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
// Use internal state, then default to returning just _id
|
|
784
|
+
const responseFormat = this.internalResponseFormat || {
|
|
785
|
+
object: {
|
|
786
|
+
_id: null,
|
|
787
|
+
},
|
|
788
|
+
};
|
|
789
|
+
const limeQuery = {
|
|
790
|
+
limetype: this.limetype,
|
|
791
|
+
responseFormat: responseFormat,
|
|
792
|
+
filter: guiFilterToLimeQuery(this.filter),
|
|
793
|
+
};
|
|
794
|
+
if (this.limit !== undefined && this.limit > 0) {
|
|
795
|
+
limeQuery.limit = this.limit;
|
|
796
|
+
}
|
|
797
|
+
this.change.emit(limeQuery);
|
|
798
|
+
}
|
|
799
|
+
updateCodeValue() {
|
|
800
|
+
if (!this.limetype) {
|
|
801
|
+
this.codeValue = JSON.stringify(this.value || {}, null, 2);
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
// Use internal state, then default to returning just _id
|
|
805
|
+
const responseFormat = this.internalResponseFormat || {
|
|
806
|
+
object: {
|
|
807
|
+
_id: null,
|
|
808
|
+
},
|
|
809
|
+
};
|
|
810
|
+
const limeQuery = {
|
|
811
|
+
limetype: this.limetype,
|
|
812
|
+
responseFormat: responseFormat,
|
|
813
|
+
filter: guiFilterToLimeQuery(this.filter),
|
|
814
|
+
};
|
|
815
|
+
if (this.limit !== undefined && this.limit > 0) {
|
|
816
|
+
limeQuery.limit = this.limit;
|
|
817
|
+
}
|
|
818
|
+
this.codeValue = JSON.stringify(limeQuery, null, 2);
|
|
656
819
|
}
|
|
657
820
|
checkGuiSupport() {
|
|
658
|
-
if (!this.limetypes
|
|
821
|
+
if (!this.limetypes) {
|
|
659
822
|
// Can't validate yet, assume all is good
|
|
660
823
|
return {
|
|
661
824
|
valid: true,
|
|
662
|
-
guiSupported:
|
|
825
|
+
guiSupported: true,
|
|
663
826
|
validationErrors: [],
|
|
664
827
|
guiLimitations: [],
|
|
665
828
|
};
|
|
666
829
|
}
|
|
667
|
-
//
|
|
668
|
-
let
|
|
669
|
-
|
|
670
|
-
|
|
830
|
+
// When in code mode, validate the parsed code value instead of current state
|
|
831
|
+
let queryToCheck;
|
|
832
|
+
if (this.mode === 'code' && this.codeValue) {
|
|
833
|
+
try {
|
|
834
|
+
queryToCheck = JSON.parse(this.codeValue);
|
|
835
|
+
}
|
|
836
|
+
catch (_a) {
|
|
837
|
+
return {
|
|
838
|
+
valid: false,
|
|
839
|
+
guiSupported: false,
|
|
840
|
+
validationErrors: ['Invalid JSON'],
|
|
841
|
+
guiLimitations: [],
|
|
842
|
+
};
|
|
843
|
+
}
|
|
671
844
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
845
|
+
else {
|
|
846
|
+
// Build query from current GUI state
|
|
847
|
+
if (!this.limetype) {
|
|
848
|
+
return {
|
|
849
|
+
valid: true,
|
|
850
|
+
guiSupported: true,
|
|
851
|
+
validationErrors: [],
|
|
852
|
+
guiLimitations: [],
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
const responseFormat = this
|
|
856
|
+
.internalResponseFormat || {
|
|
857
|
+
object: {
|
|
858
|
+
_id: null,
|
|
859
|
+
},
|
|
860
|
+
};
|
|
861
|
+
queryToCheck = {
|
|
862
|
+
limetype: this.limetype,
|
|
863
|
+
responseFormat: responseFormat,
|
|
864
|
+
filter: guiFilterToLimeQuery(this.filter),
|
|
678
865
|
};
|
|
866
|
+
if (this.limit !== undefined && this.limit > 0) {
|
|
867
|
+
queryToCheck.limit = this.limit;
|
|
868
|
+
}
|
|
679
869
|
}
|
|
680
|
-
|
|
681
|
-
// Pass undefined since it's not needed for code mode validation
|
|
682
|
-
return isLimeQuerySupported(limeQueryToCheck, this.limetypes, undefined, this.guiModeEnabled);
|
|
870
|
+
return isLimeQuerySupported(queryToCheck, this.limetypes, this.activeLimetype, this.guiModeEnabled);
|
|
683
871
|
}
|
|
684
872
|
renderModeSwitch(support) {
|
|
685
873
|
const guiDisabled = !support.guiSupported;
|
|
@@ -692,6 +880,46 @@ const LimeQueryBuilder = class {
|
|
|
692
880
|
!guiSupported.guiSupported &&
|
|
693
881
|
guiSupported.guiLimitations.length > 0 && (h("div", { class: "gui-limitations" }, h("strong", null, "Cannot switch to GUI mode:"), h("ul", null, guiSupported.guiLimitations.map((limitation) => (h("li", null, limitation))))))));
|
|
694
882
|
}
|
|
883
|
+
renderLimetypeSection() {
|
|
884
|
+
return (h("div", { class: "limetype-section" }, h("limebb-limetype-field", { platform: this.platform, context: this.context, label: "Object Type", value: this.limetype, required: true, fieldName: "limetype", helperText: "Select the type of object you want to query", onChange: this.handleLimetypeChange })));
|
|
885
|
+
}
|
|
886
|
+
renderResponseFormatSection() {
|
|
887
|
+
if (!this.limetype) {
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
return (h("div", { class: "response-format-section" }, h("limebb-response-format-editor", { platform: this.platform, context: this.context, limetype: this.limetype, value: this.internalResponseFormat, onChange: this.handleResponseFormatChange })));
|
|
891
|
+
}
|
|
892
|
+
renderFilterSection() {
|
|
893
|
+
if (!this.limetype) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
return (h("div", { class: "filter-section" }, h("h4", { class: "section-label" }, "Filter Conditions"), h("limebb-lime-query-filter-expression", { platform: this.platform, context: this.context, limetype: this.limetype, activeLimetype: this.activeLimetype, expression: this.filter, onExpressionChange: this.handleFilterChange })));
|
|
897
|
+
}
|
|
898
|
+
renderQueryOptionsSection() {
|
|
899
|
+
var _a;
|
|
900
|
+
if (!this.limetype) {
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
return (h("div", { class: "query-options-section" }, h("h4", { class: "section-label" }, "Query Options"), h("div", { class: "query-options-controls" }, h("limel-input-field", { label: "Limit", type: "number", value: ((_a = this.limit) === null || _a === void 0 ? void 0 : _a.toString()) || '', placeholder: "No limit", helperText: "Maximum number of results", onChange: this.handleLimitChange }))));
|
|
904
|
+
}
|
|
905
|
+
renderGuiMode() {
|
|
906
|
+
return (h("div", { class: "gui-mode" }, this.renderLimetypeSection(), this.renderResponseFormatSection(), this.renderFilterSection(), this.renderQueryOptionsSection()));
|
|
907
|
+
}
|
|
908
|
+
renderLabel() {
|
|
909
|
+
if (!this.label) {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
return h("h3", { class: "lime-query-builder-label" }, this.label);
|
|
913
|
+
}
|
|
914
|
+
renderModeControls(support) {
|
|
915
|
+
if (!this.guiModeEnabled) {
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
return (h("div", { class: "mode-controls" }, this.renderModeSwitch(support)));
|
|
919
|
+
}
|
|
920
|
+
renderCodeMode(support) {
|
|
921
|
+
return h("div", { class: "code-mode" }, this.renderCodeEditor(support));
|
|
922
|
+
}
|
|
695
923
|
};
|
|
696
924
|
__decorate([
|
|
697
925
|
Te()
|