@dbsp/nql 1.0.0 → 1.0.2
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/index.d.ts +2 -0
- package/dist/index.js +24 -2
- package/dist/index.js.map +1 -1
- package/package.json +61 -61
package/dist/index.d.ts
CHANGED
|
@@ -438,6 +438,8 @@ interface NqlCompilerOptions {
|
|
|
438
438
|
readonly recursiveKeywords?: readonly string[];
|
|
439
439
|
/** BATCH-001: Named parameters for ANY(:param) expressions */
|
|
440
440
|
readonly params?: Readonly<Record<string, unknown>>;
|
|
441
|
+
/** Maximum number of items allowed in an ANY(:param) array. Defaults to MAX_ANY_ITEMS (10000). */
|
|
442
|
+
readonly maxAnyItems?: number;
|
|
441
443
|
}
|
|
442
444
|
|
|
443
445
|
/**
|
package/dist/index.js
CHANGED
|
@@ -787,6 +787,7 @@ function getISOWeekCount(year) {
|
|
|
787
787
|
}
|
|
788
788
|
|
|
789
789
|
// src/compiler/compile-expression.ts
|
|
790
|
+
var MAX_ANY_ITEMS = 1e4;
|
|
790
791
|
function compileLogical(expr, ctx, fns, aliasContext, outerAliases) {
|
|
791
792
|
if (expr.type === "binary") {
|
|
792
793
|
const binary = expr;
|
|
@@ -961,7 +962,19 @@ function compileMembership(expr, ctx, fns, aliasContext, outerAliases) {
|
|
|
961
962
|
}
|
|
962
963
|
validateWhereField(ctx, field2, aliasContext, anyExpr.column);
|
|
963
964
|
const rawValues = ctx.params[anyExpr.paramName];
|
|
964
|
-
|
|
965
|
+
if (!Array.isArray(rawValues)) {
|
|
966
|
+
throw new NqlSemanticException(
|
|
967
|
+
NqlErrorCodes.SEM_INVALID_SYNTAX,
|
|
968
|
+
`ANY(:${anyExpr.paramName}) requires an array argument but received ${rawValues === void 0 ? "undefined (parameter not bound)" : typeof rawValues}`
|
|
969
|
+
);
|
|
970
|
+
}
|
|
971
|
+
if (rawValues.length > ctx.maxAnyItems) {
|
|
972
|
+
throw new NqlSemanticException(
|
|
973
|
+
NqlErrorCodes.SEM_INVALID_SYNTAX,
|
|
974
|
+
`ANY(:${anyExpr.paramName}) array length ${rawValues.length} exceeds maximum of ${ctx.maxAnyItems}`
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
const values2 = rawValues;
|
|
965
978
|
return { kind: "any", field: field2, values: values2 };
|
|
966
979
|
}
|
|
967
980
|
const inExpr = expr;
|
|
@@ -1900,13 +1913,22 @@ var NqlCompiler = class {
|
|
|
1900
1913
|
const recursive = options?.recursiveKeywords ?? DEFAULT_RECURSIVE_KEYWORDS;
|
|
1901
1914
|
const recursiveKeywords = new Set(recursive.map((k) => k.toLowerCase()));
|
|
1902
1915
|
const validator = schema ? new ColumnValidator(schema) : null;
|
|
1916
|
+
const maxAnyItemsRaw = options?.maxAnyItems;
|
|
1917
|
+
if (maxAnyItemsRaw !== void 0) {
|
|
1918
|
+
if (!Number.isSafeInteger(maxAnyItemsRaw) || maxAnyItemsRaw <= 0) {
|
|
1919
|
+
throw new Error(
|
|
1920
|
+
`Invalid maxAnyItems: ${maxAnyItemsRaw}. Must be a positive integer.`
|
|
1921
|
+
);
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1903
1924
|
this.ctx = {
|
|
1904
1925
|
currentFromTable: void 0,
|
|
1905
1926
|
currentRelationTarget: void 0,
|
|
1906
1927
|
pseudoColumnKeywords,
|
|
1907
1928
|
recursiveKeywords,
|
|
1908
1929
|
validator,
|
|
1909
|
-
params: options?.params ?? {}
|
|
1930
|
+
params: options?.params ?? {},
|
|
1931
|
+
maxAnyItems: maxAnyItemsRaw ?? MAX_ANY_ITEMS
|
|
1910
1932
|
};
|
|
1911
1933
|
this.fns = {
|
|
1912
1934
|
compileQuery: (query, ctx) => compileQuery(query, ctx, this.fns),
|