@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,419 +1,18 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { Z as Zt, T as Te } from './index.esm.js';
3
- import { g as getNormalizedProperties, a as getPropertyFromPath, d as defineCustomElement$4 } from './property-selector.js';
4
- import { d as defineCustomElement$b } from './lime-query-filter-builder.js';
5
- import { d as defineCustomElement$a } from './lime-query-filter-comparison.js';
6
- import { d as defineCustomElement$7, a as defineCustomElement$8, b as defineCustomElement$9 } from './lime-query-filter-expression.js';
7
- import { d as defineCustomElement$6 } from './lime-query-value-input.js';
8
- import { d as defineCustomElement$5 } from './limetype-field.js';
9
- import { d as defineCustomElement$3 } from './response-format-editor.js';
10
- import { d as defineCustomElement$2 } from './response-format-item.js';
2
+ import { T as Te } from './index.esm.js';
3
+ import { i as isLimeQuerySupported } from './lime-query-validation.js';
4
+ import { d as defineCustomElement$d } from './lime-query-filter-builder.js';
5
+ import { d as defineCustomElement$c } from './lime-query-filter-comparison.js';
6
+ import { d as defineCustomElement$9, a as defineCustomElement$a, b as defineCustomElement$b } from './lime-query-filter-expression.js';
7
+ import { d as defineCustomElement$8 } from './order-by-editor.js';
8
+ import { d as defineCustomElement$7 } from './order-by-item.js';
9
+ import { d as defineCustomElement$6 } from './response-format-editor.js';
10
+ import { d as defineCustomElement$5 } from './response-format-item.js';
11
+ import { d as defineCustomElement$4 } from './lime-query-value-input.js';
12
+ import { d as defineCustomElement$3 } from './limetype-field.js';
13
+ import { d as defineCustomElement$2 } from './property-selector.js';
11
14
 
12
- /**
13
- * Dynamic filter values and placeholders that are valid in Lime Query
14
- */
15
- const VALID_DYNAMIC_VALUES = new Set([
16
- // Temporal
17
- '$yesterday',
18
- '$now',
19
- '$today',
20
- '$tomorrow',
21
- // Ranges
22
- '$this_week',
23
- '$this_month',
24
- '$this_quarter',
25
- '$this_year',
26
- ]);
27
- /**
28
- * Pattern for relative date functions: $previous_day(x), $next_month(x), etc.
29
- */
30
- const RELATIVE_DATE_PATTERN = /^\$(previous|next)_(day|week|month|quarter|year)\(\d+\)$/;
31
- /**
32
- * Pattern for user context variables: $me, $me.office.name, etc.
33
- */
34
- const USER_CONTEXT_PATTERN = /^\$me(\.\w+)*$/;
35
- /**
36
- * Check if a value is a valid dynamic value or placeholder
37
- * @param value
38
- */
39
- function isValidDynamicValue(value) {
40
- if (typeof value !== 'string') {
41
- return false;
42
- }
43
- return (VALID_DYNAMIC_VALUES.has(value) ||
44
- RELATIVE_DATE_PATTERN.test(value) ||
45
- USER_CONTEXT_PATTERN.test(value));
46
- }
47
- /**
48
- * Validate a placeholder value
49
- * @param value The value to check (might be a placeholder)
50
- * @param activeLimetype The limetype of the active object
51
- * @param limetypes Record of all available limetypes
52
- * @returns Validation result with error message if invalid
53
- */
54
- function validatePlaceholder(value, activeLimetype, limetypes) {
55
- // Check if it's a valid dynamic value ($today, $me, etc.)
56
- if (isValidDynamicValue(value)) {
57
- return { valid: true };
58
- }
59
- // Not a placeholder, no validation needed
60
- if (typeof value !== 'string' || !value.startsWith('%activeObject%')) {
61
- return { valid: true };
62
- }
63
- // Placeholder used but no active limetype specified
64
- // This is always valid - activeLimetype is optional and only used for validation
65
- if (!activeLimetype) {
66
- return { valid: true };
67
- }
68
- // Extract property path from placeholder
69
- const propertyPath = value.replace(/^%activeObject%\.?/, '');
70
- // %activeObject% without property path is valid (references the ID)
71
- if (!propertyPath) {
72
- return { valid: true };
73
- }
74
- // Validate the property path exists on the active limetype
75
- try {
76
- const property = getPropertyFromPath(limetypes, activeLimetype, propertyPath);
77
- if (!property) {
78
- return {
79
- valid: false,
80
- error: `Property path '${propertyPath}' does not exist on limetype '${activeLimetype}'`,
81
- };
82
- }
83
- // Path validation is already done by getPropertyFromPath
84
- // If we can traverse the path successfully, it means all intermediate
85
- // properties are valid single relations (belongsTo/hasOne).
86
- // hasMany relations cannot be traversed in paths.
87
- return { valid: true };
88
- }
89
- catch (error) {
90
- return {
91
- valid: false,
92
- error: `Invalid placeholder path: ${error.message}`,
93
- };
94
- }
95
- }
96
- /**
97
- * Validate a response format against limetype schemas
98
- * Throws errors for invalid property references
99
- * Returns GUI limitations for features not yet supported in GUI
100
- * @param responseFormat
101
- * @param limetypes Record of all available limetypes
102
- * @param limetype The root limetype for this query
103
- * @param guiModeEnabled Whether GUI mode is enabled
104
- * @returns GUI limitations found (if any)
105
- */
106
- function validateResponseFormat(responseFormat, limetypes, limetype, guiModeEnabled = true) {
107
- const guiLimitations = [];
108
- // Check for GUI-unsupported features
109
- if (guiModeEnabled && responseFormat.aggregates) {
110
- guiLimitations.push('responseFormat.aggregates is not yet supported in GUI mode');
111
- }
112
- // Validate object properties (throws on invalid properties)
113
- if (responseFormat.object) {
114
- const objectLimitations = validatePropertySelection(responseFormat.object, limetypes, limetype, guiModeEnabled);
115
- guiLimitations.push(...objectLimitations);
116
- }
117
- return guiLimitations;
118
- }
119
- /**
120
- * Extract non-metadata keys from a property value object
121
- * Filters out _alias and all # properties (which are treated as comments)
122
- * @param propValue Property value object
123
- * @param propName Property name (for error messages)
124
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
125
- * @returns Object with non-metadata keys and any GUI limitations found
126
- */
127
- function extractNonMetadataKeys(propValue, propName, guiModeEnabled = true) {
128
- const keys = Object.keys(propValue);
129
- const guiLimitations = [];
130
- // Check for # properties other than #description (GUI limitation)
131
- if (guiModeEnabled) {
132
- const unsupportedHashProps = keys.filter((k) => k.startsWith('#') && k !== '#description');
133
- if (unsupportedHashProps.length > 0) {
134
- guiLimitations.push(`Property '${propName}' contains # properties not supported in GUI: ${unsupportedHashProps.join(', ')}`);
135
- }
136
- }
137
- // Filter out _alias and all # properties (they are metadata/comments)
138
- const nonMetadataKeys = keys.filter((k) => k !== '_alias' && !k.startsWith('#'));
139
- return { keys: nonMetadataKeys, guiLimitations };
140
- }
141
- /**
142
- * Validate a relation property value
143
- * @param propName Property name
144
- * @param propValue Property value
145
- * @param limetypes Record of all available limetypes
146
- * @param property
147
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
148
- * @returns GUI limitations found (if any)
149
- */
150
- function validateRelationProperty(propName, propValue, limetypes, property, guiModeEnabled = true) {
151
- // null is valid - just return the relation ID
152
- if (propValue === null) {
153
- return [];
154
- }
155
- if (typeof propValue !== 'object') {
156
- throw new TypeError(`Relation property '${propName}' must be null or an object`);
157
- }
158
- const propValueObj = propValue;
159
- const { keys: otherKeys, guiLimitations } = extractNonMetadataKeys(propValueObj, propName, guiModeEnabled);
160
- // If it's just {} or { _alias: "...", "#...": "..." }, that's valid
161
- if (otherKeys.length === 0) {
162
- return guiLimitations;
163
- }
164
- // Otherwise, validate nested properties
165
- const relatedLimetype = property.relation.getLimetype();
166
- if (!relatedLimetype) {
167
- throw new Error(`Could not determine related limetype for property '${propName}'`);
168
- }
169
- // Build a clean PropertySelection without metadata for recursive validation
170
- const cleanSelection = {};
171
- for (const key of otherKeys) {
172
- cleanSelection[key] = propValueObj[key];
173
- }
174
- const nestedLimitations = validatePropertySelection(cleanSelection, limetypes, relatedLimetype.name, guiModeEnabled);
175
- return [...guiLimitations, ...nestedLimitations];
176
- }
177
- /**
178
- * Validate a non-relation property value
179
- * @param propName Property name
180
- * @param propValue Property value
181
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
182
- * @returns GUI limitations found (if any)
183
- */
184
- function validateNonRelationProperty(propName, propValue, guiModeEnabled = true) {
185
- // null is valid
186
- if (propValue === null) {
187
- return [];
188
- }
189
- // Allow empty object {} or object with only metadata (_alias, #...)
190
- if (typeof propValue === 'object') {
191
- const { keys: nonMetadataKeys, guiLimitations } = extractNonMetadataKeys(propValue, propName, guiModeEnabled);
192
- if (nonMetadataKeys.length === 0) {
193
- // {} or { _alias: "...", "#...": "..." } is valid
194
- return guiLimitations;
195
- }
196
- throw new Error(`Non-relation property '${propName}' cannot have nested properties other than _alias or # properties (got: ${nonMetadataKeys.join(', ')})`);
197
- }
198
- throw new Error(`Non-relation property '${propName}' must be null or an object (got ${typeof propValue})`);
199
- }
200
- /**
201
- * Validate a single property entry
202
- * @param propName Property name
203
- * @param propValue Property value
204
- * @param normalizedProperties Normalized properties of the limetype
205
- * @param limetypes Record of all available limetypes
206
- * @param limetype Current limetype name
207
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
208
- * @returns GUI limitations found (if any)
209
- */
210
- function validateSinglePropertyEntry(propName, propValue, normalizedProperties, limetypes, limetype, guiModeEnabled = true) {
211
- // Allow empty string (editing state in GUI)
212
- if (propName === '') {
213
- // Only validate empty property name in GUI mode
214
- if (guiModeEnabled && propValue !== null) {
215
- throw new Error('Empty property name must have null value');
216
- }
217
- return [];
218
- }
219
- // Validate property exists on limetype
220
- const property = normalizedProperties[propName];
221
- if (!property) {
222
- throw new Error(`Property '${propName}' does not exist on limetype '${limetype}'`);
223
- }
224
- // Validate value based on property type
225
- if (property.relation) {
226
- return validateRelationProperty(propName, propValue, limetypes, property, guiModeEnabled);
227
- }
228
- else {
229
- return validateNonRelationProperty(propName, propValue, guiModeEnabled);
230
- }
231
- }
232
- /**
233
- * Validate a property selection object against a limetype schema
234
- * Recursively validates nested property selections for relations
235
- * @param selection
236
- * @param limetypes Record of all available limetypes
237
- * @param limetype The limetype for this level of the selection
238
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
239
- * @returns GUI limitations found (if any)
240
- */
241
- function validatePropertySelection(selection, limetypes, limetype, guiModeEnabled = true) {
242
- const limetypeObj = limetypes[limetype];
243
- if (!limetypeObj) {
244
- throw new Error(`Unknown limetype: ${limetype}`);
245
- }
246
- const normalizedProperties = getNormalizedProperties(limetypeObj);
247
- const allGuiLimitations = [];
248
- for (const [propName, propValue] of Object.entries(selection)) {
249
- // Skip # properties (comments/metadata that backend accepts via unknown=INCLUDE)
250
- // Note: _alias only appears inside property value objects, not at this level
251
- if (propName.startsWith('#')) {
252
- continue;
253
- }
254
- const limitations = validateSinglePropertyEntry(propName, propValue, normalizedProperties, limetypes, limetype, guiModeEnabled);
255
- allGuiLimitations.push(...limitations);
256
- }
257
- return allGuiLimitations;
258
- }
259
- /**
260
- * Validate a comparison expression (has 'key' property)
261
- * @param filter
262
- * @param activeLimetype
263
- * @param limetypes
264
- */
265
- function validateComparisonExpression(filter, activeLimetype, limetypes) {
266
- // Validate operator
267
- const allValidOperators = Object.values(Zt);
268
- if (!allValidOperators.includes(filter.op)) {
269
- throw new Error(`Unsupported filter operator: ${filter.op}`);
270
- }
271
- // Validate placeholder
272
- const result = validatePlaceholder(filter.exp, activeLimetype, limetypes);
273
- if (!result.valid) {
274
- throw new Error(`Invalid placeholder in filter '${filter.key}': ${result.error}`);
275
- }
276
- }
277
- /**
278
- * Validate a group expression (AND/OR/NOT)
279
- * @param filter
280
- * @param activeLimetype
281
- * @param limetypes
282
- * @param guiModeEnabled
283
- */
284
- function validateGroupExpression(filter, activeLimetype, limetypes, guiModeEnabled) {
285
- // Validate operator
286
- if (filter.op !== Zt.AND &&
287
- filter.op !== Zt.OR &&
288
- filter.op !== Zt.NOT) {
289
- throw new Error(`Unsupported group operator: ${filter.op}`);
290
- }
291
- // Recursively validate children
292
- if (filter.op === Zt.NOT) {
293
- validateFilterPlaceholders(filter.exp, activeLimetype, limetypes, guiModeEnabled);
294
- }
295
- else if (filter.op === Zt.AND || filter.op === Zt.OR) {
296
- const expressions = filter.exp;
297
- for (const expr of expressions) {
298
- validateFilterPlaceholders(expr, activeLimetype, limetypes, guiModeEnabled);
299
- }
300
- }
301
- }
302
- /**
303
- * Validate placeholders in a filter expression
304
- * @param filter Filter expression to validate
305
- * @param activeLimetype The limetype of the active object
306
- * @param limetypes Record of all available limetypes
307
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
308
- */
309
- function validateFilterPlaceholders(filter, activeLimetype, limetypes, guiModeEnabled = true) {
310
- if (!filter) {
311
- return;
312
- }
313
- if ('key' in filter) {
314
- validateComparisonExpression(filter, activeLimetype, limetypes);
315
- return;
316
- }
317
- if ('exp' in filter) {
318
- validateGroupExpression(filter, activeLimetype, limetypes, guiModeEnabled);
319
- }
320
- }
321
- /**
322
- * Validate Lime Query filter and collect errors
323
- * @param filter The filter expression or group to validate
324
- * @param activeLimetype Optional active object limetype for placeholder validation
325
- * @param limetypes Record of all available limetypes
326
- * @param guiModeEnabled Whether GUI mode is enabled
327
- * @returns Array of validation error messages
328
- */
329
- function validateLimeQueryFilterInternal(filter, activeLimetype, limetypes, guiModeEnabled) {
330
- const errors = [];
331
- try {
332
- validateFilterPlaceholders(filter, activeLimetype, limetypes, guiModeEnabled);
333
- }
334
- catch (error) {
335
- errors.push(`Invalid filter: ${error.message}`);
336
- }
337
- return errors;
338
- }
339
- /**
340
- * Validate Lime Query response format and collect errors/limitations
341
- * @param responseFormat The response format to validate
342
- * @param limetypes Record of all available limetypes
343
- * @param limetype The limetype for this Lime Query
344
- * @param guiModeEnabled Whether GUI mode is enabled
345
- * @returns Object with validation errors and GUI limitations
346
- */
347
- function validateLimeQueryResponseFormatInternal(responseFormat, limetypes, limetype, guiModeEnabled) {
348
- const errors = [];
349
- const limitations = [];
350
- try {
351
- const formatLimitations = validateResponseFormat(responseFormat, limetypes, limetype, guiModeEnabled);
352
- limitations.push(...formatLimitations);
353
- }
354
- catch (error) {
355
- errors.push(`Invalid responseFormat: ${error.message}`);
356
- }
357
- return { errors, limitations };
358
- }
359
- /**
360
- * Validate a Lime Query
361
- * Returns validation result with separate arrays for validity errors and GUI limitations
362
- * @param limeQuery The Lime Query to validate
363
- * @param limetypes Record of all available limetypes
364
- * @param activeLimetype Optional active object limetype for placeholder validation
365
- * @param guiModeEnabled Whether GUI mode is enabled (affects validation)
366
- * @returns LimeQueryValidationResult with validity status and any errors/limitations
367
- */
368
- function isLimeQuerySupported(limeQuery, limetypes, activeLimetype, guiModeEnabled = true) {
369
- // Handle empty/undefined Lime Query
370
- if (!limeQuery) {
371
- return {
372
- valid: true,
373
- guiSupported: true,
374
- validationErrors: [],
375
- guiLimitations: [],
376
- };
377
- }
378
- const validationErrors = [];
379
- const guiLimitations = [];
380
- // Validate limetype exists
381
- if (limeQuery.limetype && !limetypes[limeQuery.limetype]) {
382
- validationErrors.push(`Unknown limetype: ${limeQuery.limetype}`);
383
- }
384
- // Check for offset without orderBy (Lime Query requirement)
385
- if (limeQuery.offset !== undefined && !limeQuery.orderBy) {
386
- validationErrors.push('offset requires orderBy to be specified');
387
- }
388
- // Check for GUI-unsupported top-level properties
389
- if (guiModeEnabled) {
390
- if (limeQuery.orderBy) {
391
- guiLimitations.push('orderBy is not yet supported in GUI mode');
392
- }
393
- if (limeQuery.offset !== undefined) {
394
- guiLimitations.push('offset is not yet supported in GUI mode');
395
- }
396
- }
397
- // Validate filter
398
- if (limeQuery.filter) {
399
- const filterErrors = validateLimeQueryFilterInternal(limeQuery.filter, activeLimetype, limetypes, guiModeEnabled);
400
- validationErrors.push(...filterErrors);
401
- }
402
- // Validate responseFormat
403
- if (limeQuery.responseFormat) {
404
- const { errors, limitations } = validateLimeQueryResponseFormatInternal(limeQuery.responseFormat, limetypes, limeQuery.limetype, guiModeEnabled);
405
- validationErrors.push(...errors);
406
- guiLimitations.push(...limitations);
407
- }
408
- return {
409
- valid: validationErrors.length === 0,
410
- guiSupported: guiLimitations.length === 0,
411
- validationErrors,
412
- guiLimitations,
413
- };
414
- }
415
-
416
- 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}}";
15
+ 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}}";
417
16
  const LimebbLimeQueryBuilderStyle0 = limeQueryBuilderCss;
418
17
 
419
18
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
@@ -465,6 +64,11 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
465
64
  this.limit = value ? Number.parseInt(value, 10) : undefined;
466
65
  this.emitChange();
467
66
  };
67
+ this.handleOrderByChange = (event) => {
68
+ event.stopPropagation();
69
+ this.orderBy = event.detail;
70
+ this.emitChange();
71
+ };
468
72
  this.switchToGui = () => {
469
73
  // Validate JSON before switching
470
74
  try {
@@ -480,6 +84,7 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
480
84
  this.filter = parsed.filter;
481
85
  this.internalResponseFormat = parsed.responseFormat;
482
86
  this.limit = parsed.limit;
87
+ this.orderBy = parsed.orderBy;
483
88
  this.mode = 'gui';
484
89
  this.change.emit(parsed);
485
90
  }
@@ -521,6 +126,7 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
521
126
  this.filter = this.value.filter;
522
127
  this.internalResponseFormat = this.value.responseFormat;
523
128
  this.limit = this.value.limit;
129
+ this.orderBy = this.value.orderBy;
524
130
  }
525
131
  // Initialize code value from prop
526
132
  this.updateCodeValue();
@@ -533,7 +139,7 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
533
139
  render() {
534
140
  const guiSupported = this.checkGuiSupport();
535
141
  const showCodeMode = !this.guiModeEnabled || this.mode === 'code';
536
- return (h("div", { key: '0b4d2bb5b4d503a775d8d3215e1e4c74fdb1eceb', class: "lime-query-builder" }, this.renderLabel(), this.renderModeControls(guiSupported), showCodeMode
142
+ return (h("div", { key: 'f51ae0459c1c7f482f3a790abb4cc3bd60b83e70', class: "lime-query-builder" }, this.renderLabel(), this.renderModeControls(guiSupported), showCodeMode
537
143
  ? this.renderCodeMode(guiSupported)
538
144
  : this.renderGuiMode()));
539
145
  }
@@ -545,27 +151,16 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
545
151
  if (!this.limetype) {
546
152
  return;
547
153
  }
548
- // Use internal state, then default to returning just _id
549
- const responseFormat = this.internalResponseFormat || {
550
- object: {
551
- _id: null,
552
- },
553
- };
554
- const limeQuery = {
555
- limetype: this.limetype,
556
- responseFormat: responseFormat,
557
- filter: this.filter,
558
- };
559
- if (this.limit !== undefined && this.limit > 0) {
560
- limeQuery.limit = this.limit;
561
- }
562
- this.change.emit(limeQuery);
154
+ this.change.emit(this.buildLimeQuery());
563
155
  }
564
156
  updateCodeValue() {
565
157
  if (!this.limetype) {
566
158
  this.codeValue = JSON.stringify(this.value || {}, null, 2);
567
159
  return;
568
160
  }
161
+ this.codeValue = JSON.stringify(this.buildLimeQuery(), null, 2);
162
+ }
163
+ buildLimeQuery() {
569
164
  // Use internal state, then default to returning just _id
570
165
  const responseFormat = this.internalResponseFormat || {
571
166
  object: {
@@ -580,7 +175,10 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
580
175
  if (this.limit !== undefined && this.limit > 0) {
581
176
  limeQuery.limit = this.limit;
582
177
  }
583
- this.codeValue = JSON.stringify(limeQuery, null, 2);
178
+ if (this.orderBy && this.orderBy.length > 0) {
179
+ limeQuery.orderBy = this.orderBy;
180
+ }
181
+ return limeQuery;
584
182
  }
585
183
  checkGuiSupport() {
586
184
  if (!this.limetypes) {
@@ -652,7 +250,7 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
652
250
  if (!this.limetype) {
653
251
  return;
654
252
  }
655
- 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 })));
253
+ 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 })));
656
254
  }
657
255
  renderFilterSection() {
658
256
  if (!this.limetype) {
@@ -665,7 +263,7 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
665
263
  if (!this.limetype) {
666
264
  return;
667
265
  }
668
- 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 }))));
266
+ 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 }))));
669
267
  }
670
268
  renderGuiMode() {
671
269
  return (h("div", { class: "gui-mode" }, this.renderLimetypeSection(), this.renderResponseFormatSection(), this.renderFilterSection(), this.renderQueryOptionsSection()));
@@ -698,7 +296,8 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
698
296
  "limetype": [32],
699
297
  "filter": [32],
700
298
  "internalResponseFormat": [32],
701
- "limit": [32]
299
+ "limit": [32],
300
+ "orderBy": [32]
702
301
  }]);
703
302
  __decorate([
704
303
  Te()
@@ -707,7 +306,7 @@ function defineCustomElement$1() {
707
306
  if (typeof customElements === "undefined") {
708
307
  return;
709
308
  }
710
- const components = ["limebb-lime-query-builder", "limebb-lime-query-filter-builder", "limebb-lime-query-filter-comparison", "limebb-lime-query-filter-expression", "limebb-lime-query-filter-group", "limebb-lime-query-filter-not", "limebb-lime-query-value-input", "limebb-limetype-field", "limebb-property-selector", "limebb-response-format-editor", "limebb-response-format-item"];
309
+ const components = ["limebb-lime-query-builder", "limebb-lime-query-filter-builder", "limebb-lime-query-filter-comparison", "limebb-lime-query-filter-expression", "limebb-lime-query-filter-group", "limebb-lime-query-filter-not", "limebb-lime-query-order-by-editor", "limebb-lime-query-order-by-item", "limebb-lime-query-response-format-editor", "limebb-lime-query-response-format-item", "limebb-lime-query-value-input", "limebb-limetype-field", "limebb-property-selector"];
711
310
  components.forEach(tagName => { switch (tagName) {
712
311
  case "limebb-lime-query-builder":
713
312
  if (!customElements.get(tagName)) {
@@ -716,50 +315,60 @@ function defineCustomElement$1() {
716
315
  break;
717
316
  case "limebb-lime-query-filter-builder":
718
317
  if (!customElements.get(tagName)) {
719
- defineCustomElement$b();
318
+ defineCustomElement$d();
720
319
  }
721
320
  break;
722
321
  case "limebb-lime-query-filter-comparison":
723
322
  if (!customElements.get(tagName)) {
724
- defineCustomElement$a();
323
+ defineCustomElement$c();
725
324
  }
726
325
  break;
727
326
  case "limebb-lime-query-filter-expression":
728
327
  if (!customElements.get(tagName)) {
729
- defineCustomElement$9();
328
+ defineCustomElement$b();
730
329
  }
731
330
  break;
732
331
  case "limebb-lime-query-filter-group":
733
332
  if (!customElements.get(tagName)) {
734
- defineCustomElement$8();
333
+ defineCustomElement$a();
735
334
  }
736
335
  break;
737
336
  case "limebb-lime-query-filter-not":
337
+ if (!customElements.get(tagName)) {
338
+ defineCustomElement$9();
339
+ }
340
+ break;
341
+ case "limebb-lime-query-order-by-editor":
342
+ if (!customElements.get(tagName)) {
343
+ defineCustomElement$8();
344
+ }
345
+ break;
346
+ case "limebb-lime-query-order-by-item":
738
347
  if (!customElements.get(tagName)) {
739
348
  defineCustomElement$7();
740
349
  }
741
350
  break;
742
- case "limebb-lime-query-value-input":
351
+ case "limebb-lime-query-response-format-editor":
743
352
  if (!customElements.get(tagName)) {
744
353
  defineCustomElement$6();
745
354
  }
746
355
  break;
747
- case "limebb-limetype-field":
356
+ case "limebb-lime-query-response-format-item":
748
357
  if (!customElements.get(tagName)) {
749
358
  defineCustomElement$5();
750
359
  }
751
360
  break;
752
- case "limebb-property-selector":
361
+ case "limebb-lime-query-value-input":
753
362
  if (!customElements.get(tagName)) {
754
363
  defineCustomElement$4();
755
364
  }
756
365
  break;
757
- case "limebb-response-format-editor":
366
+ case "limebb-limetype-field":
758
367
  if (!customElements.get(tagName)) {
759
368
  defineCustomElement$3();
760
369
  }
761
370
  break;
762
- case "limebb-response-format-item":
371
+ case "limebb-property-selector":
763
372
  if (!customElements.get(tagName)) {
764
373
  defineCustomElement$2();
765
374
  }
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface LimebbLimeQueryOrderByEditor extends Components.LimebbLimeQueryOrderByEditor, HTMLElement {}
4
+ export const LimebbLimeQueryOrderByEditor: {
5
+ prototype: LimebbLimeQueryOrderByEditor;
6
+ new (): LimebbLimeQueryOrderByEditor;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { O as OrderByEditor, d as defineCustomElement$1 } from './order-by-editor.js';
2
+
3
+ const LimebbLimeQueryOrderByEditor = OrderByEditor;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { LimebbLimeQueryOrderByEditor, defineCustomElement };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface LimebbLimeQueryOrderByItem extends Components.LimebbLimeQueryOrderByItem, HTMLElement {}
4
+ export const LimebbLimeQueryOrderByItem: {
5
+ prototype: LimebbLimeQueryOrderByItem;
6
+ new (): LimebbLimeQueryOrderByItem;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { O as OrderByItemComponent, d as defineCustomElement$1 } from './order-by-item.js';
2
+
3
+ const LimebbLimeQueryOrderByItem = OrderByItemComponent;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { LimebbLimeQueryOrderByItem, defineCustomElement };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface LimebbLimeQueryResponseFormatBuilder extends Components.LimebbLimeQueryResponseFormatBuilder, HTMLElement {}
4
+ export const LimebbLimeQueryResponseFormatBuilder: {
5
+ prototype: LimebbLimeQueryResponseFormatBuilder;
6
+ new (): LimebbLimeQueryResponseFormatBuilder;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;