@nulledexp/translatable-criteria 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/criteria/criteria-factory.d.ts +70 -0
  2. package/dist/criteria/criteria-factory.d.ts.map +1 -0
  3. package/dist/criteria/criteria-factory.js +77 -0
  4. package/dist/criteria/criteria-factory.js.map +1 -0
  5. package/dist/criteria/criteria-filter-manager.d.ts +13 -0
  6. package/dist/criteria/criteria-filter-manager.d.ts.map +1 -0
  7. package/dist/criteria/criteria-filter-manager.js +21 -0
  8. package/dist/criteria/criteria-filter-manager.js.map +1 -0
  9. package/dist/criteria/criteria-join-manager.d.ts +10 -0
  10. package/dist/criteria/criteria-join-manager.d.ts.map +1 -0
  11. package/dist/criteria/criteria-join-manager.js +14 -0
  12. package/dist/criteria/criteria-join-manager.js.map +1 -0
  13. package/dist/criteria/criteria.d.ts +48 -0
  14. package/dist/criteria/criteria.d.ts.map +1 -0
  15. package/dist/criteria/criteria.js +162 -0
  16. package/dist/criteria/criteria.js.map +1 -0
  17. package/dist/criteria/cursor.d.ts +13 -0
  18. package/dist/criteria/cursor.d.ts.map +1 -0
  19. package/dist/criteria/cursor.js +31 -0
  20. package/dist/criteria/cursor.js.map +1 -0
  21. package/dist/criteria/filter/filter-group.d.ts +18 -0
  22. package/dist/criteria/filter/filter-group.d.ts.map +1 -0
  23. package/dist/criteria/filter/filter-group.js +104 -0
  24. package/dist/criteria/filter/filter-group.js.map +1 -0
  25. package/dist/criteria/filter/filter-utils.d.ts +5 -0
  26. package/dist/criteria/filter/filter-utils.d.ts.map +1 -0
  27. package/dist/criteria/filter/filter-utils.js +74 -0
  28. package/dist/criteria/filter/filter-utils.js.map +1 -0
  29. package/dist/criteria/filter/filter.d.ts +23 -0
  30. package/dist/criteria/filter/filter.d.ts.map +1 -0
  31. package/dist/criteria/filter/filter.js +126 -0
  32. package/dist/criteria/filter/filter.js.map +1 -0
  33. package/dist/criteria/filter/types/filter-primitive.types.d.ts +66 -0
  34. package/dist/criteria/filter/types/filter-primitive.types.d.ts.map +1 -0
  35. package/dist/criteria/filter/types/filter-primitive.types.js +2 -0
  36. package/dist/criteria/filter/types/filter-primitive.types.js.map +1 -0
  37. package/dist/criteria/index.d.ts +22 -0
  38. package/dist/criteria/index.d.ts.map +1 -0
  39. package/dist/criteria/index.js +16 -0
  40. package/dist/criteria/index.js.map +1 -0
  41. package/dist/criteria/join/inner.join-criteria.d.ts +27 -0
  42. package/dist/criteria/join/inner.join-criteria.d.ts.map +1 -0
  43. package/dist/criteria/join/inner.join-criteria.js +31 -0
  44. package/dist/criteria/join/inner.join-criteria.js.map +1 -0
  45. package/dist/criteria/join/left.join-criteria.d.ts +26 -0
  46. package/dist/criteria/join/left.join-criteria.d.ts.map +1 -0
  47. package/dist/criteria/join/left.join-criteria.js +30 -0
  48. package/dist/criteria/join/left.join-criteria.js.map +1 -0
  49. package/dist/criteria/join/outer.join-criteria.d.ts +27 -0
  50. package/dist/criteria/join/outer.join-criteria.d.ts.map +1 -0
  51. package/dist/criteria/join/outer.join-criteria.js +31 -0
  52. package/dist/criteria/join/outer.join-criteria.js.map +1 -0
  53. package/dist/criteria/order/order.d.ts +20 -0
  54. package/dist/criteria/order/order.d.ts.map +1 -0
  55. package/dist/criteria/order/order.js +32 -0
  56. package/dist/criteria/order/order.js.map +1 -0
  57. package/dist/criteria/root.criteria.d.ts +28 -0
  58. package/dist/criteria/root.criteria.d.ts.map +1 -0
  59. package/dist/criteria/root.criteria.js +30 -0
  60. package/dist/criteria/root.criteria.js.map +1 -0
  61. package/dist/criteria/translator/criteria-translator.d.ts +45 -0
  62. package/dist/criteria/translator/criteria-translator.d.ts.map +1 -0
  63. package/dist/criteria/translator/criteria-translator.js +30 -0
  64. package/dist/criteria/translator/criteria-translator.js.map +1 -0
  65. package/dist/criteria/types/criteria.interface.d.ts +166 -0
  66. package/dist/criteria/types/criteria.interface.d.ts.map +1 -0
  67. package/dist/criteria/types/criteria.interface.js +2 -0
  68. package/dist/criteria/types/criteria.interface.js.map +1 -0
  69. package/dist/criteria/types/filter-expression.interface.d.ts +7 -0
  70. package/dist/criteria/types/filter-expression.interface.d.ts.map +1 -0
  71. package/dist/criteria/types/filter-expression.interface.js +2 -0
  72. package/dist/criteria/types/filter-expression.interface.js.map +1 -0
  73. package/dist/criteria/types/join-input.types.d.ts +54 -0
  74. package/dist/criteria/types/join-input.types.d.ts.map +1 -0
  75. package/dist/criteria/types/join-input.types.js +2 -0
  76. package/dist/criteria/types/join-input.types.js.map +1 -0
  77. package/dist/criteria/types/join-parameter.types.d.ts +70 -0
  78. package/dist/criteria/types/join-parameter.types.d.ts.map +1 -0
  79. package/dist/criteria/types/join-parameter.types.js +2 -0
  80. package/dist/criteria/types/join-parameter.types.js.map +1 -0
  81. package/dist/criteria/types/join-utility.types.d.ts +71 -0
  82. package/dist/criteria/types/join-utility.types.d.ts.map +1 -0
  83. package/dist/criteria/types/join-utility.types.js +2 -0
  84. package/dist/criteria/types/join-utility.types.js.map +1 -0
  85. package/dist/criteria/types/manager.interface.d.ts +59 -0
  86. package/dist/criteria/types/manager.interface.d.ts.map +1 -0
  87. package/dist/criteria/types/manager.interface.js +2 -0
  88. package/dist/criteria/types/manager.interface.js.map +1 -0
  89. package/dist/criteria/types/operator.types.d.ts +92 -0
  90. package/dist/criteria/types/operator.types.d.ts.map +1 -0
  91. package/dist/criteria/types/operator.types.js +95 -0
  92. package/dist/criteria/types/operator.types.js.map +1 -0
  93. package/dist/criteria/types/schema.types.d.ts +61 -0
  94. package/dist/criteria/types/schema.types.d.ts.map +1 -0
  95. package/dist/criteria/types/schema.types.js +18 -0
  96. package/dist/criteria/types/schema.types.js.map +1 -0
  97. package/dist/criteria/types/visitor-interface.types.d.ts +24 -0
  98. package/dist/criteria/types/visitor-interface.types.d.ts.map +1 -0
  99. package/dist/criteria/types/visitor-interface.types.js +2 -0
  100. package/dist/criteria/types/visitor-interface.types.js.map +1 -0
  101. package/dist/index.d.ts +2 -0
  102. package/dist/index.d.ts.map +1 -0
  103. package/dist/index.js +2 -0
  104. package/dist/index.js.map +1 -0
  105. package/package.json +1 -1
@@ -0,0 +1,70 @@
1
+ import type { CriteriaSchema, FieldOfSchema, JoinRelationType } from './schema.types.js';
2
+ /**
3
+ * Represents the fully resolved parameters for a many-to-many join,
4
+ * including details from the parent schema and the specific relation type.
5
+ * This type is used internally by the Criteria system after processing user input.
6
+ * @template ParentSchema - The {@link CriteriaSchema} of the parent entity in the join.
7
+ * @template JoinSchema - The {@link CriteriaSchema} of the entity being joined.
8
+ * @template TJoinRelationType - The specific {@link JoinRelationType} for this join.
9
+ */
10
+ export type PivotJoin<ParentSchema extends CriteriaSchema, JoinSchema extends CriteriaSchema, TJoinRelationType extends JoinRelationType> = {
11
+ /** The type of relationship from the parent to the joined entity (e.g., 'many_to_many'). */
12
+ parent_to_join_relation_type: TJoinRelationType;
13
+ /** The source name (e.g., table name) of the parent entity. */
14
+ parent_source_name: ParentSchema['source_name'];
15
+ /** The alias used for the parent entity in the query. */
16
+ parent_alias: ParentSchema['alias'][number];
17
+ /** The source name (table name) of the pivot table. */
18
+ pivot_source_name: string;
19
+ /** Configuration for the join field on the parent side, referencing the pivot table. */
20
+ parent_field: {
21
+ /** The field name in the pivot table that links to the parent schema. */
22
+ pivot_field: string;
23
+ /**
24
+ * The field name in the parent schema that the pivot table field references.
25
+ * Must be a valid field from `ParentSchema['fields']`.
26
+ * @see FieldOfSchema<ParentSchema>
27
+ */
28
+ reference: FieldOfSchema<ParentSchema>;
29
+ };
30
+ /** Configuration for the join field on the joined side, referencing the pivot table. */
31
+ join_field: {
32
+ /** The field name in the pivot table that links to the joined schema. */
33
+ pivot_field: string;
34
+ /**
35
+ * The field name in the joined schema that the pivot table field references.
36
+ * Must be a valid field from `JoinSchema['fields']`.
37
+ * @see FieldOfSchema<JoinSchema>
38
+ */
39
+ reference: FieldOfSchema<JoinSchema>;
40
+ };
41
+ };
42
+ /**
43
+ * Represents the fully resolved parameters for a simple join (one-to-one, one-to-many, many-to-one),
44
+ * including details from the parent schema and the specific relation type.
45
+ * This type is used internally by the Criteria system after processing user input.
46
+ * @template ParentSchema - The {@link CriteriaSchema} of the parent entity in the join.
47
+ * @template JoinSchema - The {@link CriteriaSchema} of the entity being joined.
48
+ * @template TJoinRelationType - The specific {@link JoinRelationType} for this join.
49
+ */
50
+ export type SimpleJoin<ParentSchema extends CriteriaSchema, JoinSchema extends CriteriaSchema, TJoinRelationType extends JoinRelationType> = {
51
+ /** The type of relationship from the parent to the joined entity (e.g., 'one_to_one', 'many_to_one'). */
52
+ parent_to_join_relation_type: TJoinRelationType;
53
+ /** The source name (e.g., table name) of the parent entity. */
54
+ parent_source_name: ParentSchema['source_name'];
55
+ /** The alias used for the parent entity in the query. */
56
+ parent_alias: ParentSchema['alias'][number];
57
+ /**
58
+ * The field name in the parent schema used for the join condition.
59
+ * Must be a valid field from `ParentSchema['fields']`.
60
+ * @see FieldOfSchema<ParentSchema>
61
+ */
62
+ parent_field: FieldOfSchema<ParentSchema>;
63
+ /**
64
+ * The field name in the joined schema used for the join condition.
65
+ * Must be a valid field from `JoinSchema['fields']`.
66
+ * @see FieldOfSchema<JoinSchema>
67
+ */
68
+ join_field: FieldOfSchema<JoinSchema>;
69
+ };
70
+ //# sourceMappingURL=join-parameter.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join-parameter.types.d.ts","sourceRoot":"","sources":["../../../src/criteria/types/join-parameter.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,CACnB,YAAY,SAAS,cAAc,EACnC,UAAU,SAAS,cAAc,EACjC,iBAAiB,SAAS,gBAAgB,IACxC;IACF,4FAA4F;IAC5F,4BAA4B,EAAE,iBAAiB,CAAC;IAChD,+DAA+D;IAC/D,kBAAkB,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;IAChD,yDAAyD;IACzD,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;IAE5C,uDAAuD;IACvD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wFAAwF;IACxF,YAAY,EAAE;QACZ,yEAAyE;QACzE,WAAW,EAAE,MAAM,CAAC;QACpB;;;;WAIG;QACH,SAAS,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACxC,CAAC;IACF,wFAAwF;IACxF,UAAU,EAAE;QACV,yEAAyE;QACzE,WAAW,EAAE,MAAM,CAAC;QACpB;;;;WAIG;QACH,SAAS,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;KACtC,CAAC;CACH,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,CACpB,YAAY,SAAS,cAAc,EACnC,UAAU,SAAS,cAAc,EACjC,iBAAiB,SAAS,gBAAgB,IACxC;IACF,yGAAyG;IACzG,4BAA4B,EAAE,iBAAiB,CAAC;IAChD,+DAA+D;IAC/D,kBAAkB,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;IAChD,yDAAyD;IACzD,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;IAC5C;;;;OAIG;IACH,YAAY,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAC1C;;;;OAIG;IACH,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACvC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=join-parameter.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join-parameter.types.js","sourceRoot":"","sources":["../../../src/criteria/types/join-parameter.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,71 @@
1
+ import type { CriteriaSchema, JoinRelationType, SchemaJoins, SelectedAliasOf } from './schema.types.js';
2
+ import type { PivotJoin, SimpleJoin } from './join-parameter.types.js';
3
+ import type { InnerJoinCriteria } from '../join/inner.join-criteria.js';
4
+ import type { LeftJoinCriteria } from '../join/left.join-criteria.js';
5
+ import type { OuterJoinCriteria } from '../join/outer.join-criteria.js';
6
+ import type { PivotJoinInput, SimpleJoinInput } from './join-input.types.js';
7
+ /**
8
+ * Represents any type of join criteria (Inner, Left, or Outer).
9
+ * @template CSchema - The {@link CriteriaSchema} of the entity being joined.
10
+ * @template Alias - The selected alias for the joined entity from its schema.
11
+ */
12
+ export type AnyJoinCriteria<CSchema extends CriteriaSchema, Alias extends SelectedAliasOf<CSchema> = SelectedAliasOf<CSchema>> = InnerJoinCriteria<CSchema, Alias> | LeftJoinCriteria<CSchema, Alias> | OuterJoinCriteria<CSchema, Alias>;
13
+ /**
14
+ * Defines the structure for storing the details of a configured join.
15
+ * This is used internally by the Criteria system.
16
+ * @template ParentSchema - The {@link CriteriaSchema} of the parent entity in the join.
17
+ */
18
+ export interface StoredJoinDetails<ParentSchema extends CriteriaSchema> {
19
+ /**
20
+ * The fully resolved parameters for the join, either {@link PivotJoin} or {@link SimpleJoin}.
21
+ */
22
+ parameters: PivotJoin<ParentSchema, CriteriaSchema, JoinRelationType> | SimpleJoin<ParentSchema, CriteriaSchema, JoinRelationType>;
23
+ /**
24
+ * The criteria instance representing the joined entity (e.g., InnerJoinCriteria).
25
+ */
26
+ criteria: AnyJoinCriteria<CriteriaSchema, SelectedAliasOf<CriteriaSchema>>;
27
+ }
28
+ /**
29
+ * Determines the type of the criteria object to be passed to the `.join()` method.
30
+ * If the `ActualJoinedAlias` is not a valid join alias in the `ParentSchema`,
31
+ * this type resolves to an error message string, providing strong type-time feedback.
32
+ * Otherwise, it resolves to {@link AnyJoinCriteria}.
33
+ *
34
+ * @template ParentSchema - The {@link CriteriaSchema} of the parent entity.
35
+ * @template JoinedSchema - The {@link CriteriaSchema} of the entity to be joined.
36
+ * @template ActualJoinedAlias - The specific alias used for the `JoinedSchema`.
37
+ * @template MatchingConfigForActualAlias - The join configuration from `ParentSchema` that matches `ActualJoinedAlias`.
38
+ * Should be `never` if no match is found.
39
+ */
40
+ export type JoinCriteriaParameterType<ParentSchema extends CriteriaSchema, JoinedSchema extends CriteriaSchema, ActualJoinedAlias extends SelectedAliasOf<JoinedSchema>, MatchingConfigForActualAlias extends SchemaJoins<string> | never> = [MatchingConfigForActualAlias] extends [never] ? `Error: The alias '${ActualJoinedAlias}' of schema '${JoinedSchema['source_name']}' is not configured for join in '${ParentSchema['source_name']}'.` : AnyJoinCriteria<JoinedSchema, ActualJoinedAlias>;
41
+ /**
42
+ * Determines the expected shape of the join parameters object passed to the `.join()` method,
43
+ * based on the `join_relation_type` defined in the `ParentSchema` for the `ActualJoinedAlias`.
44
+ * If the `ActualJoinedAlias` is not a valid join alias, this type resolves to `never`.
45
+ * For 'many_to_many' relations, it expects {@link PivotJoinInput}.
46
+ * For other relations (one-to-one, one-to-many, many-to-one), it expects {@link SimpleJoinInput}.
47
+ *
48
+ * @template ParentSchema - The {@link CriteriaSchema} of the parent entity.
49
+ * @template JoinedSchema - The {@link CriteriaSchema} of the entity to be joined.
50
+ * @template MatchingConfigForActualAlias - The join configuration from `ParentSchema` that matches the alias of `JoinedSchema`.
51
+ * Should be `never` if no match is found.
52
+ */
53
+ export type JoinParameterType<ParentSchema extends CriteriaSchema, JoinedSchema extends CriteriaSchema, MatchingConfigForActualAlias extends SchemaJoins<string> | never> = [MatchingConfigForActualAlias] extends [never] ? never : MatchingConfigForActualAlias['join_relation_type'] extends 'many_to_many' ? PivotJoinInput<ParentSchema, JoinedSchema> : SimpleJoinInput<ParentSchema, JoinedSchema>;
54
+ /**
55
+ * Extracts the specific join configuration object from the `ParentSchema`'s `joins` array
56
+ * that matches the provided `JoinedSchemaSpecificAlias`.
57
+ * This utility type is crucial for inferring the `join_relation_type` and other
58
+ * join-specific details defined in the parent schema.
59
+ *
60
+ * @template ParentSchema - The {@link CriteriaSchema} of the parent entity.
61
+ * @template JoinedSchemaSpecificAlias - The specific alias of the joined entity,
62
+ * as defined in the `ParentSchema.joins` configuration.
63
+ * @example
64
+ * // Given UserSchema has a join defined as: { alias: 'posts', join_relation_type: 'one_to_many' }
65
+ * // type UserPostsJoinConfig = SpecificMatchingJoinConfig<typeof UserSchema, 'posts'>;
66
+ * // UserPostsJoinConfig would be: { alias: 'posts'; join_relation_type: 'one_to_many'; }
67
+ */
68
+ export type SpecificMatchingJoinConfig<ParentSchema extends CriteriaSchema, JoinedSchemaSpecificAlias extends string> = Extract<ParentSchema['joins'][number], {
69
+ alias: JoinedSchemaSpecificAlias;
70
+ }>;
71
+ //# sourceMappingURL=join-utility.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join-utility.types.d.ts","sourceRoot":"","sources":["../../../src/criteria/types/join-utility.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7E;;;;GAIG;AACH,MAAM,MAAM,eAAe,CACzB,OAAO,SAAS,cAAc,EAC9B,KAAK,SAAS,eAAe,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,IAE/D,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,GACjC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,GAChC,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAEtC;;;;GAIG;AACH,MAAM,WAAW,iBAAiB,CAA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C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=join-utility.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join-utility.types.js","sourceRoot":"","sources":["../../../src/criteria/types/join-utility.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,59 @@
1
+ import type { FilterGroup } from '../filter/filter-group.js';
2
+ import type { CriteriaSchema, FieldOfSchema, JoinRelationType, SelectedAliasOf } from './schema.types.js';
3
+ import type { FilterPrimitive } from '../filter/types/filter-primitive.types.js';
4
+ import type { PivotJoin, SimpleJoin } from './join-parameter.types.js';
5
+ import type { AnyJoinCriteria, StoredJoinDetails } from './join-utility.types.js';
6
+ import type { FilterOperator } from './operator.types.js';
7
+ /**
8
+ * Defines the contract for managing filter conditions within a Criteria object.
9
+ * @template CSchema - The {@link CriteriaSchema} of the entity to which filters are applied.
10
+ */
11
+ export interface IFilterManager<CSchema extends CriteriaSchema> {
12
+ /**
13
+ * Initializes the filter criteria with a single filter primitive.
14
+ * This replaces any existing filters.
15
+ * @param {FilterPrimitive<FieldOfSchema<CSchema>>} filterPrimitive - The filter to apply.
16
+ * @throws {Error} If the specified field in filterPrimitive is not defined in the schema.
17
+ */
18
+ where<Operator extends FilterOperator>(filterPrimitive: FilterPrimitive<FieldOfSchema<CSchema>, Operator>): void;
19
+ /**
20
+ * Adds a filter primitive to the current filter group using an AND logical operator.
21
+ * @param {FilterPrimitive<FieldOfSchema<CSchema>>} filterPrimitive - The filter to add.
22
+ * @throws {Error} If the specified field in filterPrimitive is not defined in the schema.
23
+ * @throws {Error} If `where()` has not been called first.
24
+ */
25
+ andWhere<Operator extends FilterOperator>(filterPrimitive: FilterPrimitive<FieldOfSchema<CSchema>, Operator>): void;
26
+ /**
27
+ * Adds a filter primitive, creating a new OR group with the existing filters.
28
+ * @param {FilterPrimitive<FieldOfSchema<CSchema>>} filterPrimitive - The filter to add.
29
+ * @throws {Error} If the specified field in filterPrimitive is not defined in the schema.
30
+ * @throws {Error} If `where()` has not been called first.
31
+ */
32
+ orWhere<Operator extends FilterOperator>(filterPrimitive: FilterPrimitive<FieldOfSchema<CSchema>, Operator>): void;
33
+ /**
34
+ * Retrieves the root filter group containing all applied filter conditions.
35
+ * @returns {FilterGroup} The root {@link FilterGroup}.
36
+ */
37
+ getRootFilterGroup(): FilterGroup;
38
+ }
39
+ /**
40
+ * Defines the contract for managing join operations within a Criteria object.
41
+ * @template CSchema - The {@link CriteriaSchema} of the parent entity from which joins are made.
42
+ */
43
+ export interface IJoinManager<CSchema extends CriteriaSchema> {
44
+ /**
45
+ * Adds a join configuration to the Criteria.
46
+ * @template JoinSchema - The {@link CriteriaSchema} of the entity being joined.
47
+ * @param {AnyJoinCriteria<JoinSchema, SelectedAliasOf<JoinSchema>>} criteriaToJoin -
48
+ * The criteria instance representing the entity to join (e.g., InnerJoinCriteria, LeftJoinCriteria).
49
+ * @param {PivotJoin<CSchema, JoinSchema, JoinRelationType> | SimpleJoin<CSchema, JoinSchema, JoinRelationType>} joinParameter -
50
+ * The fully resolved parameters defining how the join should be performed.
51
+ */
52
+ addJoin<JoinSchema extends CriteriaSchema>(criteriaToJoin: AnyJoinCriteria<JoinSchema, SelectedAliasOf<JoinSchema>>, joinParameter: PivotJoin<CSchema, JoinSchema, JoinRelationType> | SimpleJoin<CSchema, JoinSchema, JoinRelationType>): void;
53
+ /**
54
+ * Retrieves all configured join details.
55
+ * @returns {Array<StoredJoinDetails<CSchema>>} An array of {@link StoredJoinDetails}.
56
+ */
57
+ getJoins(): Array<StoredJoinDetails<CSchema>>;
58
+ }
59
+ //# sourceMappingURL=manager.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.interface.d.ts","sourceRoot":"","sources":["../../../src/criteria/types/manager.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACh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CAC/C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=manager.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.interface.js","sourceRoot":"","sources":["../../../src/criteria/types/manager.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Enumerates the available filter operators for comparing field values.
3
+ */
4
+ export declare enum FilterOperator {
5
+ /** Checks for equality. */
6
+ EQUALS = "=",
7
+ /** Checks for inequality. */
8
+ NOT_EQUALS = "!=",
9
+ /** Checks if a value is greater than another. */
10
+ GREATER_THAN = ">",
11
+ /** Checks if a value is greater than or equal to another. */
12
+ GREATER_THAN_OR_EQUALS = ">=",
13
+ /** Checks if a value is less than another. */
14
+ LESS_THAN = "<",
15
+ /** Checks if a value is less than or equal to another. */
16
+ LESS_THAN_OR_EQUALS = "<=",
17
+ /** Checks if a string value matches a pattern (often case-sensitive, depends on DB). */
18
+ LIKE = "LIKE",
19
+ /** Checks if a string value does not match a pattern. */
20
+ NOT_LIKE = "NOT LIKE",
21
+ /** Checks if a value is within a set of specified values. */
22
+ IN = "IN",
23
+ /** Checks if a value is not within a set of specified values. */
24
+ NOT_IN = "NOT IN",
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",
29
+ /** Checks if a string value contains a specific substring (often case-insensitive, depends on DB). */
30
+ CONTAINS = "CONTAINS",
31
+ /** Checks if a string value starts with a specific substring. */
32
+ STARTS_WITH = "STARTS_WITH",
33
+ /** Checks if a string value ends with a specific substring. */
34
+ ENDS_WITH = "ENDS_WITH",
35
+ /** Checks if a string value does not contain a specific substring. */
36
+ NOT_CONTAINS = "NOT_CONTAINS",
37
+ /**
38
+ * Checks if a field, representing a collection of predefined choices
39
+ * (where multiple can be selected), contains a specific choice.
40
+ * The specific database implementation might vary (e.g., MySQL SET type,
41
+ * a text field with delimited values, or a JSON array).
42
+ */
43
+ SET_CONTAINS = "SET_CONTAINS",
44
+ /**
45
+ * Checks if a field, representing a collection of predefined choices
46
+ * (where multiple can be selected), does NOT contain a specific choice.
47
+ * The specific database implementation might vary.
48
+ */
49
+ SET_NOT_CONTAINS = "SET_NOT_CONTAINS",
50
+ /**
51
+ * Checks if a JSON column contains a specific value or path.
52
+ * The specific implementation depends on the database (e.g., JSON_CONTAINS in MySQL, @> in PostgreSQL for JSONB).
53
+ */
54
+ JSON_CONTAINS = "JSON_CONTAINS",
55
+ /**
56
+ * Checks if a JSON column does not contain a specific value or path.
57
+ * The specific implementation depends on the database.
58
+ */
59
+ JSON_NOT_CONTAINS = "JSON_NOT_CONTAINS",
60
+ /**
61
+ * Checks if a column representing an array contains a specific element.
62
+ * The underlying column could be a native array type (e.g., PostgreSQL)
63
+ * or a JSON array (e.g., MySQL).
64
+ */
65
+ ARRAY_CONTAINS_ELEMENT = "ARRAY_CONTAINS_ELEMENT",
66
+ /**
67
+ * Checks if a column representing an array contains ALL elements from the provided array.
68
+ * The underlying column could be a native array type or a JSON array.
69
+ */
70
+ ARRAY_CONTAINS_ALL_ELEMENTS = "ARRAY_CONTAINS_ALL_ELEMENTS",
71
+ /**
72
+ * Checks if a column representing an array contains AT LEAST ONE element from the provided array.
73
+ * The underlying column could be a native array type or a JSON array.
74
+ */
75
+ ARRAY_CONTAINS_ANY_ELEMENT = "ARRAY_CONTAINS_ANY_ELEMENT",
76
+ /**
77
+ * Checks if a column representing an array is exactly equal to the provided array
78
+ * (order and elements must match).
79
+ * The underlying column could be a native array type or a JSON array.
80
+ */
81
+ ARRAY_EQUALS = "ARRAY_EQUALS"
82
+ }
83
+ /**
84
+ * Enumerates the logical operators used to combine filter conditions or groups.
85
+ */
86
+ export declare enum LogicalOperator {
87
+ /** Combines conditions with a logical AND. All conditions must be true. */
88
+ AND = "AND",
89
+ /** Combines conditions with a logical OR. At least one condition must be true. */
90
+ OR = "OR"
91
+ }
92
+ //# sourceMappingURL=operator.types.d.ts.map
@@ -0,0 +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;IAC1B,wFAAwF;IACxF,IAAI,SAAS;IACb,yDAAyD;IACzD,QAAQ,aAAa;IACrB,6DAA6D;IAC7D,EAAE,OAAO;IACT,iEAAiE;IACjE,MAAM,WAAW;IACjB,iCAAiC;IACjC,OAAO,YAAY;IACnB,qCAAqC;IACrC,WAAW,gBAAgB;IAC3B,sGAAsG;IACtG,QAAQ,aAAa;IACrB,iEAAiE;IACjE,WAAW,gBAAgB;IAC3B,+DAA+D;IAC/D,SAAS,cAAc;IACvB,sEAAsE;IACtE,YAAY,iBAAiB;IAC7B;;;;;OAKG;IACH,YAAY,iBAAiB;IAC7B;;;;OAIG;IACH,gBAAgB,qBAAqB;IAErC;;;OAGG;IACH,aAAa,kBAAkB;IAC/B;;;OAGG;IACH,iBAAiB,sBAAsB;IAGvC;;;;OAIG;IACH,sBAAsB,2BAA2B;IACjD;;;OAGG;IACH,2BAA2B,gCAAgC;IAC3D;;;OAGG;IACH,0BAA0B,+BAA+B;IACzD;;;;OAIG;IACH,YAAY,iBAAiB;CAC9B;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,2EAA2E;IAC3E,GAAG,QAAQ;IACX,kFAAkF;IAClF,EAAE,OAAO;CACV"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Enumerates the available filter operators for comparing field values.
3
+ */
4
+ export var FilterOperator;
5
+ (function (FilterOperator) {
6
+ /** Checks for equality. */
7
+ FilterOperator["EQUALS"] = "=";
8
+ /** Checks for inequality. */
9
+ FilterOperator["NOT_EQUALS"] = "!=";
10
+ /** Checks if a value is greater than another. */
11
+ FilterOperator["GREATER_THAN"] = ">";
12
+ /** Checks if a value is greater than or equal to another. */
13
+ FilterOperator["GREATER_THAN_OR_EQUALS"] = ">=";
14
+ /** Checks if a value is less than another. */
15
+ FilterOperator["LESS_THAN"] = "<";
16
+ /** Checks if a value is less than or equal to another. */
17
+ FilterOperator["LESS_THAN_OR_EQUALS"] = "<=";
18
+ /** Checks if a string value matches a pattern (often case-sensitive, depends on DB). */
19
+ FilterOperator["LIKE"] = "LIKE";
20
+ /** Checks if a string value does not match a pattern. */
21
+ FilterOperator["NOT_LIKE"] = "NOT LIKE";
22
+ /** Checks if a value is within a set of specified values. */
23
+ FilterOperator["IN"] = "IN";
24
+ /** Checks if a value is not within a set of specified values. */
25
+ FilterOperator["NOT_IN"] = "NOT IN";
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";
30
+ /** Checks if a string value contains a specific substring (often case-insensitive, depends on DB). */
31
+ FilterOperator["CONTAINS"] = "CONTAINS";
32
+ /** Checks if a string value starts with a specific substring. */
33
+ FilterOperator["STARTS_WITH"] = "STARTS_WITH";
34
+ /** Checks if a string value ends with a specific substring. */
35
+ FilterOperator["ENDS_WITH"] = "ENDS_WITH";
36
+ /** Checks if a string value does not contain a specific substring. */
37
+ FilterOperator["NOT_CONTAINS"] = "NOT_CONTAINS";
38
+ /**
39
+ * Checks if a field, representing a collection of predefined choices
40
+ * (where multiple can be selected), contains a specific choice.
41
+ * The specific database implementation might vary (e.g., MySQL SET type,
42
+ * a text field with delimited values, or a JSON array).
43
+ */
44
+ FilterOperator["SET_CONTAINS"] = "SET_CONTAINS";
45
+ /**
46
+ * Checks if a field, representing a collection of predefined choices
47
+ * (where multiple can be selected), does NOT contain a specific choice.
48
+ * The specific database implementation might vary.
49
+ */
50
+ FilterOperator["SET_NOT_CONTAINS"] = "SET_NOT_CONTAINS";
51
+ /**
52
+ * Checks if a JSON column contains a specific value or path.
53
+ * The specific implementation depends on the database (e.g., JSON_CONTAINS in MySQL, @> in PostgreSQL for JSONB).
54
+ */
55
+ FilterOperator["JSON_CONTAINS"] = "JSON_CONTAINS";
56
+ /**
57
+ * Checks if a JSON column does not contain a specific value or path.
58
+ * The specific implementation depends on the database.
59
+ */
60
+ FilterOperator["JSON_NOT_CONTAINS"] = "JSON_NOT_CONTAINS";
61
+ // --- Array Operators ---
62
+ /**
63
+ * Checks if a column representing an array contains a specific element.
64
+ * The underlying column could be a native array type (e.g., PostgreSQL)
65
+ * or a JSON array (e.g., MySQL).
66
+ */
67
+ FilterOperator["ARRAY_CONTAINS_ELEMENT"] = "ARRAY_CONTAINS_ELEMENT";
68
+ /**
69
+ * Checks if a column representing an array contains ALL elements from the provided array.
70
+ * The underlying column could be a native array type or a JSON array.
71
+ */
72
+ FilterOperator["ARRAY_CONTAINS_ALL_ELEMENTS"] = "ARRAY_CONTAINS_ALL_ELEMENTS";
73
+ /**
74
+ * Checks if a column representing an array contains AT LEAST ONE element from the provided array.
75
+ * The underlying column could be a native array type or a JSON array.
76
+ */
77
+ FilterOperator["ARRAY_CONTAINS_ANY_ELEMENT"] = "ARRAY_CONTAINS_ANY_ELEMENT";
78
+ /**
79
+ * Checks if a column representing an array is exactly equal to the provided array
80
+ * (order and elements must match).
81
+ * The underlying column could be a native array type or a JSON array.
82
+ */
83
+ FilterOperator["ARRAY_EQUALS"] = "ARRAY_EQUALS";
84
+ })(FilterOperator || (FilterOperator = {}));
85
+ /**
86
+ * Enumerates the logical operators used to combine filter conditions or groups.
87
+ */
88
+ export var LogicalOperator;
89
+ (function (LogicalOperator) {
90
+ /** Combines conditions with a logical AND. All conditions must be true. */
91
+ LogicalOperator["AND"] = "AND";
92
+ /** Combines conditions with a logical OR. At least one condition must be true. */
93
+ LogicalOperator["OR"] = "OR";
94
+ })(LogicalOperator || (LogicalOperator = {}));
95
+ //# sourceMappingURL=operator.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.types.js","sourceRoot":"","sources":["../../../src/criteria/types/operator.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,cAiFX;AAjFD,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;IAC1B,wFAAwF;IACxF,+BAAa,CAAA;IACb,yDAAyD;IACzD,uCAAqB,CAAA;IACrB,6DAA6D;IAC7D,2BAAS,CAAA;IACT,iEAAiE;IACjE,mCAAiB,CAAA;IACjB,iCAAiC;IACjC,qCAAmB,CAAA;IACnB,qCAAqC;IACrC,6CAA2B,CAAA;IAC3B,sGAAsG;IACtG,uCAAqB,CAAA;IACrB,iEAAiE;IACjE,6CAA2B,CAAA;IAC3B,+DAA+D;IAC/D,yCAAuB,CAAA;IACvB,sEAAsE;IACtE,+CAA6B,CAAA;IAC7B;;;;;OAKG;IACH,+CAA6B,CAAA;IAC7B;;;;OAIG;IACH,uDAAqC,CAAA;IAErC;;;OAGG;IACH,iDAA+B,CAAA;IAC/B;;;OAGG;IACH,yDAAuC,CAAA;IAEvC,0BAA0B;IAC1B;;;;OAIG;IACH,mEAAiD,CAAA;IACjD;;;OAGG;IACH,6EAA2D,CAAA;IAC3D;;;OAGG;IACH,2EAAyD,CAAA;IACzD;;;;OAIG;IACH,+CAA6B,CAAA;AAC/B,CAAC,EAjFW,cAAc,KAAd,cAAc,QAiFzB;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"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Defines the type of relationship for a join.
3
+ */
4
+ export type JoinRelationType = 'one_to_one' | 'one_to_many' | 'many_to_one' | 'many_to_many';
5
+ /**
6
+ * Describes the configuration for a joinable relation within a {@link CriteriaSchema}.
7
+ * @template ValidAlias - A string literal type representing a valid alias for the join.
8
+ */
9
+ export type SchemaJoins<ValidAlias extends string> = {
10
+ /** The alias used to refer to this join in criteria construction. */
11
+ alias: ValidAlias;
12
+ /** The type of relationship this join represents (e.g., 'one_to_many'). */
13
+ join_relation_type: JoinRelationType;
14
+ };
15
+ /**
16
+ * Represents the schema definition for an entity, used by the Criteria system.
17
+ * It defines the entity's source name (e.g., table name), available aliases,
18
+ * fields, and joinable relations.
19
+ * @template TFields - A readonly array of string literal types representing the entity's field names.
20
+ * @template TAliases - A readonly array of string literal types representing the entity's valid aliases.
21
+ * @template TSourceName - A string literal type for the entity's source name.
22
+ * @template JoinsAlias - A string literal type representing valid aliases for its joinable relations.
23
+ */
24
+ export type CriteriaSchema<TFields extends ReadonlyArray<string> = ReadonlyArray<string>, TAliases extends ReadonlyArray<string> = ReadonlyArray<string>, TSourceName extends string = string, JoinsAlias extends string = string> = {
25
+ /** The source name of the entity (e.g., database table name). */
26
+ source_name: TSourceName;
27
+ /** An array of valid aliases that can be used to refer to this entity. */
28
+ alias: TAliases;
29
+ /** An array of field names available for this entity. */
30
+ fields: TFields;
31
+ /** An array of configurations for entities that can be joined from this entity. */
32
+ joins: ReadonlyArray<SchemaJoins<JoinsAlias>>;
33
+ };
34
+ /**
35
+ * A helper function to infer and preserve the literal types of a schema definition.
36
+ * Use this when defining schemas to get strong typing for fields, aliases, etc.
37
+ * @template TInput - The type of the schema object being passed.
38
+ * @param {TInput} schema - The schema definition object.
39
+ * @returns {TInput} The same schema object, with its literal types preserved.
40
+ * @example
41
+ * export const UserSchema = GetTypedCriteriaSchema({
42
+ * source_name: 'users_table',
43
+ * alias: ['user', 'u'],
44
+ * fields: ['id', 'name', 'email'],
45
+ * joins: [{ alias: 'posts', join_relation_type: 'one_to_many' }]
46
+ * });
47
+ */
48
+ export declare function GetTypedCriteriaSchema<const TInput extends CriteriaSchema>(schema: TInput): TInput;
49
+ /**
50
+ * Extracts a union type of all valid field names from a given {@link CriteriaSchema}.
51
+ * @template T - The {@link CriteriaSchema} from which to extract field names.
52
+ * @example type UserFields = FieldOfSchema<typeof UserSchema>; // "id" | "name" | "email"
53
+ */
54
+ export type FieldOfSchema<T extends CriteriaSchema> = T['fields'] extends ReadonlyArray<string> ? T['fields'][number] : never;
55
+ /**
56
+ * Extracts a union type of all valid aliases from a given {@link CriteriaSchema}.
57
+ * @template T - The {@link CriteriaSchema} from which to extract aliases.
58
+ * @example type UserAliases = SelectedAliasOf<typeof UserSchema>; // "user" | "u"
59
+ */
60
+ export type SelectedAliasOf<T extends CriteriaSchema> = T['alias'] extends ReadonlyArray<string> ? T['alias'][number] : never;
61
+ //# sourceMappingURL=schema.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.types.d.ts","sourceRoot":"","sources":["../../../src/criteria/types/schema.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,aAAa,GACb,aAAa,GACb,cAAc,CAAC;AAEnB;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,UAAU,SAAS,MAAM,IAAI;IACnD,qEAAqE;IACrE,KAAK,EAAE,UAAU,CAAC;IAClB,2EAA2E;IAC3E,kBAAkB,EAAE,gBAAgB,CAAC;CACtC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,CACxB,OAAO,SAAS,aAAa,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,EAC7D,QAAQ,SAAS,aAAa,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,EAC9D,WAAW,SAAS,MAAM,GAAG,MAAM,EACnC,UAAU,SAAS,MAAM,GAAG,MAAM,IAChC;IACF,iEAAiE;IACjE,WAAW,EAAE,WAAW,CAAC;IACzB,0EAA0E;IAC1E,KAAK,EAAE,QAAQ,CAAC;IAChB,yDAAyD;IACzD,MAAM,EAAE,OAAO,CAAC;IAChB,mFAAmF;IACnF,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,MAAM,SAAS,cAAc,EACxE,MAAM,EAAE,MAAM,GACb,MAAM,CAER;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,cAAc,IAChD,CAAC,CAAC,QAAQ,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,cAAc,IAClD,CAAC,CAAC,OAAO,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * A helper function to infer and preserve the literal types of a schema definition.
3
+ * Use this when defining schemas to get strong typing for fields, aliases, etc.
4
+ * @template TInput - The type of the schema object being passed.
5
+ * @param {TInput} schema - The schema definition object.
6
+ * @returns {TInput} The same schema object, with its literal types preserved.
7
+ * @example
8
+ * export const UserSchema = GetTypedCriteriaSchema({
9
+ * source_name: 'users_table',
10
+ * alias: ['user', 'u'],
11
+ * fields: ['id', 'name', 'email'],
12
+ * joins: [{ alias: 'posts', join_relation_type: 'one_to_many' }]
13
+ * });
14
+ */
15
+ export function GetTypedCriteriaSchema(schema) {
16
+ return schema;
17
+ }
18
+ //# sourceMappingURL=schema.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.types.js","sourceRoot":"","sources":["../../../src/criteria/types/schema.types.ts"],"names":[],"mappings":"AA6CA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAc;IAEd,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { RootCriteria } from '../root.criteria.js';
2
+ import type { InnerJoinCriteria } from '../join/inner.join-criteria.js';
3
+ import type { LeftJoinCriteria } from '../join/left.join-criteria.js';
4
+ import type { OuterJoinCriteria } from '../join/outer.join-criteria.js';
5
+ import type { Filter } from '../filter/filter.js';
6
+ import type { FilterGroup } from '../filter/filter-group.js';
7
+ import type { CriteriaSchema, JoinRelationType, SelectedAliasOf } from './schema.types.js';
8
+ import type { PivotJoin, SimpleJoin } from './join-parameter.types.js';
9
+ import type { FilterOperator } from './operator.types.js';
10
+ /**
11
+ * Visitor interface for traversing Criteria objects.
12
+ * @template TranslationContext - The type of the context object passed during traversal.
13
+ * @template TranslationOutput - The type of the result returned by visitor methods.
14
+ */
15
+ export interface ICriteriaVisitor<TranslationContext, TranslationOutput = TranslationContext, TFilterVisitorOutput extends any = any> {
16
+ visitRoot<RootCSchema extends CriteriaSchema, RootAlias extends SelectedAliasOf<RootCSchema>>(criteria: RootCriteria<RootCSchema, RootAlias>, context: TranslationContext): TranslationOutput;
17
+ visitInnerJoin<ParentCSchema extends CriteriaSchema, JoinCSchema extends CriteriaSchema, JoinAlias extends SelectedAliasOf<JoinCSchema>>(criteria: InnerJoinCriteria<JoinCSchema, JoinAlias>, parameters: PivotJoin<ParentCSchema, JoinCSchema, JoinRelationType> | SimpleJoin<ParentCSchema, JoinCSchema, JoinRelationType>, context: TranslationContext): TranslationOutput;
18
+ visitLeftJoin<ParentCSchema extends CriteriaSchema, JoinCSchema extends CriteriaSchema, JoinAlias extends SelectedAliasOf<JoinCSchema>>(criteria: LeftJoinCriteria<JoinCSchema, JoinAlias>, parameters: PivotJoin<ParentCSchema, JoinCSchema, JoinRelationType> | SimpleJoin<ParentCSchema, JoinCSchema, JoinRelationType>, context: TranslationContext): TranslationOutput;
19
+ visitOuterJoin<ParentCSchema extends CriteriaSchema, JoinCSchema extends CriteriaSchema, JoinAlias extends SelectedAliasOf<JoinCSchema>>(criteria: OuterJoinCriteria<JoinCSchema, JoinAlias>, parameters: PivotJoin<ParentCSchema, JoinCSchema, JoinRelationType> | SimpleJoin<ParentCSchema, JoinCSchema, JoinRelationType>, context: TranslationContext): TranslationOutput;
20
+ visitFilter<FieldType extends string>(filter: Filter<FieldType, FilterOperator>, currentAlias: string): TFilterVisitorOutput;
21
+ visitAndGroup<FieldType extends string>(group: FilterGroup<FieldType>, currentAlias: string, context: TranslationContext): TranslationOutput;
22
+ visitOrGroup<FieldType extends string>(group: FilterGroup<FieldType>, currentAlias: string, context: TranslationContext): TranslationOutput;
23
+ }
24
+ //# sourceMappingURL=visitor-interface.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visitor-interface.types.d.ts","sourceRoot":"","sources":["../../../src/criteria/types/visitor-interface.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,KA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,gBAAgB,CAAC,GACvD,UAAU,CAAC,aAAa,EAAE,WAAW,EAAE,gBAAgB,CAAC,EAC5D,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAAC;IAErB,WAAW,CAAC,SAAS,SAAS,MAAM,EAClC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,EACzC,YAAY,EAAE,MAAM,GACnB,oBAAoB,CAAC;IAExB,aAAa,CAAC,SAAS,SAAS,MAAM,EACpC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,EAC7B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAAC;IAErB,YAAY,CAAC,SAAS,SAAS,MAAM,EACnC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,EAC7B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=visitor-interface.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visitor-interface.types.js","sourceRoot":"","sources":["../../../src/criteria/types/visitor-interface.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './criteria/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './criteria/index.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nulledexp/translatable-criteria",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "license": "MIT",
5
5
  "description": "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.",
6
6
  "keywords": [