@dataloop-ai/components 0.19.227 → 0.19.229
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/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v20.11.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataloop-ai/components",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.229",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "./index.ts",
|
|
6
6
|
"./models": "./models.ts",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"storybook": "^7.0.4",
|
|
82
82
|
"storybook-addon-themes": "^6.1.0",
|
|
83
83
|
"typescript": "^4.5.4",
|
|
84
|
-
"vite": "^4.2
|
|
84
|
+
"vite": "^4.5.2",
|
|
85
85
|
"vitest": "^0.29.2",
|
|
86
86
|
"vitest-canvas-mock": "^0.2.2",
|
|
87
87
|
"vue": "^3.3.4",
|
|
@@ -802,7 +802,9 @@ export default defineComponent({
|
|
|
802
802
|
return `<span class="clickable" style="color: ${syntaxHighlightColor.value}">${word}</span>`
|
|
803
803
|
}
|
|
804
804
|
if (word.startsWith('<')) {
|
|
805
|
-
return `<span>${word
|
|
805
|
+
return `<span>${word
|
|
806
|
+
.replace('<', '<')
|
|
807
|
+
.replace('>', '>')}</span>`
|
|
806
808
|
}
|
|
807
809
|
return word
|
|
808
810
|
})
|
|
@@ -182,7 +182,8 @@ export const useSuggestions = (
|
|
|
182
182
|
error.value = input.length
|
|
183
183
|
? getError(schemaValue, aliasesArray, expressions, {
|
|
184
184
|
strict,
|
|
185
|
-
forbiddenKeys
|
|
185
|
+
forbiddenKeys,
|
|
186
|
+
omitSuggestions
|
|
186
187
|
})
|
|
187
188
|
: null
|
|
188
189
|
}
|
|
@@ -370,6 +371,7 @@ export const useSuggestions = (
|
|
|
370
371
|
|
|
371
372
|
const errors = {
|
|
372
373
|
INVALID_EXPRESSION: 'Invalid Expression',
|
|
374
|
+
INVALID_OPERATOR: 'Invalid operator',
|
|
373
375
|
INVALID_VALUE: (field: string) => `Invalid value for "${field}" field`,
|
|
374
376
|
FORBIDDEN_KEY: (field: string) => `Forbidden field "${field}"`
|
|
375
377
|
}
|
|
@@ -403,9 +405,13 @@ const getError = (
|
|
|
403
405
|
schema: Schema,
|
|
404
406
|
aliases: Alias[],
|
|
405
407
|
expressions: Expression[],
|
|
406
|
-
options: {
|
|
408
|
+
options: {
|
|
409
|
+
strict?: Ref<boolean>
|
|
410
|
+
forbiddenKeys?: Ref<string[]>
|
|
411
|
+
omitSuggestions?: Ref<string[]>
|
|
412
|
+
} = {}
|
|
407
413
|
): string | null => {
|
|
408
|
-
const { strict, forbiddenKeys } = options
|
|
414
|
+
const { strict, forbiddenKeys, omitSuggestions } = options
|
|
409
415
|
const hasErrorInStructure = expressions
|
|
410
416
|
.flatMap((exp) => Object.values(exp))
|
|
411
417
|
.some((el, index, arr) => {
|
|
@@ -419,68 +425,85 @@ const getError = (
|
|
|
419
425
|
|
|
420
426
|
return expressions
|
|
421
427
|
.filter(({ field, value }) => field !== null && value !== null)
|
|
422
|
-
.reduce<string | null>(
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
keys
|
|
428
|
+
.reduce<string | null>(
|
|
429
|
+
(acc, { field, value, keyword, operator }, _, arr) => {
|
|
430
|
+
if (acc && acc !== 'warning') return acc
|
|
431
|
+
const fieldKey: string =
|
|
432
|
+
getAliasObjByAlias(aliases, field)?.key ?? field
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Handle nested keys to validate if the key exists in the schema or not.
|
|
436
|
+
*/
|
|
437
|
+
const keys: string[] = []
|
|
438
|
+
for (const key of Object.keys(schema)) {
|
|
439
|
+
if (isObject(schema[key]) && !Array.isArray(schema[key])) {
|
|
440
|
+
const flattened = flatten({ [key]: schema[key] })
|
|
441
|
+
for (const k of Object.keys(flattened)) {
|
|
442
|
+
keys.push(k)
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
keys.push(key)
|
|
436
446
|
}
|
|
437
|
-
} else {
|
|
438
|
-
keys.push(key)
|
|
439
447
|
}
|
|
440
|
-
}
|
|
441
448
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
+
function hasValidExpression(
|
|
450
|
+
arr: string[],
|
|
451
|
+
pattern: RegExp
|
|
452
|
+
): boolean {
|
|
453
|
+
for (const item of arr) {
|
|
454
|
+
if (pattern.test(item)) {
|
|
455
|
+
return true
|
|
456
|
+
}
|
|
449
457
|
}
|
|
458
|
+
return false
|
|
450
459
|
}
|
|
451
|
-
return false
|
|
452
|
-
}
|
|
453
460
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
461
|
+
const pattern = new RegExp(`^${fieldKey}\\.\\d`)
|
|
462
|
+
const isValid = isInputAllowed(fieldKey, keys)
|
|
463
|
+
const isForbidden = !!forbiddenKeys?.value?.includes(fieldKey)
|
|
464
|
+
if (
|
|
465
|
+
!keys.includes(fieldKey) &&
|
|
466
|
+
!hasValidExpression(keys, pattern) &&
|
|
467
|
+
!isValid &&
|
|
468
|
+
!isForbidden
|
|
469
|
+
) {
|
|
470
|
+
return strict?.value ? errors.INVALID_EXPRESSION : 'warning'
|
|
471
|
+
}
|
|
465
472
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
473
|
+
if (isForbidden) {
|
|
474
|
+
arr.splice(1)
|
|
475
|
+
return (acc = errors.FORBIDDEN_KEY(field))
|
|
476
|
+
}
|
|
470
477
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
478
|
+
const valid = isValidByDataType(
|
|
479
|
+
validateBracketValues(value),
|
|
480
|
+
getDataType(schema, aliases, fieldKey),
|
|
481
|
+
operator
|
|
482
|
+
)
|
|
476
483
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
484
|
+
if (!valid) {
|
|
485
|
+
arr.splice(1)
|
|
486
|
+
return (acc = errors.INVALID_VALUE(field))
|
|
487
|
+
}
|
|
481
488
|
|
|
482
|
-
|
|
483
|
-
|
|
489
|
+
if (omitSuggestions) {
|
|
490
|
+
if (omitSuggestions.value.includes(value)) {
|
|
491
|
+
arr.splice(1)
|
|
492
|
+
return (acc = errors.INVALID_VALUE(field))
|
|
493
|
+
}
|
|
494
|
+
if (
|
|
495
|
+
omitSuggestions.value.includes(keyword) ||
|
|
496
|
+
omitSuggestions.value.includes(operator)
|
|
497
|
+
) {
|
|
498
|
+
arr.splice(1)
|
|
499
|
+
return (acc = errors.INVALID_OPERATOR)
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return acc === 'warning' ? acc : (acc = null)
|
|
504
|
+
},
|
|
505
|
+
null
|
|
506
|
+
)
|
|
484
507
|
}
|
|
485
508
|
|
|
486
509
|
const isValidByDataType = (
|