@limetech/lime-crm-building-blocks 1.100.1 → 1.102.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 (131) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/lime-crm-building-blocks.cjs.js +1 -1
  3. package/dist/cjs/lime-query-validation-6be10fa7.js +558 -0
  4. package/dist/cjs/limebb-lime-query-builder.cjs.entry.js +22 -426
  5. package/dist/cjs/limebb-lime-query-filter-builder_3.cjs.entry.js +86 -243
  6. package/dist/cjs/limebb-lime-query-filter-comparison_2.cjs.entry.js +1 -1
  7. package/dist/cjs/limebb-lime-query-filter-group_3.cjs.entry.js +2 -2
  8. package/dist/cjs/limebb-lime-query-order-by-item.cjs.entry.js +51 -0
  9. package/dist/cjs/limebb-lime-query-response-format-builder.cjs.entry.js +242 -0
  10. package/dist/cjs/limebb-lime-query-response-format-editor_2.cjs.entry.js +322 -0
  11. package/dist/cjs/limebb-live-docs-info.cjs.entry.js +2 -2
  12. package/dist/cjs/limebb-locale-picker.cjs.entry.js +1 -1
  13. package/dist/cjs/limebb-mention-group-counter.cjs.entry.js +2 -2
  14. package/dist/cjs/limebb-navigation-button_2.cjs.entry.js +3 -3
  15. package/dist/cjs/limebb-notification-item.cjs.entry.js +1 -1
  16. package/dist/cjs/limebb-percentage-visualizer.cjs.entry.js +2 -2
  17. package/dist/cjs/limebb-text-editor.cjs.entry.js +1 -1
  18. package/dist/cjs/limebb-trend-indicator.cjs.entry.js +1 -1
  19. package/dist/cjs/loader.cjs.js +1 -1
  20. package/dist/collection/collection-manifest.json +5 -2
  21. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-comparison.js +1 -1
  22. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-group.js +1 -1
  23. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-not.js +1 -1
  24. package/dist/collection/components/lime-query-builder/lime-query-builder.css +2 -5
  25. package/dist/collection/components/lime-query-builder/lime-query-builder.js +20 -20
  26. package/dist/collection/components/lime-query-builder/lime-query-response-format-builder.css +91 -0
  27. package/dist/collection/components/lime-query-builder/lime-query-response-format-builder.js +355 -0
  28. package/dist/collection/components/lime-query-builder/lime-query-validation.js +154 -7
  29. package/dist/collection/components/lime-query-builder/limetype-field/limetype-field.js +1 -1
  30. package/dist/collection/components/lime-query-builder/order-by/order-by-editor.css +72 -0
  31. package/dist/collection/components/lime-query-builder/order-by/order-by-editor.js +252 -0
  32. package/dist/collection/components/lime-query-builder/order-by/order-by-item.css +45 -0
  33. package/dist/collection/components/lime-query-builder/order-by/order-by-item.js +173 -0
  34. package/dist/collection/components/lime-query-builder/{response-format-editor.css → response-format/response-format-editor.css} +1 -1
  35. package/dist/collection/components/lime-query-builder/{response-format-editor.js → response-format/response-format-editor.js} +5 -5
  36. package/dist/collection/components/lime-query-builder/response-format/response-format-helpers.js +92 -0
  37. package/dist/collection/components/lime-query-builder/{response-format-item.css → response-format/response-format-item.css} +1 -1
  38. package/dist/collection/components/lime-query-builder/{response-format-item.js → response-format/response-format-item.js} +6 -6
  39. package/dist/collection/components/limeobject/file-viewer/live-docs-info.js +2 -2
  40. package/dist/collection/components/locale-picker/locale-picker.js +1 -1
  41. package/dist/collection/components/notification-list/notification-item/notification-item.js +1 -1
  42. package/dist/collection/components/percentage-visualizer/percentage-visualizer.js +2 -2
  43. package/dist/collection/components/summary-popover/summary-popover.js +3 -3
  44. package/dist/collection/components/text-editor/mention-group-counter.js +2 -2
  45. package/dist/collection/components/text-editor/text-editor.js +1 -1
  46. package/dist/collection/components/trend-indicator/trend-indicator.js +1 -1
  47. package/dist/components/lime-query-filter-comparison.js +1 -1
  48. package/dist/components/lime-query-filter-expression.js +2 -2
  49. package/dist/components/lime-query-validation.js +555 -0
  50. package/dist/components/lime-query-value-input.js +1 -1
  51. package/dist/components/limebb-lime-query-builder.js +53 -444
  52. package/dist/components/limebb-lime-query-order-by-editor.d.ts +11 -0
  53. package/dist/components/limebb-lime-query-order-by-editor.js +6 -0
  54. package/dist/components/limebb-lime-query-order-by-item.d.ts +11 -0
  55. package/dist/components/limebb-lime-query-order-by-item.js +6 -0
  56. package/dist/components/limebb-lime-query-response-format-builder.d.ts +11 -0
  57. package/dist/components/limebb-lime-query-response-format-builder.js +283 -0
  58. package/dist/components/limebb-lime-query-response-format-editor.d.ts +11 -0
  59. package/dist/components/{limebb-response-format-editor.js → limebb-lime-query-response-format-editor.js} +2 -2
  60. package/dist/components/limebb-lime-query-response-format-item.d.ts +11 -0
  61. package/dist/components/{limebb-response-format-item.js → limebb-lime-query-response-format-item.js} +2 -2
  62. package/dist/components/limebb-locale-picker.js +1 -1
  63. package/dist/components/limebb-mention-group-counter.js +2 -2
  64. package/dist/components/limebb-percentage-visualizer.js +2 -2
  65. package/dist/components/limebb-text-editor.js +1 -1
  66. package/dist/components/limebb-trend-indicator.js +1 -1
  67. package/dist/components/limetype-field.js +1 -1
  68. package/dist/components/live-docs-info.js +2 -2
  69. package/dist/components/notification-item.js +1 -1
  70. package/dist/components/order-by-editor.js +123 -0
  71. package/dist/components/order-by-item.js +73 -0
  72. package/dist/components/property-selector.js +1 -1
  73. package/dist/components/response-format-editor.js +11 -11
  74. package/dist/components/response-format-item.js +9 -9
  75. package/dist/components/summary-popover.js +3 -3
  76. package/dist/esm/lime-crm-building-blocks.js +1 -1
  77. package/dist/esm/lime-query-validation-573223a5.js +555 -0
  78. package/dist/esm/limebb-lime-query-builder.entry.js +22 -426
  79. package/dist/esm/limebb-lime-query-filter-builder_3.entry.js +86 -243
  80. package/dist/esm/limebb-lime-query-filter-comparison_2.entry.js +1 -1
  81. package/dist/esm/limebb-lime-query-filter-group_3.entry.js +3 -3
  82. package/dist/esm/limebb-lime-query-order-by-item.entry.js +47 -0
  83. package/dist/esm/limebb-lime-query-response-format-builder.entry.js +238 -0
  84. package/dist/esm/limebb-lime-query-response-format-editor_2.entry.js +317 -0
  85. package/dist/esm/limebb-live-docs-info.entry.js +2 -2
  86. package/dist/esm/limebb-locale-picker.entry.js +1 -1
  87. package/dist/esm/limebb-mention-group-counter.entry.js +2 -2
  88. package/dist/esm/limebb-navigation-button_2.entry.js +3 -3
  89. package/dist/esm/limebb-notification-item.entry.js +1 -1
  90. package/dist/esm/limebb-percentage-visualizer.entry.js +2 -2
  91. package/dist/esm/limebb-property-selector.entry.js +1 -1
  92. package/dist/esm/limebb-text-editor.entry.js +1 -1
  93. package/dist/esm/limebb-trend-indicator.entry.js +1 -1
  94. package/dist/esm/loader.js +1 -1
  95. package/dist/esm/{property-resolution-fde2375e.js → property-resolution-c21a1369.js} +1 -1
  96. package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
  97. package/dist/lime-crm-building-blocks/{p-79b8b09b.entry.js → p-0de79b7f.entry.js} +1 -1
  98. package/dist/lime-crm-building-blocks/{p-1034b4a5.entry.js → p-0f7135ff.entry.js} +1 -1
  99. package/dist/lime-crm-building-blocks/{p-6aa216ec.entry.js → p-186e9f1a.entry.js} +1 -1
  100. package/dist/lime-crm-building-blocks/p-289ce8b9.entry.js +1 -0
  101. package/dist/lime-crm-building-blocks/p-3351395b.entry.js +1 -0
  102. package/dist/lime-crm-building-blocks/p-33e6d0ec.entry.js +1 -0
  103. package/dist/lime-crm-building-blocks/{p-8581245a.entry.js → p-3d1be1c9.entry.js} +1 -1
  104. package/dist/lime-crm-building-blocks/{p-b57dafef.entry.js → p-577d8909.entry.js} +1 -1
  105. package/dist/lime-crm-building-blocks/{p-89a6c396.entry.js → p-6579412e.entry.js} +1 -1
  106. package/dist/lime-crm-building-blocks/{p-8fb2e192.entry.js → p-6f6fed59.entry.js} +1 -1
  107. package/dist/lime-crm-building-blocks/{p-58782467.entry.js → p-7e5528f6.entry.js} +1 -1
  108. package/dist/lime-crm-building-blocks/{p-2048ac67.entry.js → p-a9ac501f.entry.js} +1 -1
  109. package/dist/lime-crm-building-blocks/{p-f79e354b.entry.js → p-abfc7815.entry.js} +1 -1
  110. package/dist/lime-crm-building-blocks/{p-e0ab1554.js → p-b748c770.js} +1 -1
  111. package/dist/lime-crm-building-blocks/p-be845252.entry.js +1 -0
  112. package/dist/lime-crm-building-blocks/p-cb338753.entry.js +1 -0
  113. package/dist/lime-crm-building-blocks/{p-76d81eee.entry.js → p-d0721b22.entry.js} +1 -1
  114. package/dist/lime-crm-building-blocks/p-fa2da6bc.js +1 -0
  115. package/dist/types/components/lime-query-builder/lime-query-builder.d.ts +9 -6
  116. package/dist/types/components/lime-query-builder/lime-query-response-format-builder.d.ts +102 -0
  117. package/dist/types/components/lime-query-builder/lime-query-validation.d.ts +13 -0
  118. package/dist/types/components/lime-query-builder/order-by/order-by-editor.d.ts +58 -0
  119. package/dist/types/components/lime-query-builder/order-by/order-by-item.d.ts +37 -0
  120. package/dist/types/components/lime-query-builder/{response-format-editor.d.ts → response-format/response-format-editor.d.ts} +2 -2
  121. package/dist/types/components/lime-query-builder/response-format/response-format-helpers.d.ts +42 -0
  122. package/dist/types/components/lime-query-builder/{response-format-item.d.ts → response-format/response-format-item.d.ts} +2 -2
  123. package/dist/types/components.d.ts +667 -279
  124. package/package.json +1 -1
  125. package/dist/cjs/limebb-response-format-item.cjs.entry.js +0 -80
  126. package/dist/components/limebb-response-format-editor.d.ts +0 -11
  127. package/dist/components/limebb-response-format-item.d.ts +0 -11
  128. package/dist/esm/limebb-response-format-item.entry.js +0 -76
  129. package/dist/lime-crm-building-blocks/p-244ee55b.entry.js +0 -1
  130. package/dist/lime-crm-building-blocks/p-323c49bc.entry.js +0 -1
  131. package/dist/lime-crm-building-blocks/p-f22b66f6.entry.js +0 -1
@@ -1,412 +1,9 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-96dd111f.js';
2
- import { Z as Zt, T as Te } from './index.esm-bb569663.js';
3
- import { g as getNormalizedProperties, a as getPropertyFromPath } from './property-resolution-fde2375e.js';
2
+ import { T as Te } from './index.esm-bb569663.js';
3
+ import { i as isLimeQuerySupported } from './lime-query-validation-573223a5.js';
4
+ import './property-resolution-c21a1369.js';
4
5
 
5
- /**
6
- * Dynamic filter values and placeholders that are valid in Lime Query
7
- */
8
- const VALID_DYNAMIC_VALUES = new Set([
9
- // Temporal
10
- '$yesterday',
11
- '$now',
12
- '$today',
13
- '$tomorrow',
14
- // Ranges
15
- '$this_week',
16
- '$this_month',
17
- '$this_quarter',
18
- '$this_year',
19
- ]);
20
- /**
21
- * Pattern for relative date functions: $previous_day(x), $next_month(x), etc.
22
- */
23
- const RELATIVE_DATE_PATTERN = /^\$(previous|next)_(day|week|month|quarter|year)\(\d+\)$/;
24
- /**
25
- * Pattern for user context variables: $me, $me.office.name, etc.
26
- */
27
- const USER_CONTEXT_PATTERN = /^\$me(\.\w+)*$/;
28
- /**
29
- * Check if a value is a valid dynamic value or placeholder
30
- * @param value
31
- */
32
- function isValidDynamicValue(value) {
33
- if (typeof value !== 'string') {
34
- return false;
35
- }
36
- return (VALID_DYNAMIC_VALUES.has(value) ||
37
- RELATIVE_DATE_PATTERN.test(value) ||
38
- USER_CONTEXT_PATTERN.test(value));
39
- }
40
- /**
41
- * Validate a placeholder value
42
- * @param value The value to check (might be a placeholder)
43
- * @param activeLimetype The limetype of the active object
44
- * @param limetypes Record of all available limetypes
45
- * @returns Validation result with error message if invalid
46
- */
47
- function validatePlaceholder(value, activeLimetype, limetypes) {
48
- // Check if it's a valid dynamic value ($today, $me, etc.)
49
- if (isValidDynamicValue(value)) {
50
- return { valid: true };
51
- }
52
- // Not a placeholder, no validation needed
53
- if (typeof value !== 'string' || !value.startsWith('%activeObject%')) {
54
- return { valid: true };
55
- }
56
- // Placeholder used but no active limetype specified
57
- // This is always valid - activeLimetype is optional and only used for validation
58
- if (!activeLimetype) {
59
- return { valid: true };
60
- }
61
- // Extract property path from placeholder
62
- const propertyPath = value.replace(/^%activeObject%\.?/, '');
63
- // %activeObject% without property path is valid (references the ID)
64
- if (!propertyPath) {
65
- return { valid: true };
66
- }
67
- // Validate the property path exists on the active limetype
68
- try {
69
- const property = getPropertyFromPath(limetypes, activeLimetype, propertyPath);
70
- if (!property) {
71
- return {
72
- valid: false,
73
- error: `Property path '${propertyPath}' does not exist on limetype '${activeLimetype}'`,
74
- };
75
- }
76
- // Path validation is already done by getPropertyFromPath
77
- // If we can traverse the path successfully, it means all intermediate
78
- // properties are valid single relations (belongsTo/hasOne).
79
- // hasMany relations cannot be traversed in paths.
80
- return { valid: true };
81
- }
82
- catch (error) {
83
- return {
84
- valid: false,
85
- error: `Invalid placeholder path: ${error.message}`,
86
- };
87
- }
88
- }
89
- /**
90
- * Validate a response format against limetype schemas
91
- * Throws errors for invalid property references
92
- * Returns GUI limitations for features not yet supported in GUI
93
- * @param responseFormat
94
- * @param limetypes Record of all available limetypes
95
- * @param limetype The root limetype for this query
96
- * @param guiModeEnabled Whether GUI mode is enabled
97
- * @returns GUI limitations found (if any)
98
- */
99
- function validateResponseFormat(responseFormat, limetypes, limetype, guiModeEnabled = true) {
100
- const guiLimitations = [];
101
- // Check for GUI-unsupported features
102
- if (guiModeEnabled && responseFormat.aggregates) {
103
- guiLimitations.push('responseFormat.aggregates is not yet supported in GUI mode');
104
- }
105
- // Validate object properties (throws on invalid properties)
106
- if (responseFormat.object) {
107
- const objectLimitations = validatePropertySelection(responseFormat.object, limetypes, limetype, guiModeEnabled);
108
- guiLimitations.push(...objectLimitations);
109
- }
110
- return guiLimitations;
111
- }
112
- /**
113
- * Extract non-metadata keys from a property value object
114
- * Filters out _alias and all # properties (which are treated as comments)
115
- * @param propValue Property value object
116
- * @param propName Property name (for error messages)
117
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
118
- * @returns Object with non-metadata keys and any GUI limitations found
119
- */
120
- function extractNonMetadataKeys(propValue, propName, guiModeEnabled = true) {
121
- const keys = Object.keys(propValue);
122
- const guiLimitations = [];
123
- // Check for # properties other than #description (GUI limitation)
124
- if (guiModeEnabled) {
125
- const unsupportedHashProps = keys.filter((k) => k.startsWith('#') && k !== '#description');
126
- if (unsupportedHashProps.length > 0) {
127
- guiLimitations.push(`Property '${propName}' contains # properties not supported in GUI: ${unsupportedHashProps.join(', ')}`);
128
- }
129
- }
130
- // Filter out _alias and all # properties (they are metadata/comments)
131
- const nonMetadataKeys = keys.filter((k) => k !== '_alias' && !k.startsWith('#'));
132
- return { keys: nonMetadataKeys, guiLimitations };
133
- }
134
- /**
135
- * Validate a relation property value
136
- * @param propName Property name
137
- * @param propValue Property value
138
- * @param limetypes Record of all available limetypes
139
- * @param property
140
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
141
- * @returns GUI limitations found (if any)
142
- */
143
- function validateRelationProperty(propName, propValue, limetypes, property, guiModeEnabled = true) {
144
- // null is valid - just return the relation ID
145
- if (propValue === null) {
146
- return [];
147
- }
148
- if (typeof propValue !== 'object') {
149
- throw new TypeError(`Relation property '${propName}' must be null or an object`);
150
- }
151
- const propValueObj = propValue;
152
- const { keys: otherKeys, guiLimitations } = extractNonMetadataKeys(propValueObj, propName, guiModeEnabled);
153
- // If it's just {} or { _alias: "...", "#...": "..." }, that's valid
154
- if (otherKeys.length === 0) {
155
- return guiLimitations;
156
- }
157
- // Otherwise, validate nested properties
158
- const relatedLimetype = property.relation.getLimetype();
159
- if (!relatedLimetype) {
160
- throw new Error(`Could not determine related limetype for property '${propName}'`);
161
- }
162
- // Build a clean PropertySelection without metadata for recursive validation
163
- const cleanSelection = {};
164
- for (const key of otherKeys) {
165
- cleanSelection[key] = propValueObj[key];
166
- }
167
- const nestedLimitations = validatePropertySelection(cleanSelection, limetypes, relatedLimetype.name, guiModeEnabled);
168
- return [...guiLimitations, ...nestedLimitations];
169
- }
170
- /**
171
- * Validate a non-relation property value
172
- * @param propName Property name
173
- * @param propValue Property value
174
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
175
- * @returns GUI limitations found (if any)
176
- */
177
- function validateNonRelationProperty(propName, propValue, guiModeEnabled = true) {
178
- // null is valid
179
- if (propValue === null) {
180
- return [];
181
- }
182
- // Allow empty object {} or object with only metadata (_alias, #...)
183
- if (typeof propValue === 'object') {
184
- const { keys: nonMetadataKeys, guiLimitations } = extractNonMetadataKeys(propValue, propName, guiModeEnabled);
185
- if (nonMetadataKeys.length === 0) {
186
- // {} or { _alias: "...", "#...": "..." } is valid
187
- return guiLimitations;
188
- }
189
- throw new Error(`Non-relation property '${propName}' cannot have nested properties other than _alias or # properties (got: ${nonMetadataKeys.join(', ')})`);
190
- }
191
- throw new Error(`Non-relation property '${propName}' must be null or an object (got ${typeof propValue})`);
192
- }
193
- /**
194
- * Validate a single property entry
195
- * @param propName Property name
196
- * @param propValue Property value
197
- * @param normalizedProperties Normalized properties of the limetype
198
- * @param limetypes Record of all available limetypes
199
- * @param limetype Current limetype name
200
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
201
- * @returns GUI limitations found (if any)
202
- */
203
- function validateSinglePropertyEntry(propName, propValue, normalizedProperties, limetypes, limetype, guiModeEnabled = true) {
204
- // Allow empty string (editing state in GUI)
205
- if (propName === '') {
206
- // Only validate empty property name in GUI mode
207
- if (guiModeEnabled && propValue !== null) {
208
- throw new Error('Empty property name must have null value');
209
- }
210
- return [];
211
- }
212
- // Validate property exists on limetype
213
- const property = normalizedProperties[propName];
214
- if (!property) {
215
- throw new Error(`Property '${propName}' does not exist on limetype '${limetype}'`);
216
- }
217
- // Validate value based on property type
218
- if (property.relation) {
219
- return validateRelationProperty(propName, propValue, limetypes, property, guiModeEnabled);
220
- }
221
- else {
222
- return validateNonRelationProperty(propName, propValue, guiModeEnabled);
223
- }
224
- }
225
- /**
226
- * Validate a property selection object against a limetype schema
227
- * Recursively validates nested property selections for relations
228
- * @param selection
229
- * @param limetypes Record of all available limetypes
230
- * @param limetype The limetype for this level of the selection
231
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
232
- * @returns GUI limitations found (if any)
233
- */
234
- function validatePropertySelection(selection, limetypes, limetype, guiModeEnabled = true) {
235
- const limetypeObj = limetypes[limetype];
236
- if (!limetypeObj) {
237
- throw new Error(`Unknown limetype: ${limetype}`);
238
- }
239
- const normalizedProperties = getNormalizedProperties(limetypeObj);
240
- const allGuiLimitations = [];
241
- for (const [propName, propValue] of Object.entries(selection)) {
242
- // Skip # properties (comments/metadata that backend accepts via unknown=INCLUDE)
243
- // Note: _alias only appears inside property value objects, not at this level
244
- if (propName.startsWith('#')) {
245
- continue;
246
- }
247
- const limitations = validateSinglePropertyEntry(propName, propValue, normalizedProperties, limetypes, limetype, guiModeEnabled);
248
- allGuiLimitations.push(...limitations);
249
- }
250
- return allGuiLimitations;
251
- }
252
- /**
253
- * Validate a comparison expression (has 'key' property)
254
- * @param filter
255
- * @param activeLimetype
256
- * @param limetypes
257
- */
258
- function validateComparisonExpression(filter, activeLimetype, limetypes) {
259
- // Validate operator
260
- const allValidOperators = Object.values(Zt);
261
- if (!allValidOperators.includes(filter.op)) {
262
- throw new Error(`Unsupported filter operator: ${filter.op}`);
263
- }
264
- // Validate placeholder
265
- const result = validatePlaceholder(filter.exp, activeLimetype, limetypes);
266
- if (!result.valid) {
267
- throw new Error(`Invalid placeholder in filter '${filter.key}': ${result.error}`);
268
- }
269
- }
270
- /**
271
- * Validate a group expression (AND/OR/NOT)
272
- * @param filter
273
- * @param activeLimetype
274
- * @param limetypes
275
- * @param guiModeEnabled
276
- */
277
- function validateGroupExpression(filter, activeLimetype, limetypes, guiModeEnabled) {
278
- // Validate operator
279
- if (filter.op !== Zt.AND &&
280
- filter.op !== Zt.OR &&
281
- filter.op !== Zt.NOT) {
282
- throw new Error(`Unsupported group operator: ${filter.op}`);
283
- }
284
- // Recursively validate children
285
- if (filter.op === Zt.NOT) {
286
- validateFilterPlaceholders(filter.exp, activeLimetype, limetypes, guiModeEnabled);
287
- }
288
- else if (filter.op === Zt.AND || filter.op === Zt.OR) {
289
- const expressions = filter.exp;
290
- for (const expr of expressions) {
291
- validateFilterPlaceholders(expr, activeLimetype, limetypes, guiModeEnabled);
292
- }
293
- }
294
- }
295
- /**
296
- * Validate placeholders in a filter expression
297
- * @param filter Filter expression to validate
298
- * @param activeLimetype The limetype of the active object
299
- * @param limetypes Record of all available limetypes
300
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
301
- */
302
- function validateFilterPlaceholders(filter, activeLimetype, limetypes, guiModeEnabled = true) {
303
- if (!filter) {
304
- return;
305
- }
306
- if ('key' in filter) {
307
- validateComparisonExpression(filter, activeLimetype, limetypes);
308
- return;
309
- }
310
- if ('exp' in filter) {
311
- validateGroupExpression(filter, activeLimetype, limetypes, guiModeEnabled);
312
- }
313
- }
314
- /**
315
- * Validate Lime Query filter and collect errors
316
- * @param filter The filter expression or group to validate
317
- * @param activeLimetype Optional active object limetype for placeholder validation
318
- * @param limetypes Record of all available limetypes
319
- * @param guiModeEnabled Whether GUI mode is enabled
320
- * @returns Array of validation error messages
321
- */
322
- function validateLimeQueryFilterInternal(filter, activeLimetype, limetypes, guiModeEnabled) {
323
- const errors = [];
324
- try {
325
- validateFilterPlaceholders(filter, activeLimetype, limetypes, guiModeEnabled);
326
- }
327
- catch (error) {
328
- errors.push(`Invalid filter: ${error.message}`);
329
- }
330
- return errors;
331
- }
332
- /**
333
- * Validate Lime Query response format and collect errors/limitations
334
- * @param responseFormat The response format to validate
335
- * @param limetypes Record of all available limetypes
336
- * @param limetype The limetype for this Lime Query
337
- * @param guiModeEnabled Whether GUI mode is enabled
338
- * @returns Object with validation errors and GUI limitations
339
- */
340
- function validateLimeQueryResponseFormatInternal(responseFormat, limetypes, limetype, guiModeEnabled) {
341
- const errors = [];
342
- const limitations = [];
343
- try {
344
- const formatLimitations = validateResponseFormat(responseFormat, limetypes, limetype, guiModeEnabled);
345
- limitations.push(...formatLimitations);
346
- }
347
- catch (error) {
348
- errors.push(`Invalid responseFormat: ${error.message}`);
349
- }
350
- return { errors, limitations };
351
- }
352
- /**
353
- * Validate a Lime Query
354
- * Returns validation result with separate arrays for validity errors and GUI limitations
355
- * @param limeQuery The Lime Query to validate
356
- * @param limetypes Record of all available limetypes
357
- * @param activeLimetype Optional active object limetype for placeholder validation
358
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
359
- * @returns LimeQueryValidationResult with validity status and any errors/limitations
360
- */
361
- function isLimeQuerySupported(limeQuery, limetypes, activeLimetype, guiModeEnabled = true) {
362
- // Handle empty/undefined Lime Query
363
- if (!limeQuery) {
364
- return {
365
- valid: true,
366
- guiSupported: true,
367
- validationErrors: [],
368
- guiLimitations: [],
369
- };
370
- }
371
- const validationErrors = [];
372
- const guiLimitations = [];
373
- // Validate limetype exists
374
- if (limeQuery.limetype && !limetypes[limeQuery.limetype]) {
375
- validationErrors.push(`Unknown limetype: ${limeQuery.limetype}`);
376
- }
377
- // Check for offset without orderBy (Lime Query requirement)
378
- if (limeQuery.offset !== undefined && !limeQuery.orderBy) {
379
- validationErrors.push('offset requires orderBy to be specified');
380
- }
381
- // Check for GUI-unsupported top-level properties
382
- if (guiModeEnabled) {
383
- if (limeQuery.orderBy) {
384
- guiLimitations.push('orderBy is not yet supported in GUI mode');
385
- }
386
- if (limeQuery.offset !== undefined) {
387
- guiLimitations.push('offset is not yet supported in GUI mode');
388
- }
389
- }
390
- // Validate filter
391
- if (limeQuery.filter) {
392
- const filterErrors = validateLimeQueryFilterInternal(limeQuery.filter, activeLimetype, limetypes, guiModeEnabled);
393
- validationErrors.push(...filterErrors);
394
- }
395
- // Validate responseFormat
396
- if (limeQuery.responseFormat) {
397
- const { errors, limitations } = validateLimeQueryResponseFormatInternal(limeQuery.responseFormat, limetypes, limeQuery.limetype, guiModeEnabled);
398
- validationErrors.push(...errors);
399
- guiLimitations.push(...limitations);
400
- }
401
- return {
402
- valid: validationErrors.length === 0,
403
- guiSupported: guiLimitations.length === 0,
404
- validationErrors,
405
- guiLimitations,
406
- };
407
- }
408
-
409
- 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}}";
6
+ 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:flex;flex-direction:column;gap:1rem}@media (max-width: 768px){.lime-query-builder{gap:1.5rem}}";
410
7
  const LimebbLimeQueryBuilderStyle0 = limeQueryBuilderCss;
411
8
 
412
9
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
@@ -456,6 +53,11 @@ const LimeQueryBuilder = class {
456
53
  this.limit = value ? Number.parseInt(value, 10) : undefined;
457
54
  this.emitChange();
458
55
  };
56
+ this.handleOrderByChange = (event) => {
57
+ event.stopPropagation();
58
+ this.orderBy = event.detail;
59
+ this.emitChange();
60
+ };
459
61
  this.switchToGui = () => {
460
62
  // Validate JSON before switching
461
63
  try {
@@ -471,6 +73,7 @@ const LimeQueryBuilder = class {
471
73
  this.filter = parsed.filter;
472
74
  this.internalResponseFormat = parsed.responseFormat;
473
75
  this.limit = parsed.limit;
76
+ this.orderBy = parsed.orderBy;
474
77
  this.mode = 'gui';
475
78
  this.change.emit(parsed);
476
79
  }
@@ -512,6 +115,7 @@ const LimeQueryBuilder = class {
512
115
  this.filter = this.value.filter;
513
116
  this.internalResponseFormat = this.value.responseFormat;
514
117
  this.limit = this.value.limit;
118
+ this.orderBy = this.value.orderBy;
515
119
  }
516
120
  // Initialize code value from prop
517
121
  this.updateCodeValue();
@@ -524,7 +128,7 @@ const LimeQueryBuilder = class {
524
128
  render() {
525
129
  const guiSupported = this.checkGuiSupport();
526
130
  const showCodeMode = !this.guiModeEnabled || this.mode === 'code';
527
- return (h("div", { key: '0b4d2bb5b4d503a775d8d3215e1e4c74fdb1eceb', class: "lime-query-builder" }, this.renderLabel(), this.renderModeControls(guiSupported), showCodeMode
131
+ return (h("div", { key: 'f51ae0459c1c7f482f3a790abb4cc3bd60b83e70', class: "lime-query-builder" }, this.renderLabel(), this.renderModeControls(guiSupported), showCodeMode
528
132
  ? this.renderCodeMode(guiSupported)
529
133
  : this.renderGuiMode()));
530
134
  }
@@ -536,27 +140,16 @@ const LimeQueryBuilder = class {
536
140
  if (!this.limetype) {
537
141
  return;
538
142
  }
539
- // Use internal state, then default to returning just _id
540
- const responseFormat = this.internalResponseFormat || {
541
- object: {
542
- _id: null,
543
- },
544
- };
545
- const limeQuery = {
546
- limetype: this.limetype,
547
- responseFormat: responseFormat,
548
- filter: this.filter,
549
- };
550
- if (this.limit !== undefined && this.limit > 0) {
551
- limeQuery.limit = this.limit;
552
- }
553
- this.change.emit(limeQuery);
143
+ this.change.emit(this.buildLimeQuery());
554
144
  }
555
145
  updateCodeValue() {
556
146
  if (!this.limetype) {
557
147
  this.codeValue = JSON.stringify(this.value || {}, null, 2);
558
148
  return;
559
149
  }
150
+ this.codeValue = JSON.stringify(this.buildLimeQuery(), null, 2);
151
+ }
152
+ buildLimeQuery() {
560
153
  // Use internal state, then default to returning just _id
561
154
  const responseFormat = this.internalResponseFormat || {
562
155
  object: {
@@ -571,7 +164,10 @@ const LimeQueryBuilder = class {
571
164
  if (this.limit !== undefined && this.limit > 0) {
572
165
  limeQuery.limit = this.limit;
573
166
  }
574
- this.codeValue = JSON.stringify(limeQuery, null, 2);
167
+ if (this.orderBy && this.orderBy.length > 0) {
168
+ limeQuery.orderBy = this.orderBy;
169
+ }
170
+ return limeQuery;
575
171
  }
576
172
  checkGuiSupport() {
577
173
  if (!this.limetypes) {
@@ -643,7 +239,7 @@ const LimeQueryBuilder = class {
643
239
  if (!this.limetype) {
644
240
  return;
645
241
  }
646
- 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 })));
242
+ return (h("div", { class: "response-format-section" }, h("limebb-lime-query-response-format-editor", { platform: this.platform, context: this.context, limetype: this.limetype, value: this.internalResponseFormat, onChange: this.handleResponseFormatChange })));
647
243
  }
648
244
  renderFilterSection() {
649
245
  if (!this.limetype) {
@@ -656,7 +252,7 @@ const LimeQueryBuilder = class {
656
252
  if (!this.limetype) {
657
253
  return;
658
254
  }
659
- 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 }))));
255
+ 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 }), h("limebb-lime-query-order-by-editor", { platform: this.platform, context: this.context, limetype: this.limetype, value: this.orderBy, onChange: this.handleOrderByChange }))));
660
256
  }
661
257
  renderGuiMode() {
662
258
  return (h("div", { class: "gui-mode" }, this.renderLimetypeSection(), this.renderResponseFormatSection(), this.renderFilterSection(), this.renderQueryOptionsSection()));