@react-querybuilder/core 8.13.0 → 8.14.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/{basic-_KlsCAyT.d.ts → basic-Dxm6jWFu.d.ts} +10 -10
- package/dist/{basic-Cw014pDc.d.mts → basic-GFsWfi0Z.d.mts} +10 -10
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +23 -23
- package/dist/cjs/react-querybuilder_core.cjs.development.js +24 -1
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +23 -23
- 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/{export-DRA8O1Wz.d.ts → export-6VbkhCrf.d.ts} +2 -2
- package/dist/{export-CffjLxEe.d.mts → export-_wipiqJZ.d.mts} +2 -2
- package/dist/formatQuery.d.mts +2 -2
- package/dist/formatQuery.d.ts +2 -2
- package/dist/formatQuery.js +24 -1
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +24 -1
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-CWYJkN_w.d.ts → import-D8M7awTx.d.ts} +2 -2
- package/dist/{import-DjHGaGhJ.d.mts → import-DRmutNSr.d.mts} +2 -2
- package/dist/parseCEL.d.mts +2 -2
- package/dist/parseCEL.d.ts +2 -2
- package/dist/parseCEL.js +6 -6
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +1 -1
- package/dist/parseJSONata.d.mts +2 -2
- package/dist/parseJSONata.d.ts +2 -2
- package/dist/parseJSONata.js +3 -3
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +1 -2
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +3 -3
- package/dist/parseJsonLogic.d.ts +3 -3
- package/dist/parseJsonLogic.js +1 -1
- package/dist/parseJsonLogic.mjs +1 -1
- package/dist/parseMongoDB.d.mts +2 -2
- package/dist/parseMongoDB.d.ts +2 -2
- package/dist/parseMongoDB.js +1 -1
- package/dist/parseMongoDB.mjs +1 -1
- package/dist/parseSQL.d.mts +2 -2
- package/dist/parseSQL.d.ts +2 -2
- package/dist/parseSQL.js +6 -6
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +1 -1
- package/dist/parseSpEL.d.mts +2 -2
- package/dist/parseSpEL.d.ts +2 -2
- package/dist/parseSpEL.js +1 -1
- package/dist/parseSpEL.mjs +1 -1
- package/dist/{prepareQueryObjects-6Bxx4Bs1.mjs → prepareQueryObjects-BBayjIn2.mjs} +2 -5
- package/dist/prepareQueryObjects-BBayjIn2.mjs.map +1 -0
- package/dist/{prepareQueryObjects-CkN0bTKm.js → prepareQueryObjects-BxWvIPI4.js} +2 -5
- package/dist/prepareQueryObjects-BxWvIPI4.js.map +1 -0
- package/dist/react-querybuilder_core.d.mts +23 -23
- package/dist/react-querybuilder_core.legacy-esm.d.ts +23 -23
- package/dist/react-querybuilder_core.legacy-esm.js +28 -8
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +24 -1
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +23 -23
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js +0 -1
- package/dist/transformQuery.mjs +0 -1
- package/dist/utils-CR1ToTMW.js.map +1 -1
- package/dist/utils-nQU7WCM9.mjs.map +1 -1
- package/package.json +14 -14
- package/dist/prepareQueryObjects-6Bxx4Bs1.mjs.map +0 -1
- package/dist/prepareQueryObjects-CkN0bTKm.js.map +0 -1
package/dist/parseSQL.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D as joinWith, E as parseNumber } from "./utils-nQU7WCM9.mjs";
|
|
2
2
|
import { a as lc, t as isRuleGroup } from "./isRuleGroup-DztIOOKa.mjs";
|
|
3
|
-
import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-
|
|
3
|
+
import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-BBayjIn2.mjs";
|
|
4
4
|
import { JisonParser } from "@ts-jison/parser";
|
|
5
5
|
import { JisonLexer } from "@ts-jison/lexer";
|
|
6
6
|
|
package/dist/parseSpEL.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Except, d as DefaultRuleGroupTypeIC, g as DefaultRuleGroupType } from "./basic-
|
|
2
|
-
import { t as ParserCommonOptions } from "./import-
|
|
1
|
+
import { C as Except, d as DefaultRuleGroupTypeIC, g as DefaultRuleGroupType } from "./basic-GFsWfi0Z.mjs";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-DRmutNSr.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/parseSpEL/parseSpEL.d.ts
|
|
5
5
|
|
package/dist/parseSpEL.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Except, d as DefaultRuleGroupTypeIC, g as DefaultRuleGroupType } from "./basic-
|
|
2
|
-
import { t as ParserCommonOptions } from "./import-
|
|
1
|
+
import { C as Except, d as DefaultRuleGroupTypeIC, g as DefaultRuleGroupType } from "./basic-Dxm6jWFu.js";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-D8M7awTx.js";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/parseSpEL/parseSpEL.d.ts
|
|
5
5
|
|
package/dist/parseSpEL.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-U64pC571.js');
|
|
2
2
|
const require_utils = require('./utils-CR1ToTMW.js');
|
|
3
3
|
const require_isRuleGroup = require('./isRuleGroup-Cjk1Q2mj.js');
|
|
4
|
-
const require_prepareQueryObjects = require('./prepareQueryObjects-
|
|
4
|
+
const require_prepareQueryObjects = require('./prepareQueryObjects-BxWvIPI4.js');
|
|
5
5
|
|
|
6
6
|
//#region ../../node_modules/spel2js/dist/spel2js.js
|
|
7
7
|
var require_spel2js = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
|
package/dist/parseSpEL.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D as joinWith } from "./utils-nQU7WCM9.mjs";
|
|
2
2
|
import { t as isRuleGroup } from "./isRuleGroup-DztIOOKa.mjs";
|
|
3
|
-
import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-
|
|
3
|
+
import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-BBayjIn2.mjs";
|
|
4
4
|
import { SpelExpressionEvaluator } from "spel2js";
|
|
5
5
|
|
|
6
6
|
//#region src/utils/parseSpEL/utils.ts
|
|
@@ -73,10 +73,7 @@ const getValueSourcesUtil = (fieldData, operator, getValueSources) => {
|
|
|
73
73
|
//#endregion
|
|
74
74
|
//#region src/utils/parserUtils.ts
|
|
75
75
|
const getFieldsArray = (fields) => {
|
|
76
|
-
return toFlatOptionArray(fields ? Array.isArray(fields) ? fields : Object.keys(fields).map((fld) => ({
|
|
77
|
-
...fields[fld],
|
|
78
|
-
name: fld
|
|
79
|
-
})).sort((a, b) => a.label.localeCompare(b.label)) : []);
|
|
76
|
+
return toFlatOptionArray(fields ? Array.isArray(fields) ? fields : Object.keys(fields).map((fld) => Object.assign({}, fields[fld], { name: fld })).sort((a, b) => a.label.localeCompare(b.label)) : []);
|
|
80
77
|
};
|
|
81
78
|
function fieldIsValidUtil(params) {
|
|
82
79
|
const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;
|
|
@@ -151,4 +148,4 @@ const prepareRuleGroup = (queryObject, { idGenerator = generateID } = {}) => pro
|
|
|
151
148
|
|
|
152
149
|
//#endregion
|
|
153
150
|
export { fieldIsValidUtil as n, getFieldsArray as r, prepareRuleGroup as t };
|
|
154
|
-
//# sourceMappingURL=prepareQueryObjects-
|
|
151
|
+
//# sourceMappingURL=prepareQueryObjects-BBayjIn2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareQueryObjects-BBayjIn2.mjs","names":["defaultValueSourcesArray: ValueSourceFullOptions","valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions)"],"sources":["../src/utils/filterFieldsByComparator.ts","../src/utils/getValueSourcesUtil.ts","../src/utils/parserUtils.ts","../src/utils/generateID.ts","../src/utils/prepareQueryObjects.ts"],"sourcesContent":["import type { FullField, OptionList, WithUnknownIndex } from '../types';\nimport { isFlexibleOptionGroupArray, toFullOption } from './optGroupUtils';\n\nconst filterByComparator = (field: FullField, operator: string, fieldToCompare: FullField) => {\n const fullField = toFullOption(field);\n const fullFieldToCompare = toFullOption(fieldToCompare);\n if (fullField.value === fullFieldToCompare.value) {\n return false;\n }\n if (typeof fullField.comparator === 'string') {\n return fullField[fullField.comparator] === fullFieldToCompare[fullField.comparator];\n }\n return fullField.comparator?.(fullFieldToCompare, operator) ?? /* istanbul ignore next */ false;\n};\n\n/**\n * For a given {@link FullField}, returns the `fields` list filtered for\n * other fields that match by `comparator`. Only fields *other than the\n * one in question* will ever be included, even if `comparator` is `null`\n * or `undefined`. If `comparator` is a string, fields with the same value\n * for that property will be included. If `comparator` is a function, each\n * field will be passed to the function along with the `operator` and fields\n * for which the function returns `true` will be included.\n *\n * @group Option Lists\n */\nexport const filterFieldsByComparator = (\n /** The field in question. */\n field: FullField,\n /** The full {@link FullField} list to be filtered. */\n fields: OptionList<FullField>,\n operator: string\n):\n | FullField[]\n | {\n options: WithUnknownIndex<FullField>[];\n label: string;\n }[] => {\n if (!field.comparator) {\n const filterOutSameField = (f: FullField) =>\n (f.value ?? /* istanbul ignore next */ f.name) !==\n (field.value ?? /* istanbul ignore next */ field.name);\n if (isFlexibleOptionGroupArray(fields)) {\n return fields.map(og => ({\n ...og,\n options: og.options.filter(v => filterOutSameField(v)),\n }));\n }\n return fields.filter(v => filterOutSameField(v));\n }\n\n if (isFlexibleOptionGroupArray(fields)) {\n return fields\n .map(og => ({\n ...og,\n options: og.options.filter(f => filterByComparator(field, operator, f)),\n }))\n .filter(og => og.options.length > 0);\n }\n\n return fields.filter(f => filterByComparator(field, operator, f));\n};\n","import type {\n FullField,\n GetOptionIdentifierType,\n ValueSourceFlexibleOptions,\n ValueSourceFullOptions,\n ValueSources,\n} from '../types';\nimport { lc } from './misc';\nimport { isFlexibleOptionArray, toFullOption, toFullOptionList } from './optGroupUtils';\n\nconst defaultValueSourcesArray: ValueSourceFullOptions = [\n { name: 'value', value: 'value', label: 'value' },\n];\n\nconst dummyFD = {\n name: 'name',\n value: 'name',\n valueSources: null,\n label: 'label',\n};\n\n/**\n * Utility function to get the value sources array for the given\n * field and operator. If the field definition does not define a\n * `valueSources` property, the `getValueSources` prop is used.\n * Returns `[FullOption<\"value\">]` by default.\n */\nexport const getValueSourcesUtil = <F extends FullField, O extends string>(\n fieldData: F,\n operator: string,\n getValueSources?: (\n field: GetOptionIdentifierType<F>,\n operator: O,\n misc: { fieldData: F }\n ) => ValueSources | ValueSourceFlexibleOptions\n): ValueSourceFullOptions => {\n // TypeScript doesn't allow it directly, but in practice\n // `fieldData` can end up being undefined or null. The nullish\n // coalescing assignment below avoids errors like\n // \"TypeError: Cannot read properties of undefined (reading 'name')\"\n const fd = fieldData ? toFullOption(fieldData) : dummyFD;\n\n let valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions) = fd.valueSources ?? false;\n\n if (typeof valueSourcesNEW === 'function') {\n valueSourcesNEW = valueSourcesNEW(operator as O);\n }\n\n if (!valueSourcesNEW && getValueSources) {\n valueSourcesNEW = getValueSources(fd.value as GetOptionIdentifierType<F>, operator as O, {\n fieldData: fd as F,\n });\n }\n\n if (!valueSourcesNEW) {\n return defaultValueSourcesArray;\n }\n\n if (isFlexibleOptionArray(valueSourcesNEW)) {\n return toFullOptionList(valueSourcesNEW as ValueSourceFullOptions) as ValueSourceFullOptions;\n }\n\n return valueSourcesNEW.map(\n vs =>\n defaultValueSourcesArray.find(dmm => dmm.value === lc(vs)) ?? {\n name: vs,\n value: vs,\n label: vs,\n }\n ) as ValueSourceFullOptions;\n};\n","import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n","// import type { UUID } from 'node:crypto';\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\n\n/**\n * Default `id` generator. Generates a valid v4 UUID. Uses `crypto.randomUUID()`\n * when available, otherwise uses an alternate method based on `getRandomValues`.\n * The returned string is guaranteed to match this regex:\n * ```\n * /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i\n * ```\n * @returns Valid v4 UUID\n */\n// Default implementation adapted from https://stackoverflow.com/a/68141099/217579\n// istanbul ignore next\nexport let generateID = (): UUID =>\n '00-0-4-2-000'.replaceAll(/[^-]/g, s =>\n (((Math.random() + Math.trunc(s as unknown as number)) * 0x1_00_00) >> Number.parseInt(s))\n .toString(16)\n .padStart(4, '0')\n ) as UUID;\n\n// Improve on the default implementation by using the crypto package if it's available\n// istanbul ignore else\nif (cryptoModule) {\n // istanbul ignore else\n if (typeof cryptoModule.randomUUID === 'function') {\n generateID = () => cryptoModule.randomUUID();\n } else if (typeof cryptoModule.getRandomValues === 'function') {\n // `randomUUID` is much simpler and faster, but it's only guaranteed to be\n // available in secure contexts (server-side, https, etc.). `generateID`\n // doesn't really need to be cryptographically secure, it only needs a\n // fairly low chance of collisions. We fall back to the always-available\n // `getRandomValues` here (while still generating a valid v4 UUID) when\n // `randomUUID` is not available.\n const position19vals = '89ab';\n const container = new Uint32Array(32);\n\n generateID = () => {\n cryptoModule.getRandomValues(container);\n let id = (container[0] % 16).toString(16);\n for (let i = 1; i < 32; i++) {\n if (i === 12) {\n id = `${id}${'4'}`;\n } else if (i === 16) {\n id = `${id}${position19vals[container[17] % 4]}`;\n } else {\n id = `${id}${(container[i] % 16).toString(16)}`;\n }\n\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n id = `${id}${'-'}`;\n }\n }\n return id as UUID;\n };\n }\n}\n","import { produce } from 'immer';\nimport type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { processMatchMode } from './formatQuery/utils';\nimport { generateID } from './generateID';\nimport { isRuleGroup } from './isRuleGroup';\n\n/**\n * Options for {@link prepareRule}/{@link prepareRuleGroup}.\n */\nexport interface PreparerOptions {\n idGenerator?: () => string;\n}\n\n/**\n * Ensures that a rule is valid by adding an `id` property if it does not already exist.\n */\nexport const prepareRule = (\n rule: RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleType =>\n produce(rule, draft => {\n if (!draft.id) {\n draft.id = idGenerator();\n }\n if (processMatchMode(draft)) {\n draft.value = prepareRuleGroup(draft.value, { idGenerator });\n }\n });\n\n/**\n * Ensures that a rule group is valid by recursively adding an `id` property to the group itself\n * and all its rules and subgroups where one does not already exist.\n */\nexport const prepareRuleGroup = <RG extends RuleGroupTypeAny>(\n queryObject: RG,\n { idGenerator = generateID }: PreparerOptions = {}\n): RG =>\n produce(queryObject, draft => {\n if (!draft.id) {\n draft.id = idGenerator();\n }\n draft.rules = draft.rules.map(r =>\n typeof r === 'string'\n ? r\n : isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator })\n ) as RuleGroupArray | RuleGroupICArray;\n });\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = <RG extends RuleGroupTypeAny>(\n rg: RG | RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleGroupType | RuleGroupTypeIC | RuleType =>\n isRuleGroup(rg) ? prepareRuleGroup(rg, { idGenerator }) : prepareRule(rg, { idGenerator });\n"],"mappings":";;;;;AAGA,MAAM,sBAAsB,OAAkB,UAAkB,mBAA8B;CAC5F,MAAM,YAAY,aAAa,MAAM;CACrC,MAAM,qBAAqB,aAAa,eAAe;AACvD,KAAI,UAAU,UAAU,mBAAmB,MACzC,QAAO;AAET,KAAI,OAAO,UAAU,eAAe,SAClC,QAAO,UAAU,UAAU,gBAAgB,mBAAmB,UAAU;AAE1E,QAAO,UAAU,aAAa,oBAAoB,SAAS,IAA+B;;;;;;;;;;;;;AAc5F,MAAa,4BAEX,OAEA,QACA,aAMS;AACT,KAAI,CAAC,MAAM,YAAY;EACrB,MAAM,sBAAsB,OACzB,EAAE,SAAoC,EAAE,WACxC,MAAM,SAAoC,MAAM;AACnD,MAAI,2BAA2B,OAAO,CACpC,QAAO,OAAO,KAAI,QAAO;GACvB,GAAG;GACH,SAAS,GAAG,QAAQ,QAAO,MAAK,mBAAmB,EAAE,CAAC;GACvD,EAAE;AAEL,SAAO,OAAO,QAAO,MAAK,mBAAmB,EAAE,CAAC;;AAGlD,KAAI,2BAA2B,OAAO,CACpC,QAAO,OACJ,KAAI,QAAO;EACV,GAAG;EACH,SAAS,GAAG,QAAQ,QAAO,MAAK,mBAAmB,OAAO,UAAU,EAAE,CAAC;EACxE,EAAE,CACF,QAAO,OAAM,GAAG,QAAQ,SAAS,EAAE;AAGxC,QAAO,OAAO,QAAO,MAAK,mBAAmB,OAAO,UAAU,EAAE,CAAC;;;;;AClDnE,MAAMA,2BAAmD,CACvD;CAAE,MAAM;CAAS,OAAO;CAAS,OAAO;CAAS,CAClD;AAED,MAAM,UAAU;CACd,MAAM;CACN,OAAO;CACP,cAAc;CACd,OAAO;CACR;;;;;;;AAQD,MAAa,uBACX,WACA,UACA,oBAK2B;CAK3B,MAAM,KAAK,YAAY,aAAa,UAAU,G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,OAAO,MAAM,WACT,IACA,YAAY,EAAE,GACZ,iBAAiB,GAAG,EAAE,aAAa,CAAC,GACpC,YAAY,GAAG,EAAE,aAAa,CAAC,CACtC;EACD"}
|
|
@@ -74,10 +74,7 @@ const getValueSourcesUtil = (fieldData, operator, getValueSources) => {
|
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/utils/parserUtils.ts
|
|
76
76
|
const getFieldsArray = (fields) => {
|
|
77
|
-
return require_utils.toFlatOptionArray(fields ? Array.isArray(fields) ? fields : Object.keys(fields).map((fld) => ({
|
|
78
|
-
...fields[fld],
|
|
79
|
-
name: fld
|
|
80
|
-
})).sort((a, b) => a.label.localeCompare(b.label)) : []);
|
|
77
|
+
return require_utils.toFlatOptionArray(fields ? Array.isArray(fields) ? fields : Object.keys(fields).map((fld) => Object.assign({}, fields[fld], { name: fld })).sort((a, b) => a.label.localeCompare(b.label)) : []);
|
|
81
78
|
};
|
|
82
79
|
function fieldIsValidUtil(params) {
|
|
83
80
|
const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;
|
|
@@ -169,4 +166,4 @@ Object.defineProperty(exports, 'prepareRuleGroup', {
|
|
|
169
166
|
return prepareRuleGroup;
|
|
170
167
|
}
|
|
171
168
|
});
|
|
172
|
-
//# sourceMappingURL=prepareQueryObjects-
|
|
169
|
+
//# sourceMappingURL=prepareQueryObjects-BxWvIPI4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareQueryObjects-BxWvIPI4.js","names":["toFullOption","isFlexibleOptionGroupArray","defaultValueSourcesArray: ValueSourceFullOptions","toFullOption","valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions)","isFlexibleOptionArray","toFullOptionList","lc","toFlatOptionArray","isFlexibleOptionArray","toFullOption","processMatchMode","isRuleGroup"],"sources":["../src/utils/filterFieldsByComparator.ts","../src/utils/getValueSourcesUtil.ts","../src/utils/parserUtils.ts","../src/utils/generateID.ts","../src/utils/prepareQueryObjects.ts"],"sourcesContent":["import type { FullField, OptionList, WithUnknownIndex } from '../types';\nimport { isFlexibleOptionGroupArray, toFullOption } from './optGroupUtils';\n\nconst filterByComparator = (field: FullField, operator: string, fieldToCompare: FullField) => {\n const fullField = toFullOption(field);\n const fullFieldToCompare = toFullOption(fieldToCompare);\n if (fullField.value === fullFieldToCompare.value) {\n return false;\n }\n if (typeof fullField.comparator === 'string') {\n return fullField[fullField.comparator] === fullFieldToCompare[fullField.comparator];\n }\n return fullField.comparator?.(fullFieldToCompare, operator) ?? /* istanbul ignore next */ false;\n};\n\n/**\n * For a given {@link FullField}, returns the `fields` list filtered for\n * other fields that match by `comparator`. Only fields *other than the\n * one in question* will ever be included, even if `comparator` is `null`\n * or `undefined`. If `comparator` is a string, fields with the same value\n * for that property will be included. If `comparator` is a function, each\n * field will be passed to the function along with the `operator` and fields\n * for which the function returns `true` will be included.\n *\n * @group Option Lists\n */\nexport const filterFieldsByComparator = (\n /** The field in question. */\n field: FullField,\n /** The full {@link FullField} list to be filtered. */\n fields: OptionList<FullField>,\n operator: string\n):\n | FullField[]\n | {\n options: WithUnknownIndex<FullField>[];\n label: string;\n }[] => {\n if (!field.comparator) {\n const filterOutSameField = (f: FullField) =>\n (f.value ?? /* istanbul ignore next */ f.name) !==\n (field.value ?? /* istanbul ignore next */ field.name);\n if (isFlexibleOptionGroupArray(fields)) {\n return fields.map(og => ({\n ...og,\n options: og.options.filter(v => filterOutSameField(v)),\n }));\n }\n return fields.filter(v => filterOutSameField(v));\n }\n\n if (isFlexibleOptionGroupArray(fields)) {\n return fields\n .map(og => ({\n ...og,\n options: og.options.filter(f => filterByComparator(field, operator, f)),\n }))\n .filter(og => og.options.length > 0);\n }\n\n return fields.filter(f => filterByComparator(field, operator, f));\n};\n","import type {\n FullField,\n GetOptionIdentifierType,\n ValueSourceFlexibleOptions,\n ValueSourceFullOptions,\n ValueSources,\n} from '../types';\nimport { lc } from './misc';\nimport { isFlexibleOptionArray, toFullOption, toFullOptionList } from './optGroupUtils';\n\nconst defaultValueSourcesArray: ValueSourceFullOptions = [\n { name: 'value', value: 'value', label: 'value' },\n];\n\nconst dummyFD = {\n name: 'name',\n value: 'name',\n valueSources: null,\n label: 'label',\n};\n\n/**\n * Utility function to get the value sources array for the given\n * field and operator. If the field definition does not define a\n * `valueSources` property, the `getValueSources` prop is used.\n * Returns `[FullOption<\"value\">]` by default.\n */\nexport const getValueSourcesUtil = <F extends FullField, O extends string>(\n fieldData: F,\n operator: string,\n getValueSources?: (\n field: GetOptionIdentifierType<F>,\n operator: O,\n misc: { fieldData: F }\n ) => ValueSources | ValueSourceFlexibleOptions\n): ValueSourceFullOptions => {\n // TypeScript doesn't allow it directly, but in practice\n // `fieldData` can end up being undefined or null. The nullish\n // coalescing assignment below avoids errors like\n // \"TypeError: Cannot read properties of undefined (reading 'name')\"\n const fd = fieldData ? toFullOption(fieldData) : dummyFD;\n\n let valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions) = fd.valueSources ?? false;\n\n if (typeof valueSourcesNEW === 'function') {\n valueSourcesNEW = valueSourcesNEW(operator as O);\n }\n\n if (!valueSourcesNEW && getValueSources) {\n valueSourcesNEW = getValueSources(fd.value as GetOptionIdentifierType<F>, operator as O, {\n fieldData: fd as F,\n });\n }\n\n if (!valueSourcesNEW) {\n return defaultValueSourcesArray;\n }\n\n if (isFlexibleOptionArray(valueSourcesNEW)) {\n return toFullOptionList(valueSourcesNEW as ValueSourceFullOptions) as ValueSourceFullOptions;\n }\n\n return valueSourcesNEW.map(\n vs =>\n defaultValueSourcesArray.find(dmm => dmm.value === lc(vs)) ?? {\n name: vs,\n value: vs,\n label: vs,\n }\n ) as ValueSourceFullOptions;\n};\n","import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n","// import type { UUID } from 'node:crypto';\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\n\n/**\n * Default `id` generator. Generates a valid v4 UUID. Uses `crypto.randomUUID()`\n * when available, otherwise uses an alternate method based on `getRandomValues`.\n * The returned string is guaranteed to match this regex:\n * ```\n * /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i\n * ```\n * @returns Valid v4 UUID\n */\n// Default implementation adapted from https://stackoverflow.com/a/68141099/217579\n// istanbul ignore next\nexport let generateID = (): UUID =>\n '00-0-4-2-000'.replaceAll(/[^-]/g, s =>\n (((Math.random() + Math.trunc(s as unknown as number)) * 0x1_00_00) >> Number.parseInt(s))\n .toString(16)\n .padStart(4, '0')\n ) as UUID;\n\n// Improve on the default implementation by using the crypto package if it's available\n// istanbul ignore else\nif (cryptoModule) {\n // istanbul ignore else\n if (typeof cryptoModule.randomUUID === 'function') {\n generateID = () => cryptoModule.randomUUID();\n } else if (typeof cryptoModule.getRandomValues === 'function') {\n // `randomUUID` is much simpler and faster, but it's only guaranteed to be\n // available in secure contexts (server-side, https, etc.). `generateID`\n // doesn't really need to be cryptographically secure, it only needs a\n // fairly low chance of collisions. We fall back to the always-available\n // `getRandomValues` here (while still generating a valid v4 UUID) when\n // `randomUUID` is not available.\n const position19vals = '89ab';\n const container = new Uint32Array(32);\n\n generateID = () => {\n cryptoModule.getRandomValues(container);\n let id = (container[0] % 16).toString(16);\n for (let i = 1; i < 32; i++) {\n if (i === 12) {\n id = `${id}${'4'}`;\n } else if (i === 16) {\n id = `${id}${position19vals[container[17] % 4]}`;\n } else {\n id = `${id}${(container[i] % 16).toString(16)}`;\n }\n\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n id = `${id}${'-'}`;\n }\n }\n return id as UUID;\n };\n }\n}\n","import { produce } from 'immer';\nimport type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { processMatchMode } from './formatQuery/utils';\nimport { generateID } from './generateID';\nimport { isRuleGroup } from './isRuleGroup';\n\n/**\n * Options for {@link prepareRule}/{@link prepareRuleGroup}.\n */\nexport interface PreparerOptions {\n idGenerator?: () => string;\n}\n\n/**\n * Ensures that a rule is valid by adding an `id` property if it does not already exist.\n */\nexport const prepareRule = (\n rule: RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleType =>\n produce(rule, draft => {\n if (!draft.id) {\n draft.id = idGenerator();\n }\n if (processMatchMode(draft)) {\n draft.value = prepareRuleGroup(draft.value, { idGenerator });\n }\n });\n\n/**\n * Ensures that a rule group is valid by recursively adding an `id` property to the group itself\n * and all its rules and subgroups where one does not already exist.\n */\nexport const prepareRuleGroup = <RG extends RuleGroupTypeAny>(\n queryObject: RG,\n { idGenerator = generateID }: PreparerOptions = {}\n): RG =>\n produce(queryObject, draft => {\n if (!draft.id) {\n draft.id = idGenerator();\n }\n draft.rules = draft.rules.map(r =>\n typeof r === 'string'\n ? r\n : isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator })\n ) as RuleGroupArray | RuleGroupICArray;\n });\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = <RG extends RuleGroupTypeAny>(\n rg: RG | RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleGroupType | RuleGroupTypeIC | RuleType =>\n isRuleGroup(rg) ? prepareRuleGroup(rg, { idGenerator }) : prepareRule(rg, { idGenerator });\n"],"mappings":";;;;;;AAGA,MAAM,sBAAsB,OAAkB,UAAkB,mBAA8B;CAC5F,MAAM,YAAYA,2BAAa,MAAM;CACrC,MAAM,qBAAqBA,2BAAa,eAAe;AACvD,KAAI,UAAU,UAAU,mBAAmB,MACzC,QAAO;AAET,KAAI,OAAO,UAAU,eAAe,SAClC,QAAO,UAAU,UAAU,gBAAgB,mBAAmB,UAAU;AAE1E,QAAO,UAAU,aAAa,oBAAoB,SAAS,IAA+B;;;;;;;;;;;;;AAc5F,MAAa,4BA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AAiB;EACvB,MAAM,YAAY,IAAI,YAAY,GAAG;AAErC,qBAAmB;AACjB,gBAAa,gBAAgB,UAAU;GACvC,IAAI,MAAM,UAAU,KAAK,IAAI,SAAS,GAAG;AACzC,QAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;AAC3B,QAAI,MAAM,GACR,MAAK,GAAG;aACC,MAAM,GACf,MAAK,GAAG,KAAK,eAAe,UAAU,MAAM;QAE5C,MAAK,GAAG,MAAM,UAAU,KAAK,IAAI,SAAS,GAAG;AAG/C,QAAI,MAAM,KAAK,MAAM,MAAM,MAAM,MAAM,MAAM,GAC3C,MAAK,GAAG;;AAGZ,UAAO;;;;;;;;;;AChCb,MAAa,eACX,MACA,EAAE,cAAc,eAAgC,EAAE,wBAE1C,OAAM,UAAS;AACrB,KAAI,CAAC,MAAM,GACT,OAAM,KAAK,aAAa;AAE1B,KAAIC,+BAAiB,MAAM,CACzB,OAAM,QAAQ,iBAAiB,MAAM,OAAO,EAAE,aAAa,CAAC;EAE9D;;;;;AAMJ,MAAa,oBACX,aACA,EAAE,cAAc,eAAgC,EAAE,wBAE1C,cAAa,UAAS;AAC5B,KAAI,CAAC,MAAM,GACT,OAAM,KAAK,aAAa;AAE1B,OAAM,QAAQ,MAAM,MAAM,KAAI,MAC5B,OAAO,MAAM,WACT,IACAC,gCAAY,EAAE,GACZ,iBAAiB,GAAG,EAAE,aAAa,CAAC,GACpC,YAAY,GAAG,EAAE,aAAa,CAAC,CACtC;EACD"}
|
|
@@ -567,9 +567,9 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
567
567
|
@category Type Guard
|
|
568
568
|
@category Utilities
|
|
569
569
|
*/
|
|
570
|
-
type IsEqual<A
|
|
570
|
+
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
571
571
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
572
|
-
type _IsEqual<A
|
|
572
|
+
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
573
573
|
//#endregion
|
|
574
574
|
//#region ../../node_modules/type-fest/source/omit-index-signature.d.ts
|
|
575
575
|
/**
|
|
@@ -963,7 +963,7 @@ const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
|
|
|
963
963
|
|
|
964
964
|
@category Object
|
|
965
965
|
*/
|
|
966
|
-
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever<KeysType>, never, _RequireAtLeastOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
966
|
+
type RequireAtLeastOne$1<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever<KeysType>, never, _RequireAtLeastOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
967
967
|
type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = {
|
|
968
968
|
// For each `Key` in `KeysType` make a mapped type:
|
|
969
969
|
[Key in KeysType]-?: Required<Pick<ObjectType, Key>> &
|
|
@@ -1105,7 +1105,7 @@ type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] =
|
|
|
1105
1105
|
: never; // Should never happen
|
|
1106
1106
|
//#endregion
|
|
1107
1107
|
//#region src/types/options.d.ts
|
|
1108
|
-
type RequireAtLeastOne
|
|
1108
|
+
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
|
|
1109
1109
|
type StringUnionToFlexibleOptionArray<Op extends string> = Array<Op extends unknown ? FlexibleOption<Op> : never>;
|
|
1110
1110
|
type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown ? FullOption<Op> : never>;
|
|
1111
1111
|
/**
|
|
@@ -1120,7 +1120,7 @@ type GetOptionType<OL extends FlexibleOptionList<FullOption>> = OL extends Flexi
|
|
|
1120
1120
|
*
|
|
1121
1121
|
* @group Option Lists
|
|
1122
1122
|
*/
|
|
1123
|
-
type GetOptionIdentifierType<Opt
|
|
1123
|
+
type GetOptionIdentifierType<Opt extends BaseOption> = Opt extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
|
|
1124
1124
|
/**
|
|
1125
1125
|
* Adds an `unknown` index property to an interface.
|
|
1126
1126
|
*/
|
|
@@ -1162,14 +1162,14 @@ type ValueOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequi
|
|
|
1162
1162
|
*
|
|
1163
1163
|
* @group Option Lists
|
|
1164
1164
|
*/
|
|
1165
|
-
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne
|
|
1165
|
+
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne<BaseOption<N>, "name" | "value">>>;
|
|
1166
1166
|
/**
|
|
1167
1167
|
* Utility type to turn an {@link Option}, {@link ValueOption}, or {@link BaseOption}
|
|
1168
1168
|
* into a {@link FlexibleOption}.
|
|
1169
1169
|
*
|
|
1170
1170
|
* @group Option Lists
|
|
1171
1171
|
*/
|
|
1172
|
-
type ToFlexibleOption<Opt
|
|
1172
|
+
type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
|
|
1173
1173
|
/**
|
|
1174
1174
|
* A generic {@link Option} requiring both `name` _and_ `value` properties.
|
|
1175
1175
|
* Props that extend {@link OptionList} accept {@link BaseOption}, but
|
|
@@ -1197,7 +1197,7 @@ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption
|
|
|
1197
1197
|
*
|
|
1198
1198
|
* @group Option Lists
|
|
1199
1199
|
*/
|
|
1200
|
-
type ToFullOption<Opt
|
|
1200
|
+
type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
|
|
1201
1201
|
/**
|
|
1202
1202
|
* @deprecated Renamed to {@link Option}.
|
|
1203
1203
|
*
|
|
@@ -1209,39 +1209,39 @@ type NameLabelPair<N extends string = string> = Option<N>;
|
|
|
1209
1209
|
*
|
|
1210
1210
|
* @group Option Lists
|
|
1211
1211
|
*/
|
|
1212
|
-
interface OptionGroup<Opt
|
|
1212
|
+
interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
|
|
1213
1213
|
label: string;
|
|
1214
|
-
options: WithUnknownIndex<Opt
|
|
1214
|
+
options: WithUnknownIndex<Opt>[];
|
|
1215
1215
|
}
|
|
1216
1216
|
/**
|
|
1217
1217
|
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
|
|
1218
1218
|
*
|
|
1219
1219
|
* @group Option Lists
|
|
1220
1220
|
*/
|
|
1221
|
-
type FlexibleOptionGroup<Opt
|
|
1221
|
+
type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
|
|
1222
1222
|
label: string;
|
|
1223
|
-
options: (Opt
|
|
1223
|
+
options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
|
|
1224
1224
|
};
|
|
1225
1225
|
/**
|
|
1226
1226
|
* Either an array of {@link Option}s or an array of {@link OptionGroup}s.
|
|
1227
1227
|
*
|
|
1228
1228
|
* @group Option Lists
|
|
1229
1229
|
*/
|
|
1230
|
-
type OptionList<Opt
|
|
1230
|
+
type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
|
|
1231
1231
|
/**
|
|
1232
1232
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1233
1233
|
* may use either `name` or `value` as the primary identifier.
|
|
1234
1234
|
*
|
|
1235
1235
|
* @group Option Lists
|
|
1236
1236
|
*/
|
|
1237
|
-
type FlexibleOptionList<Opt
|
|
1237
|
+
type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
|
|
1238
1238
|
/**
|
|
1239
1239
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1240
1240
|
* may use either `name` or `value` as the primary identifier.
|
|
1241
1241
|
*
|
|
1242
1242
|
* @group Option Lists
|
|
1243
1243
|
*/
|
|
1244
|
-
type FlexibleOptionListProp<Opt
|
|
1244
|
+
type FlexibleOptionListProp<Opt extends BaseOption> = (ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>>[];
|
|
1245
1245
|
/**
|
|
1246
1246
|
* An array of options or option groups, like {@link OptionList}, but using
|
|
1247
1247
|
* {@link FullOption} instead of {@link Option}. This means that every member is
|
|
@@ -1249,7 +1249,7 @@ type FlexibleOptionListProp<Opt$1 extends BaseOption> = (ToFlexibleOption<Opt$1>
|
|
|
1249
1249
|
*
|
|
1250
1250
|
* @group Option Lists
|
|
1251
1251
|
*/
|
|
1252
|
-
type FullOptionList<Opt
|
|
1252
|
+
type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
|
|
1253
1253
|
/**
|
|
1254
1254
|
* Map of option identifiers to their respective {@link Option}.
|
|
1255
1255
|
*
|
|
@@ -1317,7 +1317,7 @@ type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType
|
|
|
1317
1317
|
* All updateable properties of rules and groups (everything except
|
|
1318
1318
|
* `id`, `path`, and `rules`).
|
|
1319
1319
|
*/
|
|
1320
|
-
type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), "id" | "path" | "rules"
|
|
1320
|
+
type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), "id" | "path" | "rules"> | (string & {});
|
|
1321
1321
|
/**
|
|
1322
1322
|
* The type of the `rules` array in a {@link DefaultRuleGroupType}.
|
|
1323
1323
|
*/
|
|
@@ -3719,14 +3719,14 @@ declare const objectEntries: <Type extends Record<PropertyKey, unknown>>(value:
|
|
|
3719
3719
|
*
|
|
3720
3720
|
* @group Option Lists
|
|
3721
3721
|
*/
|
|
3722
|
-
declare function toFullOption<Opt
|
|
3722
|
+
declare function toFullOption<Opt extends BaseOption>(opt: Opt | string, baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): ToFullOption<Opt>;
|
|
3723
3723
|
/**
|
|
3724
3724
|
* Converts an {@link OptionList} or {@link FlexibleOptionList} into a {@link FullOptionList}.
|
|
3725
3725
|
* Lists of full options are left unchanged.
|
|
3726
3726
|
*
|
|
3727
3727
|
* @group Option Lists
|
|
3728
3728
|
*/
|
|
3729
|
-
declare function toFullOptionList<Opt
|
|
3729
|
+
declare function toFullOptionList<Opt extends BaseOption>(optList: unknown[], baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): FullOptionList<Opt>;
|
|
3730
3730
|
/**
|
|
3731
3731
|
* Converts a {@link FlexibleOptionList} into a {@link FullOptionList}.
|
|
3732
3732
|
* Lists of full options are left unchanged.
|
|
@@ -3752,7 +3752,7 @@ declare const uniqByName: <T extends {
|
|
|
3752
3752
|
*
|
|
3753
3753
|
* @group Option Lists
|
|
3754
3754
|
*/
|
|
3755
|
-
declare const uniqByIdentifier: <T extends RequireAtLeastOne<{
|
|
3755
|
+
declare const uniqByIdentifier: <T extends RequireAtLeastOne$1<{
|
|
3756
3756
|
name: string;
|
|
3757
3757
|
value: string;
|
|
3758
3758
|
}, "name" | "value">>(originalArray: T[]) => T[];
|
|
@@ -3808,9 +3808,9 @@ declare function getOption<OptType extends Option>(arr: FlexibleOptionList<OptTy
|
|
|
3808
3808
|
*
|
|
3809
3809
|
* @group Option Lists
|
|
3810
3810
|
*/
|
|
3811
|
-
declare function getFirstOption<Opt
|
|
3812
|
-
declare function getFirstOption<Opt
|
|
3813
|
-
declare function getFirstOption<Opt
|
|
3811
|
+
declare function getFirstOption<Opt extends FullOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3812
|
+
declare function getFirstOption<Opt extends ValueOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3813
|
+
declare function getFirstOption<Opt extends Option>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3814
3814
|
/**
|
|
3815
3815
|
* Flattens {@link FlexibleOptionGroup} arrays into {@link BaseOption} arrays.
|
|
3816
3816
|
* If the array is already flat, it is returned as is.
|
|
@@ -567,9 +567,9 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
567
567
|
@category Type Guard
|
|
568
568
|
@category Utilities
|
|
569
569
|
*/
|
|
570
|
-
type IsEqual<A
|
|
570
|
+
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
571
571
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
572
|
-
type _IsEqual<A
|
|
572
|
+
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
573
573
|
//#endregion
|
|
574
574
|
//#region ../../node_modules/type-fest/source/omit-index-signature.d.ts
|
|
575
575
|
/**
|
|
@@ -963,7 +963,7 @@ const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
|
|
|
963
963
|
|
|
964
964
|
@category Object
|
|
965
965
|
*/
|
|
966
|
-
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever<KeysType>, never, _RequireAtLeastOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
966
|
+
type RequireAtLeastOne$1<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever<KeysType>, never, _RequireAtLeastOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
967
967
|
type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = {
|
|
968
968
|
// For each `Key` in `KeysType` make a mapped type:
|
|
969
969
|
[Key in KeysType]-?: Required<Pick<ObjectType, Key>> &
|
|
@@ -1105,7 +1105,7 @@ type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] =
|
|
|
1105
1105
|
: never; // Should never happen
|
|
1106
1106
|
//#endregion
|
|
1107
1107
|
//#region src/types/options.d.ts
|
|
1108
|
-
type RequireAtLeastOne
|
|
1108
|
+
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
|
|
1109
1109
|
type StringUnionToFlexibleOptionArray<Op extends string> = Array<Op extends unknown ? FlexibleOption<Op> : never>;
|
|
1110
1110
|
type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown ? FullOption<Op> : never>;
|
|
1111
1111
|
/**
|
|
@@ -1120,7 +1120,7 @@ type GetOptionType<OL extends FlexibleOptionList<FullOption>> = OL extends Flexi
|
|
|
1120
1120
|
*
|
|
1121
1121
|
* @group Option Lists
|
|
1122
1122
|
*/
|
|
1123
|
-
type GetOptionIdentifierType<Opt
|
|
1123
|
+
type GetOptionIdentifierType<Opt extends BaseOption> = Opt extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
|
|
1124
1124
|
/**
|
|
1125
1125
|
* Adds an `unknown` index property to an interface.
|
|
1126
1126
|
*/
|
|
@@ -1162,14 +1162,14 @@ type ValueOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequi
|
|
|
1162
1162
|
*
|
|
1163
1163
|
* @group Option Lists
|
|
1164
1164
|
*/
|
|
1165
|
-
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne
|
|
1165
|
+
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne<BaseOption<N>, "name" | "value">>>;
|
|
1166
1166
|
/**
|
|
1167
1167
|
* Utility type to turn an {@link Option}, {@link ValueOption}, or {@link BaseOption}
|
|
1168
1168
|
* into a {@link FlexibleOption}.
|
|
1169
1169
|
*
|
|
1170
1170
|
* @group Option Lists
|
|
1171
1171
|
*/
|
|
1172
|
-
type ToFlexibleOption<Opt
|
|
1172
|
+
type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
|
|
1173
1173
|
/**
|
|
1174
1174
|
* A generic {@link Option} requiring both `name` _and_ `value` properties.
|
|
1175
1175
|
* Props that extend {@link OptionList} accept {@link BaseOption}, but
|
|
@@ -1197,7 +1197,7 @@ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption
|
|
|
1197
1197
|
*
|
|
1198
1198
|
* @group Option Lists
|
|
1199
1199
|
*/
|
|
1200
|
-
type ToFullOption<Opt
|
|
1200
|
+
type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
|
|
1201
1201
|
/**
|
|
1202
1202
|
* @deprecated Renamed to {@link Option}.
|
|
1203
1203
|
*
|
|
@@ -1209,39 +1209,39 @@ type NameLabelPair<N extends string = string> = Option<N>;
|
|
|
1209
1209
|
*
|
|
1210
1210
|
* @group Option Lists
|
|
1211
1211
|
*/
|
|
1212
|
-
interface OptionGroup<Opt
|
|
1212
|
+
interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
|
|
1213
1213
|
label: string;
|
|
1214
|
-
options: WithUnknownIndex<Opt
|
|
1214
|
+
options: WithUnknownIndex<Opt>[];
|
|
1215
1215
|
}
|
|
1216
1216
|
/**
|
|
1217
1217
|
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
|
|
1218
1218
|
*
|
|
1219
1219
|
* @group Option Lists
|
|
1220
1220
|
*/
|
|
1221
|
-
type FlexibleOptionGroup<Opt
|
|
1221
|
+
type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
|
|
1222
1222
|
label: string;
|
|
1223
|
-
options: (Opt
|
|
1223
|
+
options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
|
|
1224
1224
|
};
|
|
1225
1225
|
/**
|
|
1226
1226
|
* Either an array of {@link Option}s or an array of {@link OptionGroup}s.
|
|
1227
1227
|
*
|
|
1228
1228
|
* @group Option Lists
|
|
1229
1229
|
*/
|
|
1230
|
-
type OptionList<Opt
|
|
1230
|
+
type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
|
|
1231
1231
|
/**
|
|
1232
1232
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1233
1233
|
* may use either `name` or `value` as the primary identifier.
|
|
1234
1234
|
*
|
|
1235
1235
|
* @group Option Lists
|
|
1236
1236
|
*/
|
|
1237
|
-
type FlexibleOptionList<Opt
|
|
1237
|
+
type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
|
|
1238
1238
|
/**
|
|
1239
1239
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1240
1240
|
* may use either `name` or `value` as the primary identifier.
|
|
1241
1241
|
*
|
|
1242
1242
|
* @group Option Lists
|
|
1243
1243
|
*/
|
|
1244
|
-
type FlexibleOptionListProp<Opt
|
|
1244
|
+
type FlexibleOptionListProp<Opt extends BaseOption> = (ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>>[];
|
|
1245
1245
|
/**
|
|
1246
1246
|
* An array of options or option groups, like {@link OptionList}, but using
|
|
1247
1247
|
* {@link FullOption} instead of {@link Option}. This means that every member is
|
|
@@ -1249,7 +1249,7 @@ type FlexibleOptionListProp<Opt$1 extends BaseOption> = (ToFlexibleOption<Opt$1>
|
|
|
1249
1249
|
*
|
|
1250
1250
|
* @group Option Lists
|
|
1251
1251
|
*/
|
|
1252
|
-
type FullOptionList<Opt
|
|
1252
|
+
type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
|
|
1253
1253
|
/**
|
|
1254
1254
|
* Map of option identifiers to their respective {@link Option}.
|
|
1255
1255
|
*
|
|
@@ -1317,7 +1317,7 @@ type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType
|
|
|
1317
1317
|
* All updateable properties of rules and groups (everything except
|
|
1318
1318
|
* `id`, `path`, and `rules`).
|
|
1319
1319
|
*/
|
|
1320
|
-
type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), "id" | "path" | "rules"
|
|
1320
|
+
type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), "id" | "path" | "rules"> | (string & {});
|
|
1321
1321
|
/**
|
|
1322
1322
|
* The type of the `rules` array in a {@link DefaultRuleGroupType}.
|
|
1323
1323
|
*/
|
|
@@ -3719,14 +3719,14 @@ declare const objectEntries: <Type extends Record<PropertyKey, unknown>>(value:
|
|
|
3719
3719
|
*
|
|
3720
3720
|
* @group Option Lists
|
|
3721
3721
|
*/
|
|
3722
|
-
declare function toFullOption<Opt
|
|
3722
|
+
declare function toFullOption<Opt extends BaseOption>(opt: Opt | string, baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): ToFullOption<Opt>;
|
|
3723
3723
|
/**
|
|
3724
3724
|
* Converts an {@link OptionList} or {@link FlexibleOptionList} into a {@link FullOptionList}.
|
|
3725
3725
|
* Lists of full options are left unchanged.
|
|
3726
3726
|
*
|
|
3727
3727
|
* @group Option Lists
|
|
3728
3728
|
*/
|
|
3729
|
-
declare function toFullOptionList<Opt
|
|
3729
|
+
declare function toFullOptionList<Opt extends BaseOption>(optList: unknown[], baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): FullOptionList<Opt>;
|
|
3730
3730
|
/**
|
|
3731
3731
|
* Converts a {@link FlexibleOptionList} into a {@link FullOptionList}.
|
|
3732
3732
|
* Lists of full options are left unchanged.
|
|
@@ -3752,7 +3752,7 @@ declare const uniqByName: <T extends {
|
|
|
3752
3752
|
*
|
|
3753
3753
|
* @group Option Lists
|
|
3754
3754
|
*/
|
|
3755
|
-
declare const uniqByIdentifier: <T extends RequireAtLeastOne<{
|
|
3755
|
+
declare const uniqByIdentifier: <T extends RequireAtLeastOne$1<{
|
|
3756
3756
|
name: string;
|
|
3757
3757
|
value: string;
|
|
3758
3758
|
}, "name" | "value">>(originalArray: T[]) => T[];
|
|
@@ -3808,9 +3808,9 @@ declare function getOption<OptType extends Option>(arr: FlexibleOptionList<OptTy
|
|
|
3808
3808
|
*
|
|
3809
3809
|
* @group Option Lists
|
|
3810
3810
|
*/
|
|
3811
|
-
declare function getFirstOption<Opt
|
|
3812
|
-
declare function getFirstOption<Opt
|
|
3813
|
-
declare function getFirstOption<Opt
|
|
3811
|
+
declare function getFirstOption<Opt extends FullOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3812
|
+
declare function getFirstOption<Opt extends ValueOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3813
|
+
declare function getFirstOption<Opt extends Option>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3814
3814
|
/**
|
|
3815
3815
|
* Flattens {@link FlexibleOptionGroup} arrays into {@link BaseOption} arrays.
|
|
3816
3816
|
* If the array is already flat, it is returned as is.
|
|
@@ -695,7 +695,7 @@ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "str
|
|
|
695
695
|
const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
|
|
696
696
|
|
|
697
697
|
//#endregion
|
|
698
|
-
//#region \0@oxc-project+runtime@0.
|
|
698
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/typeof.js
|
|
699
699
|
function _typeof(o) {
|
|
700
700
|
"@babel/helpers - typeof";
|
|
701
701
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
@@ -706,7 +706,7 @@ function _typeof(o) {
|
|
|
706
706
|
}
|
|
707
707
|
|
|
708
708
|
//#endregion
|
|
709
|
-
//#region \0@oxc-project+runtime@0.
|
|
709
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/toPrimitive.js
|
|
710
710
|
function toPrimitive(t, r) {
|
|
711
711
|
if ("object" != _typeof(t) || !t) return t;
|
|
712
712
|
var e = t[Symbol.toPrimitive];
|
|
@@ -719,14 +719,14 @@ function toPrimitive(t, r) {
|
|
|
719
719
|
}
|
|
720
720
|
|
|
721
721
|
//#endregion
|
|
722
|
-
//#region \0@oxc-project+runtime@0.
|
|
722
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/toPropertyKey.js
|
|
723
723
|
function toPropertyKey(t) {
|
|
724
724
|
var i = toPrimitive(t, "string");
|
|
725
725
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
726
726
|
}
|
|
727
727
|
|
|
728
728
|
//#endregion
|
|
729
|
-
//#region \0@oxc-project+runtime@0.
|
|
729
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/defineProperty.js
|
|
730
730
|
function _defineProperty(e, r, t) {
|
|
731
731
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
732
732
|
value: t,
|
|
@@ -737,7 +737,7 @@ function _defineProperty(e, r, t) {
|
|
|
737
737
|
}
|
|
738
738
|
|
|
739
739
|
//#endregion
|
|
740
|
-
//#region \0@oxc-project+runtime@0.
|
|
740
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/objectSpread2.js
|
|
741
741
|
function ownKeys(e, r) {
|
|
742
742
|
var t = Object.keys(e);
|
|
743
743
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -761,7 +761,7 @@ function _objectSpread2(e) {
|
|
|
761
761
|
}
|
|
762
762
|
|
|
763
763
|
//#endregion
|
|
764
|
-
//#region \0@oxc-project+runtime@0.
|
|
764
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/objectWithoutPropertiesLoose.js
|
|
765
765
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
766
766
|
if (null == r) return {};
|
|
767
767
|
var t = {};
|
|
@@ -773,7 +773,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
773
773
|
}
|
|
774
774
|
|
|
775
775
|
//#endregion
|
|
776
|
-
//#region \0@oxc-project+runtime@0.
|
|
776
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/objectWithoutProperties.js
|
|
777
777
|
function _objectWithoutProperties(e, t) {
|
|
778
778
|
if (null == e) return {};
|
|
779
779
|
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
@@ -2649,7 +2649,27 @@ const defaultRuleProcessorElasticSearch = (rule, options = {}) => {
|
|
|
2649
2649
|
const { field, operator, value, valueSource } = rule;
|
|
2650
2650
|
const { parseNumbers, preserveValueOrder } = options;
|
|
2651
2651
|
const operatorLC = lc(operator);
|
|
2652
|
-
|
|
2652
|
+
const matchEval = processMatchMode(rule);
|
|
2653
|
+
if (matchEval === false) return false;
|
|
2654
|
+
else if (matchEval) {
|
|
2655
|
+
const { mode } = matchEval;
|
|
2656
|
+
const subQuery = defaultRuleGroupProcessorElasticSearch(transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: r.field ? `${field}.${r.field}` : field }) }), options);
|
|
2657
|
+
if (Object.keys(subQuery).length === 0) return false;
|
|
2658
|
+
switch (mode) {
|
|
2659
|
+
case "some": return { nested: {
|
|
2660
|
+
path: field,
|
|
2661
|
+
query: subQuery
|
|
2662
|
+
} };
|
|
2663
|
+
case "none": return { bool: { must_not: { nested: {
|
|
2664
|
+
path: field,
|
|
2665
|
+
query: subQuery
|
|
2666
|
+
} } } };
|
|
2667
|
+
case "all":
|
|
2668
|
+
case "atleast":
|
|
2669
|
+
case "atmost":
|
|
2670
|
+
case "exactly": return false;
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2653
2673
|
if (valueSource === "field") {
|
|
2654
2674
|
if (toArray(value).some((v) => typeof v !== "string")) return false;
|
|
2655
2675
|
const fieldForScript = escapeSQ(field);
|