@react-querybuilder/core 8.14.3 → 8.15.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.
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +201 -8
- package/dist/cjs/react-querybuilder_core.cjs.development.js +400 -62
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +201 -8
- package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
- package/dist/{convertQuery-CeJSNn37.mjs → convertQuery-BeJJH9BI.mjs} +2 -2
- package/dist/convertQuery-BeJJH9BI.mjs.map +1 -0
- package/dist/{convertQuery-J8LpTG-7.js → convertQuery-Lx2HQa0m.js} +2 -2
- package/dist/convertQuery-Lx2HQa0m.js.map +1 -0
- package/dist/formatQuery.d.mts +24 -3
- package/dist/formatQuery.d.ts +24 -3
- package/dist/formatQuery.js +379 -51
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +379 -52
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-Bltb2mT4.d.mts → import-0wp72lLT.d.mts} +2 -2
- package/dist/{import-B5Iq8XmL.d.ts → import-yRVJh7E1.d.ts} +2 -2
- package/dist/{basic-BXJVfD0P.d.ts → index-D5TXNIzF.d.ts} +595 -3
- package/dist/{basic-CNIjb6rI.d.mts → index-Lht_Wq3V.d.mts} +595 -3
- package/dist/{objectUtils-ButT0Mng.js → objectUtils-Bzug_QfX.js} +2 -2
- package/dist/objectUtils-Bzug_QfX.js.map +1 -0
- package/dist/{objectUtils-C0WB-8ex.mjs → objectUtils-D96eEEzL.mjs} +2 -2
- package/dist/objectUtils-D96eEEzL.mjs.map +1 -0
- package/dist/parseCEL.d.mts +2 -2
- package/dist/parseCEL.d.ts +2 -2
- package/dist/parseCEL.js +35 -35
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +35 -35
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseJSONata.d.mts +2 -2
- package/dist/parseJSONata.d.ts +2 -2
- package/dist/parseJSONata.js +11 -11
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +11 -11
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +2 -3
- package/dist/parseJsonLogic.d.ts +2 -3
- package/dist/parseJsonLogic.js +6 -6
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +6 -6
- package/dist/parseJsonLogic.mjs.map +1 -1
- package/dist/parseMongoDB.d.mts +2 -2
- package/dist/parseMongoDB.d.ts +2 -2
- package/dist/parseMongoDB.js +6 -6
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +6 -6
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSQL.d.mts +2 -2
- package/dist/parseSQL.d.ts +2 -2
- package/dist/parseSQL.js +16 -16
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +16 -16
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +2 -2
- package/dist/parseSpEL.d.ts +2 -2
- package/dist/parseSpEL.js +10 -10
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +10 -10
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/{prepareQueryObjects-DO3qXriW.js → prepareQueryObjects-BoG5Rt8z.js} +6 -6
- package/dist/prepareQueryObjects-BoG5Rt8z.js.map +1 -0
- package/dist/{prepareQueryObjects-BfMlS4ql.mjs → prepareQueryObjects-uA10ZpZX.mjs} +6 -6
- package/dist/prepareQueryObjects-uA10ZpZX.mjs.map +1 -0
- package/dist/query-builder.css +1 -1
- package/dist/query-builder.css.map +1 -1
- package/dist/react-querybuilder_core.d.mts +201 -8
- package/dist/react-querybuilder_core.legacy-esm.d.ts +201 -8
- package/dist/react-querybuilder_core.legacy-esm.js +441 -93
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +399 -63
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +201 -8
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/styles/_main.scss +4 -0
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js +1 -1
- package/dist/transformQuery.mjs +1 -1
- package/dist/{utils-BlMGIhvx.mjs → utils-ChLG90DP.mjs} +3 -3
- package/dist/utils-ChLG90DP.mjs.map +1 -0
- package/dist/{utils-CZRhzje-.js → utils-Qwkq2Q0F.js} +3 -3
- package/dist/utils-Qwkq2Q0F.js.map +1 -0
- package/package.json +12 -16
- package/dist/convertQuery-CeJSNn37.mjs.map +0 -1
- package/dist/convertQuery-J8LpTG-7.js.map +0 -1
- package/dist/export-6x7MilFR.d.mts +0 -451
- package/dist/export-CpJOQuZv.d.ts +0 -451
- package/dist/objectUtils-ButT0Mng.js.map +0 -1
- package/dist/objectUtils-C0WB-8ex.mjs.map +0 -1
- package/dist/prepareQueryObjects-BfMlS4ql.mjs.map +0 -1
- package/dist/prepareQueryObjects-DO3qXriW.js.map +0 -1
- package/dist/utils-BlMGIhvx.mjs.map +0 -1
- package/dist/utils-CZRhzje-.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as ValueSources, k as OptionList, y as FullField } from "./index-Lht_Wq3V.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/types/import.d.ts
|
|
4
4
|
/**
|
|
@@ -24,4 +24,4 @@ interface ParserCommonOptions {
|
|
|
24
24
|
}
|
|
25
25
|
//#endregion
|
|
26
26
|
export { ParserCommonOptions as t };
|
|
27
|
-
//# sourceMappingURL=import-
|
|
27
|
+
//# sourceMappingURL=import-0wp72lLT.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as ValueSources, k as OptionList, y as FullField } from "./index-D5TXNIzF.js";
|
|
2
2
|
|
|
3
3
|
//#region src/types/import.d.ts
|
|
4
4
|
/**
|
|
@@ -24,4 +24,4 @@ interface ParserCommonOptions {
|
|
|
24
24
|
}
|
|
25
25
|
//#endregion
|
|
26
26
|
export { ParserCommonOptions as t };
|
|
27
|
-
//# sourceMappingURL=import-
|
|
27
|
+
//# sourceMappingURL=import-yRVJh7E1.d.ts.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { RulesLogic } from "json-logic-js";
|
|
2
|
+
|
|
1
3
|
//#region ../../node_modules/type-fest/source/union-to-intersection.d.ts
|
|
2
4
|
/**
|
|
3
5
|
Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
@@ -1214,7 +1216,7 @@ type ValueEditorType = "text" | "select" | "checkbox" | "radio" | "textarea" | "
|
|
|
1214
1216
|
*/
|
|
1215
1217
|
type ValueSources = ["value"] | ["value", "field"] | ["field", "value"] | ["field"];
|
|
1216
1218
|
type ValueSourceFlexibleOptions = ToFlexibleOptionArrays<ValueSources>;
|
|
1217
|
-
type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption
|
|
1219
|
+
type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption } : never;
|
|
1218
1220
|
type WithOptionalClassName<T> = T & {
|
|
1219
1221
|
className?: Classname;
|
|
1220
1222
|
};
|
|
@@ -1296,5 +1298,595 @@ type ParseNumbersModerationLevel = "-limited" | "";
|
|
|
1296
1298
|
*/
|
|
1297
1299
|
type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
|
|
1298
1300
|
//#endregion
|
|
1299
|
-
export
|
|
1300
|
-
|
|
1301
|
+
//#region src/types/export.d.ts
|
|
1302
|
+
/**
|
|
1303
|
+
* Available export formats for {@link formatQuery}.
|
|
1304
|
+
*
|
|
1305
|
+
* @group Export
|
|
1306
|
+
*/
|
|
1307
|
+
type ExportFormat = "json" | "sql" | "json_without_ids" | "parameterized" | "parameterized_named" | "mongodb" | "mongodb_query" | "cel" | "jsonlogic" | "spel" | "elasticsearch" | "jsonata" | "natural_language" | "ldap" | "drizzle" | "prisma" | "sequelize" | "diagnostics";
|
|
1308
|
+
/**
|
|
1309
|
+
* Export formats for {@link formatQuery} that produce objects instead of strings.
|
|
1310
|
+
*
|
|
1311
|
+
* @group Export
|
|
1312
|
+
*/
|
|
1313
|
+
type ExportObjectFormats = "parameterized" | "parameterized_named" | "jsonlogic" | "elasticsearch" | "jsonata" | "mongodb_query" | "diagnostics";
|
|
1314
|
+
/**
|
|
1315
|
+
* Available presets for the "sql" export format.
|
|
1316
|
+
*
|
|
1317
|
+
* @group Export
|
|
1318
|
+
*/
|
|
1319
|
+
type SQLPreset = "ansi" | "sqlite" | "postgresql" | "mysql" | "mssql" | "oracle";
|
|
1320
|
+
/**
|
|
1321
|
+
* A map of operators to strings to be used in the output of {@link formatQuery}. If the
|
|
1322
|
+
* result can differ based on the `valueSource`, the key should map to an array where the
|
|
1323
|
+
* second element represents the string to be used when `valueSource` is "field". The first
|
|
1324
|
+
* element will be used in all other cases.
|
|
1325
|
+
*
|
|
1326
|
+
* @group Export
|
|
1327
|
+
*/
|
|
1328
|
+
type ExportOperatorMap = Partial<Record<Lowercase<DefaultOperatorName> | DefaultOperatorName, string | [string, string]>>;
|
|
1329
|
+
/**
|
|
1330
|
+
* Options object shape for {@link formatQuery}.
|
|
1331
|
+
*
|
|
1332
|
+
* @group Export
|
|
1333
|
+
*/
|
|
1334
|
+
interface FormatQueryOptions {
|
|
1335
|
+
/**
|
|
1336
|
+
* The {@link ExportFormat}.
|
|
1337
|
+
*/
|
|
1338
|
+
format?: ExportFormat;
|
|
1339
|
+
/**
|
|
1340
|
+
* This function will be used to process the `operator` from each rule
|
|
1341
|
+
* for query language formats. If not defined, the appropriate
|
|
1342
|
+
* `defaultOperatorProcessor*` for the format will be used.
|
|
1343
|
+
*/
|
|
1344
|
+
operatorProcessor?: RuleProcessor;
|
|
1345
|
+
/**
|
|
1346
|
+
* This function will be used to process the `value` from each rule
|
|
1347
|
+
* for query language formats. If not defined, the appropriate
|
|
1348
|
+
* `defaultValueProcessor*` for the format will be used.
|
|
1349
|
+
*/
|
|
1350
|
+
valueProcessor?: ValueProcessorLegacy | ValueProcessorByRule;
|
|
1351
|
+
/**
|
|
1352
|
+
* This function will be used to process each rule. If not defined, the appropriate
|
|
1353
|
+
* `defaultRuleProcessor*` for the given format will be used.
|
|
1354
|
+
*/
|
|
1355
|
+
ruleProcessor?: RuleProcessor;
|
|
1356
|
+
/**
|
|
1357
|
+
* This function will be used to process each rule group. If not defined, the appropriate
|
|
1358
|
+
* `defaultRuleGroupProcessor*` for the format will be used.
|
|
1359
|
+
*
|
|
1360
|
+
* If this function is defined, it will override the `format` option. This also allows
|
|
1361
|
+
* `formatQuery` to produce completely custom output formats.
|
|
1362
|
+
*/
|
|
1363
|
+
ruleGroupProcessor?: RuleGroupProcessor;
|
|
1364
|
+
/**
|
|
1365
|
+
* In the "sql", "parameterized", "parameterized_named", and "jsonata" export
|
|
1366
|
+
* formats, field names will be bracketed by this string. If an array of strings
|
|
1367
|
+
* is passed, field names will be preceded by the first element and
|
|
1368
|
+
* succeeded by the second element.
|
|
1369
|
+
*
|
|
1370
|
+
* Tip: Use `fieldIdentifierSeparator` to bracket identifiers individually within field names.
|
|
1371
|
+
*
|
|
1372
|
+
* @default '' // the empty string
|
|
1373
|
+
*
|
|
1374
|
+
* @example
|
|
1375
|
+
* formatQuery(query, { format: 'sql', quoteFieldNamesWith: '"' })
|
|
1376
|
+
* // `"First name" = 'Steve'`
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* formatQuery(query, { format: 'sql', quoteFieldNamesWith: ['[', ']'] })
|
|
1380
|
+
* // "[First name] = 'Steve'"
|
|
1381
|
+
*/
|
|
1382
|
+
quoteFieldNamesWith?: string | [string, string];
|
|
1383
|
+
/**
|
|
1384
|
+
* When used in conjunction with the `quoteFieldNamesWith` option, field names will
|
|
1385
|
+
* be split by this string, each part being individually processed as per the rules
|
|
1386
|
+
* of the `quoteFieldNamesWith` configuration. The parts will then be re-joined
|
|
1387
|
+
* by the same string.
|
|
1388
|
+
*
|
|
1389
|
+
* A common value for this option is `'.'`.
|
|
1390
|
+
*
|
|
1391
|
+
* A value of `''` (the empty string) will disable splitting/rejoining.
|
|
1392
|
+
*
|
|
1393
|
+
* @default ''
|
|
1394
|
+
*
|
|
1395
|
+
* @example
|
|
1396
|
+
* formatQuery(query, {
|
|
1397
|
+
* format: 'sql',
|
|
1398
|
+
* quoteFieldNamesWith: ['[', ']'],
|
|
1399
|
+
* fieldIdentifierSeparator: '.',
|
|
1400
|
+
* })
|
|
1401
|
+
* // "[dbo].[Musicians].[First name] = 'Steve'"
|
|
1402
|
+
*/
|
|
1403
|
+
fieldIdentifierSeparator?: string;
|
|
1404
|
+
/**
|
|
1405
|
+
* Character to use for quoting string values in the SQL format.
|
|
1406
|
+
* @default `'`
|
|
1407
|
+
*/
|
|
1408
|
+
quoteValuesWith?: string;
|
|
1409
|
+
/**
|
|
1410
|
+
* Validator function for the entire query. Can be the same function passed
|
|
1411
|
+
* as `validator` prop to {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1412
|
+
*/
|
|
1413
|
+
validator?: QueryValidator;
|
|
1414
|
+
/**
|
|
1415
|
+
* This can be the same {@link FullField} array passed to {@link react-querybuilder!QueryBuilder QueryBuilder}, but
|
|
1416
|
+
* really all you need to provide is the `name` and `validator` for each field.
|
|
1417
|
+
*
|
|
1418
|
+
* The full field object from this array, where the field's identifying property
|
|
1419
|
+
* matches the rule's `field`, will be passed to the rule processor.
|
|
1420
|
+
*/
|
|
1421
|
+
fields?: FlexibleOptionList<FullField>;
|
|
1422
|
+
/**
|
|
1423
|
+
* This can be the same `getOperators` function passed to {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1424
|
+
*
|
|
1425
|
+
* The full operator object from this array, where the operator's identifying property
|
|
1426
|
+
* matches the rule's `operator`, will be passed to the rule processor.
|
|
1427
|
+
*/
|
|
1428
|
+
getOperators?(field: string, misc: {
|
|
1429
|
+
fieldData: FullField;
|
|
1430
|
+
}): FlexibleOptionList<FullOperator> | null;
|
|
1431
|
+
/**
|
|
1432
|
+
* This string will be inserted in place of invalid groups for non-JSON formats.
|
|
1433
|
+
* Defaults to `'(1 = 1)'` for "sql"/"parameterized"/"parameterized_named" and
|
|
1434
|
+
* `'$and:[{$expr:true}]'` for "mongodb".
|
|
1435
|
+
*/
|
|
1436
|
+
fallbackExpression?: string;
|
|
1437
|
+
/**
|
|
1438
|
+
* This string will be placed in front of named parameters (aka bind variables)
|
|
1439
|
+
* when using the "parameterized_named" export format.
|
|
1440
|
+
*
|
|
1441
|
+
* @default ":"
|
|
1442
|
+
*/
|
|
1443
|
+
paramPrefix?: string;
|
|
1444
|
+
/**
|
|
1445
|
+
* Maintains the parameter prefix in the `params` object keys when using the
|
|
1446
|
+
* "parameterized_named" export format. Recommended when using SQLite.
|
|
1447
|
+
*
|
|
1448
|
+
* @default false
|
|
1449
|
+
*
|
|
1450
|
+
* @example
|
|
1451
|
+
* console.log(formatQuery(query, {
|
|
1452
|
+
* format: "parameterized_named",
|
|
1453
|
+
* paramPrefix: "$",
|
|
1454
|
+
* paramsKeepPrefix: true
|
|
1455
|
+
* }).params)
|
|
1456
|
+
* // { $firstName: "Stev" }
|
|
1457
|
+
* // Default (`paramsKeepPrefix` is `false`):
|
|
1458
|
+
* // { firstName: "Stev" }
|
|
1459
|
+
*/
|
|
1460
|
+
paramsKeepPrefix?: boolean;
|
|
1461
|
+
/**
|
|
1462
|
+
* Renders parameter placeholders as a series of sequential numbers
|
|
1463
|
+
* instead of '?' like the default. This option will respect the
|
|
1464
|
+
* `paramPrefix` option like the 'parameterized_named' format.
|
|
1465
|
+
*
|
|
1466
|
+
* @default false
|
|
1467
|
+
*/
|
|
1468
|
+
numberedParams?: boolean;
|
|
1469
|
+
/**
|
|
1470
|
+
* Preserves the order of values for "between" and "notBetween" rules, even if a larger
|
|
1471
|
+
* value comes before a smaller value (which will always evaluate to false).
|
|
1472
|
+
*/
|
|
1473
|
+
preserveValueOrder?: boolean;
|
|
1474
|
+
/**
|
|
1475
|
+
* Renders values as either `number`-types or unquoted strings, as
|
|
1476
|
+
* appropriate and when possible. Each `string`-type value is evaluated
|
|
1477
|
+
* against {@link numericRegex} to determine if it can be represented as a
|
|
1478
|
+
* plain numeric value. If so, `parseFloat` is used to convert it to a number.
|
|
1479
|
+
*/
|
|
1480
|
+
parseNumbers?: ParseNumbersPropConfig;
|
|
1481
|
+
/**
|
|
1482
|
+
* Any rules where the field is equal to this value will be ignored.
|
|
1483
|
+
*
|
|
1484
|
+
* @default '~'
|
|
1485
|
+
*/
|
|
1486
|
+
placeholderFieldName?: string;
|
|
1487
|
+
/**
|
|
1488
|
+
* Any rules where the operator is equal to this value will be ignored.
|
|
1489
|
+
*
|
|
1490
|
+
* @default '~'
|
|
1491
|
+
*/
|
|
1492
|
+
placeholderOperatorName?: string;
|
|
1493
|
+
/**
|
|
1494
|
+
* Any rules where the value is equal to this value will be ignored.
|
|
1495
|
+
*
|
|
1496
|
+
* @default '~'
|
|
1497
|
+
*/
|
|
1498
|
+
placeholderValueName?: string;
|
|
1499
|
+
/**
|
|
1500
|
+
* Operator to use when concatenating wildcard characters and field names in "sql" format.
|
|
1501
|
+
* The ANSI standard is `||`, while SQL Server uses `+`. MySQL does not implement a concatenation
|
|
1502
|
+
* operator by default, and therefore requires use of the `CONCAT` function.
|
|
1503
|
+
*
|
|
1504
|
+
* If `concatOperator` is set to `"CONCAT"` (case-insensitive), the `CONCAT` function will be
|
|
1505
|
+
* used. Note that Oracle SQL does not support more than two values in the `CONCAT` function,
|
|
1506
|
+
* so this option should not be used in that context. The default setting (`"||"`) is already
|
|
1507
|
+
* compatible with Oracle SQL.
|
|
1508
|
+
*
|
|
1509
|
+
* @default '||'
|
|
1510
|
+
*/
|
|
1511
|
+
concatOperator?: "||" | "+" | "CONCAT" | (string & {});
|
|
1512
|
+
/**
|
|
1513
|
+
* Option presets to maximize compatibility with various SQL dialects.
|
|
1514
|
+
*/
|
|
1515
|
+
preset?: SQLPreset;
|
|
1516
|
+
/**
|
|
1517
|
+
* Map of operators to their translations for the "natural_language" format. If the
|
|
1518
|
+
* result can differ based on the `valueSource`, the key should map to an array where the
|
|
1519
|
+
* second element represents the string to be used when `valueSource` is "field". The first
|
|
1520
|
+
* element will be used in all other cases.
|
|
1521
|
+
*/
|
|
1522
|
+
operatorMap?: ExportOperatorMap;
|
|
1523
|
+
/**
|
|
1524
|
+
* [Constituent word order](https://en.wikipedia.org/wiki/Word_order#Constituent_word_orders)
|
|
1525
|
+
* for the "natural_language" format. Can be abbreviated like "SVO" or spelled out like
|
|
1526
|
+
* "subject-verb-object".
|
|
1527
|
+
*
|
|
1528
|
+
* - Subject = field
|
|
1529
|
+
* - Verb = operator
|
|
1530
|
+
* - Object = value
|
|
1531
|
+
*/
|
|
1532
|
+
wordOrder?: ConstituentWordOrderString | Lowercase<ConstituentWordOrderString> | ({} & string);
|
|
1533
|
+
/**
|
|
1534
|
+
* Translatable strings used by the "natural_language" format.
|
|
1535
|
+
*/
|
|
1536
|
+
translations?: Partial<Record<NLTranslationKey, string>>;
|
|
1537
|
+
context?: Record<string, any>;
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Options object for {@link ValueProcessorByRule} functions.
|
|
1541
|
+
*
|
|
1542
|
+
* @group Export
|
|
1543
|
+
*/
|
|
1544
|
+
interface ValueProcessorOptions extends FormatQueryOptions {
|
|
1545
|
+
valueProcessor?: ValueProcessorByRule;
|
|
1546
|
+
escapeQuotes?: boolean;
|
|
1547
|
+
/**
|
|
1548
|
+
* The full field object, if `fields` was provided in the
|
|
1549
|
+
* {@link formatQuery} options parameter.
|
|
1550
|
+
*/
|
|
1551
|
+
fieldData?: FullField;
|
|
1552
|
+
/**
|
|
1553
|
+
* Included for the "parameterized_named" format only. Keys of this object represent
|
|
1554
|
+
* field names and values represent the current list of parameter names for that
|
|
1555
|
+
* field based on the query rules processed up to that point. Use this list to
|
|
1556
|
+
* ensure that parameter names generated by the custom rule processor are unique.
|
|
1557
|
+
*/
|
|
1558
|
+
fieldParamNames?: Record<string, string[]>;
|
|
1559
|
+
/**
|
|
1560
|
+
* Included for the "parameterized_named" format only. Call this function with a
|
|
1561
|
+
* field name to get a unique parameter name, as yet unused during query processing.
|
|
1562
|
+
*/
|
|
1563
|
+
getNextNamedParam?: (field: string) => string;
|
|
1564
|
+
/**
|
|
1565
|
+
* Additional prefix and suffix characters to wrap the value in. Useful for augmenting
|
|
1566
|
+
* the default value processor results with special syntax (e.g., for dates or function
|
|
1567
|
+
* calls).
|
|
1568
|
+
*/
|
|
1569
|
+
wrapValueWith?: [string, string];
|
|
1570
|
+
/**
|
|
1571
|
+
* Parse numbers in the rule value.
|
|
1572
|
+
*
|
|
1573
|
+
* @default false
|
|
1574
|
+
*/
|
|
1575
|
+
parseNumbers?: boolean;
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* Options object curated by {@link formatQuery} and passed to a {@link RuleGroupProcessor}.
|
|
1579
|
+
*
|
|
1580
|
+
* @group Export
|
|
1581
|
+
*/
|
|
1582
|
+
interface FormatQueryFinalOptions extends Required<Except<FormatQueryOptions, "context" | "valueProcessor" | "validator" | "placeholderValueName" | "ruleGroupProcessor" | "parseNumbers">> {
|
|
1583
|
+
fields: FullOptionList<FullField>;
|
|
1584
|
+
getParseNumberBoolean: (inputType?: InputType | null) => boolean | undefined;
|
|
1585
|
+
parseNumbers?: ParseNumbersPropConfig | undefined;
|
|
1586
|
+
placeholderValueName?: string | undefined;
|
|
1587
|
+
valueProcessor: ValueProcessorByRule;
|
|
1588
|
+
validator?: QueryValidator;
|
|
1589
|
+
validateRule: FormatQueryValidateRule;
|
|
1590
|
+
validationMap: ValidationMap;
|
|
1591
|
+
context?: Record<string, unknown>;
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Function that produces a processed value for a given {@link RuleType}.
|
|
1595
|
+
*
|
|
1596
|
+
* @group Export
|
|
1597
|
+
*/
|
|
1598
|
+
type ValueProcessorByRule = (rule: RuleType, options?: ValueProcessorOptions) => string;
|
|
1599
|
+
/**
|
|
1600
|
+
* Function that produces a processed value for a given `field`, `operator`, `value`,
|
|
1601
|
+
* and `valueSource`.
|
|
1602
|
+
*
|
|
1603
|
+
* @group Export
|
|
1604
|
+
*/
|
|
1605
|
+
type ValueProcessorLegacy = (field: string, operator: string, value: any, valueSource?: ValueSource) => string;
|
|
1606
|
+
/**
|
|
1607
|
+
* Function to produce a result that {@link formatQuery} uses when processing a
|
|
1608
|
+
* {@link RuleType} object.
|
|
1609
|
+
*
|
|
1610
|
+
* See the default rule processor for each format to know what type to return.
|
|
1611
|
+
* | Format | Default rule processor |
|
|
1612
|
+
* | ------------------------ | ----------------------------------------- |
|
|
1613
|
+
* | `sql` | {@link defaultRuleProcessorSQL} |
|
|
1614
|
+
* | `parameterized` | {@link defaultRuleProcessorParameterized} |
|
|
1615
|
+
* | `parameterized_named` | {@link defaultRuleProcessorParameterized} |
|
|
1616
|
+
* | `mongodb` _(deprecated)_ | {@link defaultRuleProcessorMongoDB} |
|
|
1617
|
+
* | `mongodb_query` | {@link defaultRuleProcessorMongoDBQuery} |
|
|
1618
|
+
* | `cel` | {@link defaultRuleProcessorCEL} |
|
|
1619
|
+
* | `spel` | {@link defaultRuleProcessorSpEL} |
|
|
1620
|
+
* | `jsonlogic` | {@link defaultRuleProcessorJsonLogic} |
|
|
1621
|
+
* | `elasticsearch` | {@link defaultRuleProcessorElasticSearch} |
|
|
1622
|
+
* | `jsonata` | {@link defaultRuleProcessorJSONata} |
|
|
1623
|
+
*
|
|
1624
|
+
* @group Export
|
|
1625
|
+
*/
|
|
1626
|
+
type RuleProcessor = (rule: RuleType, options?: ValueProcessorOptions, meta?: {
|
|
1627
|
+
processedParams?: Record<string, any> | any[];
|
|
1628
|
+
context?: Record<string, any>;
|
|
1629
|
+
}) => any;
|
|
1630
|
+
/**
|
|
1631
|
+
* Function to produce a result that {@link formatQuery} uses when processing a
|
|
1632
|
+
* {@link RuleGroupType} or {@link RuleGroupTypeIC} object.
|
|
1633
|
+
*
|
|
1634
|
+
* See the default rule group processor for each format to know what type to return.
|
|
1635
|
+
* | Format | Default rule group processor |
|
|
1636
|
+
* | ------------------------ | ---------------------------------------------- |
|
|
1637
|
+
* | `sql` | {@link defaultRuleGroupProcessorSQL} |
|
|
1638
|
+
* | `parameterized` | {@link defaultRuleGroupProcessorParameterized} |
|
|
1639
|
+
* | `parameterized_named` | {@link defaultRuleGroupProcessorParameterized} |
|
|
1640
|
+
* | `mongodb` _(deprecated)_ | {@link defaultRuleGroupProcessorMongoDB} |
|
|
1641
|
+
* | `mongodb_query` | {@link defaultRuleGroupProcessorMongoDBQuery} |
|
|
1642
|
+
* | `cel` | {@link defaultRuleGroupProcessorCEL} |
|
|
1643
|
+
* | `spel` | {@link defaultRuleGroupProcessorSpEL} |
|
|
1644
|
+
* | `jsonlogic` | {@link defaultRuleGroupProcessorJsonLogic} |
|
|
1645
|
+
* | `elasticsearch` | {@link defaultRuleGroupProcessorElasticSearch} |
|
|
1646
|
+
* | `jsonata` | {@link defaultRuleGroupProcessorJSONata} |
|
|
1647
|
+
*
|
|
1648
|
+
* @group Export
|
|
1649
|
+
*/
|
|
1650
|
+
type RuleGroupProcessor<TResult = unknown> = (ruleGroup: RuleGroupTypeAny, options: FormatQueryFinalOptions, meta?: {
|
|
1651
|
+
processedParams?: Record<string, any> | any[];
|
|
1652
|
+
context?: Record<string, any>;
|
|
1653
|
+
}) => TResult;
|
|
1654
|
+
/**
|
|
1655
|
+
* Rule validator for {@link formatQuery}.
|
|
1656
|
+
*
|
|
1657
|
+
* @group Export
|
|
1658
|
+
*/
|
|
1659
|
+
type FormatQueryValidateRule = (rule: RuleType) => readonly [boolean | ValidationResult | undefined, RuleValidator | undefined];
|
|
1660
|
+
/**
|
|
1661
|
+
* Object produced by {@link formatQuery} for the `"parameterized"` format.
|
|
1662
|
+
*
|
|
1663
|
+
* @group Export
|
|
1664
|
+
*/
|
|
1665
|
+
interface ParameterizedSQL {
|
|
1666
|
+
/** The SQL `WHERE` clause fragment with `?` placeholders for each value. */
|
|
1667
|
+
sql: string;
|
|
1668
|
+
/**
|
|
1669
|
+
* Parameter values in the same order their respective placeholders
|
|
1670
|
+
* appear in the `sql` string.
|
|
1671
|
+
*/
|
|
1672
|
+
params: any[];
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Object produced by {@link formatQuery} for the `"parameterized_named"` format.
|
|
1676
|
+
*
|
|
1677
|
+
* @group Export
|
|
1678
|
+
*/
|
|
1679
|
+
interface ParameterizedNamedSQL {
|
|
1680
|
+
/** The SQL `WHERE` clause fragment with bind variable placeholders for each value. */
|
|
1681
|
+
sql: string;
|
|
1682
|
+
/**
|
|
1683
|
+
* Map of bind variable names from the `sql` string to the associated values.
|
|
1684
|
+
*/
|
|
1685
|
+
params: Record<string, any>;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* A {@link RuleType} annotated with diagnostics results, as produced
|
|
1689
|
+
* by {@link formatQuery} for the `"diagnostics"` format.
|
|
1690
|
+
*
|
|
1691
|
+
* The generics mirror those of {@link RuleType}.
|
|
1692
|
+
*
|
|
1693
|
+
* @group Export
|
|
1694
|
+
*/
|
|
1695
|
+
type RuleDiagnosticsResult<F extends string = string, O extends string = string, V = any, C extends string = string> = RuleType<F, O, V, C> & {
|
|
1696
|
+
/** Whether the rule passed all validation checks. */valid: boolean;
|
|
1697
|
+
/**
|
|
1698
|
+
* Reasons why the rule is invalid. Only present when
|
|
1699
|
+
* the rule is invalid and specific reasons were provided
|
|
1700
|
+
* by the validator.
|
|
1701
|
+
*/
|
|
1702
|
+
reasons?: any[]; /** The path to this rule within the query tree. */
|
|
1703
|
+
path: number[]; /** The nesting depth of this rule (`path.length`). */
|
|
1704
|
+
level: number;
|
|
1705
|
+
};
|
|
1706
|
+
/**
|
|
1707
|
+
* The type of the `rules` array in a {@link RuleGroupDiagnosticsResult}.
|
|
1708
|
+
*
|
|
1709
|
+
* @group Export
|
|
1710
|
+
*/
|
|
1711
|
+
type RuleGroupDiagnosticsArray<RG extends RuleGroupDiagnosticsResult = RuleGroupDiagnosticsResult, R extends RuleDiagnosticsResult = RuleDiagnosticsResult> = RuleGroupArray<RG, R>;
|
|
1712
|
+
/**
|
|
1713
|
+
* A {@link RuleGroupType} annotated with diagnostics results, as produced
|
|
1714
|
+
* by {@link formatQuery} for the `"diagnostics"` format.
|
|
1715
|
+
*
|
|
1716
|
+
* The generics mirror those of {@link RuleGroupType}.
|
|
1717
|
+
*
|
|
1718
|
+
* @group Export
|
|
1719
|
+
*/
|
|
1720
|
+
interface RuleGroupDiagnosticsResult<R extends RuleDiagnosticsResult = RuleDiagnosticsResult, C extends string = string> extends Omit<RuleGroupType<R, C>, "rules"> {
|
|
1721
|
+
/** Whether the group and all of its descendants are valid. */
|
|
1722
|
+
valid: boolean;
|
|
1723
|
+
/**
|
|
1724
|
+
* Reasons why the group itself is invalid. Only present when
|
|
1725
|
+
* the group is invalid and specific reasons were provided
|
|
1726
|
+
* by the validator.
|
|
1727
|
+
*/
|
|
1728
|
+
reasons?: any[];
|
|
1729
|
+
/** The path to this group within the query tree. */
|
|
1730
|
+
path: number[];
|
|
1731
|
+
/** The nesting depth of this group (`path.length`). */
|
|
1732
|
+
level: number;
|
|
1733
|
+
rules: RuleGroupDiagnosticsArray<RuleGroupDiagnosticsResult<R, C>, R>;
|
|
1734
|
+
}
|
|
1735
|
+
/**
|
|
1736
|
+
* The type of the `rules` array in a {@link RuleGroupICDiagnosticsResult}.
|
|
1737
|
+
*
|
|
1738
|
+
* Mirrors {@link RuleGroupICArray} but with diagnostics-annotated node types.
|
|
1739
|
+
*
|
|
1740
|
+
* @group Export
|
|
1741
|
+
*/
|
|
1742
|
+
type RuleGroupICDiagnosticsArray<RG extends RuleGroupICDiagnosticsResult = RuleGroupICDiagnosticsResult, R extends RuleDiagnosticsResult = RuleDiagnosticsResult, C extends string = string> = RuleGroupICArray<RG, R, C>;
|
|
1743
|
+
/**
|
|
1744
|
+
* A {@link RuleGroupTypeIC} annotated with diagnostics results, as produced
|
|
1745
|
+
* by {@link formatQuery} for the `"diagnostics"` format (independent combinators).
|
|
1746
|
+
*
|
|
1747
|
+
* The generics mirror those of {@link RuleGroupTypeIC}.
|
|
1748
|
+
*
|
|
1749
|
+
* @group Export
|
|
1750
|
+
*/
|
|
1751
|
+
interface RuleGroupICDiagnosticsResult<R extends RuleDiagnosticsResult = RuleDiagnosticsResult, C extends string = string> extends Omit<RuleGroupTypeIC<R, C>, "rules"> {
|
|
1752
|
+
/** Whether the group and all of its descendants are valid. */
|
|
1753
|
+
valid: boolean;
|
|
1754
|
+
/**
|
|
1755
|
+
* Reasons why the group itself is invalid. Only present when
|
|
1756
|
+
* the group is invalid and specific reasons were provided
|
|
1757
|
+
* by the validator.
|
|
1758
|
+
*/
|
|
1759
|
+
reasons?: any[];
|
|
1760
|
+
/** The path to this group within the query tree. */
|
|
1761
|
+
path: number[];
|
|
1762
|
+
/** The nesting depth of this group (`path.length`). */
|
|
1763
|
+
level: number;
|
|
1764
|
+
rules: RuleGroupICDiagnosticsArray<RuleGroupICDiagnosticsResult<R, C>, R, C>;
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* A single diagnostic entry produced by the `"diagnostics"` format.
|
|
1768
|
+
*
|
|
1769
|
+
* @group Export
|
|
1770
|
+
*/
|
|
1771
|
+
interface DiagnosticEntry {
|
|
1772
|
+
/** The `id` of the rule or group this diagnostic pertains to. */
|
|
1773
|
+
id: string;
|
|
1774
|
+
/** The path to the rule or group within the query tree. */
|
|
1775
|
+
path: number[];
|
|
1776
|
+
/** A machine-readable code identifying the type of diagnostic. */
|
|
1777
|
+
code: string;
|
|
1778
|
+
/** A human-readable description of the diagnostic. */
|
|
1779
|
+
message: string;
|
|
1780
|
+
/**
|
|
1781
|
+
* Which check produced this diagnostic.
|
|
1782
|
+
*
|
|
1783
|
+
* - `"placeholder"` — a placeholder field, operator, or value
|
|
1784
|
+
* - `"muted"` — a muted rule or group
|
|
1785
|
+
* - `"query-validator"` — the query-level validator
|
|
1786
|
+
* - `"field-validator"` — a field-level validator
|
|
1787
|
+
* - `"type-check"` — value/type mismatch based on field `inputType`
|
|
1788
|
+
* - `"field-check"` — field existence check against the `fields` config
|
|
1789
|
+
*/
|
|
1790
|
+
source: "placeholder" | "muted" | "query-validator" | "field-validator" | "type-check" | "field-check";
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Aggregate statistics for the `"diagnostics"` format.
|
|
1794
|
+
*
|
|
1795
|
+
* @group Export
|
|
1796
|
+
*/
|
|
1797
|
+
interface DiagnosticsStats {
|
|
1798
|
+
totalRules: number;
|
|
1799
|
+
totalGroups: number;
|
|
1800
|
+
validRules: number;
|
|
1801
|
+
invalidRules: number;
|
|
1802
|
+
validGroups: number;
|
|
1803
|
+
invalidGroups: number;
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Per-field summary entry for the `"diagnostics"` format.
|
|
1807
|
+
*
|
|
1808
|
+
* @group Export
|
|
1809
|
+
*/
|
|
1810
|
+
interface DiagnosticsFieldSummaryEntry {
|
|
1811
|
+
/** Number of rules referencing this field. */
|
|
1812
|
+
ruleCount: number;
|
|
1813
|
+
/** Number of invalid rules referencing this field. */
|
|
1814
|
+
invalidCount: number;
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Top-level result of {@link formatQuery} for the `"diagnostics"` format.
|
|
1818
|
+
*
|
|
1819
|
+
* @group Export
|
|
1820
|
+
*/
|
|
1821
|
+
interface DiagnosticsResult {
|
|
1822
|
+
/** The annotated query tree with `valid`, `path`, and `level` on every node. */
|
|
1823
|
+
query: RuleGroupDiagnosticsResult | RuleGroupICDiagnosticsResult;
|
|
1824
|
+
/** A flat array of all diagnostic entries across the tree. */
|
|
1825
|
+
diagnostics: DiagnosticEntry[];
|
|
1826
|
+
/** Aggregate statistics about the query. */
|
|
1827
|
+
stats: DiagnosticsStats;
|
|
1828
|
+
/** Per-field summary of rule counts and invalid counts. */
|
|
1829
|
+
fieldSummary: Record<string, DiagnosticsFieldSummaryEntry>;
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* @group Export
|
|
1833
|
+
*/
|
|
1834
|
+
interface RQBJsonLogicStartsWith {
|
|
1835
|
+
startsWith: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* @group Export
|
|
1839
|
+
*/
|
|
1840
|
+
interface RQBJsonLogicEndsWith {
|
|
1841
|
+
endsWith: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* JsonLogic rule object with additional operators generated by {@link formatQuery}
|
|
1845
|
+
* and accepted by {@link parseJsonLogic!parseJsonLogic}.
|
|
1846
|
+
*
|
|
1847
|
+
* @group Export
|
|
1848
|
+
*/
|
|
1849
|
+
type RQBJsonLogic = RulesLogic<RQBJsonLogicStartsWith | RQBJsonLogicEndsWith>;
|
|
1850
|
+
/**
|
|
1851
|
+
* Constituent word order (as array) for the "natural_language" format.
|
|
1852
|
+
*
|
|
1853
|
+
* - S (subject) = field
|
|
1854
|
+
* - V (verb) = operator
|
|
1855
|
+
* - O (object) = value
|
|
1856
|
+
*
|
|
1857
|
+
* @group Export
|
|
1858
|
+
*/
|
|
1859
|
+
type ConstituentWordOrder = ["S", "V", "O"] | ["S", "O", "V"] | ["O", "S", "V"] | ["O", "V", "S"] | ["V", "S", "O"] | ["V", "O", "S"];
|
|
1860
|
+
/**
|
|
1861
|
+
* Constituent word order (as string) for the "natural_language" format.
|
|
1862
|
+
*
|
|
1863
|
+
* - S (subject) = field
|
|
1864
|
+
* - V (verb) = operator
|
|
1865
|
+
* - O (object) = value
|
|
1866
|
+
*
|
|
1867
|
+
* @group Export
|
|
1868
|
+
*/
|
|
1869
|
+
type ConstituentWordOrderString = "SVO" | "SOV" | "OSV" | "OVS" | "VSO" | "VOS";
|
|
1870
|
+
type RepeatStrings<S extends string[], Depth extends number[] = []> = Depth["length"] extends 2 ? "" : "" | `_${S[number]}${RepeatStrings<S, [...Depth, 1]>}`;
|
|
1871
|
+
type ZeroOrMoreGroupVariants = RepeatStrings<["xor", "not"]>;
|
|
1872
|
+
/**
|
|
1873
|
+
* Rule group condition identifier for the "natural_language" format.
|
|
1874
|
+
*
|
|
1875
|
+
* @group Export
|
|
1876
|
+
*/
|
|
1877
|
+
type GroupVariantCondition = "not" | "xor";
|
|
1878
|
+
/**
|
|
1879
|
+
* Keys for the `translations` config object used by the "natural_language" format.
|
|
1880
|
+
*
|
|
1881
|
+
* @group Export
|
|
1882
|
+
*/
|
|
1883
|
+
type NLTranslationKey = "and" | "or" | "true" | "false" | `groupPrefix${ZeroOrMoreGroupVariants}` | `groupSuffix${ZeroOrMoreGroupVariants}`;
|
|
1884
|
+
/**
|
|
1885
|
+
* `translations` config object for "natural_language" format.
|
|
1886
|
+
*
|
|
1887
|
+
* @group Export
|
|
1888
|
+
*/
|
|
1889
|
+
type NLTranslations = Partial<Record<NLTranslationKey, string>>;
|
|
1890
|
+
//#endregion
|
|
1891
|
+
export { SetRequired as A, RuleGroupTypeIC as C, RuleGroupType as D, DefaultRuleGroupType as E, RuleType as O, RuleGroupTypeAny as S, DefaultOperatorName as T, ValueProcessorLegacy as _, ExportOperatorMap as a, ValueSources as b, NLTranslationKey as c, ParameterizedSQL as d, RQBJsonLogic as f, ValueProcessorByRule as g, SQLPreset as h, ExportObjectFormats as i, Except as j, OptionList as k, NLTranslations as l, RuleProcessor as m, DiagnosticsResult as n, FormatQueryOptions as o, RuleGroupProcessor as p, ExportFormat as r, GroupVariantCondition as s, ConstituentWordOrder as t, ParameterizedNamedSQL as u, ValueProcessorOptions as v, DefaultCombinatorName as w, DefaultRuleGroupTypeIC as x, FullField as y };
|
|
1892
|
+
//# sourceMappingURL=index-D5TXNIzF.d.ts.map
|