@nulledexp/translatable-criteria 1.1.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.
Files changed (71) hide show
  1. package/README.md +89 -85
  2. package/dist/criteria/criteria-factory.d.ts +6 -5
  3. package/dist/criteria/criteria-factory.d.ts.map +1 -1
  4. package/dist/criteria/criteria-factory.js +8 -8
  5. package/dist/criteria/criteria-factory.js.map +1 -1
  6. package/dist/criteria/criteria-join-manager.js.map +1 -1
  7. package/dist/criteria/criteria.d.ts +188 -17
  8. package/dist/criteria/criteria.d.ts.map +1 -1
  9. package/dist/criteria/criteria.js +219 -44
  10. package/dist/criteria/criteria.js.map +1 -1
  11. package/dist/criteria/cursor.d.ts +15 -0
  12. package/dist/criteria/cursor.d.ts.map +1 -1
  13. package/dist/criteria/cursor.js +24 -2
  14. package/dist/criteria/cursor.js.map +1 -1
  15. package/dist/criteria/filter/filter-group.d.ts +7 -1
  16. package/dist/criteria/filter/filter-group.d.ts.map +1 -1
  17. package/dist/criteria/filter/filter-group.js +12 -3
  18. package/dist/criteria/filter/filter-group.js.map +1 -1
  19. package/dist/criteria/filter/filter.d.ts +3 -3
  20. package/dist/criteria/filter/filter.d.ts.map +1 -1
  21. package/dist/criteria/filter/filter.js +37 -14
  22. package/dist/criteria/filter/filter.js.map +1 -1
  23. package/dist/criteria/filter/types/filter-primitive.types.d.ts +16 -6
  24. package/dist/criteria/filter/types/filter-primitive.types.d.ts.map +1 -1
  25. package/dist/criteria/index.d.ts +2 -2
  26. package/dist/criteria/index.d.ts.map +1 -1
  27. package/dist/criteria/index.js.map +1 -1
  28. package/dist/criteria/join/inner.join-criteria.d.ts +12 -14
  29. package/dist/criteria/join/inner.join-criteria.d.ts.map +1 -1
  30. package/dist/criteria/join/inner.join-criteria.js +13 -15
  31. package/dist/criteria/join/inner.join-criteria.js.map +1 -1
  32. package/dist/criteria/join/left.join-criteria.d.ts +9 -4
  33. package/dist/criteria/join/left.join-criteria.d.ts.map +1 -1
  34. package/dist/criteria/join/left.join-criteria.js +10 -5
  35. package/dist/criteria/join/left.join-criteria.js.map +1 -1
  36. package/dist/criteria/join/outer.join-criteria.d.ts +15 -13
  37. package/dist/criteria/join/outer.join-criteria.d.ts.map +1 -1
  38. package/dist/criteria/join/outer.join-criteria.js +16 -14
  39. package/dist/criteria/join/outer.join-criteria.js.map +1 -1
  40. package/dist/criteria/order/order.d.ts +18 -1
  41. package/dist/criteria/order/order.d.ts.map +1 -1
  42. package/dist/criteria/order/order.js +21 -1
  43. package/dist/criteria/order/order.js.map +1 -1
  44. package/dist/criteria/root.criteria.d.ts +11 -16
  45. package/dist/criteria/root.criteria.d.ts.map +1 -1
  46. package/dist/criteria/root.criteria.js +9 -14
  47. package/dist/criteria/root.criteria.js.map +1 -1
  48. package/dist/criteria/translator/criteria-translator.d.ts +23 -32
  49. package/dist/criteria/translator/criteria-translator.d.ts.map +1 -1
  50. package/dist/criteria/translator/criteria-translator.js +5 -24
  51. package/dist/criteria/translator/criteria-translator.js.map +1 -1
  52. package/dist/criteria/types/criteria.interface.d.ts +60 -44
  53. package/dist/criteria/types/criteria.interface.d.ts.map +1 -1
  54. package/dist/criteria/types/criteria.interface.js.map +1 -1
  55. package/dist/criteria/types/join-parameter.types.d.ts +56 -6
  56. package/dist/criteria/types/join-parameter.types.d.ts.map +1 -1
  57. package/dist/criteria/types/join-utility.types.d.ts +25 -31
  58. package/dist/criteria/types/join-utility.types.d.ts.map +1 -1
  59. package/dist/criteria/types/manager.interface.d.ts +3 -3
  60. package/dist/criteria/types/manager.interface.d.ts.map +1 -1
  61. package/dist/criteria/types/operator.types.d.ts +92 -86
  62. package/dist/criteria/types/operator.types.d.ts.map +1 -1
  63. package/dist/criteria/types/operator.types.js +91 -85
  64. package/dist/criteria/types/operator.types.js.map +1 -1
  65. package/dist/criteria/types/schema.types.d.ts +127 -37
  66. package/dist/criteria/types/schema.types.d.ts.map +1 -1
  67. package/dist/criteria/types/schema.types.js +38 -11
  68. package/dist/criteria/types/schema.types.js.map +1 -1
  69. package/dist/criteria/types/visitor-interface.types.d.ts +33 -12
  70. package/dist/criteria/types/visitor-interface.types.d.ts.map +1 -1
  71. package/package.json +1 -1
package/README.md CHANGED
@@ -3,7 +3,8 @@
3
3
  [![NPM Version](https://img.shields.io/npm/v/@nulledexp/translatable-criteria.svg)](https://www.npmjs.com/package/@nulledexp/translatable-criteria)
4
4
  ![NPM Downloads](https://img.shields.io/npm/dw/%40nulledexp%2Ftranslatable-criteria)
5
5
  [![Development Stage](https://img.shields.io/badge/Development-Active%20Development-green)]()
6
- [![Documentation](https://img.shields.io/badge/Documentation-EN/ES-blue)](./src/docs/introduction/en.md)
6
+ [![Documentation](https://img.shields.io/badge/Documentation-EN-blue)](./src/docs/introduction/en.md)
7
+ [![Documentation](https://img.shields.io/badge/Documentation-ES-blue)](./src/docs/introduction/es.md)
7
8
  [![CI](https://github.com/Techscq/translatable-criteria/actions/workflows/ci.yml/badge.svg)](https://github.com/Techscq/translatable-criteria/actions/workflows/ci.yml)
8
9
 
9
10
  A TypeScript library for building data-source agnostic, translatable query criteria. Define complex filtering, ordering, and join logic in a structured, type-safe way, then translate it to your specific data source using custom translators.
@@ -16,84 +17,88 @@ npm install @nulledexp/translatable-criteria
16
17
 
17
18
  ## Overview
18
19
 
19
- This library simplifies the construction of complex data queries by providing a consistent and abstract way to define filtering, ordering, field selection, pagination (offset and cursor-based), and relationship (joins) configurations. The core concept revolves around the `Criteria` object hierarchy, which allows developers to define sophisticated query specifications in a data source-agnostic manner. These `Criteria` objects can then be processed by a `CriteriaTranslator` (using the Visitor pattern) to generate queries for various data sources.
20
+ This library simplifies the construction of complex data queries by providing a consistent and abstract way to define filtering, ordering, field selection, pagination (offset and cursor-based), and relationship (joins) configurations. The core concept revolves around the `Criteria` object hierarchy, which allows developers to define sophisticated query specifications in a data source-agnostic manner, now with enhanced schema validation (including `identifier_field`) and richer context for translators (like `parent_identifier`). These `Criteria` objects can then be processed by a `CriteriaTranslator` to generate queries for various data sources.
20
21
 
21
22
  ## Key Features
22
23
 
23
- - **Enhanced Type-Safety:** Construct queries with a fluent, strongly-typed interface, benefiting from compile-time and runtime validation of field names, aliases, and join parameters based on your schemas.
24
- - **Powerful Filtering:** Define intricate filtering logic with multiple operators (including for JSON and arrays) and grouping. Filter groups are automatically normalized for consistency.
25
- - **Flexible Join System:** Support for various join types (inner, left, full outer) and pivot table configurations, with validation of join parameters according to the relation type.
26
- - **Default Join Field Selection:** When a join is added, if `setSelect()` is not explicitly called on the `JoinCriteria`, all fields from the joined schema will be automatically included in the main `SELECT` clause. This can be overridden by using `setSelect()` on the specific `JoinCriteria`.
27
- - **Field Selection:** Specify exactly which fields to retrieve using `setSelect()`. Use `resetSelect()` to select all fields (which is also the default behavior).
24
+ - **Enhanced Type-Safety:** Construct queries with a fluent, strongly-typed interface, benefiting from compile-time and runtime validation of field names (including `identifier_field`), aliases, and join parameters based on your schemas.
25
+ - **Powerful Filtering:** Define intricate filtering logic with multiple operators (including for JSON, arrays, sets, ranges, and regex) and grouping. Filter groups are automatically normalized for consistency.
26
+ - **Flexible Join System:** Support for various join types (inner, left, full outer) and pivot table configurations. Join parameters now include `parent_identifier` to provide richer context to translators for relationship inference (e.g., for `one_to_one`).
27
+ - **Granular Null-Value Sorting:** Explicitly control whether `NULL` values appear first or last in your ordered results.
28
+ - **Filter-Only Joins:** Improve query performance by creating joins solely for filtering, without including their fields in the final `SELECT` statement.
29
+ - **Field Selection & `identifier_field`:** Specify exactly which fields to retrieve using `setSelect()`. The `identifier_field` of an entity is automatically included when `setSelect()` is used. Use `resetSelect()` to select all fields (default behavior).
28
30
  - **Pagination:** Supports both offset-based (`setTake()`, `setSkip()`) and cursor-based (`setCursor()`) pagination.
29
- - **Visitor Pattern for Translation:** Criteria objects implement an `accept` method, allowing for clean and extensible translation logic via the Visitor pattern.
30
31
  - **Data Source Agnostic:** Design criteria independently of the underlying data source.
31
32
  - **Translator-Based Architecture:** The core library defines criteria; actual translation is handled by separate translator packages that implement the `CriteriaTranslator` interface.
32
33
  - **Full TypeScript Support:** Benefit from compile-time validation and autocompletion.
33
34
 
34
35
  ## Core Concepts
35
36
 
36
- The library is built upon a few fundamental concepts. For detailed explanations, please refer to our Core Concepts Documentation.
37
+ The library is built upon a few fundamental concepts. For detailed explanations, please refer to our documentation guides.
37
38
 
38
- - **`Criteria` Hierarchy:** Abstract base for query specifications (`RootCriteria`, `InnerJoinCriteria`, etc.). Learn more.
39
- - **`CriteriaFactory`:** Recommended utility for creating `Criteria` instances (e.g., `CriteriaFactory.GetCriteria(...)`, `CriteriaFactory.GetInnerJoinCriteria(...)`). Learn more.
40
- - **Schemas (`CriteriaSchema` & `GetTypedCriteriaSchema`):** Define your data entities' structure for type-safe criteria construction. Learn more.
41
- - **`CriteriaTranslator`:** Abstract class for converting `Criteria` objects into specific data source queries using the Visitor pattern. Learn more.
39
+ - [**`Criteria` Hierarchy:**](./src/docs/core-concepts/en.md#criteria-hierarchy) Abstract base for query specifications (`RootCriteria`, `InnerJoinCriteria`, etc.).
40
+ - [**`CriteriaFactory`:**](./src/docs/core-concepts/en.md#criteriafactory) Recommended utility for creating `Criteria` instances.
41
+ - [**Schemas (`CriteriaSchema` & `GetTypedCriteriaSchema`):**](./src/docs/guides/schema-definitions/en.md) Define your data entities' structure for type-safe criteria construction.
42
+ - [**`CriteriaTranslator`:**](./src/docs/guides/developing-translators/en.md) Abstract class responsible for converting `Criteria` objects into specific data source queries.
42
43
 
43
44
  ## Usage Example (Core Library)
44
45
 
45
- This package provides the tools to define your query criteria.
46
+ This package provides the tools to define your query criteria. The core philosophy is to define relationship logic **once** in the schema, and then simply reference it when building criteria.
46
47
 
47
48
  ### 1. Define Schemas
48
49
 
50
+ First, define your entity schemas using `GetTypedCriteriaSchema`. This is where you declare how entities are related by defining `local_field`, `relation_field`, etc.
51
+
49
52
  ```typescript
50
53
  import { GetTypedCriteriaSchema } from '@nulledexp/translatable-criteria';
51
54
 
52
55
  export const UserSchema = GetTypedCriteriaSchema({
53
- source_name: 'user',
54
- alias: ['users', 'user', 'publisher'],
55
- fields: ['uuid', 'email', 'username', 'created_at'],
56
- joins: [
57
- { alias: 'posts', join_relation_type: 'one_to_many' },
58
- // other joins like 'permissions', 'addresses' can be defined here
56
+ source_name: 'users',
57
+ alias: 'u',
58
+ fields: ['id', 'username', 'email', 'age', 'isActive', 'createdAt'],
59
+ identifier_field: 'id',
60
+ relations: [
61
+ {
62
+ relation_alias: 'posts',
63
+ target_source_name: 'posts',
64
+ relation_type: 'one_to_many',
65
+ local_field: 'id',
66
+ relation_field: 'userId',
67
+ },
59
68
  ],
60
69
  });
61
- export type UserSchema = typeof UserSchema;
62
70
 
63
71
  export const PostSchema = GetTypedCriteriaSchema({
64
- source_name: 'post',
65
- alias: ['posts', 'post'],
66
- fields: [
67
- 'uuid',
68
- 'title',
69
- 'body',
70
- 'user_uuid',
71
- 'created_at',
72
- 'categories', // Example: for array filters
73
- 'metadata', // Example: for JSON filters
74
- ],
75
- joins: [
76
- { alias: 'comments', join_relation_type: 'one_to_many' },
77
- { alias: 'publisher', join_relation_type: 'many_to_one' },
72
+ source_name: 'posts',
73
+ alias: 'p',
74
+ fields: ['id', 'title', 'content', 'userId', 'createdAt'],
75
+ identifier_field: 'id',
76
+ relations: [
77
+ {
78
+ relation_alias: 'user',
79
+ target_source_name: 'users',
80
+ relation_type: 'many_to_one',
81
+ local_field: 'userId',
82
+ relation_field: 'id',
83
+ },
78
84
  ],
79
85
  });
80
- export type PostSchema = typeof PostSchema;
81
-
82
- // Define other schemas (PermissionSchema, PostCommentSchema, AddressSchema) as needed for your application.
83
- // See the full documentation for more examples.
84
86
  ```
85
87
 
86
- ### 2. Create Criteria
88
+ ### 2. Create a Simple Criteria
89
+
90
+ Use `CriteriaFactory` to create a `Criteria` object and apply filters or ordering.
87
91
 
88
92
  ```typescript
89
93
  import {
90
94
  CriteriaFactory,
91
95
  FilterOperator,
96
+ OrderDirection,
92
97
  } from '@nulledexp/translatable-criteria';
93
- import { UserSchema } from './path/to/your/criteria/schemas'; // Adjust path
98
+ import { UserSchema } from './path/to/your/schemas'; // Adjust path
94
99
 
95
100
  // Create Criteria for the User entity
96
- const userCriteria = CriteriaFactory.GetCriteria(UserSchema, 'users');
101
+ const userCriteria = CriteriaFactory.GetCriteria(UserSchema);
97
102
 
98
103
  // Example: Add a simple filter
99
104
  userCriteria.where({
@@ -103,17 +108,45 @@ userCriteria.where({
103
108
  });
104
109
 
105
110
  // Example: Add ordering
106
- userCriteria.orderBy('created_at', 'DESC');
111
+ userCriteria.orderBy('createdAt', OrderDirection.DESC);
107
112
 
108
113
  // The 'userCriteria' object is now ready to be passed to a translator.
109
114
  ```
110
115
 
116
+ ### 3. Create Criteria with a Join
117
+
118
+ To add a join, simply call the `.join()` method with the `relation_alias` you defined in the schema. The library automatically uses the configuration you provided, eliminating the need for manual join parameters.
119
+
120
+ ```typescript
121
+ import {
122
+ CriteriaFactory,
123
+ FilterOperator,
124
+ } from '@nulledexp/translatable-criteria';
125
+ import { PostSchema, UserSchema } from './path/to/your/schemas'; // Adjust path
126
+
127
+ // Find posts from active users
128
+ const postCriteria = CriteriaFactory.GetCriteria(PostSchema);
129
+
130
+ const activeUserJoin = CriteriaFactory.GetInnerJoinCriteria(UserSchema).where({
131
+ field: 'isActive',
132
+ operator: FilterOperator.EQUALS,
133
+ value: true,
134
+ });
135
+
136
+ // The join is now declarative. Just provide the relation alias.
137
+ postCriteria.join('user', activeUserJoin);
138
+
139
+ // The 'postCriteria' object is now ready to be passed to a translator.
140
+ ```
141
+
142
+ ---
143
+
111
144
  ## Available Translators
112
145
 
113
- To interact with a database, you'll need a translator package.
146
+ To interact with a database, you'll need a translator package. You can either build your own following our Criteria Translator Development Guide or use one from the community.
114
147
 
115
148
  - **`@nulledexp/typeorm-mysql-criteria-translator`**:
116
- A translator for generating TypeORM `SelectQueryBuilder` instances for MySQL.
149
+ - A translator for generating TypeORM `SelectQueryBuilder` instances for MySQL.
117
150
  - **Author:** Nelson Cabrera
118
151
  - **Installation**:
119
152
 
@@ -121,58 +154,25 @@ To interact with a database, you'll need a translator package.
121
154
  npm install @nulledexp/typeorm-mysql-criteria-translator
122
155
  ```
123
156
 
124
- - **Usage (basic)**:
125
-
126
- ```typescript
127
- import {
128
- CriteriaFactory,
129
- FilterOperator,
130
- } from '@nulledexp/translatable-criteria';
131
- import { TypeOrmMysqlTranslator } from '@nulledexp/typeorm-mysql-criteria-translator'; // Using new suggested name
132
- import { UserSchema } from './path/to/your/criteria/schemas'; // Your Criteria Schema
133
- // import { YourTypeOrmUserEntity } from './path/to/your/typeorm/entities'; // Your actual TypeORM entity
134
- // import { DbDatasource } from './path-to-your-datasource-config'; // Your initialized TypeORM DataSource instance
135
-
136
- // 1. Define your Criteria using @nulledexp/translatable-criteria
137
- const criteria = CriteriaFactory.GetCriteria(UserSchema, 'users') // 'users' is an alias from UserSchema
138
- .where({
139
- field: 'username', // Field from UserSchema
140
- operator: FilterOperator.EQUALS,
141
- value: 'testuser',
142
- })
143
- .setTake(10);
144
-
145
- // 2. Use the translator with your TypeORM QueryBuilder
146
- // (Conceptual - assuming DbDatasource and YourTypeOrmUserEntity are set up)
147
-
148
- // const queryBuilder = DbDatasource.getRepository(YourTypeOrmUserEntity)
149
- // .createQueryBuilder(criteria.alias); // Alias must match root criteria alias
150
-
151
- // const translator = new TypeOrmMysqlTranslator<YourTypeOrmUserEntity>();
152
- // translator.translate(criteria, queryBuilder);
153
-
154
- // Now queryBuilder is populated with the translated criteria
155
- // console.log(queryBuilder.getSql(), queryBuilder.getParameters());
156
- // const results = await queryBuilder.getMany();
157
- ```
157
+ - **Usage:**
158
158
 
159
- - **Note:** This translator has been tested with integration tests. Please review its implementation at its repository (replace with actual repo link if different) to ensure it meets your specific project needs and production requirements. Contributions and bug reports are welcome!
159
+ - See the TypeORM Translator Usage Guide for detailed instructions.
160
160
 
161
161
  - **(More translators coming soon or can be created by the community)**
162
162
 
163
- ### Developing Custom Translators
164
-
165
- You can create your own translators by extending the abstract `CriteriaTranslator` class. See the Developing Custom Translators Guide for details.
163
+ **Important Note for Translator Developers:** Translators should be updated to handle the new `parent_identifier` in join parameters (especially for inferring `one_to_one` relationships) and to support the new filter operators. Refer to the Developing Custom Translators Guide for details.
166
164
 
167
165
  ## Type Safety Features
168
166
 
169
167
  - Compile-time validation of field names within criteria based on schemas.
168
+ - Validation of `identifier_field` definition within schemas.
170
169
  - Type-checked join configurations ensuring compatibility between schemas.
171
170
  - Autocomplete support for schema fields and defined join aliases.
172
171
  - Validation of alias usage in `Criteria` constructors.
173
172
  - Robust validation of join parameters based on `join_relation_type`.
174
173
  - Validation for selected fields, cursor fields, take/skip values.
175
174
  - Strictly typed filter values based on the `FilterOperator` used.
175
+ - Inclusion of `parent_identifier` in resolved join parameters for translator use.
176
176
 
177
177
  ## Roadmap (Core Library)
178
178
 
@@ -182,9 +182,13 @@ You can create your own translators by extending the abstract `CriteriaTranslato
182
182
  - [x] Implement `LIMIT` and `OFFSET` (take/skip) for pagination.
183
183
  - [x] Implement `PivotJoin` for many-to-many relationships.
184
184
  - [x] Strictly typed filter values based on operator.
185
- - [x] New filter operators (JSON, Array, Set).
186
- - [x] Enhanced documentation with detailed examples for translator development.
185
+ - [x] New filter operators (JSON, Array, Set, Range, Regex, ILIKE).
187
186
  - [x] `OuterJoinCriteria` support in the core logic.
187
+ - [x] Introduce `identifier_field` in schemas and `parent_identifier` in join parameters.
188
+ - [x] Enforce stricter schema validation at type level.
189
+ - [x] Implement `NULLS FIRST/LAST` ordering.
190
+ - [x] Implement filter-only joins (`withSelect`).
191
+ - [x] Enhanced documentation with detailed examples for translator development.
188
192
  - [ ] Explore utility functions to simplify translator development.
189
193
  - [ ] Explore utility functions to simplify schema development.
190
194
  - [ ] Add more comprehensive unit test coverage for criteria construction and edge cases.
@@ -1,8 +1,9 @@
1
1
  import { RootCriteria } from './root.criteria.js';
2
- import type { CriteriaSchema, SelectedAliasOf } from './types/schema.types.js';
2
+ import type { CriteriaSchema } from './types/schema.types.js';
3
3
  import { InnerJoinCriteria } from './join/inner.join-criteria.js';
4
4
  import { LeftJoinCriteria } from './join/left.join-criteria.js';
5
5
  import { OuterJoinCriteria } from './join/outer.join-criteria.js';
6
+ import type { ValidSchema } from './criteria.js';
6
7
  /**
7
8
  * Provides static methods for creating instances of different types of `Criteria`.
8
9
  * This simplifies the creation of `Criteria` objects and ensures they are instantiated
@@ -22,7 +23,7 @@ export declare class CriteriaFactory {
22
23
  *
23
24
  * const userCriteria = CriteriaFactory.GetCriteria(UserSchema, 'users');
24
25
  */
25
- static GetCriteria<CSchema extends CriteriaSchema, Alias extends SelectedAliasOf<CSchema>>(schema: CSchema, alias: Alias): RootCriteria<CSchema, Alias>;
26
+ static GetCriteria<CSchema extends CriteriaSchema>(schema: ValidSchema<CSchema>): RootCriteria<CSchema>;
26
27
  /**
27
28
  * Creates an instance of `InnerJoinCriteria`. Used to define an `INNER JOIN` in a query.
28
29
  * @template CSchema - The type of the `CriteriaSchema` for the entity to be joined.
@@ -37,7 +38,7 @@ export declare class CriteriaFactory {
37
38
  * const postJoinCriteria = CriteriaFactory.GetInnerJoinCriteria(PostSchema, 'posts');
38
39
  * // postJoinCriteria can then be used in the .join() method of another Criteria
39
40
  */
40
- static GetInnerJoinCriteria<CSchema extends CriteriaSchema, Alias extends SelectedAliasOf<CSchema>>(schema: CSchema, alias: Alias): InnerJoinCriteria<CSchema, Alias>;
41
+ static GetInnerJoinCriteria<CSchema extends CriteriaSchema>(schema: ValidSchema<CSchema>): InnerJoinCriteria<CSchema>;
41
42
  /**
42
43
  * Creates an instance of `LeftJoinCriteria`. Used to define a `LEFT JOIN` in a query.
43
44
  * @template CSchema - The type of the `CriteriaSchema` for the entity to be joined.
@@ -51,7 +52,7 @@ export declare class CriteriaFactory {
51
52
  *
52
53
  * const commentJoinCriteria = CriteriaFactory.GetLeftJoinCriteria(CommentSchema, 'comments');
53
54
  */
54
- static GetLeftJoinCriteria<CSchema extends CriteriaSchema, Alias extends SelectedAliasOf<CSchema>>(schema: CSchema, alias: Alias): LeftJoinCriteria<CSchema, Alias>;
55
+ static GetLeftJoinCriteria<CSchema extends CriteriaSchema>(schema: ValidSchema<CSchema>): LeftJoinCriteria<CSchema>;
55
56
  /**
56
57
  * Creates an instance of `OuterJoinCriteria`. Used to define a `FULL OUTER JOIN` in a query.
57
58
  * @template CSchema - The type of the `CriteriaSchema` for the entity to be joined.
@@ -65,6 +66,6 @@ export declare class CriteriaFactory {
65
66
  *
66
67
  * const profileJoinCriteria = CriteriaFactory.GetOuterJoinCriteria(ProfileSchema, 'profiles');
67
68
  */
68
- static GetOuterJoinCriteria<CSchema extends CriteriaSchema, Alias extends SelectedAliasOf<CSchema>>(schema: CSchema, alias: Alias): OuterJoinCriteria<CSchema, Alias>;
69
+ static GetOuterJoinCriteria<CSchema extends CriteriaSchema>(schema: ValidSchema<CSchema>): OuterJoinCriteria<CSchema>;
69
70
  }
70
71
  //# sourceMappingURL=criteria-factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"criteria-factory.d.ts","sourceRoot":"","sources":["../../src/criteria/criteria-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;GAIG;AACH,qBAAa,eAAe;IAC1B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,WAAW,CAChB,OAAO,SAAS,cAAc,EAC9B,KAAK,SAAS,eAAe,CAAC,OAAO,CAAC,EACtC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC;IAI9D;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,oBAAoB,CACzB,OAAO,SAAS,cAAc,EAC9B,KAAK,SAAS,eAAe,CAAC,OAAO,CAAC,EACtC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC;IAInE;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,mBAAmB,CACxB,OAAO,SAAS,cAAc,EAC9B,KAAK,SAAS,eAAe,CAAC,OAAO,CAAC,EACtC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC;IAIlE;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,oBAAoB,CACzB,OAAO,SAAS,cAAc,EAC9B,KAAK,SAAS,eAAe,CAAC,OAAO,CAAC,EACtC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC;CAGpE"}
1
+ {"version":3,"file":"criteria-factory.d.ts","sourceRoot":"","sources":["../../src/criteria/criteria-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;GAIG;AACH,qBAAa,eAAe;IAC1B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,SAAS,cAAc,EAC/C,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAC3B,YAAY,CAAC,OAAO,CAAC;IAIxB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACxD,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAC3B,iBAAiB,CAAC,OAAO,CAAC;IAI7B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,mBAAmB,CAAC,OAAO,SAAS,cAAc,EACvD,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAC3B,gBAAgB,CAAC,OAAO,CAAC;IAI5B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACxD,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAC3B,iBAAiB,CAAC,OAAO,CAAC;CAG9B"}
@@ -21,8 +21,8 @@ export class CriteriaFactory {
21
21
  *
22
22
  * const userCriteria = CriteriaFactory.GetCriteria(UserSchema, 'users');
23
23
  */
24
- static GetCriteria(schema, alias) {
25
- return new RootCriteria(schema, alias);
24
+ static GetCriteria(schema) {
25
+ return new RootCriteria(schema);
26
26
  }
27
27
  /**
28
28
  * Creates an instance of `InnerJoinCriteria`. Used to define an `INNER JOIN` in a query.
@@ -38,8 +38,8 @@ export class CriteriaFactory {
38
38
  * const postJoinCriteria = CriteriaFactory.GetInnerJoinCriteria(PostSchema, 'posts');
39
39
  * // postJoinCriteria can then be used in the .join() method of another Criteria
40
40
  */
41
- static GetInnerJoinCriteria(schema, alias) {
42
- return new InnerJoinCriteria(schema, alias);
41
+ static GetInnerJoinCriteria(schema) {
42
+ return new InnerJoinCriteria(schema);
43
43
  }
44
44
  /**
45
45
  * Creates an instance of `LeftJoinCriteria`. Used to define a `LEFT JOIN` in a query.
@@ -54,8 +54,8 @@ export class CriteriaFactory {
54
54
  *
55
55
  * const commentJoinCriteria = CriteriaFactory.GetLeftJoinCriteria(CommentSchema, 'comments');
56
56
  */
57
- static GetLeftJoinCriteria(schema, alias) {
58
- return new LeftJoinCriteria(schema, alias);
57
+ static GetLeftJoinCriteria(schema) {
58
+ return new LeftJoinCriteria(schema);
59
59
  }
60
60
  /**
61
61
  * Creates an instance of `OuterJoinCriteria`. Used to define a `FULL OUTER JOIN` in a query.
@@ -70,8 +70,8 @@ export class CriteriaFactory {
70
70
  *
71
71
  * const profileJoinCriteria = CriteriaFactory.GetOuterJoinCriteria(ProfileSchema, 'profiles');
72
72
  */
73
- static GetOuterJoinCriteria(schema, alias) {
74
- return new OuterJoinCriteria(schema, alias);
73
+ static GetOuterJoinCriteria(schema) {
74
+ return new OuterJoinCriteria(schema);
75
75
  }
76
76
  }
77
77
  //# sourceMappingURL=criteria-factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"criteria-factory.js","sourceRoot":"","sources":["../../src/criteria/criteria-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAC1B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,WAAW,CAGhB,MAAe,EAAE,KAAY;QAC7B,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,oBAAoB,CAGzB,MAAe,EAAE,KAAY;QAC7B,OAAO,IAAI,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,mBAAmB,CAGxB,MAAe,EAAE,KAAY;QAC7B,OAAO,IAAI,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,oBAAoB,CAGzB,MAAe,EAAE,KAAY;QAC7B,OAAO,IAAI,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;CACF"}
1
+ {"version":3,"file":"criteria-factory.js","sourceRoot":"","sources":["../../src/criteria/criteria-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAC1B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,WAAW,CAChB,MAA4B;QAE5B,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,oBAAoB,CACzB,MAA4B;QAE5B,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,mBAAmB,CACxB,MAA4B;QAE5B,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,oBAAoB,CACzB,MAA4B;QAE5B,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"criteria-join-manager.js","sourceRoot":"","sources":["../../src/criteria/criteria-join-manager.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,mBAAmB;IAGtB,MAAM,GAA4C,IAAI,GAAG,EAAE,CAAC;IAEpE,OAAO,CACL,cAA2C,EAC3C,aAEqD;QAErD,MAAM,WAAW,GAA+B;YAC9C,UAAU,EAAE,aAAa;YACzB,QAAQ,EAAE,cAAc;SACzB,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,QAAQ;QACN,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF"}
1
+ {"version":3,"file":"criteria-join-manager.js","sourceRoot":"","sources":["../../src/criteria/criteria-join-manager.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,mBAAmB;IAGtB,MAAM,GAA4C,IAAI,GAAG,EAAE,CAAC;IAEpE,OAAO,CACL,cAA2C,EAC3C,aAEqD;QAErD,MAAM,WAAW,GAA+B;YAC9C,UAAU,EAAE,aAAa;YACzB,QAAQ,EAAE,cAAiD;SAC5D,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,QAAQ;QACN,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF"}
@@ -1,36 +1,137 @@
1
- import type { CriteriaSchema, FieldOfSchema, SelectedAliasOf } from './types/schema.types.js';
1
+ import type { CriteriaSchema, FieldOfSchema } from './types/schema.types.js';
2
2
  import { Cursor } from './cursor.js';
3
3
  import { Order, OrderDirection } from './order/order.js';
4
4
  import type { FilterPrimitive } from './filter/types/filter-primitive.types.js';
5
5
  import type { ICriteriaBase } from './types/criteria.interface.js';
6
- import type { JoinCriteriaParameterType, JoinParameterType, SpecificMatchingJoinConfig } from './types/join-utility.types.js';
6
+ import type { JoinCriteriaType, StoredJoinDetails } from './types/join-utility.types.js';
7
7
  import { FilterOperator } from './types/operator.types.js';
8
- export declare abstract class Criteria<TSchema extends CriteriaSchema, CurrentAlias extends SelectedAliasOf<TSchema> = SelectedAliasOf<TSchema>> implements ICriteriaBase<TSchema, CurrentAlias> {
9
- protected readonly schema: TSchema;
10
- protected _alias: CurrentAlias;
8
+ import type { FilterGroup } from './filter/filter-group.js';
9
+ export type ValidSchema<CSchema extends CriteriaSchema> = CSchema['identifier_field'] extends CSchema['fields'][number] ? CSchema : `Schema identifier_field '${CSchema['identifier_field']}' must be one of the schema's defined fields. Schema: ${CSchema['source_name']}`;
10
+ /**
11
+ * Abstract base class for constructing query criteria.
12
+ * It provides a fluent API for defining filters, joins, selections, ordering, and pagination.
13
+ * Concrete criteria types (e.g., RootCriteria, JoinCriteria) will extend this class.
14
+ *
15
+ * @template TSchema - The schema definition for the entity this criteria operates on.
16
+ */
17
+ export declare abstract class Criteria<const TSchema extends CriteriaSchema> implements ICriteriaBase<TSchema> {
11
18
  private readonly _filterManager;
12
19
  private readonly _joinManager;
13
20
  private readonly _source_name;
14
21
  private _take;
22
+ /**
23
+ * Stores the set of fields explicitly selected by the user.
24
+ * This is used when `_selectAll` is false.
25
+ * @protected
26
+ */
15
27
  protected _select: Set<FieldOfSchema<TSchema>>;
16
28
  private _selectAll;
29
+ /**
30
+ * Stores the cursor configuration for pagination, if set.
31
+ * @protected
32
+ */
17
33
  protected _cursor: Cursor<FieldOfSchema<TSchema>, FilterOperator.GREATER_THAN | FilterOperator.LESS_THAN> | undefined;
18
- constructor(schema: TSchema, _alias: CurrentAlias);
19
- get select(): FieldOfSchema<TSchema>[];
20
- abstract resetCriteria(): ICriteriaBase<TSchema, CurrentAlias>;
34
+ protected readonly _schema: TSchema;
35
+ /**
36
+ * Initializes a new instance of the Criteria class.
37
+ * @param {ValidSchema<TSchema>} schema - The schema definition for the entity.
38
+ * @throws {Error} If the schema's identifier_field is not one of its defined fields.
39
+ * @protected
40
+ */
41
+ constructor(schema: ValidSchema<TSchema>);
42
+ get schema(): TSchema;
43
+ /**
44
+ * Gets the metadata associated with the root schema of this criteria.
45
+ * @returns {TSchema['metadata']} The metadata object from the schema, which can be undefined.
46
+ * @remarks This is intended primarily for use by translators.
47
+ */
48
+ get schemaMetadata(): TSchema['metadata'];
49
+ /**
50
+ * Gets the name of the identifier field for the current schema.
51
+ * @returns {FieldOfSchema<TSchema>} The name of the identifier field.
52
+ */
53
+ get identifierField(): FieldOfSchema<TSchema>;
54
+ /**
55
+ * Gets the currently selected fields.
56
+ * If `_selectAll` is true (default or after `resetSelect()`), it returns all fields from the schema.
57
+ * If `_selectAll` is false (after `setSelect()`), it returns the fields explicitly set by the user,
58
+ * plus the schema's `identifier_field` (which is added implicitly by `setSelect`).
59
+ * @returns {Array<FieldOfSchema<TSchema>>} An array of selected field names.
60
+ */
61
+ get select(): Array<FieldOfSchema<TSchema>>;
62
+ /**
63
+ * Resets the selection to include all fields from the schema.
64
+ * Later calls to `get select()` will return all schema fields
65
+ * until `setSelect()` is called again.
66
+ * @returns {this} The current criteria instance for chaining.
67
+ */
21
68
  resetSelect(): this;
69
+ /**
70
+ * Indicates whether all fields are currently configured to be selected.
71
+ * @returns {boolean} True if all fields are selected, false if specific fields are selected.
72
+ */
22
73
  get selectAll(): boolean;
74
+ /**
75
+ * Specifies which fields to select for the entity.
76
+ * Calling this method sets `selectAll` to false.
77
+ * The schema's `identifier_field` will always be included in the selection
78
+ * if it's not already present in `selectFields`.
79
+ * If `selectFields` is empty, only the `identifier_field` will be selected.
80
+ * @param {Array<FieldOfSchema<TSchema>>} selectFields - An array of field names to select.
81
+ * @returns {this} The current criteria instance for chaining.
82
+ * @throws {Error} If any of the specified fields are not defined in the schema.
83
+ */
23
84
  setSelect(selectFields: Array<FieldOfSchema<TSchema>>): this;
85
+ /**
86
+ * Gets the maximum number of records to return (LIMIT).
87
+ * @returns {number} The take value.
88
+ */
24
89
  get take(): number;
25
90
  private _skip;
91
+ /**
92
+ * Gets the number of records to skip (OFFSET).
93
+ * @returns {number} The skip value.
94
+ */
26
95
  get skip(): number;
27
96
  private _orders;
97
+ /**
98
+ * Gets the current ordering rules applied to this criteria.
99
+ * @returns {ReadonlyArray<Order<FieldOfSchema<TSchema>>>} A readonly array of order objects.
100
+ */
28
101
  get orders(): ReadonlyArray<Order<FieldOfSchema<TSchema>>>;
29
- get joins(): import("./types/join-utility.types.js").StoredJoinDetails<TSchema>[];
30
- get rootFilterGroup(): import("./index.js").FilterGroup<string>;
31
- get sourceName(): TSchema["source_name"];
32
- get alias(): CurrentAlias;
102
+ /**
103
+ * Gets the configured join details for this criteria.
104
+ * @returns {ReadonlyArray<StoredJoinDetails<TSchema>>} A readonly array of join configurations.
105
+ */
106
+ get joins(): ReadonlyArray<StoredJoinDetails<TSchema>>;
107
+ /**
108
+ * Gets the root filter group for this criteria, which holds all filter conditions.
109
+ * @returns {FilterGroup} The root filter group.
110
+ */
111
+ get rootFilterGroup(): FilterGroup;
112
+ /**
113
+ * Gets the source name (e.g., table name) for the entity of this criteria.
114
+ * @returns {TSchema['source_name']} The source name string.
115
+ */
116
+ get sourceName(): TSchema['source_name'];
117
+ /**
118
+ * Gets the alias used for the entity of this criteria.
119
+ * @returns {CurrentAlias} The alias string.
120
+ */
121
+ get alias(): TSchema['alias'];
122
+ /**
123
+ * Sets the maximum number of records to return (LIMIT).
124
+ * @param {number} amount - The number of records to take. Must be non-negative.
125
+ * @returns {this} The current criteria instance for chaining.
126
+ * @throws {Error} If the amount is negative.
127
+ */
33
128
  setTake(amount: number): this;
129
+ /**
130
+ * Sets the number of records to skip before starting to return records (OFFSET).
131
+ * @param {number} amount - The number of records to skip. Must be non-negative.
132
+ * @returns {this} The current criteria instance for chaining.
133
+ * @throws {Error} If the amount is negative.
134
+ */
34
135
  setSkip(amount: number): this;
35
136
  /**
36
137
  * Asserts that a given field name is defined within the current criteria's schema.
@@ -41,19 +142,89 @@ export declare abstract class Criteria<TSchema extends CriteriaSchema, CurrentAl
41
142
  * @param {FieldOfSchema<TSchema>} field - The field name to validate.
42
143
  * @throws {Error} If the field is not defined in the schema.
43
144
  */
44
- protected assetFieldOnSchema(field: FieldOfSchema<TSchema>): void;
45
- orderBy(field: FieldOfSchema<TSchema>, direction: OrderDirection): this;
145
+ protected assetFieldOnSchema(field: TSchema['fields'][number]): void;
146
+ /**
147
+ * Adds an ordering rule to the criteria.
148
+ * Multiple calls will append new ordering rules.
149
+ * @param {FieldOfSchema<TSchema>} field - The field to order by.
150
+ * @param {OrderDirection} direction - The direction of the ordering (ASC or DESC).
151
+ * @param {boolean} [nullFirst=false] - If true, null values will be ordered first.
152
+ * @returns {this} The current criteria instance for chaining.
153
+ * @throws {Error} If the specified field is not defined in the schema.
154
+ */
155
+ orderBy(field: FieldOfSchema<TSchema>, direction: OrderDirection, nullFirst?: boolean): this;
156
+ /**
157
+ * Initializes the filter criteria with a single filter primitive.
158
+ * This replaces any existing filters in the root filter group.
159
+ * @template Operator - The specific filter operator type.
160
+ * @param {FilterPrimitive<FieldOfSchema<TSchema>, Operator>} filterPrimitive - The filter to apply.
161
+ * @returns {this} The current criteria instance for chaining.
162
+ * @throws {Error} If the specified field in filterPrimitive is not defined in the schema.
163
+ */
46
164
  where<Operator extends FilterOperator>(filterPrimitive: FilterPrimitive<FieldOfSchema<TSchema>, Operator>): this;
165
+ /**
166
+ * Adds a filter primitive to the current filter group using an AND logical operator.
167
+ * Requires `where()` to have been called first to initialize the filter group.
168
+ * @template Operator - The specific filter operator type.
169
+ * @param {FilterPrimitive<FieldOfSchema<TSchema>, Operator>} filterPrimitive - The filter to add.
170
+ * @returns {this} The current criteria instance for chaining.
171
+ * @throws {Error} If the specified field in filterPrimitive is not defined in the schema.
172
+ * @throws {Error} If `where()` has not been called first.
173
+ */
47
174
  andWhere<Operator extends FilterOperator>(filterPrimitive: FilterPrimitive<FieldOfSchema<TSchema>, Operator>): this;
175
+ /**
176
+ * Adds a filter primitive to the current filter group using an OR logical operator.
177
+ * Requires `where()` to have been called first to initialize the filter group.
178
+ * @template Operator - The specific filter operator type.
179
+ * @param {FilterPrimitive<FieldOfSchema<TSchema>, Operator>} filterPrimitive - The filter to add.
180
+ * @returns {this} The current criteria instance for chaining.
181
+ * @throws {Error} If the specified field in filterPrimitive is not defined in the schema.
182
+ * @throws {Error} If `where()` has not been called first.
183
+ */
48
184
  orWhere<Operator extends FilterOperator>(filterPrimitive: FilterPrimitive<FieldOfSchema<TSchema>, Operator>): this;
49
- join<TJoinSchema extends CriteriaSchema, TJoinedCriteriaAlias extends SelectedAliasOf<TJoinSchema>, TMatchingJoinConfig extends SpecificMatchingJoinConfig<TSchema, TJoinedCriteriaAlias>>(criteriaToJoin: JoinCriteriaParameterType<TSchema, TJoinSchema, TJoinedCriteriaAlias, TMatchingJoinConfig>, joinParameter: JoinParameterType<TSchema, TJoinSchema, TMatchingJoinConfig>): this;
50
- private assertIsValidJoinOptions;
185
+ /**
186
+ * Adds a join to another criteria. This method is fully type-safe.
187
+ * The `joinAlias` argument provides autocompletion for all valid relation aliases defined in the schema.
188
+ * The `criteriaToJoin` argument is then validated to ensure its `source_name` matches the one
189
+ * configured for the chosen `joinAlias`, providing clear, compile-time error messages if they mismatch.
190
+ *
191
+ * @template TJoinSchema - The schema of the entity to join.
192
+ * @template SpecificRelationAlias - The literal type of the relation alias being used for the join.
193
+ * @param {SpecificRelationAlias} joinAlias - The specific alias defined in the parent schema's `relations` array for
194
+ * this relation.
195
+ * @param {JoinCriteriaType<TSchema, TJoinSchema, SpecificRelationAlias>} criteriaToJoin - The criteria instance
196
+ * representing the entity to join (e.g., `InnerJoinCriteria`).
197
+ * @param {boolean} [withSelect=true] - If true (default), the joined entity's fields will be included in the final
198
+ * selection. If false, the join will only be used for filtering and its fields will not be selected.
199
+ * @returns {this} The current criteria instance for chaining.
200
+ */
201
+ join<const TJoinSchema extends CriteriaSchema, const SpecificRelationAlias extends TSchema['relations'][number]['relation_alias']>(joinAlias: SpecificRelationAlias, criteriaToJoin: JoinCriteriaType<TSchema, TJoinSchema, SpecificRelationAlias>, withSelect?: boolean): this;
202
+ /**
203
+ * Gets the current cursor configuration, if set.
204
+ * @returns {Cursor<FieldOfSchema<TSchema>, FilterOperator.GREATER_THAN | FilterOperator.LESS_THAN> | undefined}
205
+ * The cursor object or undefined.
206
+ */
51
207
  get cursor(): Cursor<FieldOfSchema<TSchema>, FilterOperator.GREATER_THAN | FilterOperator.LESS_THAN> | undefined;
208
+ /**
209
+ * Sets the cursor for pagination.
210
+ * @template Operator - The specific comparison operator for the cursor.
211
+ * @param {readonly [Omit<FilterPrimitive<FieldOfSchema<TSchema>, Operator>, 'operator'>] | readonly
212
+ * [Omit<FilterPrimitive<FieldOfSchema<TSchema>, Operator>, 'operator'>,
213
+ * Omit<FilterPrimitive<FieldOfSchema<TSchema>, Operator>, 'operator'>]} filterPrimitives - An array of one or two
214
+ * filter primitives defining the cursor's fields and values.
215
+ * @param {Operator} operator - The comparison operator (GREATER_THAN or LESS_THAN).
216
+ * @param {OrderDirection} order - The primary order direction for pagination.
217
+ * @returns {this} The current criteria instance for chaining.
218
+ * @throws {Error} If filterPrimitives does not contain exactly 1 or 2 elements.
219
+ * @throws {Error} If any cursor field is not defined in the schema.
220
+ * @throws {Error} If any cursor value is undefined (null is allowed, per Cursor constructor).
221
+ * @throws {Error} If two cursor fields are provided and they are identical (per Cursor constructor).
222
+ */
52
223
  setCursor<Operator extends FilterOperator.GREATER_THAN | FilterOperator.LESS_THAN>(filterPrimitives: readonly [
53
224
  Omit<FilterPrimitive<FieldOfSchema<TSchema>, Operator>, 'operator'>
54
225
  ] | readonly [
55
226
  Omit<FilterPrimitive<FieldOfSchema<TSchema>, Operator>, 'operator'>,
56
227
  Omit<FilterPrimitive<FieldOfSchema<TSchema>, Operator>, 'operator'>
57
- ], operator: Operator, order: OrderDirection): ICriteriaBase<TSchema, CurrentAlias>;
228
+ ], operator: Operator, order: OrderDirection): this;
58
229
  }
59
230
  //# sourceMappingURL=criteria.d.ts.map