joist-core 2.3.0-next.87 → 2.3.0-next.89
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/build/EntityManager.cjs.map +1 -1
- package/build/EntityManager.d.cts +3 -3
- package/build/EntityManager.d.cts.map +1 -1
- package/build/EntityManager.d.mts +3 -3
- package/build/EntityManager.d.mts.map +1 -1
- package/build/EntityManager.js.map +1 -1
- package/build/Expr.cjs +12 -6
- package/build/Expr.cjs.map +1 -1
- package/build/Expr.d.cts +4 -4
- package/build/Expr.d.cts.map +1 -1
- package/build/Expr.d.mts +4 -4
- package/build/Expr.d.mts.map +1 -1
- package/build/Expr.js +12 -6
- package/build/Expr.js.map +1 -1
- package/build/expressions/case.cjs +71 -0
- package/build/expressions/case.cjs.map +1 -0
- package/build/expressions/case.d.cts +57 -0
- package/build/expressions/case.d.cts.map +1 -0
- package/build/expressions/case.d.mts +57 -0
- package/build/expressions/case.d.mts.map +1 -0
- package/build/expressions/case.js +68 -0
- package/build/expressions/case.js.map +1 -0
- package/build/expressions/coalesce.cjs +25 -0
- package/build/expressions/coalesce.cjs.map +1 -0
- package/build/expressions/coalesce.d.cts +21 -0
- package/build/expressions/coalesce.d.cts.map +1 -0
- package/build/expressions/coalesce.d.mts +21 -0
- package/build/expressions/coalesce.d.mts.map +1 -0
- package/build/expressions/coalesce.js +22 -0
- package/build/expressions/coalesce.js.map +1 -0
- package/build/expressions/codecs.cjs +112 -0
- package/build/expressions/codecs.cjs.map +1 -0
- package/build/expressions/codecs.d.cts +11 -0
- package/build/expressions/codecs.d.cts.map +1 -0
- package/build/expressions/codecs.d.mts +11 -0
- package/build/expressions/codecs.d.mts.map +1 -0
- package/build/expressions/codecs.js +111 -0
- package/build/expressions/codecs.js.map +1 -0
- package/build/expressions/expression.cjs +99 -0
- package/build/expressions/expression.cjs.map +1 -0
- package/build/expressions/expression.d.cts +23 -0
- package/build/expressions/expression.d.cts.map +1 -0
- package/build/expressions/expression.d.mts +23 -0
- package/build/expressions/expression.d.mts.map +1 -0
- package/build/expressions/expression.js +94 -0
- package/build/expressions/expression.js.map +1 -0
- package/build/expressions/greatest.cjs +25 -0
- package/build/expressions/greatest.cjs.map +1 -0
- package/build/expressions/greatest.d.cts +21 -0
- package/build/expressions/greatest.d.cts.map +1 -0
- package/build/expressions/greatest.d.mts +21 -0
- package/build/expressions/greatest.d.mts.map +1 -0
- package/build/expressions/greatest.js +22 -0
- package/build/expressions/greatest.js.map +1 -0
- package/build/expressions/least.cjs +25 -0
- package/build/expressions/least.cjs.map +1 -0
- package/build/expressions/least.d.cts +21 -0
- package/build/expressions/least.d.cts.map +1 -0
- package/build/expressions/least.d.mts +21 -0
- package/build/expressions/least.d.mts.map +1 -0
- package/build/expressions/least.js +22 -0
- package/build/expressions/least.js.map +1 -0
- package/build/expressions/nullIf.cjs +27 -0
- package/build/expressions/nullIf.cjs.map +1 -0
- package/build/expressions/nullIf.d.cts +22 -0
- package/build/expressions/nullIf.d.cts.map +1 -0
- package/build/expressions/nullIf.d.mts +22 -0
- package/build/expressions/nullIf.d.mts.map +1 -0
- package/build/expressions/nullIf.js +24 -0
- package/build/expressions/nullIf.js.map +1 -0
- package/build/expressions/parseExpression.cjs +70 -0
- package/build/expressions/parseExpression.cjs.map +1 -0
- package/build/expressions/parseExpression.d.cts +19 -0
- package/build/expressions/parseExpression.d.cts.map +1 -0
- package/build/expressions/parseExpression.d.mts +19 -0
- package/build/expressions/parseExpression.d.mts.map +1 -0
- package/build/expressions/parseExpression.js +65 -0
- package/build/expressions/parseExpression.js.map +1 -0
- package/build/expressions/types.cjs +1 -0
- package/build/expressions/types.d.cts +94 -0
- package/build/expressions/types.d.cts.map +1 -0
- package/build/expressions/types.d.mts +94 -0
- package/build/expressions/types.d.mts.map +1 -0
- package/build/expressions/types.js +1 -0
- package/build/index.cjs +2 -0
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +5 -2
- package/build/index.d.cts.map +1 -1
- package/build/index.d.mts +5 -2
- package/build/index.d.mts.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/query.cjs +14 -6
- package/build/query.cjs.map +1 -1
- package/build/query.d.cts +39 -47
- package/build/query.d.cts.map +1 -1
- package/build/query.d.mts +39 -47
- package/build/query.d.mts.map +1 -1
- package/build/query.js +14 -6
- package/build/query.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullIf.js","names":[],"sources":["../../src/expressions/nullIf.ts"],"sourcesContent":["import type { ExprContext, SqlFragment } from \"../Expr.ts\";\nimport { functionToSql } from \"./expression.ts\";\nimport { parseExpression } from \"./parseExpression.ts\";\nimport type { ParsedExpression, ResultCodec } from \"./types.ts\";\n\n/** A value and the value it must equal for NULLIF to return SQL NULL. */\nexport interface NullIfInput {\n readonly nullIf: readonly unknown[];\n}\n\n/** NULLIF returns value unless it matches equals. */\nexport interface ParsedNullIfExpression {\n kind: \"nullIf\";\n value: ParsedExpression;\n equals: ParsedExpression;\n}\n\n/** Parses exactly two NULLIF operands into their distinct roles. */\nexport function parseNullIfExpression(input: unknown): ParsedNullIfExpression {\n if (!Array.isArray(input) || input.length !== 2) throw new Error(\"NULLIF needs exactly two values\");\n return { kind: \"nullIf\", value: parseExpression(input[0]), equals: parseExpression(input[1]) };\n}\n\n/** Renders the returned value before its equality comparison operand. */\nexport function nullIfToSql(parsed: ParsedNullIfExpression, ctx: ExprContext, codec: ResultCodec): SqlFragment {\n return functionToSql(\"NULLIF\", [parsed.value, parsed.equals], ctx, codec);\n}\n\n/** NULLIF can return SQL NULL when its operands match. */\nexport function nullIfNullable(): true {\n return true;\n}\n"],"mappings":";;;;AAkBA,SAAgB,sBAAsB,OAAwC;CAC5E,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GAAG,MAAM,IAAI,MAAM,iCAAiC;CAClG,OAAO;EAAE,MAAM;EAAU,OAAO,gBAAgB,MAAM,EAAE;EAAG,QAAQ,gBAAgB,MAAM,EAAE;CAAE;AAC/F;;AAGA,SAAgB,YAAY,QAAgC,KAAkB,OAAiC;CAC7G,OAAO,cAAc,UAAU,CAAC,OAAO,OAAO,OAAO,MAAM,GAAG,KAAK,KAAK;AAC1E;;AAGA,SAAgB,iBAAuB;CACrC,OAAO;AACT"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils = require("../utils.cjs");
|
|
3
|
+
const require_Expr = require("../Expr.cjs");
|
|
4
|
+
const require_expressions_coalesce = require("./coalesce.cjs");
|
|
5
|
+
const require_expressions_greatest = require("./greatest.cjs");
|
|
6
|
+
const require_expressions_least = require("./least.cjs");
|
|
7
|
+
const require_expressions_nullIf = require("./nullIf.cjs");
|
|
8
|
+
const require_expressions_case = require("./case.cjs");
|
|
9
|
+
//#region src/expressions/parseExpression.ts
|
|
10
|
+
const exprNames = [
|
|
11
|
+
"coalesce",
|
|
12
|
+
"nullIf",
|
|
13
|
+
"greatest",
|
|
14
|
+
"least"
|
|
15
|
+
];
|
|
16
|
+
/** Requires an expression object at the root before parsing its nested operands. */
|
|
17
|
+
function parseExpressionInput(input) {
|
|
18
|
+
if (!isObject(input) || !("case" in input) && !exprNames.some((name) => name in input)) throw new Error("expr expects an object with case, coalesce, nullIf, greatest, or least");
|
|
19
|
+
return parseExpression(input);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parses expression inputs into a ParsedExpression, validating their shape and copying operand arrays.
|
|
23
|
+
* Nested expressions stay together so their literals can use a column's codec from another branch.
|
|
24
|
+
* I.e. COALESCE(Book.id, CASE ... THEN "b:9" END) must encode "b:9" as an integer.
|
|
25
|
+
*/
|
|
26
|
+
function parseExpression(input) {
|
|
27
|
+
if (input instanceof require_Expr.BaseExpr) return input;
|
|
28
|
+
if (input === void 0) throw new Error("Use null for a SQL NULL value");
|
|
29
|
+
const name = isObject(input) ? exprNames.find((name) => name in input) : void 0;
|
|
30
|
+
if (name && isObject(input)) {
|
|
31
|
+
checkKeys(input, [name]);
|
|
32
|
+
switch (name) {
|
|
33
|
+
case "coalesce": return require_expressions_coalesce.parseCoalesceExpression(input.coalesce);
|
|
34
|
+
case "nullIf": return require_expressions_nullIf.parseNullIfExpression(input.nullIf);
|
|
35
|
+
case "greatest": return require_expressions_greatest.parseGreatestExpression(input.greatest);
|
|
36
|
+
case "least": return require_expressions_least.parseLeastExpression(input.least);
|
|
37
|
+
default: return require_utils.assertNever(name);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (isObject(input) && "case" in input) {
|
|
41
|
+
checkKeys(input, ["case"]);
|
|
42
|
+
return require_expressions_case.parseCaseExpression(input.case);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
kind: "literal",
|
|
46
|
+
value: input
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Validates and copies a nonempty operand array, preserving its first element in the parsed type. */
|
|
50
|
+
function parseNonEmptyOperands(input, name) {
|
|
51
|
+
if (!Array.isArray(input) || input.length === 0) throw new Error(`${name} needs at least one value`);
|
|
52
|
+
const [first, ...rest] = input;
|
|
53
|
+
return [parseExpression(first), ...rest.map((operand) => parseExpression(operand))];
|
|
54
|
+
}
|
|
55
|
+
/** Rejects misspelled or mixed expression keys rather than silently ignoring them. */
|
|
56
|
+
function checkKeys(value, allowed) {
|
|
57
|
+
for (const key of Reflect.ownKeys(value)) if (typeof key !== "string" || !allowed.includes(key)) throw new Error(`Unknown expression key '${String(key)}'`);
|
|
58
|
+
}
|
|
59
|
+
/** Narrows expression input objects without treating null as an object. */
|
|
60
|
+
function isObject(value) {
|
|
61
|
+
return typeof value === "object" && value !== null;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
exports.checkKeys = checkKeys;
|
|
65
|
+
exports.isObject = isObject;
|
|
66
|
+
exports.parseExpression = parseExpression;
|
|
67
|
+
exports.parseExpressionInput = parseExpressionInput;
|
|
68
|
+
exports.parseNonEmptyOperands = parseNonEmptyOperands;
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=parseExpression.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseExpression.cjs","names":["BaseExpr","parseCoalesceExpression","parseNullIfExpression","parseGreatestExpression","parseLeastExpression","assertNever","parseCaseExpression"],"sources":["../../src/expressions/parseExpression.ts"],"sourcesContent":["import { BaseExpr } from \"../Expr.ts\";\nimport { assertNever } from \"../utils.ts\";\nimport { parseCaseExpression } from \"./case.ts\";\nimport { parseCoalesceExpression } from \"./coalesce.ts\";\nimport { parseGreatestExpression } from \"./greatest.ts\";\nimport { parseLeastExpression } from \"./least.ts\";\nimport { parseNullIfExpression } from \"./nullIf.ts\";\nimport type { ExprName, ParsedExpression } from \"./types.ts\";\n\n// These expressions take operand arrays; CASE uses WHEN/THEN entries instead.\nconst exprNames = [\"coalesce\", \"nullIf\", \"greatest\", \"least\"] as const satisfies readonly ExprName[];\n\n/** Requires an expression object at the root before parsing its nested operands. */\nexport function parseExpressionInput(input: unknown): ParsedExpression {\n if (!isObject(input) || (!(\"case\" in input) && !exprNames.some((name) => name in input))) {\n throw new Error(\"expr expects an object with case, coalesce, nullIf, greatest, or least\");\n }\n return parseExpression(input);\n}\n\n/**\n * Parses expression inputs into a ParsedExpression, validating their shape and copying operand arrays.\n * Nested expressions stay together so their literals can use a column's codec from another branch.\n * I.e. COALESCE(Book.id, CASE ... THEN \"b:9\" END) must encode \"b:9\" as an integer.\n */\nexport function parseExpression(input: unknown): ParsedExpression {\n if (input instanceof BaseExpr) return input;\n if (input === undefined) throw new Error(\"Use null for a SQL NULL value\");\n const name = isObject(input) ? exprNames.find((name) => name in input) : undefined;\n if (name && isObject(input)) {\n checkKeys(input, [name]);\n switch (name) {\n case \"coalesce\":\n return parseCoalesceExpression(input.coalesce);\n case \"nullIf\":\n return parseNullIfExpression(input.nullIf);\n case \"greatest\":\n return parseGreatestExpression(input.greatest);\n case \"least\":\n return parseLeastExpression(input.least);\n default:\n return assertNever(name);\n }\n }\n if (isObject(input) && \"case\" in input) {\n checkKeys(input, [\"case\"]);\n return parseCaseExpression(input.case);\n }\n return { kind: \"literal\", value: input };\n}\n\n/** Validates and copies a nonempty operand array, preserving its first element in the parsed type. */\nexport function parseNonEmptyOperands(input: unknown, name: string): [ParsedExpression, ...ParsedExpression[]] {\n if (!Array.isArray(input) || input.length === 0) throw new Error(`${name} needs at least one value`);\n // Validation above guarantees a first operand; keep that guarantee in the parsed type.\n const [first, ...rest] = input;\n return [parseExpression(first), ...rest.map((operand) => parseExpression(operand))];\n}\n\n/** Rejects misspelled or mixed expression keys rather than silently ignoring them. */\nexport function checkKeys(value: object, allowed: string[]): void {\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key !== \"string\" || !allowed.includes(key)) throw new Error(`Unknown expression key '${String(key)}'`);\n }\n}\n\n/** Narrows expression input objects without treating null as an object. */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,YAAY;CAAC;CAAY;CAAU;CAAY;AAAO;;AAG5D,SAAgB,qBAAqB,OAAkC;CACrE,IAAI,CAAC,SAAS,KAAK,KAAM,EAAE,UAAU,UAAU,CAAC,UAAU,MAAM,SAAS,QAAQ,KAAK,GACpF,MAAM,IAAI,MAAM,wEAAwE;CAE1F,OAAO,gBAAgB,KAAK;AAC9B;;;;;;AAOA,SAAgB,gBAAgB,OAAkC;CAChE,IAAI,iBAAiBA,aAAAA,UAAU,OAAO;CACtC,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,+BAA+B;CACxE,MAAM,OAAO,SAAS,KAAK,IAAI,UAAU,MAAM,SAAS,QAAQ,KAAK,IAAI,KAAA;CACzE,IAAI,QAAQ,SAAS,KAAK,GAAG;EAC3B,UAAU,OAAO,CAAC,IAAI,CAAC;EACvB,QAAQ,MAAR;GACE,KAAK,YACH,OAAOC,6BAAAA,wBAAwB,MAAM,QAAQ;GAC/C,KAAK,UACH,OAAOC,2BAAAA,sBAAsB,MAAM,MAAM;GAC3C,KAAK,YACH,OAAOC,6BAAAA,wBAAwB,MAAM,QAAQ;GAC/C,KAAK,SACH,OAAOC,0BAAAA,qBAAqB,MAAM,KAAK;GACzC,SACE,OAAOC,cAAAA,YAAY,IAAI;EAC3B;CACF;CACA,IAAI,SAAS,KAAK,KAAK,UAAU,OAAO;EACtC,UAAU,OAAO,CAAC,MAAM,CAAC;EACzB,OAAOC,yBAAAA,oBAAoB,MAAM,IAAI;CACvC;CACA,OAAO;EAAE,MAAM;EAAW,OAAO;CAAM;AACzC;;AAGA,SAAgB,sBAAsB,OAAgB,MAAyD;CAC7G,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GAAG,MAAM,IAAI,MAAM,GAAG,KAAK,0BAA0B;CAEnG,MAAM,CAAC,OAAO,GAAG,QAAQ;CACzB,OAAO,CAAC,gBAAgB,KAAK,GAAG,GAAG,KAAK,KAAK,YAAY,gBAAgB,OAAO,CAAC,CAAC;AACpF;;AAGA,SAAgB,UAAU,OAAe,SAAyB;CAChE,KAAK,MAAM,OAAO,QAAQ,QAAQ,KAAK,GACrC,IAAI,OAAO,QAAQ,YAAY,CAAC,QAAQ,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,2BAA2B,OAAO,GAAG,EAAE,EAAE;AAEpH;;AAGA,SAAgB,SAAS,OAAkD;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU;AAChD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ParsedExpression } from "./types.cjs";
|
|
2
|
+
//#region src/expressions/parseExpression.d.ts
|
|
3
|
+
/** Requires an expression object at the root before parsing its nested operands. */
|
|
4
|
+
declare function parseExpressionInput(input: unknown): ParsedExpression;
|
|
5
|
+
/**
|
|
6
|
+
* Parses expression inputs into a ParsedExpression, validating their shape and copying operand arrays.
|
|
7
|
+
* Nested expressions stay together so their literals can use a column's codec from another branch.
|
|
8
|
+
* I.e. COALESCE(Book.id, CASE ... THEN "b:9" END) must encode "b:9" as an integer.
|
|
9
|
+
*/
|
|
10
|
+
declare function parseExpression(input: unknown): ParsedExpression;
|
|
11
|
+
/** Validates and copies a nonempty operand array, preserving its first element in the parsed type. */
|
|
12
|
+
declare function parseNonEmptyOperands(input: unknown, name: string): [ParsedExpression, ...ParsedExpression[]];
|
|
13
|
+
/** Rejects misspelled or mixed expression keys rather than silently ignoring them. */
|
|
14
|
+
declare function checkKeys(value: object, allowed: string[]): void;
|
|
15
|
+
/** Narrows expression input objects without treating null as an object. */
|
|
16
|
+
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { checkKeys, isObject, parseExpression, parseExpressionInput, parseNonEmptyOperands };
|
|
19
|
+
//# sourceMappingURL=parseExpression.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseExpression.d.cts","names":[],"sources":["../../src/expressions/parseExpression.ts"],"mappings":";;;iBAagB,qBAAqB,iBAAiB;;;;;;iBAYtC,gBAAgB,iBAAiB;;iBA2BjC,sBAAsB,gBAAgB,gBAAgB,qBAAqB;;iBAQ3E,UAAU,eAAe;;iBAOzB,SAAS,iBAAiB,SAAS"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ParsedExpression } from "./types.mjs";
|
|
2
|
+
//#region src/expressions/parseExpression.d.ts
|
|
3
|
+
/** Requires an expression object at the root before parsing its nested operands. */
|
|
4
|
+
declare function parseExpressionInput(input: unknown): ParsedExpression;
|
|
5
|
+
/**
|
|
6
|
+
* Parses expression inputs into a ParsedExpression, validating their shape and copying operand arrays.
|
|
7
|
+
* Nested expressions stay together so their literals can use a column's codec from another branch.
|
|
8
|
+
* I.e. COALESCE(Book.id, CASE ... THEN "b:9" END) must encode "b:9" as an integer.
|
|
9
|
+
*/
|
|
10
|
+
declare function parseExpression(input: unknown): ParsedExpression;
|
|
11
|
+
/** Validates and copies a nonempty operand array, preserving its first element in the parsed type. */
|
|
12
|
+
declare function parseNonEmptyOperands(input: unknown, name: string): [ParsedExpression, ...ParsedExpression[]];
|
|
13
|
+
/** Rejects misspelled or mixed expression keys rather than silently ignoring them. */
|
|
14
|
+
declare function checkKeys(value: object, allowed: string[]): void;
|
|
15
|
+
/** Narrows expression input objects without treating null as an object. */
|
|
16
|
+
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { checkKeys, isObject, parseExpression, parseExpressionInput, parseNonEmptyOperands };
|
|
19
|
+
//# sourceMappingURL=parseExpression.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseExpression.d.mts","names":[],"sources":["../../src/expressions/parseExpression.ts"],"mappings":";;;iBAagB,qBAAqB,iBAAiB;;;;;;iBAYtC,gBAAgB,iBAAiB;;iBA2BjC,sBAAsB,gBAAgB,gBAAgB,qBAAqB;;iBAQ3E,UAAU,eAAe;;iBAOzB,SAAS,iBAAiB,SAAS"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { assertNever } from "../utils.js";
|
|
2
|
+
import { BaseExpr } from "../Expr.js";
|
|
3
|
+
import { parseCoalesceExpression } from "./coalesce.js";
|
|
4
|
+
import { parseGreatestExpression } from "./greatest.js";
|
|
5
|
+
import { parseLeastExpression } from "./least.js";
|
|
6
|
+
import { parseNullIfExpression } from "./nullIf.js";
|
|
7
|
+
import { parseCaseExpression } from "./case.js";
|
|
8
|
+
//#region src/expressions/parseExpression.ts
|
|
9
|
+
const exprNames = [
|
|
10
|
+
"coalesce",
|
|
11
|
+
"nullIf",
|
|
12
|
+
"greatest",
|
|
13
|
+
"least"
|
|
14
|
+
];
|
|
15
|
+
/** Requires an expression object at the root before parsing its nested operands. */
|
|
16
|
+
function parseExpressionInput(input) {
|
|
17
|
+
if (!isObject(input) || !("case" in input) && !exprNames.some((name) => name in input)) throw new Error("expr expects an object with case, coalesce, nullIf, greatest, or least");
|
|
18
|
+
return parseExpression(input);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parses expression inputs into a ParsedExpression, validating their shape and copying operand arrays.
|
|
22
|
+
* Nested expressions stay together so their literals can use a column's codec from another branch.
|
|
23
|
+
* I.e. COALESCE(Book.id, CASE ... THEN "b:9" END) must encode "b:9" as an integer.
|
|
24
|
+
*/
|
|
25
|
+
function parseExpression(input) {
|
|
26
|
+
if (input instanceof BaseExpr) return input;
|
|
27
|
+
if (input === void 0) throw new Error("Use null for a SQL NULL value");
|
|
28
|
+
const name = isObject(input) ? exprNames.find((name) => name in input) : void 0;
|
|
29
|
+
if (name && isObject(input)) {
|
|
30
|
+
checkKeys(input, [name]);
|
|
31
|
+
switch (name) {
|
|
32
|
+
case "coalesce": return parseCoalesceExpression(input.coalesce);
|
|
33
|
+
case "nullIf": return parseNullIfExpression(input.nullIf);
|
|
34
|
+
case "greatest": return parseGreatestExpression(input.greatest);
|
|
35
|
+
case "least": return parseLeastExpression(input.least);
|
|
36
|
+
default: return assertNever(name);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (isObject(input) && "case" in input) {
|
|
40
|
+
checkKeys(input, ["case"]);
|
|
41
|
+
return parseCaseExpression(input.case);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
kind: "literal",
|
|
45
|
+
value: input
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Validates and copies a nonempty operand array, preserving its first element in the parsed type. */
|
|
49
|
+
function parseNonEmptyOperands(input, name) {
|
|
50
|
+
if (!Array.isArray(input) || input.length === 0) throw new Error(`${name} needs at least one value`);
|
|
51
|
+
const [first, ...rest] = input;
|
|
52
|
+
return [parseExpression(first), ...rest.map((operand) => parseExpression(operand))];
|
|
53
|
+
}
|
|
54
|
+
/** Rejects misspelled or mixed expression keys rather than silently ignoring them. */
|
|
55
|
+
function checkKeys(value, allowed) {
|
|
56
|
+
for (const key of Reflect.ownKeys(value)) if (typeof key !== "string" || !allowed.includes(key)) throw new Error(`Unknown expression key '${String(key)}'`);
|
|
57
|
+
}
|
|
58
|
+
/** Narrows expression input objects without treating null as an object. */
|
|
59
|
+
function isObject(value) {
|
|
60
|
+
return typeof value === "object" && value !== null;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { checkKeys, isObject, parseExpression, parseExpressionInput, parseNonEmptyOperands };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=parseExpression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseExpression.js","names":[],"sources":["../../src/expressions/parseExpression.ts"],"sourcesContent":["import { BaseExpr } from \"../Expr.ts\";\nimport { assertNever } from \"../utils.ts\";\nimport { parseCaseExpression } from \"./case.ts\";\nimport { parseCoalesceExpression } from \"./coalesce.ts\";\nimport { parseGreatestExpression } from \"./greatest.ts\";\nimport { parseLeastExpression } from \"./least.ts\";\nimport { parseNullIfExpression } from \"./nullIf.ts\";\nimport type { ExprName, ParsedExpression } from \"./types.ts\";\n\n// These expressions take operand arrays; CASE uses WHEN/THEN entries instead.\nconst exprNames = [\"coalesce\", \"nullIf\", \"greatest\", \"least\"] as const satisfies readonly ExprName[];\n\n/** Requires an expression object at the root before parsing its nested operands. */\nexport function parseExpressionInput(input: unknown): ParsedExpression {\n if (!isObject(input) || (!(\"case\" in input) && !exprNames.some((name) => name in input))) {\n throw new Error(\"expr expects an object with case, coalesce, nullIf, greatest, or least\");\n }\n return parseExpression(input);\n}\n\n/**\n * Parses expression inputs into a ParsedExpression, validating their shape and copying operand arrays.\n * Nested expressions stay together so their literals can use a column's codec from another branch.\n * I.e. COALESCE(Book.id, CASE ... THEN \"b:9\" END) must encode \"b:9\" as an integer.\n */\nexport function parseExpression(input: unknown): ParsedExpression {\n if (input instanceof BaseExpr) return input;\n if (input === undefined) throw new Error(\"Use null for a SQL NULL value\");\n const name = isObject(input) ? exprNames.find((name) => name in input) : undefined;\n if (name && isObject(input)) {\n checkKeys(input, [name]);\n switch (name) {\n case \"coalesce\":\n return parseCoalesceExpression(input.coalesce);\n case \"nullIf\":\n return parseNullIfExpression(input.nullIf);\n case \"greatest\":\n return parseGreatestExpression(input.greatest);\n case \"least\":\n return parseLeastExpression(input.least);\n default:\n return assertNever(name);\n }\n }\n if (isObject(input) && \"case\" in input) {\n checkKeys(input, [\"case\"]);\n return parseCaseExpression(input.case);\n }\n return { kind: \"literal\", value: input };\n}\n\n/** Validates and copies a nonempty operand array, preserving its first element in the parsed type. */\nexport function parseNonEmptyOperands(input: unknown, name: string): [ParsedExpression, ...ParsedExpression[]] {\n if (!Array.isArray(input) || input.length === 0) throw new Error(`${name} needs at least one value`);\n // Validation above guarantees a first operand; keep that guarantee in the parsed type.\n const [first, ...rest] = input;\n return [parseExpression(first), ...rest.map((operand) => parseExpression(operand))];\n}\n\n/** Rejects misspelled or mixed expression keys rather than silently ignoring them. */\nexport function checkKeys(value: object, allowed: string[]): void {\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key !== \"string\" || !allowed.includes(key)) throw new Error(`Unknown expression key '${String(key)}'`);\n }\n}\n\n/** Narrows expression input objects without treating null as an object. */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,YAAY;CAAC;CAAY;CAAU;CAAY;AAAO;;AAG5D,SAAgB,qBAAqB,OAAkC;CACrE,IAAI,CAAC,SAAS,KAAK,KAAM,EAAE,UAAU,UAAU,CAAC,UAAU,MAAM,SAAS,QAAQ,KAAK,GACpF,MAAM,IAAI,MAAM,wEAAwE;CAE1F,OAAO,gBAAgB,KAAK;AAC9B;;;;;;AAOA,SAAgB,gBAAgB,OAAkC;CAChE,IAAI,iBAAiB,UAAU,OAAO;CACtC,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,+BAA+B;CACxE,MAAM,OAAO,SAAS,KAAK,IAAI,UAAU,MAAM,SAAS,QAAQ,KAAK,IAAI,KAAA;CACzE,IAAI,QAAQ,SAAS,KAAK,GAAG;EAC3B,UAAU,OAAO,CAAC,IAAI,CAAC;EACvB,QAAQ,MAAR;GACE,KAAK,YACH,OAAO,wBAAwB,MAAM,QAAQ;GAC/C,KAAK,UACH,OAAO,sBAAsB,MAAM,MAAM;GAC3C,KAAK,YACH,OAAO,wBAAwB,MAAM,QAAQ;GAC/C,KAAK,SACH,OAAO,qBAAqB,MAAM,KAAK;GACzC,SACE,OAAO,YAAY,IAAI;EAC3B;CACF;CACA,IAAI,SAAS,KAAK,KAAK,UAAU,OAAO;EACtC,UAAU,OAAO,CAAC,MAAM,CAAC;EACzB,OAAO,oBAAoB,MAAM,IAAI;CACvC;CACA,OAAO;EAAE,MAAM;EAAW,OAAO;CAAM;AACzC;;AAGA,SAAgB,sBAAsB,OAAgB,MAAyD;CAC7G,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GAAG,MAAM,IAAI,MAAM,GAAG,KAAK,0BAA0B;CAEnG,MAAM,CAAC,OAAO,GAAG,QAAQ;CACzB,OAAO,CAAC,gBAAgB,KAAK,GAAG,GAAG,KAAK,KAAK,YAAY,gBAAgB,OAAO,CAAC,CAAC;AACpF;;AAGA,SAAgB,UAAU,OAAe,SAAyB;CAChE,KAAK,MAAM,OAAO,QAAQ,QAAQ,KAAK,GACrC,IAAI,OAAO,QAAQ,YAAY,CAAC,QAAQ,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,2BAA2B,OAAO,GAAG,EAAE,EAAE;AAEpH;;AAGA,SAAgB,SAAS,OAAkD;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU;AAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CaseArmValue, CaseInput, CheckCase, ParsedCaseExpression } from "./case.cjs";
|
|
2
|
+
import { CoalesceInput, ParsedCoalesceExpression } from "./coalesce.cjs";
|
|
3
|
+
import { GreatestInput, ParsedGreatestExpression } from "./greatest.cjs";
|
|
4
|
+
import { LeastInput, ParsedLeastExpression } from "./least.cjs";
|
|
5
|
+
import { NullIfInput, ParsedNullIfExpression } from "./nullIf.cjs";
|
|
6
|
+
import { CompatibleValue, MaybeNull, QueryJoins } from "../query.cjs";
|
|
7
|
+
import { BaseExpr, Expr, ExprBrand, ExprLike, exprBrand } from "../Expr.cjs";
|
|
8
|
+
//#region src/expressions/types.d.ts
|
|
9
|
+
/** Each operation owns its input fields; the combined input permits exactly one operation. */
|
|
10
|
+
interface ExprInputs {
|
|
11
|
+
case: CaseInput;
|
|
12
|
+
coalesce: CoalesceInput;
|
|
13
|
+
nullIf: NullIfInput;
|
|
14
|
+
greatest: GreatestInput;
|
|
15
|
+
least: LeastInput;
|
|
16
|
+
}
|
|
17
|
+
type ExprName = Exclude<keyof ExprInputs, "case">;
|
|
18
|
+
type ExprArgsInput = { [K in ExprName]: { readonly [P in K]: readonly unknown[]; }; }[ExprName];
|
|
19
|
+
type ExprArgs<V> = Extract<V[keyof V & ExprName], readonly unknown[]>;
|
|
20
|
+
/** An expression object used in select or passed to expr, i.e. { coalesce: [a.last_name, a.first_name] }. */
|
|
21
|
+
type ExprInput = { [K in keyof ExprInputs]: ExprInputs[K] & { readonly [P in Exclude<keyof ExprInputs | "else", K>]?: never; }; }[keyof ExprInputs];
|
|
22
|
+
declare const inputBrand: unique symbol;
|
|
23
|
+
/** Retains the input object so query results can account for LEFT joins in each candidate separately. */
|
|
24
|
+
type ExprFromInput<I> = Expr<InputResult<I, []>, ExpressionSources<I>> & {
|
|
25
|
+
readonly [inputBrand]: I;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Computes the TypeScript result type, including null from LEFT joins.
|
|
29
|
+
* I.e. Book.title is string | null when Book is LEFT-joined; COALESCE(Book.title, "Unknown") is string.
|
|
30
|
+
*/
|
|
31
|
+
type ExpressionValue<V, J extends QueryJoins> = unknown extends V ? V : V extends {
|
|
32
|
+
readonly [inputBrand]: infer I;
|
|
33
|
+
} ? InputResult<I, J> : V extends {
|
|
34
|
+
readonly [exprBrand]: ExprBrand<infer R, infer S>;
|
|
35
|
+
} ? MaybeNull<R, S, J> : V extends ExprArgsInput ? V extends {
|
|
36
|
+
readonly nullIf: readonly unknown[];
|
|
37
|
+
} ? ExpressionValue<ExprArgs<V>[0], J> | null : V extends {
|
|
38
|
+
readonly coalesce: readonly unknown[];
|
|
39
|
+
} ? CoalesceValue<ExprArgs<V>, J> : Exclude<ExpressionValue<ExprArgs<V>[number], J>, null> | (null extends CoalesceValue<ExprArgs<V>, J> ? null : never) : V extends {
|
|
40
|
+
readonly case: infer A;
|
|
41
|
+
} ? ExpressionValue<CaseArmValue<A>, J> | (A extends readonly [...unknown[], {
|
|
42
|
+
readonly else: unknown;
|
|
43
|
+
}] ? never : null) : WidenLiteral<V>;
|
|
44
|
+
/** Turns literal types such as "Alice" and 18 into string and number, including array elements. */
|
|
45
|
+
type WidenLiteral<V> = V extends string ? string : V extends number ? number : V extends boolean ? boolean : V extends bigint ? bigint : V extends readonly (infer E)[] ? WidenLiteral<E>[] : V;
|
|
46
|
+
/**
|
|
47
|
+
* Uses existing expressions' result types for their literal fallbacks, just as their codecs do at runtime.
|
|
48
|
+
* I.e. COALESCE(Book.id, "b:9") returns BookId rather than string. ExpressionValue supplies the nullability.
|
|
49
|
+
*/
|
|
50
|
+
type InputResult<I, J extends QueryJoins> = [Exclude<BranchResult<I>, null>] extends [never] ? ExpressionValue<I, J> : Exclude<BranchResult<I>, null> | (null extends ExpressionValue<I, J> ? null : never);
|
|
51
|
+
/** Collects the types supplied by columns and existing expressions, excluding plain literal fallbacks. */
|
|
52
|
+
type BranchResult<V> = unknown extends V ? never : V extends ExprLike<infer R> ? R : V extends ExprArgsInput ? BranchResult<V extends {
|
|
53
|
+
readonly nullIf: readonly unknown[];
|
|
54
|
+
} ? ExprArgs<V>[0] : ExprArgs<V>[number]> : V extends {
|
|
55
|
+
readonly case: infer A;
|
|
56
|
+
} ? BranchResult<CaseArmValue<A>> : never;
|
|
57
|
+
/** A fixed non-null candidate guarantees a result; a possibly empty candidate array does not. */
|
|
58
|
+
type CoalesceValue<A extends readonly unknown[], J extends QueryJoins> = A extends readonly [infer H, ...infer T] ? Exclude<ExpressionValue<H, J>, null> | (null extends ExpressionValue<H, J> ? CoalesceValue<T, J> : never) : A extends readonly [...infer Before, infer Last] ? Exclude<ExpressionValue<A[number], J>, null> | (null extends ExpressionValue<Last, J> ? (null extends CoalesceValue<Before, J> ? null : never) : never) : ExpressionValue<A[number], J> | null;
|
|
59
|
+
/** Conditions affect which value is chosen, but do not make that value nullable through a LEFT join. */
|
|
60
|
+
type ExpressionSources<V> = unknown extends V ? string : V extends ExprLike<unknown> ? V[typeof exprBrand]["__source"] : V extends ExprArgsInput ? ExpressionSources<ExprArgs<V>[number]> : V extends {
|
|
61
|
+
readonly case: infer A;
|
|
62
|
+
} ? ExpressionSources<CaseArmValue<A>> : never;
|
|
63
|
+
/**
|
|
64
|
+
* Compares every operand with the others using the same type check as query set operations.
|
|
65
|
+
* I.e. Author.age and 18 both yield number; Author.age and Author.first_name yield incompatible types.
|
|
66
|
+
* SQL storage types and codecs are checked separately at runtime.
|
|
67
|
+
*/
|
|
68
|
+
type CompatibleValues<V, All = V> = false extends (V extends unknown ? All extends unknown ? CompatibleValue<ExpressionValue<V, []>, ExpressionValue<All, []>> : never : never) ? "Expression values must have compatible types" : unknown;
|
|
69
|
+
/** Checks nested expression shapes and literal fallbacks in one pass; R is the type supplied by existing expressions. */
|
|
70
|
+
type CheckExpression<V, R> = V extends ExprLike<unknown> ? unknown : V extends ExprArgsInput ? V extends ExprInput ? { readonly [K in keyof V]: K extends ExprName ? V[K] extends readonly unknown[] ? CheckOperands<V[K], K, R> : never : never; } : never : V extends {
|
|
71
|
+
readonly case: infer A;
|
|
72
|
+
} ? {
|
|
73
|
+
readonly case: CheckCase<A, R>;
|
|
74
|
+
} & CompatibleValues<CaseArmValue<A>> & { readonly [K in Exclude<keyof V, "case">]: never; } : V extends undefined ? "Use null for a SQL NULL value" : [R] extends [never] ? unknown : V extends null ? unknown : V extends (R extends readonly unknown[] ? Readonly<R> : R) ? unknown : "Literal values must match the expression";
|
|
75
|
+
/** Checks fixed argument counts and then each operand; dynamic array lengths are checked at runtime. */
|
|
76
|
+
type CheckOperands<A extends readonly unknown[], Name extends ExprName, R> = (Name extends "nullIf" ? number extends A["length"] ? unknown : A extends readonly [unknown, unknown] ? unknown : "NULLIF needs exactly two values" : A extends readonly [] ? `${Uppercase<Name>} needs at least one value` : unknown) & { readonly [K in keyof A]: CheckExpression<A[K], R>; } & CompatibleValues<A[number]>;
|
|
77
|
+
/** Valid inputs need no extra constraint; this keeps spread arrays from losing their fixed final operand. */
|
|
78
|
+
type CheckInput<I> = [I] extends [CheckExpression<I, Exclude<BranchResult<I>, null>>] ? unknown : CheckExpression<I, Exclude<BranchResult<I>, null>>;
|
|
79
|
+
/**
|
|
80
|
+
* The internal form produced by parsing expression inputs, like ParsedFindQuery for em.find filters.
|
|
81
|
+
* Existing Expr instances remain intact; literal operands and CASE results are parsed recursively.
|
|
82
|
+
* CASE conditions retain their query input until SQL rendering supplies the alias context.
|
|
83
|
+
*/
|
|
84
|
+
type ParsedExpression = BaseExpr | ParsedLiteralExpression | ParsedCoalesceExpression | ParsedNullIfExpression | ParsedGreatestExpression | ParsedLeastExpression | ParsedCaseExpression;
|
|
85
|
+
/** A bound value whose encoder is selected from the surrounding expression. */
|
|
86
|
+
interface ParsedLiteralExpression {
|
|
87
|
+
kind: "literal";
|
|
88
|
+
value: unknown;
|
|
89
|
+
}
|
|
90
|
+
/** The conversions shared by all result values, separate from their SQL rendering. */
|
|
91
|
+
type ResultCodec = Pick<BaseExpr, "outputType" | "encode" | "decode">;
|
|
92
|
+
//#endregion
|
|
93
|
+
export { CheckExpression, CheckInput, ExprFromInput, ExprInput, ExprName, ExpressionSources, ExpressionValue, ParsedExpression, ParsedLiteralExpression, ResultCodec };
|
|
94
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/expressions/types.ts"],"mappings":";;;;;;;;;UASU;EACR,MAAM;EACN,UAAU;EACV,QAAQ;EACR,UAAU;EACV,OAAO;;KAIG,WAAW,cAAc;KAChC,mBAAmB,KAAK,uBAAuB,KAAK,6BAA2B;KAC/E,SAAS,KAAK,QAAQ,QAAQ,IAAI;;KAG3B,eACT,WAAW,aAAa,WAAW,iBAAiB,KAAK,cAAc,qBAAqB,wBACvF;cAEM;;KAGF,cAAc,KAAK,KAAK,YAAY,QAAQ,kBAAkB;YAC9D,aAAa;;;;;;KAOb,gBAAgB,GAAG,UAAU,8BAA8B,IACnE,IACA;YAAsB,mBAAmB;IACvC,YAAY,GAAG,KACf;YAAsB,YAAY,gBAAgB,SAAS;IACzD,UAAU,GAAG,GAAG,KAChB,UAAU,gBACR;WAAqB;IACnB,gBAAgB,SAAS,OAAO,YAChC;WAAqB;IACnB,cAAc,SAAS,IAAI,KAEvB,QAAQ,gBAAgB,SAAS,YAAY,0BAC/B,cAAc,SAAS,IAAI,qBACjD;WAAqB,YAAY;IAE3B,gBAAgB,aAAa,IAAI,MAChC;WAA6C;qBAClD,aAAa;;KAGpB,aAAa,KAAK,4BAEnB,4BAEE,8BAEE,4BAEE,0BAA0B,OACxB,aAAa,OACb;;;;;KAMP,YAAY,GAAG,UAAU,eAAe,QAAQ,aAAa,6BAC9D,gBAAgB,GAAG,KACnB,QAAQ,aAAa,0BAA0B,gBAAgB,GAAG;;KAGjE,aAAa,qBAAqB,YAEnC,UAAU,eAAe,KACvB,IACA,UAAU,gBACR,aAAa;WAAqB;IAA+B,SAAS,QAAQ,SAAS,cAC3F;WAAqB,YAAY;IAC/B,aAAa,aAAa;;KAI/B,cAAc,8BAA8B,UAAU,cAAc,0BAA0B,YAAY,KAC3G,QAAQ,gBAAgB,GAAG,0BAA0B,gBAAgB,GAAG,KAAK,cAAc,GAAG,cAC9F,6BAA6B,cAAc,QAErC,QAAQ,gBAAgB,WAAW,0BACrB,gBAAgB,MAAM,mBAAmB,cAAc,QAAQ,8BACjF,gBAAgB,WAAW;;KAGrB,kBAAkB,qBAAqB,aAE/C,UAAU,oBACR,SAAS,yBACT,UAAU,gBACR,kBAAkB,SAAS,cAC3B;WAAqB,YAAY;IAC/B,kBAAkB,aAAa;;;;;;KAQpC,iBAAiB,GAAG,MAAM,oBAC7B,oBACI,sBACE,gBAAgB,gBAAgB,QAAQ,gBAAgB;;KAQpD,gBAAgB,GAAG,KAC7B,UAAU,8BAEN,UAAU,gBACR,UAAU,wBAEI,WAAW,IAAI,UAAU,WAC/B,EAAE,gCACA,cAAc,EAAE,IAAI,GAAG,gCAKjC;WAAqB,YAAY;;WACpB,MAAM,UAAU,GAAG;IAAO,iBAAiB,aAAa,kBACrD,KAAK,cAAc,wBAEjC,yDAEG,+BAEC,2BAEE,WAAW,+BAA+B,SAAS,KAAK;;KAKnE,cAAc,8BAA8B,aAAa,UAAU,MAAM,uCAC3D,wBAEb,sFAGF,2BACK,UAAU,0DACU,WAAW,IAAI,gBAAgB,EAAE,IAAI,QAAO,iBAAiB;;KAG9E,WAAW,MAAM,YAAY,gBAAgB,GAAG,QAAQ,aAAa,wBAE7E,gBAAgB,GAAG,QAAQ,aAAa;;;;;;KAOhC,mBACR,WACA,0BACA,2BACA,yBACA,2BACA,wBACA;;UAGa;EACf;EACA;;;KAIU,cAAc,KAAK"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CaseArmValue, CaseInput, CheckCase, ParsedCaseExpression } from "./case.mjs";
|
|
2
|
+
import { CoalesceInput, ParsedCoalesceExpression } from "./coalesce.mjs";
|
|
3
|
+
import { GreatestInput, ParsedGreatestExpression } from "./greatest.mjs";
|
|
4
|
+
import { LeastInput, ParsedLeastExpression } from "./least.mjs";
|
|
5
|
+
import { NullIfInput, ParsedNullIfExpression } from "./nullIf.mjs";
|
|
6
|
+
import { CompatibleValue, MaybeNull, QueryJoins } from "../query.mjs";
|
|
7
|
+
import { BaseExpr, Expr, ExprBrand, ExprLike, exprBrand } from "../Expr.mjs";
|
|
8
|
+
//#region src/expressions/types.d.ts
|
|
9
|
+
/** Each operation owns its input fields; the combined input permits exactly one operation. */
|
|
10
|
+
interface ExprInputs {
|
|
11
|
+
case: CaseInput;
|
|
12
|
+
coalesce: CoalesceInput;
|
|
13
|
+
nullIf: NullIfInput;
|
|
14
|
+
greatest: GreatestInput;
|
|
15
|
+
least: LeastInput;
|
|
16
|
+
}
|
|
17
|
+
type ExprName = Exclude<keyof ExprInputs, "case">;
|
|
18
|
+
type ExprArgsInput = { [K in ExprName]: { readonly [P in K]: readonly unknown[]; }; }[ExprName];
|
|
19
|
+
type ExprArgs<V> = Extract<V[keyof V & ExprName], readonly unknown[]>;
|
|
20
|
+
/** An expression object used in select or passed to expr, i.e. { coalesce: [a.last_name, a.first_name] }. */
|
|
21
|
+
type ExprInput = { [K in keyof ExprInputs]: ExprInputs[K] & { readonly [P in Exclude<keyof ExprInputs | "else", K>]?: never; }; }[keyof ExprInputs];
|
|
22
|
+
declare const inputBrand: unique symbol;
|
|
23
|
+
/** Retains the input object so query results can account for LEFT joins in each candidate separately. */
|
|
24
|
+
type ExprFromInput<I> = Expr<InputResult<I, []>, ExpressionSources<I>> & {
|
|
25
|
+
readonly [inputBrand]: I;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Computes the TypeScript result type, including null from LEFT joins.
|
|
29
|
+
* I.e. Book.title is string | null when Book is LEFT-joined; COALESCE(Book.title, "Unknown") is string.
|
|
30
|
+
*/
|
|
31
|
+
type ExpressionValue<V, J extends QueryJoins> = unknown extends V ? V : V extends {
|
|
32
|
+
readonly [inputBrand]: infer I;
|
|
33
|
+
} ? InputResult<I, J> : V extends {
|
|
34
|
+
readonly [exprBrand]: ExprBrand<infer R, infer S>;
|
|
35
|
+
} ? MaybeNull<R, S, J> : V extends ExprArgsInput ? V extends {
|
|
36
|
+
readonly nullIf: readonly unknown[];
|
|
37
|
+
} ? ExpressionValue<ExprArgs<V>[0], J> | null : V extends {
|
|
38
|
+
readonly coalesce: readonly unknown[];
|
|
39
|
+
} ? CoalesceValue<ExprArgs<V>, J> : Exclude<ExpressionValue<ExprArgs<V>[number], J>, null> | (null extends CoalesceValue<ExprArgs<V>, J> ? null : never) : V extends {
|
|
40
|
+
readonly case: infer A;
|
|
41
|
+
} ? ExpressionValue<CaseArmValue<A>, J> | (A extends readonly [...unknown[], {
|
|
42
|
+
readonly else: unknown;
|
|
43
|
+
}] ? never : null) : WidenLiteral<V>;
|
|
44
|
+
/** Turns literal types such as "Alice" and 18 into string and number, including array elements. */
|
|
45
|
+
type WidenLiteral<V> = V extends string ? string : V extends number ? number : V extends boolean ? boolean : V extends bigint ? bigint : V extends readonly (infer E)[] ? WidenLiteral<E>[] : V;
|
|
46
|
+
/**
|
|
47
|
+
* Uses existing expressions' result types for their literal fallbacks, just as their codecs do at runtime.
|
|
48
|
+
* I.e. COALESCE(Book.id, "b:9") returns BookId rather than string. ExpressionValue supplies the nullability.
|
|
49
|
+
*/
|
|
50
|
+
type InputResult<I, J extends QueryJoins> = [Exclude<BranchResult<I>, null>] extends [never] ? ExpressionValue<I, J> : Exclude<BranchResult<I>, null> | (null extends ExpressionValue<I, J> ? null : never);
|
|
51
|
+
/** Collects the types supplied by columns and existing expressions, excluding plain literal fallbacks. */
|
|
52
|
+
type BranchResult<V> = unknown extends V ? never : V extends ExprLike<infer R> ? R : V extends ExprArgsInput ? BranchResult<V extends {
|
|
53
|
+
readonly nullIf: readonly unknown[];
|
|
54
|
+
} ? ExprArgs<V>[0] : ExprArgs<V>[number]> : V extends {
|
|
55
|
+
readonly case: infer A;
|
|
56
|
+
} ? BranchResult<CaseArmValue<A>> : never;
|
|
57
|
+
/** A fixed non-null candidate guarantees a result; a possibly empty candidate array does not. */
|
|
58
|
+
type CoalesceValue<A extends readonly unknown[], J extends QueryJoins> = A extends readonly [infer H, ...infer T] ? Exclude<ExpressionValue<H, J>, null> | (null extends ExpressionValue<H, J> ? CoalesceValue<T, J> : never) : A extends readonly [...infer Before, infer Last] ? Exclude<ExpressionValue<A[number], J>, null> | (null extends ExpressionValue<Last, J> ? (null extends CoalesceValue<Before, J> ? null : never) : never) : ExpressionValue<A[number], J> | null;
|
|
59
|
+
/** Conditions affect which value is chosen, but do not make that value nullable through a LEFT join. */
|
|
60
|
+
type ExpressionSources<V> = unknown extends V ? string : V extends ExprLike<unknown> ? V[typeof exprBrand]["__source"] : V extends ExprArgsInput ? ExpressionSources<ExprArgs<V>[number]> : V extends {
|
|
61
|
+
readonly case: infer A;
|
|
62
|
+
} ? ExpressionSources<CaseArmValue<A>> : never;
|
|
63
|
+
/**
|
|
64
|
+
* Compares every operand with the others using the same type check as query set operations.
|
|
65
|
+
* I.e. Author.age and 18 both yield number; Author.age and Author.first_name yield incompatible types.
|
|
66
|
+
* SQL storage types and codecs are checked separately at runtime.
|
|
67
|
+
*/
|
|
68
|
+
type CompatibleValues<V, All = V> = false extends (V extends unknown ? All extends unknown ? CompatibleValue<ExpressionValue<V, []>, ExpressionValue<All, []>> : never : never) ? "Expression values must have compatible types" : unknown;
|
|
69
|
+
/** Checks nested expression shapes and literal fallbacks in one pass; R is the type supplied by existing expressions. */
|
|
70
|
+
type CheckExpression<V, R> = V extends ExprLike<unknown> ? unknown : V extends ExprArgsInput ? V extends ExprInput ? { readonly [K in keyof V]: K extends ExprName ? V[K] extends readonly unknown[] ? CheckOperands<V[K], K, R> : never : never; } : never : V extends {
|
|
71
|
+
readonly case: infer A;
|
|
72
|
+
} ? {
|
|
73
|
+
readonly case: CheckCase<A, R>;
|
|
74
|
+
} & CompatibleValues<CaseArmValue<A>> & { readonly [K in Exclude<keyof V, "case">]: never; } : V extends undefined ? "Use null for a SQL NULL value" : [R] extends [never] ? unknown : V extends null ? unknown : V extends (R extends readonly unknown[] ? Readonly<R> : R) ? unknown : "Literal values must match the expression";
|
|
75
|
+
/** Checks fixed argument counts and then each operand; dynamic array lengths are checked at runtime. */
|
|
76
|
+
type CheckOperands<A extends readonly unknown[], Name extends ExprName, R> = (Name extends "nullIf" ? number extends A["length"] ? unknown : A extends readonly [unknown, unknown] ? unknown : "NULLIF needs exactly two values" : A extends readonly [] ? `${Uppercase<Name>} needs at least one value` : unknown) & { readonly [K in keyof A]: CheckExpression<A[K], R>; } & CompatibleValues<A[number]>;
|
|
77
|
+
/** Valid inputs need no extra constraint; this keeps spread arrays from losing their fixed final operand. */
|
|
78
|
+
type CheckInput<I> = [I] extends [CheckExpression<I, Exclude<BranchResult<I>, null>>] ? unknown : CheckExpression<I, Exclude<BranchResult<I>, null>>;
|
|
79
|
+
/**
|
|
80
|
+
* The internal form produced by parsing expression inputs, like ParsedFindQuery for em.find filters.
|
|
81
|
+
* Existing Expr instances remain intact; literal operands and CASE results are parsed recursively.
|
|
82
|
+
* CASE conditions retain their query input until SQL rendering supplies the alias context.
|
|
83
|
+
*/
|
|
84
|
+
type ParsedExpression = BaseExpr | ParsedLiteralExpression | ParsedCoalesceExpression | ParsedNullIfExpression | ParsedGreatestExpression | ParsedLeastExpression | ParsedCaseExpression;
|
|
85
|
+
/** A bound value whose encoder is selected from the surrounding expression. */
|
|
86
|
+
interface ParsedLiteralExpression {
|
|
87
|
+
kind: "literal";
|
|
88
|
+
value: unknown;
|
|
89
|
+
}
|
|
90
|
+
/** The conversions shared by all result values, separate from their SQL rendering. */
|
|
91
|
+
type ResultCodec = Pick<BaseExpr, "outputType" | "encode" | "decode">;
|
|
92
|
+
//#endregion
|
|
93
|
+
export { CheckExpression, CheckInput, ExprFromInput, ExprInput, ExprName, ExpressionSources, ExpressionValue, ParsedExpression, ParsedLiteralExpression, ResultCodec };
|
|
94
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/expressions/types.ts"],"mappings":";;;;;;;;;UASU;EACR,MAAM;EACN,UAAU;EACV,QAAQ;EACR,UAAU;EACV,OAAO;;KAIG,WAAW,cAAc;KAChC,mBAAmB,KAAK,uBAAuB,KAAK,6BAA2B;KAC/E,SAAS,KAAK,QAAQ,QAAQ,IAAI;;KAG3B,eACT,WAAW,aAAa,WAAW,iBAAiB,KAAK,cAAc,qBAAqB,wBACvF;cAEM;;KAGF,cAAc,KAAK,KAAK,YAAY,QAAQ,kBAAkB;YAC9D,aAAa;;;;;;KAOb,gBAAgB,GAAG,UAAU,8BAA8B,IACnE,IACA;YAAsB,mBAAmB;IACvC,YAAY,GAAG,KACf;YAAsB,YAAY,gBAAgB,SAAS;IACzD,UAAU,GAAG,GAAG,KAChB,UAAU,gBACR;WAAqB;IACnB,gBAAgB,SAAS,OAAO,YAChC;WAAqB;IACnB,cAAc,SAAS,IAAI,KAEvB,QAAQ,gBAAgB,SAAS,YAAY,0BAC/B,cAAc,SAAS,IAAI,qBACjD;WAAqB,YAAY;IAE3B,gBAAgB,aAAa,IAAI,MAChC;WAA6C;qBAClD,aAAa;;KAGpB,aAAa,KAAK,4BAEnB,4BAEE,8BAEE,4BAEE,0BAA0B,OACxB,aAAa,OACb;;;;;KAMP,YAAY,GAAG,UAAU,eAAe,QAAQ,aAAa,6BAC9D,gBAAgB,GAAG,KACnB,QAAQ,aAAa,0BAA0B,gBAAgB,GAAG;;KAGjE,aAAa,qBAAqB,YAEnC,UAAU,eAAe,KACvB,IACA,UAAU,gBACR,aAAa;WAAqB;IAA+B,SAAS,QAAQ,SAAS,cAC3F;WAAqB,YAAY;IAC/B,aAAa,aAAa;;KAI/B,cAAc,8BAA8B,UAAU,cAAc,0BAA0B,YAAY,KAC3G,QAAQ,gBAAgB,GAAG,0BAA0B,gBAAgB,GAAG,KAAK,cAAc,GAAG,cAC9F,6BAA6B,cAAc,QAErC,QAAQ,gBAAgB,WAAW,0BACrB,gBAAgB,MAAM,mBAAmB,cAAc,QAAQ,8BACjF,gBAAgB,WAAW;;KAGrB,kBAAkB,qBAAqB,aAE/C,UAAU,oBACR,SAAS,yBACT,UAAU,gBACR,kBAAkB,SAAS,cAC3B;WAAqB,YAAY;IAC/B,kBAAkB,aAAa;;;;;;KAQpC,iBAAiB,GAAG,MAAM,oBAC7B,oBACI,sBACE,gBAAgB,gBAAgB,QAAQ,gBAAgB;;KAQpD,gBAAgB,GAAG,KAC7B,UAAU,8BAEN,UAAU,gBACR,UAAU,wBAEI,WAAW,IAAI,UAAU,WAC/B,EAAE,gCACA,cAAc,EAAE,IAAI,GAAG,gCAKjC;WAAqB,YAAY;;WACpB,MAAM,UAAU,GAAG;IAAO,iBAAiB,aAAa,kBACrD,KAAK,cAAc,wBAEjC,yDAEG,+BAEC,2BAEE,WAAW,+BAA+B,SAAS,KAAK;;KAKnE,cAAc,8BAA8B,aAAa,UAAU,MAAM,uCAC3D,wBAEb,sFAGF,2BACK,UAAU,0DACU,WAAW,IAAI,gBAAgB,EAAE,IAAI,QAAO,iBAAiB;;KAG9E,WAAW,MAAM,YAAY,gBAAgB,GAAG,QAAQ,aAAa,wBAE7E,gBAAgB,GAAG,QAAQ,aAAa;;;;;;KAOhC,mBACR,WACA,0BACA,2BACA,yBACA,2BACA,wBACA;;UAGa;EACf;EACA;;;KAIU,cAAc,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/index.cjs
CHANGED
|
@@ -63,6 +63,7 @@ const require_skipCondition = require("./skipCondition.cjs");
|
|
|
63
63
|
const require_Expr = require("./Expr.cjs");
|
|
64
64
|
const require_Tables = require("./Tables.cjs");
|
|
65
65
|
const require_ConditionBuilder = require("./ConditionBuilder.cjs");
|
|
66
|
+
const require_expressions_expression = require("./expressions/expression.cjs");
|
|
66
67
|
const require_InstanceData = require("./InstanceData.cjs");
|
|
67
68
|
const require_PluginManager = require("./PluginManager.cjs");
|
|
68
69
|
const require_QueryParser_collectionJoins = require("./QueryParser.collectionJoins.cjs");
|
|
@@ -291,6 +292,7 @@ exports.ensureRectangularArraySizes = require_unnest.ensureRectangularArraySizes
|
|
|
291
292
|
exports.ensureTagged = require_keys.ensureTagged;
|
|
292
293
|
exports.ensureWithLoaded = require_withLoaded.ensureWithLoaded;
|
|
293
294
|
exports.entityQueryBrand = require_query.entityQueryBrand;
|
|
295
|
+
exports.expr = require_expressions_expression.expr;
|
|
294
296
|
exports.exprBrand = require_Expr.exprBrand;
|
|
295
297
|
exports.factories = require_newTestInstance.factories;
|
|
296
298
|
exports.fail = require_utils.fail;
|
package/build/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["getMetadata","getProperties","getBaseMeta","getField","AbstractRelationImpl","isLazyField","isProperty","isAsyncProperty","isReactiveGetter","isReactiveField","isAsyncReactiveField","FactoryInitialValue","ReactiveFieldImpl","AsyncReactiveFieldImpl","getInstanceData"],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"./BaseEntity.ts\";\nimport { getDefaultDependencies } from \"./defaults.ts\";\nimport { buildWhereClause } from \"./drivers/buildUtils.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor } from \"./EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"./EntityMetadata.ts\";\nimport { getField, setField } from \"./fields.ts\";\nimport { getProperties } from \"./getProperties.ts\";\nimport { type New } from \"./loadHints.ts\";\nimport { isAllSqlPaths } from \"./loadLens.ts\";\nimport { FactoryInitialValue } from \"./newTestInstance.ts\";\nimport { partitionHint } from \"./preloading/partitionHint.ts\";\nimport { AbstractRelationImpl } from \"./relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"./relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"./relations/index.ts\";\nimport { ReactiveFieldImpl } from \"./relations/ReactiveField.ts\";\nimport { type OptsOf } from \"./typeMap.ts\";\nimport { fail } from \"./utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"./AliasAssigner.ts\";\nexport {\n type AndCondition,\n type ConditionGroup,\n type DomainPredicate,\n type OrCondition,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"./conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"./Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableFor,\n type TableMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"./Tables.ts\";\nexport { BaseEntity, getInstanceData } from \"./BaseEntity.ts\";\nexport { ConditionBuilder } from \"./ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"./Entity.ts\";\nexport type * from \"./EntityFields.ts\";\nexport * from \"./EntityFilter.ts\";\nexport * from \"./EntityGraphQLFilter.ts\";\nexport * from \"./EntityManager.ts\";\nexport * from \"./EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"./execute.ts\";\nexport type { EnumMetadata } from \"./EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `toSql`/`decode`/`encode` never show up as something a user could call.\nexport {\n type ArrayAggOptions,\n type Expr,\n type ExprBrand,\n exprBrand,\n type ExprLike,\n type InnerJoin,\n type LeftJoin,\n} from \"./Expr.ts\";\nexport { skipCondition } from \"./skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"./HintTree.ts\";\nexport { InstanceData } from \"./InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"./JoinRows.ts\";\nexport type * from \"./PendingChanges.ts\";\nexport { Plugin } from \"./PluginManager.ts\";\nexport * from \"./QueryParser.ts\";\nexport * from \"./QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"./QueryVisitor.ts\";\nexport * from \"./RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"./Todo.ts\";\nexport * from \"./changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"./config.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"./configure.ts\";\nexport { driverApi } from \"./driverApi.ts\";\nexport * from \"./drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"./fields.ts\";\nexport * from \"./getProperties.ts\";\nexport * from \"./json.ts\";\nexport * from \"./keys.ts\";\nexport { kq, kqDot, kqStar } from \"./keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"./loadHints.ts\";\nexport * from \"./loadLens.ts\";\nexport { setFactoryWriter } from \"./logging/FactoryLogger.ts\";\nexport * from \"./logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"./logging/ReactionLogger.ts\";\nexport { lazyField } from \"./newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"./newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"./normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"./plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"./plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"./preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseUserQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoins,\n type QueryOrderBy,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n recursiveQuery,\n type RecursiveOptions,\n type ScalarQuery,\n type SetQuery,\n query,\n sql,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"./query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"./reactiveHints.ts\";\nexport * from \"./relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"./rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"./runtimeConfig.ts\";\nexport { nowUTC } from \"./nowUTC.ts\";\nexport * from \"./serde.ts\";\nexport * from \"./columns.ts\";\nexport * from \"./fieldSerde.ts\";\nexport * from \"./scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"./temporal.ts\";\nexport * from \"./temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"./trusted.ts\";\nexport type * from \"./typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"./unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"./upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"./utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"./withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id; otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" ? getField(entity, key) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["getMetadata","getProperties","getBaseMeta","getField","AbstractRelationImpl","isLazyField","isProperty","isAsyncProperty","isReactiveGetter","isReactiveField","isAsyncReactiveField","FactoryInitialValue","ReactiveFieldImpl","AsyncReactiveFieldImpl","getInstanceData"],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"./BaseEntity.ts\";\nimport { getDefaultDependencies } from \"./defaults.ts\";\nimport { buildWhereClause } from \"./drivers/buildUtils.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor } from \"./EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"./EntityMetadata.ts\";\nimport { getField, setField } from \"./fields.ts\";\nimport { getProperties } from \"./getProperties.ts\";\nimport { type New } from \"./loadHints.ts\";\nimport { isAllSqlPaths } from \"./loadLens.ts\";\nimport { FactoryInitialValue } from \"./newTestInstance.ts\";\nimport { partitionHint } from \"./preloading/partitionHint.ts\";\nimport { AbstractRelationImpl } from \"./relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"./relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"./relations/index.ts\";\nimport { ReactiveFieldImpl } from \"./relations/ReactiveField.ts\";\nimport { type OptsOf } from \"./typeMap.ts\";\nimport { fail } from \"./utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"./AliasAssigner.ts\";\nexport {\n type AndCondition,\n type ConditionGroup,\n type DomainPredicate,\n type OrCondition,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"./conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"./Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableFor,\n type TableMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"./Tables.ts\";\nexport { BaseEntity, getInstanceData } from \"./BaseEntity.ts\";\nexport { ConditionBuilder } from \"./ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"./Entity.ts\";\nexport type * from \"./EntityFields.ts\";\nexport * from \"./EntityFilter.ts\";\nexport * from \"./EntityGraphQLFilter.ts\";\nexport * from \"./EntityManager.ts\";\nexport * from \"./EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"./execute.ts\";\nexport type { EnumMetadata } from \"./EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `toSql`/`decode`/`encode` never show up as something a user could call.\nexport {\n type ArrayAggOptions,\n type Expr,\n type ExprBrand,\n exprBrand,\n type ExprLike,\n type InnerJoin,\n type LeftJoin,\n} from \"./Expr.ts\";\nexport { expr, type CaseElse, type CaseWhen, type ExprFromInput, type ExprInput } from \"./expressions/expression.ts\";\nexport { skipCondition } from \"./skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"./HintTree.ts\";\nexport { InstanceData } from \"./InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"./JoinRows.ts\";\nexport type * from \"./PendingChanges.ts\";\nexport { Plugin } from \"./PluginManager.ts\";\nexport * from \"./QueryParser.ts\";\nexport * from \"./QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"./QueryVisitor.ts\";\nexport * from \"./RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"./Todo.ts\";\nexport * from \"./changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"./config.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"./configure.ts\";\nexport { driverApi } from \"./driverApi.ts\";\nexport * from \"./drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"./fields.ts\";\nexport * from \"./getProperties.ts\";\nexport * from \"./json.ts\";\nexport * from \"./keys.ts\";\nexport { kq, kqDot, kqStar } from \"./keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"./loadHints.ts\";\nexport * from \"./loadLens.ts\";\nexport { setFactoryWriter } from \"./logging/FactoryLogger.ts\";\nexport * from \"./logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"./logging/ReactionLogger.ts\";\nexport { lazyField } from \"./newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"./newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"./normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"./plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"./plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"./preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseUserQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExpressionOrderBy,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoins,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n recursiveQuery,\n type RecursiveOptions,\n type ScalarQuery,\n type SetQuery,\n query,\n sql,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"./query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"./reactiveHints.ts\";\nexport * from \"./relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"./rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"./runtimeConfig.ts\";\nexport { nowUTC } from \"./nowUTC.ts\";\nexport * from \"./serde.ts\";\nexport * from \"./columns.ts\";\nexport * from \"./fieldSerde.ts\";\nexport * from \"./scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"./temporal.ts\";\nexport * from \"./temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"./trusted.ts\";\nexport type * from \"./typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"./unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"./upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"./utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"./withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id; otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" ? getField(entity, key) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":"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"}
|
package/build/index.d.cts
CHANGED
|
@@ -56,7 +56,10 @@ import { SubqueryRenderer, buildValueCondition, buildWhereClause } from "./drive
|
|
|
56
56
|
import { Lens, getLens, getLensPath, isAllSqlPaths, isLensLoaded, isLensLoadedPath, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, mapPathsToTarget } from "./loadLens.cjs";
|
|
57
57
|
import { partitionHint } from "./preloading/partitionHint.cjs";
|
|
58
58
|
import { configureMetadata, getConstructorFromTaggedId, getMetadataForTable, getMetadataForType, maybeGetConstructorFromReference } from "./configure.cjs";
|
|
59
|
-
import {
|
|
59
|
+
import { CaseElse, CaseWhen } from "./expressions/case.cjs";
|
|
60
|
+
import { ExprFromInput, ExprInput } from "./expressions/types.cjs";
|
|
61
|
+
import { expr } from "./expressions/expression.cjs";
|
|
62
|
+
import { CheckScope, Clauses, EntityQuery, ExistsQuery, ExpressionOrderBy, MaybeNull, NameOf, NotWidened, OrderByDirection, OrderByKeys, Query, QueryArg, QueryCondition, QueryJoin, QueryJoins, QueryRow, QuerySelect, QuerySource, QueryValue, RecursiveOptions, ScalarQuery, SetQuery, Subquery, SubqueryBrand, WithInput, WithSource, entityQueryBrand, query, recursiveQuery, sql, subqueryBrand } from "./query.cjs";
|
|
60
63
|
import { ArrayAggOptions, Expr, ExprBrand, ExprLike, InnerJoin, LeftJoin, exprBrand } from "./Expr.cjs";
|
|
61
64
|
import { CollectionJoin, EntityColumn, PolyReference, PrimitiveColumn, ReferenceColumn, ReferenceJoin, Table, TableBrand, TableFilter, TableFor, TableMgmt, getTableMetadata, getTableMgmt, isTable, newTableProxy, table, tableMgmt, tables } from "./Tables.cjs";
|
|
62
65
|
import { BaseEntity, getInstanceData } from "./BaseEntity.cjs";
|
|
@@ -168,5 +171,5 @@ declare function failNoIdYet(entity: string): never;
|
|
|
168
171
|
*/
|
|
169
172
|
declare function isNewEntity<T extends Entity>(entity: T): entity is New<T>;
|
|
170
173
|
//#endregion
|
|
171
|
-
export { type ActualFactoryOpts, type Alias, AliasAssigner, type AliasBrand, type AliasColumn, AliasFn, type AliasMgmt, type AndCondition, type ArrayAggOptions, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, Changes, type CheckScope, type Clauses, type Collection, type CollectionJoin, Column, ColumnCondition, ColumnDescriptors, type ColumnsOf, ConditionBuilder, type ConditionGroup, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type DeleteStatement, type DomainPredicate, type Driver, type DriverQueryResult, type Entity, type EntityAlias, EntityChanges, type EntityColumn, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, type EntityQuery, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, type ExecuteResult, ExistsCondition, type ExistsQuery, type Expr, type ExprBrand, type ExprLike, ExpressionCondition, ExpressionFilter, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, FieldColumn, FieldLogger, FieldLoggerWatch, FieldSerde, FieldStatus, type FieldsOf, FilterAndSettings, type FilterOf, FilterWithAlias, FindCountFilterOptions, FindFilter, FindFilterOptions, FindGqlFilterOptions, FindOperation, Flavor, FlushOptions, type GenericError, GraphQLFilterAndSettings, type GraphQLFilterOf, GraphQLFilterWithAlias, type HintNode, IdAssigner, IdOf, type IdType, ImmutableEntitiesPlugin, type InheritanceTypeOf, type InnerJoin, InsertFixup, InsertOp, type InsertStatement, type InsertValues, InstanceData, type JoinColumnValue, type JoinResult, type JoinRow, JoinRowOperation, type JoinRowTodo, JoinTable, JsonAggregatePreloader, JsonHint, JsonPayload, JsonSerde, Jsonable, JsonableValue, KeySerde, type LargeCollection, LargeOneToManyField, LateralJoinTable, type LazyField, LazyFieldImpl, type LeftJoin, Lens, type LoadHint, type Loadable, type Loaded, type LoadedCollection, type LoadedEnumCollection, type LoadedMethod, type LoadedProperty, type LoadedReadOnlyCollection, type LoadedReference, LoaderCache, ManyToManyCollection, ManyToManyEnumField, ManyToManyField, ManyToManyFieldStatus, ManyToManyLargeCollection, type ManyToManyLike, ManyToOneField, ManyToOneFieldStatus, type ManyToOneReference, ManyToOneReferenceImpl, type MarkLoaded, MaybeAbstractEntityConstructor, type MaybeNull, type MutationReturning, type MutationStatement, type NameOf, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, type NotWidened, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, type OrCondition, OrderBy, type OrderByDirection, type OrderByKeys, type OrderOf, ParsedCteClause, ParsedEntityFilter, ParsedExpressionCondition, ParsedExpressionFilter, ParsedFindQuery, ParsedGroupBy, ParsedOrderBy, ParsedSelect, ParsedTable, ParsedValueFilter, PartialOrNull, type PendingChange, type PendingCreate, type PendingDelete, type PendingM2M, type PendingUpdate, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, type PolyAlias, PolyComponent, type PolyReference, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PredicateBrand, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, type PrimitiveAlias, type PrimitiveColumn, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, type Query, type QueryArg, type QueryCondition, type QueryJoin, type QueryJoins, type
|
|
174
|
+
export { type ActualFactoryOpts, type Alias, AliasAssigner, type AliasBrand, type AliasColumn, AliasFn, type AliasMgmt, type AndCondition, type ArrayAggOptions, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, type CaseElse, type CaseWhen, Changes, type CheckScope, type Clauses, type Collection, type CollectionJoin, Column, ColumnCondition, ColumnDescriptors, type ColumnsOf, ConditionBuilder, type ConditionGroup, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type DeleteStatement, type DomainPredicate, type Driver, type DriverQueryResult, type Entity, type EntityAlias, EntityChanges, type EntityColumn, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, type EntityQuery, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, type ExecuteResult, ExistsCondition, type ExistsQuery, type Expr, type ExprBrand, type ExprFromInput, type ExprInput, type ExprLike, ExpressionCondition, ExpressionFilter, type ExpressionOrderBy, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, FieldColumn, FieldLogger, FieldLoggerWatch, FieldSerde, FieldStatus, type FieldsOf, FilterAndSettings, type FilterOf, FilterWithAlias, FindCountFilterOptions, FindFilter, FindFilterOptions, FindGqlFilterOptions, FindOperation, Flavor, FlushOptions, type GenericError, GraphQLFilterAndSettings, type GraphQLFilterOf, GraphQLFilterWithAlias, type HintNode, IdAssigner, IdOf, type IdType, ImmutableEntitiesPlugin, type InheritanceTypeOf, type InnerJoin, InsertFixup, InsertOp, type InsertStatement, type InsertValues, InstanceData, type JoinColumnValue, type JoinResult, type JoinRow, JoinRowOperation, type JoinRowTodo, JoinTable, JsonAggregatePreloader, JsonHint, JsonPayload, JsonSerde, Jsonable, JsonableValue, KeySerde, type LargeCollection, LargeOneToManyField, LateralJoinTable, type LazyField, LazyFieldImpl, type LeftJoin, Lens, type LoadHint, type Loadable, type Loaded, type LoadedCollection, type LoadedEnumCollection, type LoadedMethod, type LoadedProperty, type LoadedReadOnlyCollection, type LoadedReference, LoaderCache, ManyToManyCollection, ManyToManyEnumField, ManyToManyField, ManyToManyFieldStatus, ManyToManyLargeCollection, type ManyToManyLike, ManyToOneField, ManyToOneFieldStatus, type ManyToOneReference, ManyToOneReferenceImpl, type MarkLoaded, MaybeAbstractEntityConstructor, type MaybeNull, type MutationReturning, type MutationStatement, type NameOf, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, type NotWidened, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, type OrCondition, OrderBy, type OrderByDirection, type OrderByKeys, type OrderOf, ParsedCteClause, ParsedEntityFilter, ParsedExpressionCondition, ParsedExpressionFilter, ParsedFindQuery, ParsedGroupBy, ParsedOrderBy, ParsedSelect, ParsedTable, ParsedValueFilter, PartialOrNull, type PendingChange, type PendingCreate, type PendingDelete, type PendingM2M, type PendingUpdate, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, type PolyAlias, PolyComponent, type PolyReference, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PredicateBrand, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, type PrimitiveAlias, type PrimitiveColumn, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, type Query, type QueryArg, type QueryCondition, type QueryJoin, type QueryJoins, type QueryRow, type QuerySelect, type QuerySource, type QueryValue, RandomUuidAssigner, RawCondition, type Reactable, type Reacted, ReactionLogger, type ReactiveField, type ReactiveGetter, type ReactiveHint, type ReactiveManyToMany, ReactiveManyToManyImpl, type ReactiveManyToManyOtherSide, ReactiveManyToManyOtherSideImpl, type ReactiveReference, ReactiveReferenceImpl, type ReactiveTarget, type ReadOnlyCollection, ReadOnlyError, RecursiveCycleError, type RecursiveOptions, type Reference, type ReferenceColumn, type ReferenceJoin, type Relation, type RelationsIn, type RelationsOf, ResolvedScope, type RootTypeNameOf, RowData, type RuntimeConfig, ScalarCodec, type ScalarQuery, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SetQuery, type SettableFields, SimpleFieldSerde, type SqlCondition, type SqlPredicate, StubbedRelation, type Subquery, type SubqueryBrand, SubqueryRenderer, SuperstructSerde, type Table, type TableBrand, type TableFilter, type TableFor, type TableMgmt, TaggedId, Temporal, TestUuidAssigner, TimestampCodec, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TypeMap, type TypeMapEntry, type TypeNameOf, UniqueFilter, UnknownProperty, UpdateOp, type UpdateStatement, type UpdateValues, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, type WithInput, type WithLoaded, type WithSource, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, expr, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, indexBy, internals, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
|
|
172
175
|
//# sourceMappingURL=index.d.cts.map
|