@limetech/lime-crm-building-blocks 1.105.1 → 1.105.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/lime-crm-building-blocks.cjs.js +1 -1
- package/dist/cjs/{lime-query-validation-82aa2855.js → lime-query-validation-6d419d03.js} +78 -16
- package/dist/cjs/limebb-info-tile.cjs.entry.js +46 -2
- package/dist/cjs/limebb-lime-query-builder.cjs.entry.js +2 -2
- package/dist/cjs/limebb-lime-query-filter-group_3.cjs.entry.js +1 -1
- package/dist/cjs/limebb-lime-query-response-format-builder.cjs.entry.js +2 -2
- package/dist/cjs/limebb-property-selector.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{property-resolution-fb42a46b.js → property-resolution-5f798b03.js} +47 -0
- package/dist/collection/components/chat-list/chat-item/chat-item.css +3 -0
- package/dist/collection/components/chat-list/chat-list.css +3 -0
- package/dist/collection/components/document-picker/document-picker.css +3 -0
- package/dist/collection/components/feed/feed-item/feed-timeline-item.css +3 -0
- package/dist/collection/components/feed/feed-item-thumbnail-file-info/feed-item-thumbnail-file-info.css +3 -0
- package/dist/collection/components/info-tile/info-tile.js +49 -4
- package/dist/collection/components/kanban/kanban-group/kanban-group.css +3 -0
- package/dist/collection/components/kanban/kanban-item/kanban-item.css +3 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-expression.css +3 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-group.css +3 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-not.css +3 -0
- package/dist/collection/components/lime-query-builder/lime-query-validation.js +78 -17
- package/dist/collection/components/lime-query-builder/property-resolution.js +46 -0
- package/dist/collection/components/lime-query-builder/response-format/response-format-item.css +3 -0
- package/dist/collection/components/navigation-button/navigation-button.css +3 -0
- package/dist/collection/components/notification-list/notification-item/notification-item.css +3 -0
- package/dist/collection/components/notification-list/notification-list.css +3 -0
- package/dist/collection/components/percentage-visualizer/percentage-visualizer.css +3 -0
- package/dist/collection/components/trend-indicator/trend-indicator.css +3 -0
- package/dist/components/lime-query-validation.js +78 -16
- package/dist/components/limebb-info-tile.js +49 -4
- package/dist/components/property-selector.js +47 -1
- package/dist/esm/lime-crm-building-blocks.js +1 -1
- package/dist/esm/{lime-query-validation-9e386da8.js → lime-query-validation-237ee440.js} +78 -16
- package/dist/esm/limebb-info-tile.entry.js +47 -3
- package/dist/esm/limebb-lime-query-builder.entry.js +2 -2
- package/dist/esm/limebb-lime-query-filter-group_3.entry.js +1 -1
- package/dist/esm/limebb-lime-query-response-format-builder.entry.js +2 -2
- package/dist/esm/limebb-property-selector.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{property-resolution-c21a1369.js → property-resolution-e4e8dcf7.js} +47 -1
- package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
- package/dist/lime-crm-building-blocks/{p-ac9e81c9.entry.js → p-09ce8be4.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/p-11aa4103.js +1 -0
- package/dist/lime-crm-building-blocks/p-45caed2d.entry.js +1 -0
- package/dist/lime-crm-building-blocks/{p-d8696b23.entry.js → p-9c2062bc.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/p-b02c99d5.js +1 -0
- package/dist/lime-crm-building-blocks/{p-908dd7d5.entry.js → p-ee0e42dd.entry.js} +1 -1
- package/dist/lime-crm-building-blocks/{p-1421e1f8.entry.js → p-f7ea292d.entry.js} +1 -1
- package/dist/types/components/info-tile/info-tile.d.ts +3 -0
- package/dist/types/components/lime-query-builder/lime-query-validation.d.ts +14 -0
- package/dist/types/components/lime-query-builder/property-resolution.d.ts +12 -0
- package/package.json +2 -2
- package/dist/lime-crm-building-blocks/p-a200954f.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-b748c770.js +0 -1
- package/dist/lime-crm-building-blocks/p-efa5bcd4.js +0 -1
|
@@ -9,7 +9,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
9
9
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
10
|
};
|
|
11
11
|
import { h } from "@stencil/core";
|
|
12
|
-
import { AggregateOperator, PlatformServiceName, SelectFilters, SelectConfig, } from "@limetech/lime-web-components";
|
|
12
|
+
import { AggregateOperator, PlatformServiceName, SelectFilters, SelectConfig, Operator, SelectLimeTypes, } from "@limetech/lime-web-components";
|
|
13
13
|
import { isEmpty } from "lodash-es";
|
|
14
14
|
import { InfoTileLoader } from "./loader";
|
|
15
15
|
import { InfoTileFormatterFactory } from "./format/factory";
|
|
@@ -92,7 +92,7 @@ export class InfoTile {
|
|
|
92
92
|
const errorProps = Object.assign(Object.assign({}, baseProps), { icon: 'error', prefix: 'ERROR', loading: true, label: this.getLabel(filter) });
|
|
93
93
|
const normalProps = Object.assign(Object.assign({}, baseProps), { label: this.getLabel(filter), link: this.getLink(filter), loading: this.loading, value: value === null || value === void 0 ? void 0 : value.value.trim() });
|
|
94
94
|
const props = !filter || this.error ? errorProps : normalProps;
|
|
95
|
-
return (h("limel-info-tile", Object.assign({ key: '
|
|
95
|
+
return (h("limel-info-tile", Object.assign({ key: '2f234d921ab8b45f9ce00f1830fb782bd9d9aa72', class: { error: !filter || this.error } }, props)));
|
|
96
96
|
}
|
|
97
97
|
getFormattedValue() {
|
|
98
98
|
if (!this.value && this.value !== 0) {
|
|
@@ -137,8 +137,32 @@ export class InfoTile {
|
|
|
137
137
|
if (!filter) {
|
|
138
138
|
return { href: '#' };
|
|
139
139
|
}
|
|
140
|
+
const baseHref = ['explorer', filter.limetype, filter.id].join('/');
|
|
141
|
+
const relationPropertyName = this.getRelationPropertyName(this.limetypes[filter.limetype]);
|
|
142
|
+
const contextAwareFilter = this.buildContextAwareFilter(filter.filter, relationPropertyName);
|
|
143
|
+
if (!contextAwareFilter) {
|
|
144
|
+
return { href: baseHref };
|
|
145
|
+
}
|
|
146
|
+
const filterQuery = encodeURIComponent(JSON.stringify(contextAwareFilter));
|
|
147
|
+
return { href: `${baseHref}?filter=${filterQuery}` };
|
|
148
|
+
}
|
|
149
|
+
buildContextAwareFilter(filter, relationPropertyName) {
|
|
150
|
+
if (!relationPropertyName) {
|
|
151
|
+
return filter;
|
|
152
|
+
}
|
|
153
|
+
const relationFilter = {
|
|
154
|
+
key: relationPropertyName,
|
|
155
|
+
op: Operator.EQUALS,
|
|
156
|
+
exp: this.context.id,
|
|
157
|
+
};
|
|
158
|
+
if (!filter) {
|
|
159
|
+
return {
|
|
160
|
+
relationFilter,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
140
163
|
return {
|
|
141
|
-
|
|
164
|
+
op: Operator.AND,
|
|
165
|
+
exp: [relationFilter, filter],
|
|
142
166
|
};
|
|
143
167
|
}
|
|
144
168
|
getFilter() {
|
|
@@ -148,6 +172,23 @@ export class InfoTile {
|
|
|
148
172
|
getFormatter(value) {
|
|
149
173
|
return new InfoTileFormatterFactory(this.language).createFormatter(this.format, value);
|
|
150
174
|
}
|
|
175
|
+
getRelationPropertyName(limetype) {
|
|
176
|
+
var _a, _b, _c;
|
|
177
|
+
if (!limetype || !this.context.limetype || !this.context.id) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (this.propertyName) {
|
|
181
|
+
const currentLimeType = this.limetypes[this.context.limetype];
|
|
182
|
+
const backReference = (_b = (_a = currentLimeType === null || currentLimeType === void 0 ? void 0 : currentLimeType.getProperty(this.propertyName)) === null || _a === void 0 ? void 0 : _a.relation) === null || _b === void 0 ? void 0 : _b.getBackreference();
|
|
183
|
+
if (backReference) {
|
|
184
|
+
return backReference.name;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return (_c = Object.values(limetype.properties).find((property) => {
|
|
188
|
+
var _a;
|
|
189
|
+
return (((_a = property.relation) === null || _a === void 0 ? void 0 : _a.getLimetype().name) === this.context.limetype);
|
|
190
|
+
})) === null || _c === void 0 ? void 0 : _c.name;
|
|
191
|
+
}
|
|
151
192
|
get translator() {
|
|
152
193
|
return this.platform.get(PlatformServiceName.Translate);
|
|
153
194
|
}
|
|
@@ -422,7 +463,8 @@ export class InfoTile {
|
|
|
422
463
|
"filters": {},
|
|
423
464
|
"value": {},
|
|
424
465
|
"loading": {},
|
|
425
|
-
"error": {}
|
|
466
|
+
"error": {},
|
|
467
|
+
"limetypes": {}
|
|
426
468
|
};
|
|
427
469
|
}
|
|
428
470
|
static get watchers() {
|
|
@@ -444,3 +486,6 @@ __decorate([
|
|
|
444
486
|
__decorate([
|
|
445
487
|
SelectFilters()
|
|
446
488
|
], InfoTile.prototype, "filters", void 0);
|
|
489
|
+
__decorate([
|
|
490
|
+
SelectLimeTypes()
|
|
491
|
+
], InfoTile.prototype, "limetypes", void 0);
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-expression.css
CHANGED
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-group.css
CHANGED
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Operator } from "@limetech/lime-web-components";
|
|
2
|
-
import { getNormalizedProperties } from "./property-resolution";
|
|
3
|
-
import { getPropertyFromPath } from "./property-resolution";
|
|
2
|
+
import { getNormalizedProperties, getPropertyFromPath, validatePropertyPath, } from "./property-resolution";
|
|
4
3
|
/**
|
|
5
4
|
* Dynamic filter values and placeholders that are valid in Lime Query
|
|
6
5
|
*/
|
|
@@ -85,6 +84,46 @@ export function validatePlaceholder(value, activeLimetype, limetypes) {
|
|
|
85
84
|
};
|
|
86
85
|
}
|
|
87
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Validates a filter expression key (property path).
|
|
89
|
+
* Supports both regular property paths and placeholders.
|
|
90
|
+
*
|
|
91
|
+
* @param key - Property path to validate (e.g., "name", "company.name", "%activeObject%.name")
|
|
92
|
+
* @param limetypes - All limetype definitions
|
|
93
|
+
* @param limetype - The limetype being filtered
|
|
94
|
+
* @param activeLimetype - Active limetype for placeholder resolution
|
|
95
|
+
* @returns Validation result with error message if invalid
|
|
96
|
+
*/
|
|
97
|
+
export function validateFilterKey(key, limetypes, limetype, activeLimetype) {
|
|
98
|
+
// 1. Handle empty/missing keys
|
|
99
|
+
if (!key) {
|
|
100
|
+
return { valid: false, error: 'Filter key cannot be empty' };
|
|
101
|
+
}
|
|
102
|
+
// 2. Check if key is a placeholder
|
|
103
|
+
if (key.startsWith('%activeObject%')) {
|
|
104
|
+
const placeholderResult = validatePlaceholder(key, activeLimetype, limetypes);
|
|
105
|
+
if (!placeholderResult.valid) {
|
|
106
|
+
return placeholderResult;
|
|
107
|
+
}
|
|
108
|
+
// Extract property path after the placeholder and validate for hasMany/hasAndBelongsToMany
|
|
109
|
+
const propertyPath = key.replace(/^%activeObject%\.?/, '');
|
|
110
|
+
if (propertyPath && activeLimetype) {
|
|
111
|
+
const { error } = validatePropertyPath(limetypes, activeLimetype, propertyPath);
|
|
112
|
+
if (error) {
|
|
113
|
+
return { valid: false, error };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return placeholderResult;
|
|
117
|
+
}
|
|
118
|
+
// 3. Validate regular property path (including intermediate properties)
|
|
119
|
+
const { error } = validatePropertyPath(limetypes, limetype, key);
|
|
120
|
+
if (error) {
|
|
121
|
+
return { valid: false, error };
|
|
122
|
+
}
|
|
123
|
+
// validatePropertyPath always returns an error if property is undefined,
|
|
124
|
+
// so if we reach here, the property exists and is valid
|
|
125
|
+
return { valid: true };
|
|
126
|
+
}
|
|
88
127
|
/**
|
|
89
128
|
* Validate a response format against limetype schemas
|
|
90
129
|
* Throws errors for invalid property references
|
|
@@ -253,13 +292,19 @@ export function validatePropertySelection(selection, limetypes, limetype, visual
|
|
|
253
292
|
* @param filter
|
|
254
293
|
* @param activeLimetype
|
|
255
294
|
* @param limetypes
|
|
295
|
+
* @param limetype
|
|
256
296
|
*/
|
|
257
|
-
function validateComparisonExpression(filter, activeLimetype, limetypes) {
|
|
297
|
+
function validateComparisonExpression(filter, activeLimetype, limetypes, limetype) {
|
|
258
298
|
// Validate operator
|
|
259
299
|
const allValidOperators = Object.values(Operator);
|
|
260
300
|
if (!allValidOperators.includes(filter.op)) {
|
|
261
301
|
throw new Error(`Unsupported filter operator: ${filter.op}`);
|
|
262
302
|
}
|
|
303
|
+
// Validate filter key
|
|
304
|
+
const keyResult = validateFilterKey(filter.key, limetypes, limetype, activeLimetype);
|
|
305
|
+
if (!keyResult.valid) {
|
|
306
|
+
throw new Error(`Invalid filter key '${filter.key}': ${keyResult.error}`);
|
|
307
|
+
}
|
|
263
308
|
// Validate placeholder
|
|
264
309
|
const result = validatePlaceholder(filter.exp, activeLimetype, limetypes);
|
|
265
310
|
if (!result.valid) {
|
|
@@ -271,9 +316,10 @@ function validateComparisonExpression(filter, activeLimetype, limetypes) {
|
|
|
271
316
|
* @param filter
|
|
272
317
|
* @param activeLimetype
|
|
273
318
|
* @param limetypes
|
|
319
|
+
* @param limetype
|
|
274
320
|
* @param visualModeEnabled
|
|
275
321
|
*/
|
|
276
|
-
function validateGroupExpression(filter, activeLimetype, limetypes, visualModeEnabled) {
|
|
322
|
+
function validateGroupExpression(filter, activeLimetype, limetypes, limetype, visualModeEnabled) {
|
|
277
323
|
// Validate operator
|
|
278
324
|
if (filter.op !== Operator.AND &&
|
|
279
325
|
filter.op !== Operator.OR &&
|
|
@@ -282,12 +328,12 @@ function validateGroupExpression(filter, activeLimetype, limetypes, visualModeEn
|
|
|
282
328
|
}
|
|
283
329
|
// Recursively validate children
|
|
284
330
|
if (filter.op === Operator.NOT) {
|
|
285
|
-
validateFilterPlaceholders(filter.exp, activeLimetype, limetypes, visualModeEnabled);
|
|
331
|
+
validateFilterPlaceholders(filter.exp, activeLimetype, limetypes, limetype, visualModeEnabled);
|
|
286
332
|
}
|
|
287
333
|
else if (filter.op === Operator.AND || filter.op === Operator.OR) {
|
|
288
334
|
const expressions = filter.exp;
|
|
289
335
|
for (const expr of expressions) {
|
|
290
|
-
validateFilterPlaceholders(expr, activeLimetype, limetypes, visualModeEnabled);
|
|
336
|
+
validateFilterPlaceholders(expr, activeLimetype, limetypes, limetype, visualModeEnabled);
|
|
291
337
|
}
|
|
292
338
|
}
|
|
293
339
|
}
|
|
@@ -296,37 +342,51 @@ function validateGroupExpression(filter, activeLimetype, limetypes, visualModeEn
|
|
|
296
342
|
* @param filter Filter expression to validate
|
|
297
343
|
* @param activeLimetype The limetype of the active object
|
|
298
344
|
* @param limetypes Record of all available limetypes
|
|
345
|
+
* @param limetype The limetype being filtered
|
|
299
346
|
* @param visualModeEnabled Whether visual mode is enabled (affects validation)
|
|
300
347
|
*/
|
|
301
|
-
function validateFilterPlaceholders(filter, activeLimetype, limetypes, visualModeEnabled = true) {
|
|
348
|
+
function validateFilterPlaceholders(filter, activeLimetype, limetypes, limetype, visualModeEnabled = true) {
|
|
302
349
|
if (!filter) {
|
|
303
350
|
return;
|
|
304
351
|
}
|
|
305
352
|
if ('key' in filter) {
|
|
306
|
-
validateComparisonExpression(filter, activeLimetype, limetypes);
|
|
353
|
+
validateComparisonExpression(filter, activeLimetype, limetypes, limetype);
|
|
307
354
|
return;
|
|
308
355
|
}
|
|
309
356
|
if ('exp' in filter) {
|
|
310
|
-
validateGroupExpression(filter, activeLimetype, limetypes, visualModeEnabled);
|
|
357
|
+
validateGroupExpression(filter, activeLimetype, limetypes, limetype, visualModeEnabled);
|
|
311
358
|
}
|
|
312
359
|
}
|
|
313
360
|
/**
|
|
314
|
-
* Validate Lime Query filter and collect errors
|
|
361
|
+
* Validate Lime Query filter and collect errors and visual mode limitations
|
|
315
362
|
* @param filter The filter expression or group to validate
|
|
316
363
|
* @param activeLimetype Optional active object limetype for placeholder validation
|
|
317
364
|
* @param limetypes Record of all available limetypes
|
|
365
|
+
* @param limetype The limetype being filtered
|
|
318
366
|
* @param visualModeEnabled Whether visual mode is enabled
|
|
319
|
-
* @returns
|
|
367
|
+
* @returns Object with validation errors and visual mode limitations
|
|
320
368
|
*/
|
|
321
|
-
function validateLimeQueryFilterInternal(filter, activeLimetype, limetypes, visualModeEnabled) {
|
|
369
|
+
function validateLimeQueryFilterInternal(filter, activeLimetype, limetypes, limetype, visualModeEnabled) {
|
|
322
370
|
const errors = [];
|
|
371
|
+
const limitations = [];
|
|
323
372
|
try {
|
|
324
|
-
validateFilterPlaceholders(filter, activeLimetype, limetypes, visualModeEnabled);
|
|
373
|
+
validateFilterPlaceholders(filter, activeLimetype, limetypes, limetype, visualModeEnabled);
|
|
325
374
|
}
|
|
326
375
|
catch (error) {
|
|
327
|
-
|
|
376
|
+
const errorMessage = error.message;
|
|
377
|
+
// Invalid keys are BOTH spec violations AND rendering limitations:
|
|
378
|
+
// - Backend will reject them (validation error)
|
|
379
|
+
// - Visual mode can't show them in property selector (visual limitation)
|
|
380
|
+
if (errorMessage.includes('Invalid filter key') ||
|
|
381
|
+
errorMessage.includes('Cannot filter on many-relation')) {
|
|
382
|
+
errors.push(`Invalid filter: ${errorMessage}`);
|
|
383
|
+
limitations.push(errorMessage);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
errors.push(`Invalid filter: ${errorMessage}`);
|
|
387
|
+
}
|
|
328
388
|
}
|
|
329
|
-
return errors;
|
|
389
|
+
return { errors, limitations };
|
|
330
390
|
}
|
|
331
391
|
/**
|
|
332
392
|
* Validate orderBy specification
|
|
@@ -495,8 +555,9 @@ export function isLimeQuerySupported(limeQuery, limetypes, activeLimetype, visua
|
|
|
495
555
|
}
|
|
496
556
|
// Validate filter
|
|
497
557
|
if (limeQuery.filter) {
|
|
498
|
-
const
|
|
499
|
-
validationErrors.push(...
|
|
558
|
+
const { errors, limitations } = validateLimeQueryFilterInternal(limeQuery.filter, activeLimetype, limetypes, limeQuery.limetype, visualModeEnabled);
|
|
559
|
+
validationErrors.push(...errors);
|
|
560
|
+
visualModeLimitations.push(...limitations);
|
|
500
561
|
}
|
|
501
562
|
// Validate responseFormat
|
|
502
563
|
if (limeQuery.responseFormat) {
|
|
@@ -59,3 +59,49 @@ export function getPropertyFromPath(limetypes, limetype, path) {
|
|
|
59
59
|
}
|
|
60
60
|
return property;
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Validates a property path to ensure no intermediate properties are hasMany or hasAndBelongsToMany relations.
|
|
64
|
+
* These relation types cannot be traversed in filter expressions.
|
|
65
|
+
* @param limetypes All limetype definitions
|
|
66
|
+
* @param limetype The starting limetype
|
|
67
|
+
* @param path The property path to validate (e.g., "company.name")
|
|
68
|
+
* @returns The property at the end of the path if valid, or undefined with error if invalid
|
|
69
|
+
*/
|
|
70
|
+
export function validatePropertyPath(limetypes, limetype, path) {
|
|
71
|
+
if (!path || !limetype || !limetypes) {
|
|
72
|
+
return { property: undefined };
|
|
73
|
+
}
|
|
74
|
+
const parts = path.split('.');
|
|
75
|
+
let currentType = limetypes[limetype];
|
|
76
|
+
let property;
|
|
77
|
+
for (let i = 0; i < parts.length; i++) {
|
|
78
|
+
const part = parts[i];
|
|
79
|
+
if (!currentType) {
|
|
80
|
+
return { property: undefined };
|
|
81
|
+
}
|
|
82
|
+
const normalizedProperties = getNormalizedProperties(currentType);
|
|
83
|
+
property = normalizedProperties[part];
|
|
84
|
+
if (!property) {
|
|
85
|
+
return {
|
|
86
|
+
property: undefined,
|
|
87
|
+
error: `Property '${part}' does not exist on limetype '${currentType.name}'`,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// Check if this property is a hasMany/hasAndBelongsToMany relation
|
|
91
|
+
// These cannot be traversed in filter expressions
|
|
92
|
+
if (property.type === 'hasmany' ||
|
|
93
|
+
property.type === 'hasandbelongstomany') {
|
|
94
|
+
// Build the path up to this point for the error message
|
|
95
|
+
const invalidPath = parts.slice(0, i + 1).join('.');
|
|
96
|
+
return {
|
|
97
|
+
property: undefined,
|
|
98
|
+
error: `Cannot filter on many-relation '${invalidPath}'. Use a related limetype's filter instead.`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// If this is a relation, get the related limetype for next iteration
|
|
102
|
+
if (property.relation) {
|
|
103
|
+
currentType = property.relation.getLimetype();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return { property };
|
|
107
|
+
}
|
package/dist/collection/components/lime-query-builder/response-format/response-format-item.css
CHANGED
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
package/dist/collection/components/notification-list/notification-item/notification-item.css
CHANGED
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
|
@@ -70,6 +70,9 @@
|
|
|
70
70
|
* of some components, to demonstrate how the component
|
|
71
71
|
* behaves in a resizable container.
|
|
72
72
|
*/
|
|
73
|
+
/**
|
|
74
|
+
* Drag to reorder mixins
|
|
75
|
+
*/
|
|
73
76
|
/**
|
|
74
77
|
* The breakpoints below are used to create responsive designs
|
|
75
78
|
* in Lime's products. Therefore, they are here to get distributed
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
* of some components, to demonstrate how the component
|
|
68
68
|
* behaves in a resizable container.
|
|
69
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Drag to reorder mixins
|
|
72
|
+
*/
|
|
70
73
|
/**
|
|
71
74
|
* The breakpoints below are used to create responsive designs
|
|
72
75
|
* in Lime's products. Therefore, they are here to get distributed
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Z as Zt } from './index.esm.js';
|
|
2
|
-
import { g as getPropertyFromPath, a as getNormalizedProperties } from './property-selector.js';
|
|
2
|
+
import { g as getPropertyFromPath, a as getNormalizedProperties, v as validatePropertyPath } from './property-selector.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Dynamic filter values and placeholders that are valid in Lime Query
|
|
@@ -85,6 +85,46 @@ function validatePlaceholder(value, activeLimetype, limetypes) {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Validates a filter expression key (property path).
|
|
90
|
+
* Supports both regular property paths and placeholders.
|
|
91
|
+
*
|
|
92
|
+
* @param key - Property path to validate (e.g., "name", "company.name", "%activeObject%.name")
|
|
93
|
+
* @param limetypes - All limetype definitions
|
|
94
|
+
* @param limetype - The limetype being filtered
|
|
95
|
+
* @param activeLimetype - Active limetype for placeholder resolution
|
|
96
|
+
* @returns Validation result with error message if invalid
|
|
97
|
+
*/
|
|
98
|
+
function validateFilterKey(key, limetypes, limetype, activeLimetype) {
|
|
99
|
+
// 1. Handle empty/missing keys
|
|
100
|
+
if (!key) {
|
|
101
|
+
return { valid: false, error: 'Filter key cannot be empty' };
|
|
102
|
+
}
|
|
103
|
+
// 2. Check if key is a placeholder
|
|
104
|
+
if (key.startsWith('%activeObject%')) {
|
|
105
|
+
const placeholderResult = validatePlaceholder(key, activeLimetype, limetypes);
|
|
106
|
+
if (!placeholderResult.valid) {
|
|
107
|
+
return placeholderResult;
|
|
108
|
+
}
|
|
109
|
+
// Extract property path after the placeholder and validate for hasMany/hasAndBelongsToMany
|
|
110
|
+
const propertyPath = key.replace(/^%activeObject%\.?/, '');
|
|
111
|
+
if (propertyPath && activeLimetype) {
|
|
112
|
+
const { error } = validatePropertyPath(limetypes, activeLimetype, propertyPath);
|
|
113
|
+
if (error) {
|
|
114
|
+
return { valid: false, error };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return placeholderResult;
|
|
118
|
+
}
|
|
119
|
+
// 3. Validate regular property path (including intermediate properties)
|
|
120
|
+
const { error } = validatePropertyPath(limetypes, limetype, key);
|
|
121
|
+
if (error) {
|
|
122
|
+
return { valid: false, error };
|
|
123
|
+
}
|
|
124
|
+
// validatePropertyPath always returns an error if property is undefined,
|
|
125
|
+
// so if we reach here, the property exists and is valid
|
|
126
|
+
return { valid: true };
|
|
127
|
+
}
|
|
88
128
|
/**
|
|
89
129
|
* Validate a response format against limetype schemas
|
|
90
130
|
* Throws errors for invalid property references
|
|
@@ -253,13 +293,19 @@ function validatePropertySelection(selection, limetypes, limetype, visualModeEna
|
|
|
253
293
|
* @param filter
|
|
254
294
|
* @param activeLimetype
|
|
255
295
|
* @param limetypes
|
|
296
|
+
* @param limetype
|
|
256
297
|
*/
|
|
257
|
-
function validateComparisonExpression(filter, activeLimetype, limetypes) {
|
|
298
|
+
function validateComparisonExpression(filter, activeLimetype, limetypes, limetype) {
|
|
258
299
|
// Validate operator
|
|
259
300
|
const allValidOperators = Object.values(Zt);
|
|
260
301
|
if (!allValidOperators.includes(filter.op)) {
|
|
261
302
|
throw new Error(`Unsupported filter operator: ${filter.op}`);
|
|
262
303
|
}
|
|
304
|
+
// Validate filter key
|
|
305
|
+
const keyResult = validateFilterKey(filter.key, limetypes, limetype, activeLimetype);
|
|
306
|
+
if (!keyResult.valid) {
|
|
307
|
+
throw new Error(`Invalid filter key '${filter.key}': ${keyResult.error}`);
|
|
308
|
+
}
|
|
263
309
|
// Validate placeholder
|
|
264
310
|
const result = validatePlaceholder(filter.exp, activeLimetype, limetypes);
|
|
265
311
|
if (!result.valid) {
|
|
@@ -271,9 +317,10 @@ function validateComparisonExpression(filter, activeLimetype, limetypes) {
|
|
|
271
317
|
* @param filter
|
|
272
318
|
* @param activeLimetype
|
|
273
319
|
* @param limetypes
|
|
320
|
+
* @param limetype
|
|
274
321
|
* @param visualModeEnabled
|
|
275
322
|
*/
|
|
276
|
-
function validateGroupExpression(filter, activeLimetype, limetypes, visualModeEnabled) {
|
|
323
|
+
function validateGroupExpression(filter, activeLimetype, limetypes, limetype, visualModeEnabled) {
|
|
277
324
|
// Validate operator
|
|
278
325
|
if (filter.op !== Zt.AND &&
|
|
279
326
|
filter.op !== Zt.OR &&
|
|
@@ -282,12 +329,12 @@ function validateGroupExpression(filter, activeLimetype, limetypes, visualModeEn
|
|
|
282
329
|
}
|
|
283
330
|
// Recursively validate children
|
|
284
331
|
if (filter.op === Zt.NOT) {
|
|
285
|
-
validateFilterPlaceholders(filter.exp, activeLimetype, limetypes, visualModeEnabled);
|
|
332
|
+
validateFilterPlaceholders(filter.exp, activeLimetype, limetypes, limetype, visualModeEnabled);
|
|
286
333
|
}
|
|
287
334
|
else if (filter.op === Zt.AND || filter.op === Zt.OR) {
|
|
288
335
|
const expressions = filter.exp;
|
|
289
336
|
for (const expr of expressions) {
|
|
290
|
-
validateFilterPlaceholders(expr, activeLimetype, limetypes, visualModeEnabled);
|
|
337
|
+
validateFilterPlaceholders(expr, activeLimetype, limetypes, limetype, visualModeEnabled);
|
|
291
338
|
}
|
|
292
339
|
}
|
|
293
340
|
}
|
|
@@ -296,37 +343,51 @@ function validateGroupExpression(filter, activeLimetype, limetypes, visualModeEn
|
|
|
296
343
|
* @param filter Filter expression to validate
|
|
297
344
|
* @param activeLimetype The limetype of the active object
|
|
298
345
|
* @param limetypes Record of all available limetypes
|
|
346
|
+
* @param limetype The limetype being filtered
|
|
299
347
|
* @param visualModeEnabled Whether visual mode is enabled (affects validation)
|
|
300
348
|
*/
|
|
301
|
-
function validateFilterPlaceholders(filter, activeLimetype, limetypes, visualModeEnabled = true) {
|
|
349
|
+
function validateFilterPlaceholders(filter, activeLimetype, limetypes, limetype, visualModeEnabled = true) {
|
|
302
350
|
if (!filter) {
|
|
303
351
|
return;
|
|
304
352
|
}
|
|
305
353
|
if ('key' in filter) {
|
|
306
|
-
validateComparisonExpression(filter, activeLimetype, limetypes);
|
|
354
|
+
validateComparisonExpression(filter, activeLimetype, limetypes, limetype);
|
|
307
355
|
return;
|
|
308
356
|
}
|
|
309
357
|
if ('exp' in filter) {
|
|
310
|
-
validateGroupExpression(filter, activeLimetype, limetypes, visualModeEnabled);
|
|
358
|
+
validateGroupExpression(filter, activeLimetype, limetypes, limetype, visualModeEnabled);
|
|
311
359
|
}
|
|
312
360
|
}
|
|
313
361
|
/**
|
|
314
|
-
* Validate Lime Query filter and collect errors
|
|
362
|
+
* Validate Lime Query filter and collect errors and visual mode limitations
|
|
315
363
|
* @param filter The filter expression or group to validate
|
|
316
364
|
* @param activeLimetype Optional active object limetype for placeholder validation
|
|
317
365
|
* @param limetypes Record of all available limetypes
|
|
366
|
+
* @param limetype The limetype being filtered
|
|
318
367
|
* @param visualModeEnabled Whether visual mode is enabled
|
|
319
|
-
* @returns
|
|
368
|
+
* @returns Object with validation errors and visual mode limitations
|
|
320
369
|
*/
|
|
321
|
-
function validateLimeQueryFilterInternal(filter, activeLimetype, limetypes, visualModeEnabled) {
|
|
370
|
+
function validateLimeQueryFilterInternal(filter, activeLimetype, limetypes, limetype, visualModeEnabled) {
|
|
322
371
|
const errors = [];
|
|
372
|
+
const limitations = [];
|
|
323
373
|
try {
|
|
324
|
-
validateFilterPlaceholders(filter, activeLimetype, limetypes, visualModeEnabled);
|
|
374
|
+
validateFilterPlaceholders(filter, activeLimetype, limetypes, limetype, visualModeEnabled);
|
|
325
375
|
}
|
|
326
376
|
catch (error) {
|
|
327
|
-
|
|
377
|
+
const errorMessage = error.message;
|
|
378
|
+
// Invalid keys are BOTH spec violations AND rendering limitations:
|
|
379
|
+
// - Backend will reject them (validation error)
|
|
380
|
+
// - Visual mode can't show them in property selector (visual limitation)
|
|
381
|
+
if (errorMessage.includes('Invalid filter key') ||
|
|
382
|
+
errorMessage.includes('Cannot filter on many-relation')) {
|
|
383
|
+
errors.push(`Invalid filter: ${errorMessage}`);
|
|
384
|
+
limitations.push(errorMessage);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
errors.push(`Invalid filter: ${errorMessage}`);
|
|
388
|
+
}
|
|
328
389
|
}
|
|
329
|
-
return errors;
|
|
390
|
+
return { errors, limitations };
|
|
330
391
|
}
|
|
331
392
|
/**
|
|
332
393
|
* Validate orderBy specification
|
|
@@ -495,8 +556,9 @@ function isLimeQuerySupported(limeQuery, limetypes, activeLimetype, visualModeEn
|
|
|
495
556
|
}
|
|
496
557
|
// Validate filter
|
|
497
558
|
if (limeQuery.filter) {
|
|
498
|
-
const
|
|
499
|
-
validationErrors.push(...
|
|
559
|
+
const { errors, limitations } = validateLimeQueryFilterInternal(limeQuery.filter, activeLimetype, limetypes, limeQuery.limetype, visualModeEnabled);
|
|
560
|
+
validationErrors.push(...errors);
|
|
561
|
+
visualModeLimitations.push(...limitations);
|
|
500
562
|
}
|
|
501
563
|
// Validate responseFormat
|
|
502
564
|
if (limeQuery.responseFormat) {
|