@nulledexp/translatable-criteria 1.0.4 → 1.2.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 (56) hide show
  1. package/README.md +3 -3
  2. package/dist/criteria/criteria.d.ts +182 -10
  3. package/dist/criteria/criteria.d.ts.map +1 -1
  4. package/dist/criteria/criteria.js +182 -8
  5. package/dist/criteria/criteria.js.map +1 -1
  6. package/dist/criteria/cursor.d.ts +31 -0
  7. package/dist/criteria/cursor.d.ts.map +1 -1
  8. package/dist/criteria/cursor.js +34 -6
  9. package/dist/criteria/cursor.js.map +1 -1
  10. package/dist/criteria/filter/filter-utils.d.ts +6 -0
  11. package/dist/criteria/filter/filter-utils.d.ts.map +1 -1
  12. package/dist/criteria/filter/filter-utils.js +29 -9
  13. package/dist/criteria/filter/filter-utils.js.map +1 -1
  14. package/dist/criteria/filter/filter.d.ts +3 -0
  15. package/dist/criteria/filter/filter.d.ts.map +1 -1
  16. package/dist/criteria/filter/filter.js +62 -35
  17. package/dist/criteria/filter/filter.js.map +1 -1
  18. package/dist/criteria/filter/types/filter-primitive.types.d.ts +8 -11
  19. package/dist/criteria/filter/types/filter-primitive.types.d.ts.map +1 -1
  20. package/dist/criteria/join/inner.join-criteria.d.ts +5 -0
  21. package/dist/criteria/join/inner.join-criteria.d.ts.map +1 -1
  22. package/dist/criteria/join/inner.join-criteria.js +5 -0
  23. package/dist/criteria/join/inner.join-criteria.js.map +1 -1
  24. package/dist/criteria/join/left.join-criteria.d.ts +5 -0
  25. package/dist/criteria/join/left.join-criteria.d.ts.map +1 -1
  26. package/dist/criteria/join/left.join-criteria.js +5 -0
  27. package/dist/criteria/join/left.join-criteria.js.map +1 -1
  28. package/dist/criteria/join/outer.join-criteria.d.ts +5 -0
  29. package/dist/criteria/join/outer.join-criteria.d.ts.map +1 -1
  30. package/dist/criteria/join/outer.join-criteria.js +5 -0
  31. package/dist/criteria/join/outer.join-criteria.js.map +1 -1
  32. package/dist/criteria/order/order.d.ts +49 -0
  33. package/dist/criteria/order/order.d.ts.map +1 -1
  34. package/dist/criteria/order/order.js +39 -0
  35. package/dist/criteria/order/order.js.map +1 -1
  36. package/dist/criteria/root.criteria.d.ts +5 -0
  37. package/dist/criteria/root.criteria.d.ts.map +1 -1
  38. package/dist/criteria/root.criteria.js +5 -0
  39. package/dist/criteria/root.criteria.js.map +1 -1
  40. package/dist/criteria/types/criteria.interface.d.ts +32 -27
  41. package/dist/criteria/types/criteria.interface.d.ts.map +1 -1
  42. package/dist/criteria/types/filter-expression.interface.d.ts +12 -0
  43. package/dist/criteria/types/filter-expression.interface.d.ts.map +1 -1
  44. package/dist/criteria/types/join-parameter.types.d.ts +36 -2
  45. package/dist/criteria/types/join-parameter.types.d.ts.map +1 -1
  46. package/dist/criteria/types/join-utility.types.d.ts +5 -5
  47. package/dist/criteria/types/join-utility.types.d.ts.map +1 -1
  48. package/dist/criteria/types/operator.types.d.ts +44 -7
  49. package/dist/criteria/types/operator.types.d.ts.map +1 -1
  50. package/dist/criteria/types/operator.types.js +44 -8
  51. package/dist/criteria/types/operator.types.js.map +1 -1
  52. package/dist/criteria/types/schema.types.d.ts +26 -2
  53. package/dist/criteria/types/schema.types.d.ts.map +1 -1
  54. package/dist/criteria/types/schema.types.js +1 -1
  55. package/dist/criteria/types/schema.types.js.map +1 -1
  56. package/package.json +1 -1
@@ -36,18 +36,55 @@ export var FilterOperator;
36
36
  /** Checks if a string value does not contain a specific substring. */
37
37
  FilterOperator["NOT_CONTAINS"] = "NOT_CONTAINS";
38
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).
39
+ * Checks if a field, representing a collection of values (e.g., MySQL SET type
40
+ * or a text field with comma-delimited values), contains a specific value.
41
+ * Expects a single value.
43
42
  */
44
43
  FilterOperator["SET_CONTAINS"] = "SET_CONTAINS";
45
44
  /**
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.
45
+ * Checks if a field, representing a collection of values (e.g., MySQL SET type
46
+ * or a text field with comma-delimited values), does NOT contain a specific value.
47
+ * Expects a single value.
49
48
  */
50
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
+ */
66
+ FilterOperator["BETWEEN"] = "BETWEEN";
67
+ /**
68
+ * Checks if a value is outside a specified range (inclusive).
69
+ * Expects an array or tuple of two values: [min, max].
70
+ */
71
+ FilterOperator["NOT_BETWEEN"] = "NOT_BETWEEN";
72
+ /**
73
+ * Checks if a string value matches a regular expression pattern.
74
+ * The specific regex syntax may depend on the database.
75
+ * Expects a string representing the regular expression.
76
+ */
77
+ FilterOperator["MATCHES_REGEX"] = "MATCHES_REGEX";
78
+ /**
79
+ * Checks if a string value matches a pattern (case-insensitive).
80
+ * Expects a string for the pattern.
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";
51
88
  /**
52
89
  * Checks if a JSON column contains a specific value or path.
53
90
  * The specific implementation depends on the database (e.g., JSON_CONTAINS in MySQL, @> in PostgreSQL for JSONB).
@@ -58,7 +95,6 @@ export var FilterOperator;
58
95
  * The specific implementation depends on the database.
59
96
  */
60
97
  FilterOperator["JSON_NOT_CONTAINS"] = "JSON_NOT_CONTAINS";
61
- // --- Array Operators ---
62
98
  /**
63
99
  * Checks if a column representing an array contains a specific element.
64
100
  * The underlying column could be a native array type (e.g., PostgreSQL)
@@ -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,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"}
1
+ {"version":3,"file":"operator.types.js","sourceRoot":"","sources":["../../../src/criteria/types/operator.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,cAmHX;AAnHD,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;;;;OAIG;IACH,+CAA6B,CAAA;IAC7B;;;;OAIG;IACH,uDAAqC,CAAA;IACrC;;;;OAIG;IACH,uDAAqC,CAAA;IACrC;;;;OAIG;IACH,uDAAqC,CAAA;IACrC;;;OAGG;IACH,qCAAmB,CAAA;IACnB;;;OAGG;IACH,6CAA2B,CAAA;IAC3B;;;;OAIG;IACH,iDAA+B,CAAA;IAC/B;;;OAGG;IACH,iCAAe,CAAA;IACf;;;OAGG;IACH,yCAAuB,CAAA;IACvB;;;OAGG;IACH,iDAA+B,CAAA;IAC/B;;;OAGG;IACH,yDAAuC,CAAA;IACvC;;;;OAIG;IACH,mEAAiD,CAAA;IACjD;;;OAGG;IACH,6EAA2D,CAAA;IAC3D;;;OAGG;IACH,2EAAyD,CAAA;IACzD;;;;OAIG;IACH,+CAA6B,CAAA;AAC/B,CAAC,EAnHW,cAAc,KAAd,cAAc,QAmHzB;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"}
@@ -1,5 +1,9 @@
1
1
  /**
2
2
  * Defines the type of relationship for a join.
3
+ * - `one_to_one`: Represents a one-to-one relationship.
4
+ * - `one_to_many`: Represents a one-to-many relationship.
5
+ * - `many_to_one`: Represents a many-to-one relationship.
6
+ * - `many_to_many`: Represents a many-to-many relationship, typically involving a pivot table.
3
7
  */
4
8
  export type JoinRelationType = 'one_to_one' | 'one_to_many' | 'many_to_one' | 'many_to_many';
5
9
  /**
@@ -10,7 +14,17 @@ export type SchemaJoins<ValidAlias extends string> = {
10
14
  /** The alias used to refer to this join in criteria construction. */
11
15
  alias: ValidAlias;
12
16
  /** The type of relationship this join represents (e.g., 'one_to_many'). */
13
- join_relation_type: JoinRelationType;
17
+ relation_type: JoinRelationType;
18
+ /**
19
+ * 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
+ */
25
+ metadata?: {
26
+ [key: string]: any;
27
+ };
14
28
  };
15
29
  /**
16
30
  * Represents the schema definition for an entity, used by the Criteria system.
@@ -30,6 +44,16 @@ export type CriteriaSchema<TFields extends ReadonlyArray<string> = ReadonlyArray
30
44
  fields: TFields;
31
45
  /** An array of configurations for entities that can be joined from this entity. */
32
46
  joins: ReadonlyArray<SchemaJoins<JoinsAlias>>;
47
+ /**
48
+ * Optional metadata associated with the entire schema definition.
49
+ * This can be used to store arbitrary, translator-specific information
50
+ * or configuration relevant to the entity this schema represents.
51
+ * For example, it could hold information about custom data types,
52
+ * default behaviors, or ORM-specific settings.
53
+ */
54
+ metadata?: {
55
+ [key: string]: any;
56
+ };
33
57
  };
34
58
  /**
35
59
  * A helper function to infer and preserve the literal types of a schema definition.
@@ -42,7 +66,7 @@ export type CriteriaSchema<TFields extends ReadonlyArray<string> = ReadonlyArray
42
66
  * source_name: 'users_table',
43
67
  * alias: ['user', 'u'],
44
68
  * fields: ['id', 'name', 'email'],
45
- * joins: [{ alias: 'posts', join_relation_type: 'one_to_many' }]
69
+ * joins: [{ alias: 'posts', relation_type: 'one_to_many' }]
46
70
  * });
47
71
  */
48
72
  export declare function GetTypedCriteriaSchema<const TInput extends CriteriaSchema>(schema: TInput): TInput;
@@ -1 +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;IAC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,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;IAC9C;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACnC,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"}
@@ -9,7 +9,7 @@
9
9
  * source_name: 'users_table',
10
10
  * alias: ['user', 'u'],
11
11
  * fields: ['id', 'name', 'email'],
12
- * joins: [{ alias: 'posts', join_relation_type: 'one_to_many' }]
12
+ * joins: [{ alias: 'posts', relation_type: 'one_to_many' }]
13
13
  * });
14
14
  */
15
15
  export function GetTypedCriteriaSchema(schema) {
@@ -1 +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"}
1
+ {"version":3,"file":"schema.types.js","sourceRoot":"","sources":["../../../src/criteria/types/schema.types.ts"],"names":[],"mappings":"AAiEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAc;IAEd,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nulledexp/translatable-criteria",
3
- "version": "1.0.4",
3
+ "version": "1.2.0",
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": [