@limetech/lime-crm-building-blocks 1.104.0 → 1.104.1
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 +7 -0
- package/dist/cjs/{lime-query-validation-6be10fa7.js → lime-query-validation-82aa2855.js} +84 -84
- package/dist/cjs/limebb-lime-query-builder.cjs.entry.js +44 -43
- package/dist/cjs/limebb-lime-query-filter-builder_3.cjs.entry.js +1 -1
- package/dist/cjs/limebb-lime-query-response-format-builder.cjs.entry.js +42 -42
- package/dist/collection/components/lime-query-builder/lime-query-builder.css +9 -9
- package/dist/collection/components/lime-query-builder/lime-query-builder.js +42 -41
- package/dist/collection/components/lime-query-builder/lime-query-response-format-builder.css +5 -5
- package/dist/collection/components/lime-query-builder/lime-query-response-format-builder.js +42 -42
- package/dist/collection/components/lime-query-builder/lime-query-validation.js +84 -84
- package/dist/collection/components/lime-query-builder/order-by/order-by-editor.css +2 -2
- package/dist/collection/components/lime-query-builder/response-format/response-format-helpers.js +2 -2
- package/dist/components/lime-query-validation.js +84 -84
- package/dist/components/limebb-lime-query-builder.js +43 -42
- package/dist/components/limebb-lime-query-response-format-builder.js +41 -41
- package/dist/components/order-by-editor.js +1 -1
- package/dist/esm/{lime-query-validation-573223a5.js → lime-query-validation-9e386da8.js} +84 -84
- package/dist/esm/limebb-lime-query-builder.entry.js +44 -43
- package/dist/esm/limebb-lime-query-filter-builder_3.entry.js +1 -1
- package/dist/esm/limebb-lime-query-response-format-builder.entry.js +42 -42
- package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
- package/dist/lime-crm-building-blocks/{p-6c7af6bb.entry.js → p-7d2188aa.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/p-7fbb6eba.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-ac9e81c9.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-efa5bcd4.js +1 -0
- package/dist/types/components/lime-query-builder/lime-query-builder.d.ts +3 -3
- package/dist/types/components/lime-query-builder/lime-query-response-format-builder.d.ts +13 -13
- package/dist/types/components/lime-query-builder/lime-query-validation.d.ts +17 -17
- package/dist/types/components.d.ts +12 -12
- package/package.json +1 -1
- package/dist/lime-crm-building-blocks/p-96fee7ee.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-fa2da6bc.js +0 -1
- package/dist/lime-crm-building-blocks/p-fe6a94a1.entry.js +0 -1
|
@@ -88,47 +88,47 @@ function validatePlaceholder(value, activeLimetype, limetypes) {
|
|
|
88
88
|
/**
|
|
89
89
|
* Validate a response format against limetype schemas
|
|
90
90
|
* Throws errors for invalid property references
|
|
91
|
-
* Returns
|
|
91
|
+
* Returns visual mode limitations for features not yet supported in visual mode
|
|
92
92
|
* @param responseFormat
|
|
93
93
|
* @param limetypes Record of all available limetypes
|
|
94
94
|
* @param limetype The root limetype for this query
|
|
95
|
-
* @param
|
|
96
|
-
* @returns
|
|
95
|
+
* @param visualModeEnabled Whether visual mode is enabled
|
|
96
|
+
* @returns Visual mode limitations found (if any)
|
|
97
97
|
*/
|
|
98
|
-
function validateResponseFormat(responseFormat, limetypes, limetype,
|
|
99
|
-
const
|
|
100
|
-
// Check for
|
|
101
|
-
if (
|
|
102
|
-
|
|
98
|
+
function validateResponseFormat(responseFormat, limetypes, limetype, visualModeEnabled = true) {
|
|
99
|
+
const visualModeLimitations = [];
|
|
100
|
+
// Check for visual-mode-unsupported features
|
|
101
|
+
if (visualModeEnabled && responseFormat.aggregates) {
|
|
102
|
+
visualModeLimitations.push('responseFormat.aggregates is not yet supported in visual mode');
|
|
103
103
|
}
|
|
104
104
|
// Validate object properties (throws on invalid properties)
|
|
105
105
|
if (responseFormat.object) {
|
|
106
|
-
const objectLimitations = validatePropertySelection(responseFormat.object, limetypes, limetype,
|
|
107
|
-
|
|
106
|
+
const objectLimitations = validatePropertySelection(responseFormat.object, limetypes, limetype, visualModeEnabled);
|
|
107
|
+
visualModeLimitations.push(...objectLimitations);
|
|
108
108
|
}
|
|
109
|
-
return
|
|
109
|
+
return visualModeLimitations;
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* Extract non-metadata keys from a property value object
|
|
113
113
|
* Filters out _alias and all # properties (which are treated as comments)
|
|
114
114
|
* @param propValue Property value object
|
|
115
115
|
* @param propName Property name (for error messages)
|
|
116
|
-
* @param
|
|
117
|
-
* @returns Object with non-metadata keys and any
|
|
116
|
+
* @param visualModeEnabled Whether visual mode is enabled (affects validation)
|
|
117
|
+
* @returns Object with non-metadata keys and any visual mode limitations found
|
|
118
118
|
*/
|
|
119
|
-
function extractNonMetadataKeys(propValue, propName,
|
|
119
|
+
function extractNonMetadataKeys(propValue, propName, visualModeEnabled = true) {
|
|
120
120
|
const keys = Object.keys(propValue);
|
|
121
|
-
const
|
|
122
|
-
// Check for # properties other than #description (
|
|
123
|
-
if (
|
|
121
|
+
const visualModeLimitations = [];
|
|
122
|
+
// Check for # properties other than #description (visual mode limitation)
|
|
123
|
+
if (visualModeEnabled) {
|
|
124
124
|
const unsupportedHashProps = keys.filter((k) => k.startsWith('#') && k !== '#description');
|
|
125
125
|
if (unsupportedHashProps.length > 0) {
|
|
126
|
-
|
|
126
|
+
visualModeLimitations.push(`Property '${propName}' contains # properties not supported in visual mode: ${unsupportedHashProps.join(', ')}`);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
// Filter out _alias and all # properties (they are metadata/comments)
|
|
130
130
|
const nonMetadataKeys = keys.filter((k) => k !== '_alias' && !k.startsWith('#'));
|
|
131
|
-
return { keys: nonMetadataKeys,
|
|
131
|
+
return { keys: nonMetadataKeys, visualModeLimitations };
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* Validate a relation property value
|
|
@@ -136,10 +136,10 @@ function extractNonMetadataKeys(propValue, propName, guiModeEnabled = true) {
|
|
|
136
136
|
* @param propValue Property value
|
|
137
137
|
* @param limetypes Record of all available limetypes
|
|
138
138
|
* @param property
|
|
139
|
-
* @param
|
|
140
|
-
* @returns
|
|
139
|
+
* @param visualModeEnabled Whether visual mode is enabled (affects validation)
|
|
140
|
+
* @returns Visual mode limitations found (if any)
|
|
141
141
|
*/
|
|
142
|
-
function validateRelationProperty(propName, propValue, limetypes, property,
|
|
142
|
+
function validateRelationProperty(propName, propValue, limetypes, property, visualModeEnabled = true) {
|
|
143
143
|
// null is valid - just return the relation ID
|
|
144
144
|
if (propValue === null) {
|
|
145
145
|
return [];
|
|
@@ -148,10 +148,10 @@ function validateRelationProperty(propName, propValue, limetypes, property, guiM
|
|
|
148
148
|
throw new TypeError(`Relation property '${propName}' must be null or an object`);
|
|
149
149
|
}
|
|
150
150
|
const propValueObj = propValue;
|
|
151
|
-
const { keys: otherKeys,
|
|
151
|
+
const { keys: otherKeys, visualModeLimitations } = extractNonMetadataKeys(propValueObj, propName, visualModeEnabled);
|
|
152
152
|
// If it's just {} or { _alias: "...", "#...": "..." }, that's valid
|
|
153
153
|
if (otherKeys.length === 0) {
|
|
154
|
-
return
|
|
154
|
+
return visualModeLimitations;
|
|
155
155
|
}
|
|
156
156
|
// Otherwise, validate nested properties
|
|
157
157
|
const relatedLimetype = property.relation.getLimetype();
|
|
@@ -163,27 +163,27 @@ function validateRelationProperty(propName, propValue, limetypes, property, guiM
|
|
|
163
163
|
for (const key of otherKeys) {
|
|
164
164
|
cleanSelection[key] = propValueObj[key];
|
|
165
165
|
}
|
|
166
|
-
const nestedLimitations = validatePropertySelection(cleanSelection, limetypes, relatedLimetype.name,
|
|
167
|
-
return [...
|
|
166
|
+
const nestedLimitations = validatePropertySelection(cleanSelection, limetypes, relatedLimetype.name, visualModeEnabled);
|
|
167
|
+
return [...visualModeLimitations, ...nestedLimitations];
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Validate a non-relation property value
|
|
171
171
|
* @param propName Property name
|
|
172
172
|
* @param propValue Property value
|
|
173
|
-
* @param
|
|
174
|
-
* @returns
|
|
173
|
+
* @param visualModeEnabled Whether visual mode is enabled (affects validation)
|
|
174
|
+
* @returns Visual mode limitations found (if any)
|
|
175
175
|
*/
|
|
176
|
-
function validateNonRelationProperty(propName, propValue,
|
|
176
|
+
function validateNonRelationProperty(propName, propValue, visualModeEnabled = true) {
|
|
177
177
|
// null is valid
|
|
178
178
|
if (propValue === null) {
|
|
179
179
|
return [];
|
|
180
180
|
}
|
|
181
181
|
// Allow empty object {} or object with only metadata (_alias, #...)
|
|
182
182
|
if (typeof propValue === 'object') {
|
|
183
|
-
const { keys: nonMetadataKeys,
|
|
183
|
+
const { keys: nonMetadataKeys, visualModeLimitations } = extractNonMetadataKeys(propValue, propName, visualModeEnabled);
|
|
184
184
|
if (nonMetadataKeys.length === 0) {
|
|
185
185
|
// {} or { _alias: "...", "#...": "..." } is valid
|
|
186
|
-
return
|
|
186
|
+
return visualModeLimitations;
|
|
187
187
|
}
|
|
188
188
|
throw new Error(`Non-relation property '${propName}' cannot have nested properties other than _alias or # properties (got: ${nonMetadataKeys.join(', ')})`);
|
|
189
189
|
}
|
|
@@ -196,14 +196,14 @@ function validateNonRelationProperty(propName, propValue, guiModeEnabled = true)
|
|
|
196
196
|
* @param normalizedProperties Normalized properties of the limetype
|
|
197
197
|
* @param limetypes Record of all available limetypes
|
|
198
198
|
* @param limetype Current limetype name
|
|
199
|
-
* @param
|
|
200
|
-
* @returns
|
|
199
|
+
* @param visualModeEnabled Whether visual mode is enabled (affects validation)
|
|
200
|
+
* @returns Visual mode limitations found (if any)
|
|
201
201
|
*/
|
|
202
|
-
function validateSinglePropertyEntry(propName, propValue, normalizedProperties, limetypes, limetype,
|
|
203
|
-
// Allow empty string (editing state in
|
|
202
|
+
function validateSinglePropertyEntry(propName, propValue, normalizedProperties, limetypes, limetype, visualModeEnabled = true) {
|
|
203
|
+
// Allow empty string (editing state in visual mode)
|
|
204
204
|
if (propName === '') {
|
|
205
|
-
// Only validate empty property name in
|
|
206
|
-
if (
|
|
205
|
+
// Only validate empty property name in visual mode
|
|
206
|
+
if (visualModeEnabled && propValue !== null) {
|
|
207
207
|
throw new Error('Empty property name must have null value');
|
|
208
208
|
}
|
|
209
209
|
return [];
|
|
@@ -215,10 +215,10 @@ function validateSinglePropertyEntry(propName, propValue, normalizedProperties,
|
|
|
215
215
|
}
|
|
216
216
|
// Validate value based on property type
|
|
217
217
|
if (property.relation) {
|
|
218
|
-
return validateRelationProperty(propName, propValue, limetypes, property,
|
|
218
|
+
return validateRelationProperty(propName, propValue, limetypes, property, visualModeEnabled);
|
|
219
219
|
}
|
|
220
220
|
else {
|
|
221
|
-
return validateNonRelationProperty(propName, propValue,
|
|
221
|
+
return validateNonRelationProperty(propName, propValue, visualModeEnabled);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
@@ -227,26 +227,26 @@ function validateSinglePropertyEntry(propName, propValue, normalizedProperties,
|
|
|
227
227
|
* @param selection
|
|
228
228
|
* @param limetypes Record of all available limetypes
|
|
229
229
|
* @param limetype The limetype for this level of the selection
|
|
230
|
-
* @param
|
|
231
|
-
* @returns
|
|
230
|
+
* @param visualModeEnabled Whether visual mode is enabled (affects validation)
|
|
231
|
+
* @returns Visual mode limitations found (if any)
|
|
232
232
|
*/
|
|
233
|
-
function validatePropertySelection(selection, limetypes, limetype,
|
|
233
|
+
function validatePropertySelection(selection, limetypes, limetype, visualModeEnabled = true) {
|
|
234
234
|
const limetypeObj = limetypes[limetype];
|
|
235
235
|
if (!limetypeObj) {
|
|
236
236
|
throw new Error(`Unknown limetype: ${limetype}`);
|
|
237
237
|
}
|
|
238
238
|
const normalizedProperties = getNormalizedProperties(limetypeObj);
|
|
239
|
-
const
|
|
239
|
+
const allVisualModeLimitations = [];
|
|
240
240
|
for (const [propName, propValue] of Object.entries(selection)) {
|
|
241
241
|
// Skip # properties (comments/metadata that backend accepts via unknown=INCLUDE)
|
|
242
242
|
// Note: _alias only appears inside property value objects, not at this level
|
|
243
243
|
if (propName.startsWith('#')) {
|
|
244
244
|
continue;
|
|
245
245
|
}
|
|
246
|
-
const limitations = validateSinglePropertyEntry(propName, propValue, normalizedProperties, limetypes, limetype,
|
|
247
|
-
|
|
246
|
+
const limitations = validateSinglePropertyEntry(propName, propValue, normalizedProperties, limetypes, limetype, visualModeEnabled);
|
|
247
|
+
allVisualModeLimitations.push(...limitations);
|
|
248
248
|
}
|
|
249
|
-
return
|
|
249
|
+
return allVisualModeLimitations;
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
252
252
|
* Validate a comparison expression (has 'key' property)
|
|
@@ -271,9 +271,9 @@ function validateComparisonExpression(filter, activeLimetype, limetypes) {
|
|
|
271
271
|
* @param filter
|
|
272
272
|
* @param activeLimetype
|
|
273
273
|
* @param limetypes
|
|
274
|
-
* @param
|
|
274
|
+
* @param visualModeEnabled
|
|
275
275
|
*/
|
|
276
|
-
function validateGroupExpression(filter, activeLimetype, limetypes,
|
|
276
|
+
function validateGroupExpression(filter, activeLimetype, limetypes, visualModeEnabled) {
|
|
277
277
|
// Validate operator
|
|
278
278
|
if (filter.op !== Zt.AND &&
|
|
279
279
|
filter.op !== Zt.OR &&
|
|
@@ -282,12 +282,12 @@ function validateGroupExpression(filter, activeLimetype, limetypes, guiModeEnabl
|
|
|
282
282
|
}
|
|
283
283
|
// Recursively validate children
|
|
284
284
|
if (filter.op === Zt.NOT) {
|
|
285
|
-
validateFilterPlaceholders(filter.exp, activeLimetype, limetypes,
|
|
285
|
+
validateFilterPlaceholders(filter.exp, activeLimetype, limetypes, visualModeEnabled);
|
|
286
286
|
}
|
|
287
287
|
else if (filter.op === Zt.AND || filter.op === Zt.OR) {
|
|
288
288
|
const expressions = filter.exp;
|
|
289
289
|
for (const expr of expressions) {
|
|
290
|
-
validateFilterPlaceholders(expr, activeLimetype, limetypes,
|
|
290
|
+
validateFilterPlaceholders(expr, activeLimetype, limetypes, visualModeEnabled);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
}
|
|
@@ -296,9 +296,9 @@ function validateGroupExpression(filter, activeLimetype, limetypes, guiModeEnabl
|
|
|
296
296
|
* @param filter Filter expression to validate
|
|
297
297
|
* @param activeLimetype The limetype of the active object
|
|
298
298
|
* @param limetypes Record of all available limetypes
|
|
299
|
-
* @param
|
|
299
|
+
* @param visualModeEnabled Whether visual mode is enabled (affects validation)
|
|
300
300
|
*/
|
|
301
|
-
function validateFilterPlaceholders(filter, activeLimetype, limetypes,
|
|
301
|
+
function validateFilterPlaceholders(filter, activeLimetype, limetypes, visualModeEnabled = true) {
|
|
302
302
|
if (!filter) {
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
@@ -307,7 +307,7 @@ function validateFilterPlaceholders(filter, activeLimetype, limetypes, guiModeEn
|
|
|
307
307
|
return;
|
|
308
308
|
}
|
|
309
309
|
if ('exp' in filter) {
|
|
310
|
-
validateGroupExpression(filter, activeLimetype, limetypes,
|
|
310
|
+
validateGroupExpression(filter, activeLimetype, limetypes, visualModeEnabled);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
@@ -315,13 +315,13 @@ function validateFilterPlaceholders(filter, activeLimetype, limetypes, guiModeEn
|
|
|
315
315
|
* @param filter The filter expression or group to validate
|
|
316
316
|
* @param activeLimetype Optional active object limetype for placeholder validation
|
|
317
317
|
* @param limetypes Record of all available limetypes
|
|
318
|
-
* @param
|
|
318
|
+
* @param visualModeEnabled Whether visual mode is enabled
|
|
319
319
|
* @returns Array of validation error messages
|
|
320
320
|
*/
|
|
321
|
-
function validateLimeQueryFilterInternal(filter, activeLimetype, limetypes,
|
|
321
|
+
function validateLimeQueryFilterInternal(filter, activeLimetype, limetypes, visualModeEnabled) {
|
|
322
322
|
const errors = [];
|
|
323
323
|
try {
|
|
324
|
-
validateFilterPlaceholders(filter, activeLimetype, limetypes,
|
|
324
|
+
validateFilterPlaceholders(filter, activeLimetype, limetypes, visualModeEnabled);
|
|
325
325
|
}
|
|
326
326
|
catch (error) {
|
|
327
327
|
errors.push(`Invalid filter: ${error.message}`);
|
|
@@ -440,14 +440,14 @@ function validateOrderByPropertyPath(propertyPath, limetypes, limetype, index) {
|
|
|
440
440
|
* @param responseFormat The response format to validate
|
|
441
441
|
* @param limetypes Record of all available limetypes
|
|
442
442
|
* @param limetype The limetype for this Lime Query
|
|
443
|
-
* @param
|
|
444
|
-
* @returns Object with validation errors and
|
|
443
|
+
* @param visualModeEnabled Whether visual mode is enabled
|
|
444
|
+
* @returns Object with validation errors and visual mode limitations
|
|
445
445
|
*/
|
|
446
|
-
function validateLimeQueryResponseFormatInternal(responseFormat, limetypes, limetype,
|
|
446
|
+
function validateLimeQueryResponseFormatInternal(responseFormat, limetypes, limetype, visualModeEnabled) {
|
|
447
447
|
const errors = [];
|
|
448
448
|
const limitations = [];
|
|
449
449
|
try {
|
|
450
|
-
const formatLimitations = validateResponseFormat(responseFormat, limetypes, limetype,
|
|
450
|
+
const formatLimitations = validateResponseFormat(responseFormat, limetypes, limetype, visualModeEnabled);
|
|
451
451
|
limitations.push(...formatLimitations);
|
|
452
452
|
}
|
|
453
453
|
catch (error) {
|
|
@@ -457,25 +457,25 @@ function validateLimeQueryResponseFormatInternal(responseFormat, limetypes, lime
|
|
|
457
457
|
}
|
|
458
458
|
/**
|
|
459
459
|
* Validate a Lime Query
|
|
460
|
-
* Returns validation result with separate arrays for validity errors and
|
|
460
|
+
* Returns validation result with separate arrays for validity errors and visual mode limitations
|
|
461
461
|
* @param limeQuery The Lime Query to validate
|
|
462
462
|
* @param limetypes Record of all available limetypes
|
|
463
463
|
* @param activeLimetype Optional active object limetype for placeholder validation
|
|
464
|
-
* @param
|
|
464
|
+
* @param visualModeEnabled Whether visual mode is enabled (affects validation)
|
|
465
465
|
* @returns LimeQueryValidationResult with validity status and any errors/limitations
|
|
466
466
|
*/
|
|
467
|
-
function isLimeQuerySupported(limeQuery, limetypes, activeLimetype,
|
|
467
|
+
function isLimeQuerySupported(limeQuery, limetypes, activeLimetype, visualModeEnabled = true) {
|
|
468
468
|
// Handle empty/undefined Lime Query
|
|
469
469
|
if (!limeQuery) {
|
|
470
470
|
return {
|
|
471
471
|
valid: true,
|
|
472
|
-
|
|
472
|
+
visualModeSupported: true,
|
|
473
473
|
validationErrors: [],
|
|
474
|
-
|
|
474
|
+
visualModeLimitations: [],
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
477
|
const validationErrors = [];
|
|
478
|
-
const
|
|
478
|
+
const visualModeLimitations = [];
|
|
479
479
|
// Validate limetype exists
|
|
480
480
|
if (limeQuery.limetype && !limetypes[limeQuery.limetype]) {
|
|
481
481
|
validationErrors.push(`Unknown limetype: ${limeQuery.limetype}`);
|
|
@@ -489,26 +489,26 @@ function isLimeQuerySupported(limeQuery, limetypes, activeLimetype, guiModeEnabl
|
|
|
489
489
|
const orderByErrors = validateOrderBy(limeQuery.orderBy, limetypes, limeQuery.limetype);
|
|
490
490
|
validationErrors.push(...orderByErrors);
|
|
491
491
|
}
|
|
492
|
-
// Check for
|
|
493
|
-
if (
|
|
494
|
-
|
|
492
|
+
// Check for visual-mode-unsupported top-level properties
|
|
493
|
+
if (visualModeEnabled && limeQuery.offset !== undefined) {
|
|
494
|
+
visualModeLimitations.push('offset is not yet supported in visual mode');
|
|
495
495
|
}
|
|
496
496
|
// Validate filter
|
|
497
497
|
if (limeQuery.filter) {
|
|
498
|
-
const filterErrors = validateLimeQueryFilterInternal(limeQuery.filter, activeLimetype, limetypes,
|
|
498
|
+
const filterErrors = validateLimeQueryFilterInternal(limeQuery.filter, activeLimetype, limetypes, visualModeEnabled);
|
|
499
499
|
validationErrors.push(...filterErrors);
|
|
500
500
|
}
|
|
501
501
|
// Validate responseFormat
|
|
502
502
|
if (limeQuery.responseFormat) {
|
|
503
|
-
const { errors, limitations } = validateLimeQueryResponseFormatInternal(limeQuery.responseFormat, limetypes, limeQuery.limetype,
|
|
503
|
+
const { errors, limitations } = validateLimeQueryResponseFormatInternal(limeQuery.responseFormat, limetypes, limeQuery.limetype, visualModeEnabled);
|
|
504
504
|
validationErrors.push(...errors);
|
|
505
|
-
|
|
505
|
+
visualModeLimitations.push(...limitations);
|
|
506
506
|
}
|
|
507
507
|
return {
|
|
508
508
|
valid: validationErrors.length === 0,
|
|
509
|
-
|
|
509
|
+
visualModeSupported: visualModeLimitations.length === 0,
|
|
510
510
|
validationErrors,
|
|
511
|
-
|
|
511
|
+
visualModeLimitations,
|
|
512
512
|
};
|
|
513
513
|
}
|
|
514
514
|
// ============================================================================
|
|
@@ -523,32 +523,32 @@ function isLimeQuerySupported(limeQuery, limetypes, activeLimetype, guiModeEnabl
|
|
|
523
523
|
* @param responseFormat - The response format to validate
|
|
524
524
|
* @param limetypes - Record of all available limetypes
|
|
525
525
|
* @param limetype - The limetype context for validation
|
|
526
|
-
* @param
|
|
527
|
-
* @returns Validation result with errors and
|
|
526
|
+
* @param visualModeEnabled - Whether visual mode is enabled (affects validation)
|
|
527
|
+
* @returns Validation result with errors and visual mode limitations
|
|
528
528
|
*/
|
|
529
|
-
function validateResponseFormatOnly(responseFormat, limetypes, limetype,
|
|
529
|
+
function validateResponseFormatOnly(responseFormat, limetypes, limetype, visualModeEnabled = true) {
|
|
530
530
|
const validationErrors = [];
|
|
531
|
-
const
|
|
531
|
+
const visualModeLimitations = [];
|
|
532
532
|
// Validate limetype exists
|
|
533
533
|
if (!limetypes[limetype]) {
|
|
534
534
|
validationErrors.push(`Unknown limetype: ${limetype}`);
|
|
535
535
|
// Can't proceed with property validation if limetype is unknown
|
|
536
536
|
return {
|
|
537
537
|
valid: false,
|
|
538
|
-
|
|
538
|
+
visualModeSupported: false,
|
|
539
539
|
validationErrors,
|
|
540
|
-
|
|
540
|
+
visualModeLimitations,
|
|
541
541
|
};
|
|
542
542
|
}
|
|
543
543
|
// Use internal validation logic
|
|
544
|
-
const { errors, limitations } = validateLimeQueryResponseFormatInternal(responseFormat, limetypes, limetype,
|
|
544
|
+
const { errors, limitations } = validateLimeQueryResponseFormatInternal(responseFormat, limetypes, limetype, visualModeEnabled);
|
|
545
545
|
validationErrors.push(...errors);
|
|
546
|
-
|
|
546
|
+
visualModeLimitations.push(...limitations);
|
|
547
547
|
return {
|
|
548
548
|
valid: validationErrors.length === 0,
|
|
549
|
-
|
|
549
|
+
visualModeSupported: visualModeLimitations.length === 0,
|
|
550
550
|
validationErrors,
|
|
551
|
-
|
|
551
|
+
visualModeLimitations,
|
|
552
552
|
};
|
|
553
553
|
}
|
|
554
554
|
|
|
@@ -12,7 +12,7 @@ import { d as defineCustomElement$4 } from './lime-query-value-input.js';
|
|
|
12
12
|
import { d as defineCustomElement$3 } from './limetype-field.js';
|
|
13
13
|
import { d as defineCustomElement$2 } from './property-selector.js';
|
|
14
14
|
|
|
15
|
-
const limeQueryBuilderCss = "*,*:before,*:after{box-sizing:border-box}:host(limebb-lime-query-builder){--header-background-color:rgb(var(--contrast-400));--limebb-lime-query-builder-background-color:rgb(var(--contrast-100));--limebb-lime-query-builder-border-radius:0.75rem;--limebb-lime-query-builder-
|
|
15
|
+
const limeQueryBuilderCss = "*,*:before,*:after{box-sizing:border-box}:host(limebb-lime-query-builder){--header-background-color:rgb(var(--contrast-400));--limebb-lime-query-builder-background-color:rgb(var(--contrast-100));--limebb-lime-query-builder-border-radius:0.75rem;--limebb-lime-query-builder-visual-mode-padding:1rem;--limebb-lime-query-builder-group-color:rgb(var(--color-sky-lighter));box-sizing:border-box;width:calc(100% - 1.5rem);margin:0.75rem auto;display:flex;flex-direction:column;border-radius:var(--limebb-lime-query-builder-border-radius);background-color:var(--limebb-lime-query-builder-background-color);box-shadow:var(--shadow-inflated-16)}.visual-mode{display:flex;flex-direction:column;gap:1rem;padding:var(--limebb-lime-query-builder-visual-mode-padding);border:1px solid var(--header-background-color);border-radius:0 0 var(--limebb-lime-query-builder-border-radius) var(--limebb-lime-query-builder-border-radius)}.code-mode{--code-editor-max-height:70vh;display:flex;flex-direction:column;gap:1rem}.code-mode .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-mode .validation-errors strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-mode .validation-errors ul{margin:0;padding-left:1.5rem}.code-mode .validation-errors li{margin:0.25rem 0}.code-mode .visual-mode-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-mode .visual-mode-limitations strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-mode .visual-mode-limitations ul{margin:0;padding-left:1.5rem}.code-mode .visual-mode-limitations li{margin:0.25rem 0}section.filter,section.query-options{display:flex;flex-direction:column;gap:1rem}section h4{margin:0;font-size:1.125rem;font-weight:600;color:rgb(var(--contrast-1000))}limel-header.is-narrow{--header-top-right-left-border-radius:0;width:calc(100% + var(--limebb-lime-query-builder-visual-mode-padding) * 2);margin-left:calc(var(--limebb-lime-query-builder-visual-mode-padding) * -1)}.query-options-controls{display:flex;flex-direction:column;gap:1rem}";
|
|
16
16
|
const LimebbLimeQueryBuilderStyle0 = limeQueryBuilderCss;
|
|
17
17
|
|
|
18
18
|
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -31,7 +31,7 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
|
|
|
31
31
|
this.__registerHost();
|
|
32
32
|
this.__attachShadow();
|
|
33
33
|
this.change = createEvent(this, "change", 7);
|
|
34
|
-
this.mode = '
|
|
34
|
+
this.mode = 'visual';
|
|
35
35
|
this.codeValue = '';
|
|
36
36
|
this.limetype = '';
|
|
37
37
|
this.handleLimetypeChange = (event) => {
|
|
@@ -70,11 +70,11 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
|
|
|
70
70
|
this.handleChange = (event) => {
|
|
71
71
|
event.stopPropagation();
|
|
72
72
|
const mode = event.detail.id;
|
|
73
|
-
if (mode === '
|
|
73
|
+
if (mode === 'visual') {
|
|
74
74
|
try {
|
|
75
75
|
const parsed = JSON.parse(this.codeValue);
|
|
76
|
-
const support = this.
|
|
77
|
-
if (!support.
|
|
76
|
+
const support = this.checkVisualModeSupport();
|
|
77
|
+
if (!support.visualModeSupported) {
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
this.limetype = parsed.limetype || '';
|
|
@@ -82,7 +82,7 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
|
|
|
82
82
|
this.internalResponseFormat = parsed.responseFormat;
|
|
83
83
|
this.limit = parsed.limit;
|
|
84
84
|
this.orderBy = parsed.orderBy;
|
|
85
|
-
this.mode = '
|
|
85
|
+
this.mode = 'visual';
|
|
86
86
|
this.change.emit(parsed);
|
|
87
87
|
}
|
|
88
88
|
catch (_a) {
|
|
@@ -111,19 +111,19 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
|
|
|
111
111
|
getButtons() {
|
|
112
112
|
return [
|
|
113
113
|
{
|
|
114
|
-
id: '
|
|
114
|
+
id: 'visual',
|
|
115
115
|
title: 'Visual',
|
|
116
116
|
},
|
|
117
117
|
{ id: 'code', title: 'Code' },
|
|
118
118
|
];
|
|
119
119
|
}
|
|
120
|
-
get
|
|
120
|
+
get visualModeEnabled() {
|
|
121
121
|
var _a, _b, _c;
|
|
122
122
|
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);
|
|
123
123
|
}
|
|
124
124
|
componentWillLoad() {
|
|
125
|
-
// Force code mode if
|
|
126
|
-
if (!this.
|
|
125
|
+
// Force code mode if visual mode is disabled
|
|
126
|
+
if (!this.visualModeEnabled) {
|
|
127
127
|
this.mode = 'code';
|
|
128
128
|
// Initialize code value from prop
|
|
129
129
|
this.updateCodeValue();
|
|
@@ -138,24 +138,24 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
|
|
|
138
138
|
}
|
|
139
139
|
// Initialize code value from prop
|
|
140
140
|
this.updateCodeValue();
|
|
141
|
-
// Check if
|
|
142
|
-
const support = this.
|
|
143
|
-
if (!support.
|
|
141
|
+
// Check if visual mode is supported
|
|
142
|
+
const support = this.checkVisualModeSupport();
|
|
143
|
+
if (!support.visualModeSupported) {
|
|
144
144
|
this.mode = 'code';
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
render() {
|
|
148
|
-
return (h(Host, { key: '
|
|
148
|
+
return (h(Host, { key: '4f1481f575b1afdd63a3115761a52a62699d7f84' }, this.renderHeader(), this.renderContent()));
|
|
149
149
|
}
|
|
150
150
|
renderContent() {
|
|
151
|
-
const
|
|
152
|
-
const showCodeMode = !this.
|
|
151
|
+
const visualModeSupported = this.checkVisualModeSupport();
|
|
152
|
+
const showCodeMode = !this.visualModeEnabled || this.mode === 'code';
|
|
153
153
|
return showCodeMode
|
|
154
|
-
? this.renderCodeMode(
|
|
155
|
-
: this.
|
|
154
|
+
? this.renderCodeMode(visualModeSupported)
|
|
155
|
+
: this.renderVisualMode();
|
|
156
156
|
}
|
|
157
157
|
emitChange() {
|
|
158
|
-
// Only emit in
|
|
158
|
+
// Only emit in visual mode
|
|
159
159
|
if (this.mode === 'code') {
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
@@ -191,14 +191,14 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
|
|
|
191
191
|
}
|
|
192
192
|
return limeQuery;
|
|
193
193
|
}
|
|
194
|
-
|
|
194
|
+
checkVisualModeSupport() {
|
|
195
195
|
if (!this.limetypes) {
|
|
196
196
|
// Can't validate yet, assume all is good
|
|
197
197
|
return {
|
|
198
198
|
valid: true,
|
|
199
|
-
|
|
199
|
+
visualModeSupported: true,
|
|
200
200
|
validationErrors: [],
|
|
201
|
-
|
|
201
|
+
visualModeLimitations: [],
|
|
202
202
|
};
|
|
203
203
|
}
|
|
204
204
|
// When in code mode, validate the parsed code value instead of current state
|
|
@@ -210,20 +210,20 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
|
|
|
210
210
|
catch (_a) {
|
|
211
211
|
return {
|
|
212
212
|
valid: false,
|
|
213
|
-
|
|
213
|
+
visualModeSupported: false,
|
|
214
214
|
validationErrors: ['Invalid JSON'],
|
|
215
|
-
|
|
215
|
+
visualModeLimitations: [],
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
else {
|
|
220
|
-
// Build query from current
|
|
220
|
+
// Build query from current visual state
|
|
221
221
|
if (!this.limetype) {
|
|
222
222
|
return {
|
|
223
223
|
valid: true,
|
|
224
|
-
|
|
224
|
+
visualModeSupported: true,
|
|
225
225
|
validationErrors: [],
|
|
226
|
-
|
|
226
|
+
visualModeLimitations: [],
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
229
|
const responseFormat = this
|
|
@@ -241,23 +241,24 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
|
|
|
241
241
|
queryToCheck.limit = this.limit;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
return isLimeQuerySupported(queryToCheck, this.limetypes, this.activeLimetype, this.
|
|
244
|
+
return isLimeQuerySupported(queryToCheck, this.limetypes, this.activeLimetype, this.visualModeEnabled);
|
|
245
245
|
}
|
|
246
246
|
renderModeSwitch(support) {
|
|
247
|
-
const
|
|
247
|
+
const visualDisabled = !support.visualModeSupported;
|
|
248
248
|
const buttons = this.getButtons().map((button) => (Object.assign(Object.assign({}, button), { selected: button.id === this.mode })));
|
|
249
|
-
return (h("limel-button-group", { slot: "actions", onChange: this.handleChange, value: buttons, disabled:
|
|
249
|
+
return (h("limel-button-group", { slot: "actions", onChange: this.handleChange, value: buttons, disabled: visualDisabled }));
|
|
250
250
|
}
|
|
251
|
-
renderCodeEditor(
|
|
251
|
+
renderCodeEditor(visualModeSupported) {
|
|
252
252
|
return [
|
|
253
253
|
h("limel-code-editor", { value: this.codeValue, language: "json", lineNumbers: true, fold: true, lint: true, onChange: this.handleCodeChange }),
|
|
254
254
|
/* Show validation errors (invalid Lime Query) */
|
|
255
|
-
!
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
255
|
+
!visualModeSupported.valid &&
|
|
256
|
+
visualModeSupported.validationErrors.length > 0 && (h("div", { class: "validation-errors" }, h("strong", null, "Invalid Lime Query:"), h("ul", null, visualModeSupported.validationErrors.map((error) => (h("li", null, error)))))),
|
|
257
|
+
/* Show visual mode limitations (only when visual mode is enabled and Lime Query is valid) */
|
|
258
|
+
this.visualModeEnabled &&
|
|
259
|
+
visualModeSupported.valid &&
|
|
260
|
+
!visualModeSupported.visualModeSupported &&
|
|
261
|
+
visualModeSupported.visualModeLimitations.length > 0 && (h("div", { class: "visual-mode-limitations" }, h("strong", null, "Cannot switch to visual mode:"), h("ul", null, visualModeSupported.visualModeLimitations.map((limitation) => (h("li", null, limitation)))))),
|
|
261
262
|
];
|
|
262
263
|
}
|
|
263
264
|
renderLimetypeSection() {
|
|
@@ -282,15 +283,15 @@ const LimeQueryBuilder = /*@__PURE__*/ proxyCustomElement(class LimeQueryBuilder
|
|
|
282
283
|
}
|
|
283
284
|
return (h("section", { class: "query-options" }, h("limel-header", { class: "is-narrow", heading: "Query Options", icon: "ask_question" }), 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 }))));
|
|
284
285
|
}
|
|
285
|
-
|
|
286
|
-
return (h("div", { class: "
|
|
286
|
+
renderVisualMode() {
|
|
287
|
+
return (h("div", { class: "visual-mode" }, this.renderLimetypeSection(), this.renderResponseFormatSection(), this.renderFilterSection(), this.renderQueryOptionsSection()));
|
|
287
288
|
}
|
|
288
289
|
renderHeader() {
|
|
289
|
-
const
|
|
290
|
-
return (h("limel-header", { heading: this.label }, this.renderModeControls(
|
|
290
|
+
const visualModeSupported = this.checkVisualModeSupport();
|
|
291
|
+
return (h("limel-header", { heading: this.label }, this.renderModeControls(visualModeSupported)));
|
|
291
292
|
}
|
|
292
293
|
renderModeControls(support) {
|
|
293
|
-
if (!this.
|
|
294
|
+
if (!this.visualModeEnabled) {
|
|
294
295
|
return;
|
|
295
296
|
}
|
|
296
297
|
return this.renderModeSwitch(support);
|