@nulledexp/translatable-criteria 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -85
- package/dist/criteria/criteria-factory.d.ts +6 -5
- package/dist/criteria/criteria-factory.d.ts.map +1 -1
- package/dist/criteria/criteria-factory.js +8 -8
- package/dist/criteria/criteria-factory.js.map +1 -1
- package/dist/criteria/criteria-join-manager.js.map +1 -1
- package/dist/criteria/criteria.d.ts +45 -35
- package/dist/criteria/criteria.d.ts.map +1 -1
- package/dist/criteria/criteria.js +80 -69
- package/dist/criteria/criteria.js.map +1 -1
- package/dist/criteria/cursor.d.ts +15 -0
- package/dist/criteria/cursor.d.ts.map +1 -1
- package/dist/criteria/cursor.js +22 -0
- package/dist/criteria/cursor.js.map +1 -1
- package/dist/criteria/filter/filter-group.d.ts +7 -1
- package/dist/criteria/filter/filter-group.d.ts.map +1 -1
- package/dist/criteria/filter/filter-group.js +12 -3
- package/dist/criteria/filter/filter-group.js.map +1 -1
- package/dist/criteria/filter/filter.d.ts +3 -3
- package/dist/criteria/filter/filter.d.ts.map +1 -1
- package/dist/criteria/filter/filter.js +37 -14
- package/dist/criteria/filter/filter.js.map +1 -1
- package/dist/criteria/filter/types/filter-primitive.types.d.ts +16 -6
- package/dist/criteria/filter/types/filter-primitive.types.d.ts.map +1 -1
- package/dist/criteria/index.d.ts +2 -2
- package/dist/criteria/index.d.ts.map +1 -1
- package/dist/criteria/index.js.map +1 -1
- package/dist/criteria/join/inner.join-criteria.d.ts +10 -17
- package/dist/criteria/join/inner.join-criteria.d.ts.map +1 -1
- package/dist/criteria/join/inner.join-criteria.js +11 -18
- package/dist/criteria/join/inner.join-criteria.js.map +1 -1
- package/dist/criteria/join/left.join-criteria.d.ts +4 -4
- package/dist/criteria/join/left.join-criteria.d.ts.map +1 -1
- package/dist/criteria/join/left.join-criteria.js +5 -5
- package/dist/criteria/join/left.join-criteria.js.map +1 -1
- package/dist/criteria/join/outer.join-criteria.d.ts +13 -16
- package/dist/criteria/join/outer.join-criteria.d.ts.map +1 -1
- package/dist/criteria/join/outer.join-criteria.js +14 -17
- package/dist/criteria/join/outer.join-criteria.js.map +1 -1
- package/dist/criteria/order/order.d.ts +18 -1
- package/dist/criteria/order/order.d.ts.map +1 -1
- package/dist/criteria/order/order.js +21 -1
- package/dist/criteria/order/order.js.map +1 -1
- package/dist/criteria/root.criteria.d.ts +6 -16
- package/dist/criteria/root.criteria.d.ts.map +1 -1
- package/dist/criteria/root.criteria.js +4 -14
- package/dist/criteria/root.criteria.js.map +1 -1
- package/dist/criteria/translator/criteria-translator.d.ts +23 -32
- package/dist/criteria/translator/criteria-translator.d.ts.map +1 -1
- package/dist/criteria/translator/criteria-translator.js +5 -24
- package/dist/criteria/translator/criteria-translator.js.map +1 -1
- package/dist/criteria/types/criteria.interface.d.ts +35 -22
- package/dist/criteria/types/criteria.interface.d.ts.map +1 -1
- package/dist/criteria/types/criteria.interface.js.map +1 -1
- package/dist/criteria/types/join-parameter.types.d.ts +20 -4
- package/dist/criteria/types/join-parameter.types.d.ts.map +1 -1
- package/dist/criteria/types/join-utility.types.d.ts +25 -31
- package/dist/criteria/types/join-utility.types.d.ts.map +1 -1
- package/dist/criteria/types/manager.interface.d.ts +3 -3
- package/dist/criteria/types/manager.interface.d.ts.map +1 -1
- package/dist/criteria/types/operator.types.d.ts +92 -86
- package/dist/criteria/types/operator.types.d.ts.map +1 -1
- package/dist/criteria/types/operator.types.js +91 -85
- package/dist/criteria/types/operator.types.js.map +1 -1
- package/dist/criteria/types/schema.types.d.ts +107 -41
- package/dist/criteria/types/schema.types.d.ts.map +1 -1
- package/dist/criteria/types/schema.types.js +38 -11
- package/dist/criteria/types/schema.types.js.map +1 -1
- package/dist/criteria/types/visitor-interface.types.d.ts +33 -12
- package/dist/criteria/types/visitor-interface.types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -18,104 +18,110 @@ export declare enum FilterOperator {
|
|
|
18
18
|
LIKE = "LIKE",
|
|
19
19
|
/** Checks if a string value does not match a pattern. */
|
|
20
20
|
NOT_LIKE = "NOT LIKE",
|
|
21
|
-
/** Checks if a value
|
|
22
|
-
|
|
23
|
-
/** Checks if a value
|
|
24
|
-
|
|
25
|
-
/** Checks if a value is NULL. */
|
|
26
|
-
IS_NULL = "IS NULL",
|
|
27
|
-
/** Checks if a value is NOT NULL. */
|
|
28
|
-
IS_NOT_NULL = "IS NOT NULL",
|
|
21
|
+
/** Checks if a string value matches a pattern (case-insensitive). */
|
|
22
|
+
ILIKE = "ILIKE",
|
|
23
|
+
/** Checks if a string value does not match a pattern (case-insensitive). */
|
|
24
|
+
NOT_ILIKE = "NOT_ILIKE",
|
|
29
25
|
/** Checks if a string value contains a specific substring (often case-insensitive, depends on DB). */
|
|
30
26
|
CONTAINS = "CONTAINS",
|
|
27
|
+
/** Checks if a string value does not contain a specific substring. */
|
|
28
|
+
NOT_CONTAINS = "NOT_CONTAINS",
|
|
31
29
|
/** Checks if a string value starts with a specific substring. */
|
|
32
30
|
STARTS_WITH = "STARTS_WITH",
|
|
33
31
|
/** Checks if a string value ends with a specific substring. */
|
|
34
32
|
ENDS_WITH = "ENDS_WITH",
|
|
35
|
-
/** Checks if a string value
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*/
|
|
48
|
-
SET_NOT_CONTAINS = "SET_NOT_CONTAINS",
|
|
49
|
-
/**
|
|
50
|
-
* Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
51
|
-
* or a text field with comma-delimited values), contains AT LEAST ONE of the specified values.
|
|
52
|
-
* Expects an array of values.
|
|
53
|
-
*/
|
|
54
|
-
SET_CONTAINS_ANY = "SET_CONTAINS_ANY",
|
|
55
|
-
/**
|
|
56
|
-
* Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
57
|
-
* or a text field with comma-delimited values), contains ALL of the specified values.
|
|
58
|
-
* Expects an array of values.
|
|
59
|
-
*/
|
|
60
|
-
SET_CONTAINS_ALL = "SET_CONTAINS_ALL",
|
|
61
|
-
/**
|
|
62
|
-
* Checks if a value is within a specified range (inclusive).
|
|
63
|
-
* Expects an array or tuple of two values: [min, max].
|
|
64
|
-
*/
|
|
33
|
+
/** Checks if a string value matches a regular expression pattern.
|
|
34
|
+
* The specific regex syntax may depend on the database. */
|
|
35
|
+
MATCHES_REGEX = "MATCHES_REGEX",
|
|
36
|
+
/** Checks if a value is within a set of specified values. */
|
|
37
|
+
IN = "IN",
|
|
38
|
+
/** Checks if a value is not within a set of specified values. */
|
|
39
|
+
NOT_IN = "NOT IN",
|
|
40
|
+
/** Checks if a value is NULL. */
|
|
41
|
+
IS_NULL = "IS_NULL",
|
|
42
|
+
/** Checks if a value is NOT NULL. */
|
|
43
|
+
IS_NOT_NULL = "IS_NOT_NULL",
|
|
44
|
+
/** Checks if a value is within a specified range (inclusive).
|
|
45
|
+
* Expects an array or tuple of two values: [min, max]. */
|
|
65
46
|
BETWEEN = "BETWEEN",
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
* Expects an array or tuple of two values: [min, max].
|
|
69
|
-
*/
|
|
47
|
+
/** Checks if a value is outside a specified range (inclusive).
|
|
48
|
+
* Expects an array or tuple of two values: [min, max]. */
|
|
70
49
|
NOT_BETWEEN = "NOT_BETWEEN",
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
*/
|
|
81
|
-
ILIKE = "ILIKE",
|
|
82
|
-
/**
|
|
83
|
-
* Checks if a string value does not match a pattern (case-insensitive).
|
|
84
|
-
* Expects a string for the pattern.
|
|
85
|
-
*/
|
|
86
|
-
NOT_ILIKE = "NOT_ILIKE",
|
|
87
|
-
/**
|
|
88
|
-
* Checks if a JSON column contains a specific value or path.
|
|
89
|
-
* The specific implementation depends on the database (e.g., JSON_CONTAINS in MySQL, @> in PostgreSQL for JSONB).
|
|
90
|
-
*/
|
|
50
|
+
/** Checks if the value at a specific JSON path is equal to a given primitive value.
|
|
51
|
+
* This is for simple key-value equality checks within a JSON object.
|
|
52
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_PATH_VALUE_EQUALS, value: { 'status': 'published', 'views': 100 } } */
|
|
53
|
+
JSON_PATH_VALUE_EQUALS = "JSON_PATH_VALUE_EQUALS",
|
|
54
|
+
/** Checks if the value at a specific JSON path is NOT equal to a given primitive value.
|
|
55
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_PATH_VALUE_NOT_EQUALS, value: { 'status': 'draft' } } */
|
|
56
|
+
JSON_PATH_VALUE_NOT_EQUALS = "JSON_PATH_VALUE_NOT_EQUALS",
|
|
57
|
+
/** Checks if a JSON document (or a value at a specific path within it) contains a specified JSON value.
|
|
58
|
+
* This maps directly to database functions like MySQL's `JSON_CONTAINS`.
|
|
59
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_CONTAINS, value: { 'tags': 'tech', 'details.views': 100 } } */
|
|
91
60
|
JSON_CONTAINS = "JSON_CONTAINS",
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*/
|
|
61
|
+
/** Checks if a JSON document (or a value at a specific path within it) does NOT contain a specified JSON value.
|
|
62
|
+
* This maps directly to database functions like MySQL's `JSON_CONTAINS` with negation.
|
|
63
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_NOT_CONTAINS, value: { 'tags': 'spam' } } */
|
|
96
64
|
JSON_NOT_CONTAINS = "JSON_NOT_CONTAINS",
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*/
|
|
65
|
+
/** Checks if a JSON document (or a value at a specific path within it) contains AT LEAST ONE of the specified JSON values.
|
|
66
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_CONTAINS_ANY, value: { 'tags': ['tech', 'news'] } } */
|
|
67
|
+
JSON_CONTAINS_ANY = "JSON_CONTAINS_ANY",
|
|
68
|
+
/** Checks if a JSON document (or a value at a specific path within it) does NOT contain AT LEAST ONE of the specified JSON values.
|
|
69
|
+
* (i.e., it contains none of them). */
|
|
70
|
+
JSON_NOT_CONTAINS_ANY = "JSON_NOT_CONTAINS_ANY",
|
|
71
|
+
/** Checks if a JSON document (or a value at a specific path within it) contains ALL of the specified JSON values.
|
|
72
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_CONTAINS_ALL, value: { 'tags': ['tech', 'important'] } } */
|
|
73
|
+
JSON_CONTAINS_ALL = "JSON_CONTAINS_ALL",
|
|
74
|
+
/** Checks if a JSON document (or a value at a specific path within it) does NOT contain ALL of the specified JSON values.
|
|
75
|
+
* (i.e., it is missing at least one of them). */
|
|
76
|
+
JSON_NOT_CONTAINS_ALL = "JSON_NOT_CONTAINS_ALL",
|
|
77
|
+
/** Checks if an array contains a specific element.
|
|
78
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_CONTAINS_ELEMENT, value: 'tech' } */
|
|
102
79
|
ARRAY_CONTAINS_ELEMENT = "ARRAY_CONTAINS_ELEMENT",
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Checks if a column representing an array contains AT LEAST ONE element from the provided array.
|
|
110
|
-
* The underlying column could be a native array type or a JSON array.
|
|
111
|
-
*/
|
|
80
|
+
/** Checks if an array does NOT contain a specific element.
|
|
81
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_NOT_CONTAINS_ELEMENT, value: 'finance' } */
|
|
82
|
+
ARRAY_NOT_CONTAINS_ELEMENT = "ARRAY_NOT_CONTAINS_ELEMENT",
|
|
83
|
+
/** Checks if an array contains AT LEAST ONE element from a given array.
|
|
84
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_CONTAINS_ANY_ELEMENT, value: ['tech', 'news'] } */
|
|
112
85
|
ARRAY_CONTAINS_ANY_ELEMENT = "ARRAY_CONTAINS_ANY_ELEMENT",
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*/
|
|
118
|
-
|
|
86
|
+
/** Checks if an array does NOT contain AT LEAST ONE element from a given array.
|
|
87
|
+
* (i.e., it contains none of them). */
|
|
88
|
+
ARRAY_NOT_CONTAINS_ANY_ELEMENT = "ARRAY_NOT_CONTAINS_ANY_ELEMENT",
|
|
89
|
+
/** Checks if an array contains ALL elements from a given array.
|
|
90
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_CONTAINS_ALL_ELEMENTS, value: ['tech', 'important'] } */
|
|
91
|
+
ARRAY_CONTAINS_ALL_ELEMENTS = "ARRAY_CONTAINS_ALL_ELEMENTS",
|
|
92
|
+
/** Checks if an array does NOT contain ALL elements from a given array.
|
|
93
|
+
* (i.e., it is missing at least one of them). */
|
|
94
|
+
ARRAY_NOT_CONTAINS_ALL_ELEMENTS = "ARRAY_NOT_CONTAINS_ALL_ELEMENTS",
|
|
95
|
+
/** Checks if an array is equal to a given array (order-insensitive).
|
|
96
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_EQUALS, value: ['news', 'tech'] } */
|
|
97
|
+
ARRAY_EQUALS = "ARRAY_EQUALS",
|
|
98
|
+
/** Checks if an array is NOT equal to a given array (order-insensitive).
|
|
99
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_NOT_EQUALS, value: ['finance', 'sports'] } */
|
|
100
|
+
ARRAY_NOT_EQUALS = "ARRAY_NOT_EQUALS",
|
|
101
|
+
/** Checks if an array is exactly equal to a given array (order-sensitive).
|
|
102
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_EQUALS_STRICT, value: ['tech', 'news'] } */
|
|
103
|
+
ARRAY_EQUALS_STRICT = "ARRAY_EQUALS_STRICT",
|
|
104
|
+
/** Checks if an array is NOT exactly equal to a given array (order-sensitive).
|
|
105
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_NOT_EQUALS_STRICT, value: ['news', 'tech'] } */
|
|
106
|
+
ARRAY_NOT_EQUALS_STRICT = "ARRAY_NOT_EQUALS_STRICT",
|
|
107
|
+
/** Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
108
|
+
* or a text field with comma-delimited values), contains a specific value. */
|
|
109
|
+
SET_CONTAINS = "SET_CONTAINS",
|
|
110
|
+
/** Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
111
|
+
* or a text field with comma-delimited values), does NOT contain a specific value. */
|
|
112
|
+
SET_NOT_CONTAINS = "SET_NOT_CONTAINS",
|
|
113
|
+
/** Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
114
|
+
* or a text field with comma-delimited values), contains AT LEAST ONE of the specified values. */
|
|
115
|
+
SET_CONTAINS_ANY = "SET_CONTAINS_ANY",
|
|
116
|
+
/** Checks if a field, representing a collection of values, does NOT contain AT LEAST ONE of the specified values.
|
|
117
|
+
* (i.e., it contains none of them). */
|
|
118
|
+
SET_NOT_CONTAINS_ANY = "SET_NOT_CONTAINS_ANY",
|
|
119
|
+
/** Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
120
|
+
* or a text field with comma-delimited values), contains ALL of the specified values. */
|
|
121
|
+
SET_CONTAINS_ALL = "SET_CONTAINS_ALL",
|
|
122
|
+
/** Checks if a field, representing a collection of values, does NOT contain ALL of the specified values.
|
|
123
|
+
* (i.e., it is missing at least one of them). */
|
|
124
|
+
SET_NOT_CONTAINS_ALL = "SET_NOT_CONTAINS_ALL"
|
|
119
125
|
}
|
|
120
126
|
/**
|
|
121
127
|
* Enumerates the logical operators used to combine filter conditions or groups.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.types.d.ts","sourceRoot":"","sources":["../../../src/criteria/types/operator.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,cAAc;IACxB,2BAA2B;IAC3B,MAAM,MAAM;IACZ,6BAA6B;IAC7B,UAAU,OAAO;IACjB,iDAAiD;IACjD,YAAY,MAAM;IAClB,6DAA6D;IAC7D,sBAAsB,OAAO;IAC7B,8CAA8C;IAC9C,SAAS,MAAM;IACf,0DAA0D;IAC1D,mBAAmB,OAAO;
|
|
1
|
+
{"version":3,"file":"operator.types.d.ts","sourceRoot":"","sources":["../../../src/criteria/types/operator.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,cAAc;IACxB,2BAA2B;IAC3B,MAAM,MAAM;IACZ,6BAA6B;IAC7B,UAAU,OAAO;IACjB,iDAAiD;IACjD,YAAY,MAAM;IAClB,6DAA6D;IAC7D,sBAAsB,OAAO;IAC7B,8CAA8C;IAC9C,SAAS,MAAM;IACf,0DAA0D;IAC1D,mBAAmB,OAAO;IAE1B,wFAAwF;IACxF,IAAI,SAAS;IACb,yDAAyD;IACzD,QAAQ,aAAa;IACrB,qEAAqE;IACrE,KAAK,UAAU;IACf,4EAA4E;IAC5E,SAAS,cAAc;IACvB,sGAAsG;IACtG,QAAQ,aAAa;IACrB,sEAAsE;IACtE,YAAY,iBAAiB;IAC7B,iEAAiE;IACjE,WAAW,gBAAgB;IAC3B,+DAA+D;IAC/D,SAAS,cAAc;IACvB;+DAC2D;IAC3D,aAAa,kBAAkB;IAE/B,6DAA6D;IAC7D,EAAE,OAAO;IACT,iEAAiE;IACjE,MAAM,WAAW;IACjB,iCAAiC;IACjC,OAAO,YAAY;IACnB,qCAAqC;IACrC,WAAW,gBAAgB;IAE3B;8DAC0D;IAC1D,OAAO,YAAY;IACnB;8DAC0D;IAC1D,WAAW,gBAAgB;IAE3B;;yIAEqI;IACrI,sBAAsB,2BAA2B;IACjD;2HACuH;IACvH,0BAA0B,+BAA+B;IACzD;;iIAE6H;IAC7H,aAAa,kBAAkB;IAC/B;;+GAE2G;IAC3G,iBAAiB,sBAAsB;IACvC;yHACqH;IACrH,iBAAiB,sBAAsB;IACvC;2CACuC;IACvC,qBAAqB,0BAA0B;IAC/C;8HAC0H;IAC1H,iBAAiB,sBAAsB;IACvC;qDACiD;IACjD,qBAAqB,0BAA0B;IAE/C;oGACgG;IAChG,sBAAsB,2BAA2B;IACjD;2GACuG;IACvG,0BAA0B,+BAA+B;IACzD;kHAC8G;IAC9G,0BAA0B,+BAA+B;IACzD;2CACuC;IACvC,8BAA8B,mCAAmC;IACjE;wHACoH;IACpH,2BAA2B,gCAAgC;IAC3D;qDACiD;IACjD,+BAA+B,oCAAoC;IACnE;oGACgG;IAChG,YAAY,iBAAiB;IAC7B;6GACyG;IACzG,gBAAgB,qBAAqB;IACrC;2GACuG;IACvG,mBAAmB,wBAAwB;IAC3C;+GAC2G;IAC3G,uBAAuB,4BAA4B;IACnD;kFAC8E;IAC9E,YAAY,iBAAiB;IAC7B;0FACsF;IACtF,gBAAgB,qBAAqB;IACrC;sGACkG;IAClG,gBAAgB,qBAAqB;IACrC;2CACuC;IACvC,oBAAoB,yBAAyB;IAC7C;6FACyF;IACzF,gBAAgB,qBAAqB;IACrC;qDACiD;IACjD,oBAAoB,yBAAyB;CAC9C;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,2EAA2E;IAC3E,GAAG,QAAQ;IACX,kFAAkF;IAClF,EAAE,OAAO;CACV"}
|
|
@@ -19,104 +19,110 @@ export var FilterOperator;
|
|
|
19
19
|
FilterOperator["LIKE"] = "LIKE";
|
|
20
20
|
/** Checks if a string value does not match a pattern. */
|
|
21
21
|
FilterOperator["NOT_LIKE"] = "NOT LIKE";
|
|
22
|
-
/** Checks if a value
|
|
23
|
-
FilterOperator["
|
|
24
|
-
/** Checks if a value
|
|
25
|
-
FilterOperator["
|
|
26
|
-
/** Checks if a value is NULL. */
|
|
27
|
-
FilterOperator["IS_NULL"] = "IS NULL";
|
|
28
|
-
/** Checks if a value is NOT NULL. */
|
|
29
|
-
FilterOperator["IS_NOT_NULL"] = "IS NOT NULL";
|
|
22
|
+
/** Checks if a string value matches a pattern (case-insensitive). */
|
|
23
|
+
FilterOperator["ILIKE"] = "ILIKE";
|
|
24
|
+
/** Checks if a string value does not match a pattern (case-insensitive). */
|
|
25
|
+
FilterOperator["NOT_ILIKE"] = "NOT_ILIKE";
|
|
30
26
|
/** Checks if a string value contains a specific substring (often case-insensitive, depends on DB). */
|
|
31
27
|
FilterOperator["CONTAINS"] = "CONTAINS";
|
|
28
|
+
/** Checks if a string value does not contain a specific substring. */
|
|
29
|
+
FilterOperator["NOT_CONTAINS"] = "NOT_CONTAINS";
|
|
32
30
|
/** Checks if a string value starts with a specific substring. */
|
|
33
31
|
FilterOperator["STARTS_WITH"] = "STARTS_WITH";
|
|
34
32
|
/** Checks if a string value ends with a specific substring. */
|
|
35
33
|
FilterOperator["ENDS_WITH"] = "ENDS_WITH";
|
|
36
|
-
/** Checks if a string value
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*/
|
|
49
|
-
FilterOperator["SET_NOT_CONTAINS"] = "SET_NOT_CONTAINS";
|
|
50
|
-
/**
|
|
51
|
-
* Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
52
|
-
* or a text field with comma-delimited values), contains AT LEAST ONE of the specified values.
|
|
53
|
-
* Expects an array of values.
|
|
54
|
-
*/
|
|
55
|
-
FilterOperator["SET_CONTAINS_ANY"] = "SET_CONTAINS_ANY";
|
|
56
|
-
/**
|
|
57
|
-
* Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
58
|
-
* or a text field with comma-delimited values), contains ALL of the specified values.
|
|
59
|
-
* Expects an array of values.
|
|
60
|
-
*/
|
|
61
|
-
FilterOperator["SET_CONTAINS_ALL"] = "SET_CONTAINS_ALL";
|
|
62
|
-
/**
|
|
63
|
-
* Checks if a value is within a specified range (inclusive).
|
|
64
|
-
* Expects an array or tuple of two values: [min, max].
|
|
65
|
-
*/
|
|
34
|
+
/** Checks if a string value matches a regular expression pattern.
|
|
35
|
+
* The specific regex syntax may depend on the database. */
|
|
36
|
+
FilterOperator["MATCHES_REGEX"] = "MATCHES_REGEX";
|
|
37
|
+
/** Checks if a value is within a set of specified values. */
|
|
38
|
+
FilterOperator["IN"] = "IN";
|
|
39
|
+
/** Checks if a value is not within a set of specified values. */
|
|
40
|
+
FilterOperator["NOT_IN"] = "NOT IN";
|
|
41
|
+
/** Checks if a value is NULL. */
|
|
42
|
+
FilterOperator["IS_NULL"] = "IS_NULL";
|
|
43
|
+
/** Checks if a value is NOT NULL. */
|
|
44
|
+
FilterOperator["IS_NOT_NULL"] = "IS_NOT_NULL";
|
|
45
|
+
/** Checks if a value is within a specified range (inclusive).
|
|
46
|
+
* Expects an array or tuple of two values: [min, max]. */
|
|
66
47
|
FilterOperator["BETWEEN"] = "BETWEEN";
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
* Expects an array or tuple of two values: [min, max].
|
|
70
|
-
*/
|
|
48
|
+
/** Checks if a value is outside a specified range (inclusive).
|
|
49
|
+
* Expects an array or tuple of two values: [min, max]. */
|
|
71
50
|
FilterOperator["NOT_BETWEEN"] = "NOT_BETWEEN";
|
|
72
|
-
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*
|
|
81
|
-
*/
|
|
82
|
-
FilterOperator["ILIKE"] = "ILIKE";
|
|
83
|
-
/**
|
|
84
|
-
* Checks if a string value does not match a pattern (case-insensitive).
|
|
85
|
-
* Expects a string for the pattern.
|
|
86
|
-
*/
|
|
87
|
-
FilterOperator["NOT_ILIKE"] = "NOT_ILIKE";
|
|
88
|
-
/**
|
|
89
|
-
* Checks if a JSON column contains a specific value or path.
|
|
90
|
-
* The specific implementation depends on the database (e.g., JSON_CONTAINS in MySQL, @> in PostgreSQL for JSONB).
|
|
91
|
-
*/
|
|
51
|
+
/** Checks if the value at a specific JSON path is equal to a given primitive value.
|
|
52
|
+
* This is for simple key-value equality checks within a JSON object.
|
|
53
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_PATH_VALUE_EQUALS, value: { 'status': 'published', 'views': 100 } } */
|
|
54
|
+
FilterOperator["JSON_PATH_VALUE_EQUALS"] = "JSON_PATH_VALUE_EQUALS";
|
|
55
|
+
/** Checks if the value at a specific JSON path is NOT equal to a given primitive value.
|
|
56
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_PATH_VALUE_NOT_EQUALS, value: { 'status': 'draft' } } */
|
|
57
|
+
FilterOperator["JSON_PATH_VALUE_NOT_EQUALS"] = "JSON_PATH_VALUE_NOT_EQUALS";
|
|
58
|
+
/** Checks if a JSON document (or a value at a specific path within it) contains a specified JSON value.
|
|
59
|
+
* This maps directly to database functions like MySQL's `JSON_CONTAINS`.
|
|
60
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_CONTAINS, value: { 'tags': 'tech', 'details.views': 100 } } */
|
|
92
61
|
FilterOperator["JSON_CONTAINS"] = "JSON_CONTAINS";
|
|
93
|
-
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*/
|
|
62
|
+
/** Checks if a JSON document (or a value at a specific path within it) does NOT contain a specified JSON value.
|
|
63
|
+
* This maps directly to database functions like MySQL's `JSON_CONTAINS` with negation.
|
|
64
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_NOT_CONTAINS, value: { 'tags': 'spam' } } */
|
|
97
65
|
FilterOperator["JSON_NOT_CONTAINS"] = "JSON_NOT_CONTAINS";
|
|
98
|
-
/**
|
|
99
|
-
*
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*/
|
|
66
|
+
/** Checks if a JSON document (or a value at a specific path within it) contains AT LEAST ONE of the specified JSON values.
|
|
67
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_CONTAINS_ANY, value: { 'tags': ['tech', 'news'] } } */
|
|
68
|
+
FilterOperator["JSON_CONTAINS_ANY"] = "JSON_CONTAINS_ANY";
|
|
69
|
+
/** Checks if a JSON document (or a value at a specific path within it) does NOT contain AT LEAST ONE of the specified JSON values.
|
|
70
|
+
* (i.e., it contains none of them). */
|
|
71
|
+
FilterOperator["JSON_NOT_CONTAINS_ANY"] = "JSON_NOT_CONTAINS_ANY";
|
|
72
|
+
/** Checks if a JSON document (or a value at a specific path within it) contains ALL of the specified JSON values.
|
|
73
|
+
* @example { field: 'metadata', operator: FilterOperator.JSON_CONTAINS_ALL, value: { 'tags': ['tech', 'important'] } } */
|
|
74
|
+
FilterOperator["JSON_CONTAINS_ALL"] = "JSON_CONTAINS_ALL";
|
|
75
|
+
/** Checks if a JSON document (or a value at a specific path within it) does NOT contain ALL of the specified JSON values.
|
|
76
|
+
* (i.e., it is missing at least one of them). */
|
|
77
|
+
FilterOperator["JSON_NOT_CONTAINS_ALL"] = "JSON_NOT_CONTAINS_ALL";
|
|
78
|
+
/** Checks if an array contains a specific element.
|
|
79
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_CONTAINS_ELEMENT, value: 'tech' } */
|
|
103
80
|
FilterOperator["ARRAY_CONTAINS_ELEMENT"] = "ARRAY_CONTAINS_ELEMENT";
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Checks if a column representing an array contains AT LEAST ONE element from the provided array.
|
|
111
|
-
* The underlying column could be a native array type or a JSON array.
|
|
112
|
-
*/
|
|
81
|
+
/** Checks if an array does NOT contain a specific element.
|
|
82
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_NOT_CONTAINS_ELEMENT, value: 'finance' } */
|
|
83
|
+
FilterOperator["ARRAY_NOT_CONTAINS_ELEMENT"] = "ARRAY_NOT_CONTAINS_ELEMENT";
|
|
84
|
+
/** Checks if an array contains AT LEAST ONE element from a given array.
|
|
85
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_CONTAINS_ANY_ELEMENT, value: ['tech', 'news'] } */
|
|
113
86
|
FilterOperator["ARRAY_CONTAINS_ANY_ELEMENT"] = "ARRAY_CONTAINS_ANY_ELEMENT";
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*/
|
|
87
|
+
/** Checks if an array does NOT contain AT LEAST ONE element from a given array.
|
|
88
|
+
* (i.e., it contains none of them). */
|
|
89
|
+
FilterOperator["ARRAY_NOT_CONTAINS_ANY_ELEMENT"] = "ARRAY_NOT_CONTAINS_ANY_ELEMENT";
|
|
90
|
+
/** Checks if an array contains ALL elements from a given array.
|
|
91
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_CONTAINS_ALL_ELEMENTS, value: ['tech', 'important'] } */
|
|
92
|
+
FilterOperator["ARRAY_CONTAINS_ALL_ELEMENTS"] = "ARRAY_CONTAINS_ALL_ELEMENTS";
|
|
93
|
+
/** Checks if an array does NOT contain ALL elements from a given array.
|
|
94
|
+
* (i.e., it is missing at least one of them). */
|
|
95
|
+
FilterOperator["ARRAY_NOT_CONTAINS_ALL_ELEMENTS"] = "ARRAY_NOT_CONTAINS_ALL_ELEMENTS";
|
|
96
|
+
/** Checks if an array is equal to a given array (order-insensitive).
|
|
97
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_EQUALS, value: ['news', 'tech'] } */
|
|
119
98
|
FilterOperator["ARRAY_EQUALS"] = "ARRAY_EQUALS";
|
|
99
|
+
/** Checks if an array is NOT equal to a given array (order-insensitive).
|
|
100
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_NOT_EQUALS, value: ['finance', 'sports'] } */
|
|
101
|
+
FilterOperator["ARRAY_NOT_EQUALS"] = "ARRAY_NOT_EQUALS";
|
|
102
|
+
/** Checks if an array is exactly equal to a given array (order-sensitive).
|
|
103
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_EQUALS_STRICT, value: ['tech', 'news'] } */
|
|
104
|
+
FilterOperator["ARRAY_EQUALS_STRICT"] = "ARRAY_EQUALS_STRICT";
|
|
105
|
+
/** Checks if an array is NOT exactly equal to a given array (order-sensitive).
|
|
106
|
+
* @example { field: 'tags', operator: FilterOperator.ARRAY_NOT_EQUALS_STRICT, value: ['news', 'tech'] } */
|
|
107
|
+
FilterOperator["ARRAY_NOT_EQUALS_STRICT"] = "ARRAY_NOT_EQUALS_STRICT";
|
|
108
|
+
/** Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
109
|
+
* or a text field with comma-delimited values), contains a specific value. */
|
|
110
|
+
FilterOperator["SET_CONTAINS"] = "SET_CONTAINS";
|
|
111
|
+
/** Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
112
|
+
* or a text field with comma-delimited values), does NOT contain a specific value. */
|
|
113
|
+
FilterOperator["SET_NOT_CONTAINS"] = "SET_NOT_CONTAINS";
|
|
114
|
+
/** Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
115
|
+
* or a text field with comma-delimited values), contains AT LEAST ONE of the specified values. */
|
|
116
|
+
FilterOperator["SET_CONTAINS_ANY"] = "SET_CONTAINS_ANY";
|
|
117
|
+
/** Checks if a field, representing a collection of values, does NOT contain AT LEAST ONE of the specified values.
|
|
118
|
+
* (i.e., it contains none of them). */
|
|
119
|
+
FilterOperator["SET_NOT_CONTAINS_ANY"] = "SET_NOT_CONTAINS_ANY";
|
|
120
|
+
/** Checks if a field, representing a collection of values (e.g., MySQL SET type
|
|
121
|
+
* or a text field with comma-delimited values), contains ALL of the specified values. */
|
|
122
|
+
FilterOperator["SET_CONTAINS_ALL"] = "SET_CONTAINS_ALL";
|
|
123
|
+
/** Checks if a field, representing a collection of values, does NOT contain ALL of the specified values.
|
|
124
|
+
* (i.e., it is missing at least one of them). */
|
|
125
|
+
FilterOperator["SET_NOT_CONTAINS_ALL"] = "SET_NOT_CONTAINS_ALL";
|
|
120
126
|
})(FilterOperator || (FilterOperator = {}));
|
|
121
127
|
/**
|
|
122
128
|
* Enumerates the logical operators used to combine filter conditions or groups.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.types.js","sourceRoot":"","sources":["../../../src/criteria/types/operator.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"operator.types.js","sourceRoot":"","sources":["../../../src/criteria/types/operator.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,cA8HX;AA9HD,WAAY,cAAc;IACxB,2BAA2B;IAC3B,8BAAY,CAAA;IACZ,6BAA6B;IAC7B,mCAAiB,CAAA;IACjB,iDAAiD;IACjD,oCAAkB,CAAA;IAClB,6DAA6D;IAC7D,+CAA6B,CAAA;IAC7B,8CAA8C;IAC9C,iCAAe,CAAA;IACf,0DAA0D;IAC1D,4CAA0B,CAAA;IAE1B,wFAAwF;IACxF,+BAAa,CAAA;IACb,yDAAyD;IACzD,uCAAqB,CAAA;IACrB,qEAAqE;IACrE,iCAAe,CAAA;IACf,4EAA4E;IAC5E,yCAAuB,CAAA;IACvB,sGAAsG;IACtG,uCAAqB,CAAA;IACrB,sEAAsE;IACtE,+CAA6B,CAAA;IAC7B,iEAAiE;IACjE,6CAA2B,CAAA;IAC3B,+DAA+D;IAC/D,yCAAuB,CAAA;IACvB;+DAC2D;IAC3D,iDAA+B,CAAA;IAE/B,6DAA6D;IAC7D,2BAAS,CAAA;IACT,iEAAiE;IACjE,mCAAiB,CAAA;IACjB,iCAAiC;IACjC,qCAAmB,CAAA;IACnB,qCAAqC;IACrC,6CAA2B,CAAA;IAE3B;8DAC0D;IAC1D,qCAAmB,CAAA;IACnB;8DAC0D;IAC1D,6CAA2B,CAAA;IAE3B;;yIAEqI;IACrI,mEAAiD,CAAA;IACjD;2HACuH;IACvH,2EAAyD,CAAA;IACzD;;iIAE6H;IAC7H,iDAA+B,CAAA;IAC/B;;+GAE2G;IAC3G,yDAAuC,CAAA;IACvC;yHACqH;IACrH,yDAAuC,CAAA;IACvC;2CACuC;IACvC,iEAA+C,CAAA;IAC/C;8HAC0H;IAC1H,yDAAuC,CAAA;IACvC;qDACiD;IACjD,iEAA+C,CAAA;IAE/C;oGACgG;IAChG,mEAAiD,CAAA;IACjD;2GACuG;IACvG,2EAAyD,CAAA;IACzD;kHAC8G;IAC9G,2EAAyD,CAAA;IACzD;2CACuC;IACvC,mFAAiE,CAAA;IACjE;wHACoH;IACpH,6EAA2D,CAAA;IAC3D;qDACiD;IACjD,qFAAmE,CAAA;IACnE;oGACgG;IAChG,+CAA6B,CAAA;IAC7B;6GACyG;IACzG,uDAAqC,CAAA;IACrC;2GACuG;IACvG,6DAA2C,CAAA;IAC3C;+GAC2G;IAC3G,qEAAmD,CAAA;IACnD;kFAC8E;IAC9E,+CAA6B,CAAA;IAC7B;0FACsF;IACtF,uDAAqC,CAAA;IACrC;sGACkG;IAClG,uDAAqC,CAAA;IACrC;2CACuC;IACvC,+DAA6C,CAAA;IAC7C;6FACyF;IACzF,uDAAqC,CAAA;IACrC;qDACiD;IACjD,+DAA6C,CAAA;AAC/C,CAAC,EA9HW,cAAc,KAAd,cAAc,QA8HzB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,2EAA2E;IAC3E,8BAAW,CAAA;IACX,kFAAkF;IAClF,4BAAS,CAAA;AACX,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B"}
|
|
@@ -7,43 +7,115 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export type JoinRelationType = 'one_to_one' | 'one_to_many' | 'many_to_one' | 'many_to_many';
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @template
|
|
10
|
+
* Extracts a union type of all valid field names from a given {@link CriteriaSchema}.
|
|
11
|
+
* @template T - The {@link CriteriaSchema} from which to extract field names.
|
|
12
|
+
* @example type UserFields = FieldOfSchema<typeof UserSchema>; // "id" | "name" | "email"
|
|
12
13
|
*/
|
|
13
|
-
export type
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
export type FieldOfSchema<T extends CriteriaSchema> = T['fields'] extends ReadonlyArray<string> ? T['fields'][number] : never;
|
|
15
|
+
/**
|
|
16
|
+
* Describes the configuration for a simple joinable relation (one-to-one, one-to-many, many-to-one).
|
|
17
|
+
* The `relation_field` is not strongly typed against the target schema at compile-time to avoid complex cross-schema dependencies.
|
|
18
|
+
* It will be validated at runtime when the schema is defined and when the join is processed.
|
|
19
|
+
* @template TFields - The readonly array of field names from the local schema.
|
|
20
|
+
* @template ValidAlias - A string literal type representing the alias for this specific relation.
|
|
21
|
+
*/
|
|
22
|
+
export type SchemaSimpleJoin<TFields extends ReadonlyArray<string>, ValidAlias extends string> = {
|
|
23
|
+
/** The alias for this specific relation, used to identify it in `.join()` calls. */
|
|
24
|
+
relation_alias: ValidAlias;
|
|
16
25
|
/** The type of relationship this join represents (e.g., 'one_to_many'). */
|
|
17
|
-
relation_type:
|
|
26
|
+
relation_type: 'one_to_one' | 'one_to_many' | 'many_to_one';
|
|
27
|
+
/** The `source_name` of the schema that this relation targets. Used for robust validation. */
|
|
28
|
+
target_source_name: string;
|
|
29
|
+
/**
|
|
30
|
+
* The field name in the local schema used for the join condition.
|
|
31
|
+
* This field is strongly typed against the local schema's fields.
|
|
32
|
+
*/
|
|
33
|
+
local_field: TFields[number];
|
|
34
|
+
/**
|
|
35
|
+
* The field name in the target schema (the related entity) used for the join condition.
|
|
36
|
+
* This field is a string and will be validated at runtime.
|
|
37
|
+
*/
|
|
38
|
+
relation_field: string;
|
|
39
|
+
/**
|
|
40
|
+
* Optional metadata associated with this specific join configuration.
|
|
41
|
+
*/
|
|
42
|
+
metadata?: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Describes the configuration for a many-to-many joinable relation (via a pivot table).
|
|
48
|
+
* The `relation_field.reference` is not strongly typed against the target schema at compile-time to avoid complex cross-schema dependencies.
|
|
49
|
+
* It will be validated at runtime when the schema is defined and when the join is processed.
|
|
50
|
+
* @template TFields - The readonly array of field names from the local schema.
|
|
51
|
+
* @template ValidAlias - A string literal type representing the alias for this specific relation.
|
|
52
|
+
*/
|
|
53
|
+
export type SchemaPivotJoin<TFields extends ReadonlyArray<string>, ValidAlias extends string> = {
|
|
54
|
+
/** The alias for this specific relation, used to identify it in `.join()` calls. */
|
|
55
|
+
relation_alias: ValidAlias;
|
|
56
|
+
/** The type of relationship this join represents (must be 'many_to_many'). */
|
|
57
|
+
relation_type: 'many_to_many';
|
|
58
|
+
/** The `source_name` of the schema that this relation targets. Used for robust validation. */
|
|
59
|
+
target_source_name: string;
|
|
60
|
+
/** The source name (table name) of the pivot table. */
|
|
61
|
+
pivot_source_name: string;
|
|
62
|
+
/** Configuration for the join field on the local side, referencing the pivot table. */
|
|
63
|
+
local_field: {
|
|
64
|
+
/** The field name in the pivot table that links to the local schema. */
|
|
65
|
+
pivot_field: string;
|
|
66
|
+
/**
|
|
67
|
+
* The field name in the local schema that the pivot table field references.
|
|
68
|
+
* This field is strongly typed against the local schema's fields.
|
|
69
|
+
*/
|
|
70
|
+
reference: TFields[number];
|
|
71
|
+
};
|
|
72
|
+
/** Configuration for the join field on the related side, referencing the pivot table. */
|
|
73
|
+
relation_field: {
|
|
74
|
+
/** The field name in the pivot table that links to the related schema. */
|
|
75
|
+
pivot_field: string;
|
|
76
|
+
/**
|
|
77
|
+
* The field name in the related schema that the pivot table field references.
|
|
78
|
+
* This field is a string and will be validated at runtime.
|
|
79
|
+
*/
|
|
80
|
+
reference: string;
|
|
81
|
+
};
|
|
18
82
|
/**
|
|
19
83
|
* Optional metadata associated with this specific join configuration.
|
|
20
|
-
* This allows for storing arbitrary, translator-specific information
|
|
21
|
-
* or hints directly within the schema definition for a join.
|
|
22
|
-
* For example, it could hold database-specific join hints or
|
|
23
|
-
* information about how to handle the join in a particular ORM.
|
|
24
84
|
*/
|
|
25
85
|
metadata?: {
|
|
26
86
|
[key: string]: any;
|
|
27
87
|
};
|
|
28
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Describes the configuration for a joinable relation within a {@link CriteriaSchema}.
|
|
91
|
+
* It is a union of simple and pivot join types.
|
|
92
|
+
* @template TFields - The readonly array of field names from the local schema.
|
|
93
|
+
* @template ValidAlias - A string literal type representing the alias for this specific relation.
|
|
94
|
+
*/
|
|
95
|
+
export type SchemaJoins<TFields extends ReadonlyArray<string>, ValidAlias extends string> = SchemaSimpleJoin<TFields, ValidAlias> | SchemaPivotJoin<TFields, ValidAlias>;
|
|
29
96
|
/**
|
|
30
97
|
* Represents the schema definition for an entity, used by the Criteria system.
|
|
31
|
-
* It defines the entity's source name (e.g., table name),
|
|
98
|
+
* It defines the entity's source name (e.g., table name), a single canonical alias,
|
|
32
99
|
* fields, and joinable relations.
|
|
33
100
|
* @template TFields - A readonly array of string literal types representing the entity's field names.
|
|
34
|
-
* @template
|
|
101
|
+
* @template TAliase - A string literal type for the entity's canonical alias.
|
|
35
102
|
* @template TSourceName - A string literal type for the entity's source name.
|
|
36
|
-
* @template
|
|
103
|
+
* @template Joins - A readonly array of `SchemaJoins` capturing the exact literal types of the relations.
|
|
37
104
|
*/
|
|
38
|
-
export type CriteriaSchema<TFields extends ReadonlyArray<string> = ReadonlyArray<string>,
|
|
105
|
+
export type CriteriaSchema<TFields extends ReadonlyArray<string> = ReadonlyArray<string>, TAliase extends string = string, TSourceName extends string = string, Joins extends ReadonlyArray<SchemaJoins<TFields, string>> = ReadonlyArray<SchemaJoins<TFields, string>>> = {
|
|
39
106
|
/** The source name of the entity (e.g., database table name). */
|
|
40
107
|
source_name: TSourceName;
|
|
41
|
-
/**
|
|
42
|
-
alias:
|
|
108
|
+
/** The canonical alias used to refer to this entity in queries. */
|
|
109
|
+
alias: TAliase;
|
|
43
110
|
/** An array of field names available for this entity. */
|
|
44
111
|
fields: TFields;
|
|
45
112
|
/** An array of configurations for entities that can be joined from this entity. */
|
|
46
|
-
|
|
113
|
+
relations: Joins;
|
|
114
|
+
/**
|
|
115
|
+
* The name of the field that uniquely identifies an entity of this schema.
|
|
116
|
+
* This field **must** be one of the names listed in the `fields` array.
|
|
117
|
+
*/
|
|
118
|
+
identifier_field: TFields[number];
|
|
47
119
|
/**
|
|
48
120
|
* Optional metadata associated with the entire schema definition.
|
|
49
121
|
* This can be used to store arbitrary, translator-specific information
|
|
@@ -57,29 +129,23 @@ export type CriteriaSchema<TFields extends ReadonlyArray<string> = ReadonlyArray
|
|
|
57
129
|
};
|
|
58
130
|
/**
|
|
59
131
|
* A helper function to infer and preserve the literal types of a schema definition.
|
|
60
|
-
* Use this when defining schemas to get strong typing for fields, aliases,
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
63
|
-
* @
|
|
64
|
-
* @
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* fields: ['id', 'name', 'email'],
|
|
69
|
-
* joins: [{ alias: 'posts', relation_type: 'one_to_many' }]
|
|
70
|
-
* });
|
|
71
|
-
*/
|
|
72
|
-
export declare function GetTypedCriteriaSchema<const TInput extends CriteriaSchema>(schema: TInput): TInput;
|
|
73
|
-
/**
|
|
74
|
-
* Extracts a union type of all valid field names from a given {@link CriteriaSchema}.
|
|
75
|
-
* @template T - The {@link CriteriaSchema} from which to extract field names.
|
|
76
|
-
* @example type UserFields = FieldOfSchema<typeof UserSchema>; // "id" | "name" | "email"
|
|
77
|
-
*/
|
|
78
|
-
export type FieldOfSchema<T extends CriteriaSchema> = T['fields'] extends ReadonlyArray<string> ? T['fields'][number] : never;
|
|
79
|
-
/**
|
|
80
|
-
* Extracts a union type of all valid aliases from a given {@link CriteriaSchema}.
|
|
81
|
-
* @template T - The {@link CriteriaSchema} from which to extract aliases.
|
|
82
|
-
* @example type UserAliases = SelectedAliasOf<typeof UserSchema>; // "user" | "u"
|
|
132
|
+
* Use this when defining schemas to get strong typing for fields, aliases, and relations.
|
|
133
|
+
* This function also performs runtime validation for the schema structure.
|
|
134
|
+
* @template TFields - A readonly array of string literal types representing the entity's field names.
|
|
135
|
+
* @template TAliase - A string literal type for the entity's canonical alias.
|
|
136
|
+
* @template TSourceName - A string literal type for the entity's source name.
|
|
137
|
+
* @template Joins - A readonly array of `SchemaJoins` capturing the exact literal types of the relations.
|
|
138
|
+
* @param schema - The schema definition object.
|
|
139
|
+
* @returns The same schema object, with its literal types preserved for strong type inference.
|
|
83
140
|
*/
|
|
84
|
-
export
|
|
141
|
+
export declare function GetTypedCriteriaSchema<const TFields extends ReadonlyArray<string>, const TAliase extends string, const TSourceName extends string, const Joins extends ReadonlyArray<SchemaJoins<TFields, string>>>(schema: {
|
|
142
|
+
source_name: TSourceName;
|
|
143
|
+
alias: TAliase;
|
|
144
|
+
fields: TFields;
|
|
145
|
+
relations: Joins;
|
|
146
|
+
identifier_field: TFields[number];
|
|
147
|
+
metadata?: {
|
|
148
|
+
[key: string]: any;
|
|
149
|
+
};
|
|
150
|
+
}): CriteriaSchema<TFields, TAliase, TSourceName, Joins>;
|
|
85
151
|
//# sourceMappingURL=schema.types.d.ts.map
|