Skip to content

Commit 645e9cb

Browse files
committed
strongly typed filtering
1 parent 26d9dcd commit 645e9cb

File tree

99 files changed

+860
-569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+860
-569
lines changed

Kontent.Ai.Delivery.Abstractions.Tests/CheckNamespaces.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Linq;
32
using System.Reflection;
43
using System.Runtime.CompilerServices;

Kontent.Ai.Delivery.Abstractions/QueryBuilders/Filtering/FilterValue.cs

Lines changed: 0 additions & 142 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Kontent.Ai.Delivery.Abstractions.QueryBuilders.Filtering;
2+
3+
/// <summary>
4+
/// Represents a filter value.
5+
/// </summary>
6+
public interface IFilterValue
7+
{
8+
/// <summary>
9+
/// Serializes the filter value to a string format suitable for the API.
10+
/// </summary>
11+
string Serialize();
12+
}
Lines changed: 34 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,68 @@
1-
using System;
1+
using Scalar = OneOf.OneOf<string, double, System.DateTime, bool>;
2+
using ScalarArray = OneOf.OneOf<string[], double[], System.DateTime[]>;
3+
using RangeTuple = OneOf.OneOf<(double Lower, double Upper), (System.DateTime Lower, System.DateTime Upper)>;
4+
using Comparable = OneOf.OneOf<double, System.DateTime, string>;
25

36
namespace Kontent.Ai.Delivery.Abstractions.QueryBuilders.Filtering;
4-
57
/// <summary>
6-
/// Filter builder interface for content items endpoint.
7-
/// Provides full filtering capabilities including system and element properties with all operators.
8+
/// Interface for item filters.
89
/// </summary>
910
public interface IItemFilters
1011
{
1112
/// <summary>
12-
/// Retrieves items where the specified property equals the specified value.
13+
/// Retrieves items where the property specified by path equals the specified value.
1314
/// </summary>
14-
IFilter Equals(string propertyPath, string value);
15-
/// <inheritdoc cref="Equals(string, string)"/>
16-
IFilter Equals(string propertyPath, double value);
17-
/// <inheritdoc cref="Equals(string, string)"/>
18-
IFilter Equals(string propertyPath, DateTime value);
19-
/// <inheritdoc cref="Equals(string, string)"/>
20-
IFilter Equals(string propertyPath, bool value);
21-
15+
IFilter Equals(IPropertyPath path, Scalar value);
2216
/// <summary>
23-
/// Retrieves items where the specified property does not equal the specified value.
17+
/// Retrieves items where the property specified by path does not equal the specified value.
2418
/// </summary>
25-
IFilter NotEquals(string propertyPath, string value);
26-
/// <inheritdoc cref="NotEquals(string, string)"/>
27-
IFilter NotEquals(string propertyPath, double value);
28-
/// <inheritdoc cref="NotEquals(string, string)"/>
29-
IFilter NotEquals(string propertyPath, DateTime value);
30-
/// <inheritdoc cref="NotEquals(string, string)"/>
31-
IFilter NotEquals(string propertyPath, bool value);
32-
19+
IFilter NotEquals(IPropertyPath path, Scalar value);
3320
/// <summary>
34-
/// Retrieves items where the specified property is less than the specified value.
21+
/// Retrieves items where the property specified by path is less than the specified value.
3522
/// </summary>
36-
IFilter LessThan(string propertyPath, double value);
37-
/// <inheritdoc cref="LessThan(string, double)"/>
38-
IFilter LessThan(string propertyPath, DateTime value);
39-
23+
IFilter LessThan(IPropertyPath path, Comparable value);
4024
/// <summary>
41-
/// Retrieves items where the specified property is less than or equal to the specified value.
25+
/// Retrieves items where the property specified by path is less than or equal to the specified value.
4226
/// </summary>
43-
IFilter LessThanOrEqual(string propertyPath, double value);
44-
/// <inheritdoc cref="LessThanOrEqual(string, double)"/>
45-
IFilter LessThanOrEqual(string propertyPath, DateTime value);
46-
27+
IFilter LessThanOrEqual(IPropertyPath path, Comparable value);
4728
/// <summary>
48-
/// Retrieves items where the specified property is greater than the specified value.
29+
/// Retrieves items where the property specified by path is greater than the specified value.
4930
/// </summary>
50-
IFilter GreaterThan(string propertyPath, double value);
51-
/// <inheritdoc cref="GreaterThan(string, double)"/>
52-
IFilter GreaterThan(string propertyPath, DateTime value);
53-
31+
IFilter GreaterThan(IPropertyPath path, Comparable value);
5432
/// <summary>
55-
/// Retrieves items where the specified property is greater than or equal to the specified value.
33+
/// Retrieves items where the property specified by path is greater than or equal to the specified value.
5634
/// </summary>
57-
IFilter GreaterThanOrEqual(string propertyPath, double value);
58-
/// <inheritdoc cref="GreaterThanOrEqual(string, double)"/>
59-
IFilter GreaterThanOrEqual(string propertyPath, DateTime value);
60-
35+
IFilter GreaterThanOrEqual(IPropertyPath path, Comparable value);
6136
/// <summary>
62-
/// Retrieves items where the specified property is within the specified range.
37+
/// Retrieves items where the property specified by path is within the specified range.
6338
/// </summary>
64-
IFilter Range(string propertyPath, double lowerBound, double upperBound);
65-
/// <inheritdoc cref="Range(string, double, double)"/>
66-
IFilter Range(string propertyPath, DateTime lowerBound, DateTime upperBound);
67-
39+
IFilter Range(IPropertyPath path, RangeTuple range);
6840
/// <summary>
69-
/// Retrieves items where the specified property is in the specified collection.
41+
/// Retrieves items where the property specified by path is in the specified collection.
7042
/// </summary>
71-
IFilter In(string propertyPath, params string[] values);
72-
/// <inheritdoc cref="In(string, string[])"/>
73-
IFilter In(string propertyPath, params double[] values);
74-
/// <inheritdoc cref="In(string, string[])"/>
75-
IFilter In(string propertyPath, params DateTime[] values);
76-
/// <inheritdoc cref="In(string, string[])"/>
77-
43+
IFilter In(IPropertyPath path, ScalarArray values);
7844
/// <summary>
79-
/// Retrieves items where the specified property is not in the specified collection.
45+
/// Retrieves items where the property specified by path is not in the specified collection.
8046
/// </summary>
81-
IFilter NotIn(string propertyPath, params string[] values);
82-
/// <inheritdoc cref="NotIn(string, string[])"/>
83-
IFilter NotIn(string propertyPath, params double[] values);
84-
/// <inheritdoc cref="NotIn(string, string[])"/>
85-
IFilter NotIn(string propertyPath, params DateTime[] values);
86-
47+
IFilter NotIn(IPropertyPath path, ScalarArray values);
8748
/// <summary>
88-
/// Retrieves items where the specified array property contains the specified value.
49+
/// Retrieves items where the property specified by path contains the specified value.
8950
/// </summary>
90-
IFilter Contains(string propertyPath, string value);
91-
51+
IFilter Contains(IPropertyPath path, string value);
9252
/// <summary>
93-
/// Retrieves items where the specified array property contains any of the specified values.
53+
/// Retrieves items where the property specified by path contains any of the specified values.
9454
/// </summary>
95-
IFilter Any(string propertyPath, params string[] values);
55+
IFilter Any(IPropertyPath path, params string[] values);
9656
/// <summary>
97-
/// Retrieves items where the specified array property contains all of the specified values.
57+
/// Retrieves items where the property specified by path contains all of the specified values.
9858
/// </summary>
99-
IFilter All(string propertyPath, params string[] values);
100-
59+
IFilter All(IPropertyPath path, params string[] values);
10160
/// <summary>
102-
/// Retrieves items where the specified property is empty.
61+
/// Retrieves items where the property specified by path is empty.
10362
/// </summary>
104-
IFilter Empty(string propertyPath);
63+
IFilter Empty(IPropertyPath path);
10564
/// <summary>
106-
/// Retrieves items where the specified property is not empty.
65+
/// Retrieves items where the property specified by path is not empty.
10766
/// </summary>
108-
IFilter NotEmpty(string propertyPath);
109-
}
67+
IFilter NotEmpty(IPropertyPath path);
68+
}

Kontent.Ai.Delivery.Abstractions/QueryBuilders/Filtering/ITaxonomyFilters.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ namespace Kontent.Ai.Delivery.Abstractions.QueryBuilders.Filtering;
99
public interface ITaxonomyFilters
1010
{
1111
/// <summary>
12-
/// Retrieves taxonomy groups where the specified property equals the specified value.
12+
/// Retrieves taxonomy groups where the specified system property equals the specified value.
1313
/// </summary>
14-
IFilter Equals(string propertyPath, string value);
14+
IFilter Equals(TaxonomySystemProps propertyPath, string value);
1515
/// <summary>
16-
/// Retrieves taxonomy groups where the specified property does not equal the specified value.
16+
/// Retrieves taxonomy groups where the specified system property does not equal the specified value.
1717
/// </summary>
18-
IFilter NotEquals(string propertyPath, string value);
18+
IFilter NotEquals(TaxonomySystemProps propertyPath, string value);
1919

20-
/// <inheritdoc cref="Equals(string, string)"/>
21-
IFilter Equals(string propertyPath, DateTime value);
22-
/// <inheritdoc cref="NotEquals(string, string)"/>
23-
IFilter NotEquals(string propertyPath, DateTime value);
20+
/// <inheritdoc cref="Equals(TaxonomySystemProps, string)"/>
21+
IFilter Equals(TaxonomySystemProps propertyPath, DateTime value);
22+
/// <inheritdoc cref="NotEquals(TaxonomySystemProps, string)"/>
23+
IFilter NotEquals(TaxonomySystemProps propertyPath, DateTime value);
2424
}

Kontent.Ai.Delivery.Abstractions/QueryBuilders/Filtering/ITypeFilters.cs

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,49 @@ namespace Kontent.Ai.Delivery.Abstractions.QueryBuilders.Filtering;
99
public interface ITypeFilters
1010
{
1111
// Basic equality operators for system properties
12-
IFilter Equals(string propertyPath, string value);
13-
IFilter NotEquals(string propertyPath, string value);
12+
/// <summary>
13+
/// Retrieves types where the specified system property equals the specified value.
14+
/// </summary>
15+
IFilter Equals(TypeSystemProps propertyPath, string value);
16+
/// <inheritdoc cref="Equals(TypeSystemProps, string)"/>
17+
IFilter Equals(TypeSystemProps propertyPath, DateTime value);
18+
19+
/// <summary>
20+
/// Retrieves types where the specified system property does not equal the specified value.
21+
/// </summary>
22+
IFilter NotEquals(TypeSystemProps propertyPath, string value);
23+
/// <inheritdoc cref="NotEquals(TypeSystemProps, string)"/>
24+
IFilter NotEquals(TypeSystemProps propertyPath, DateTime value);
1425

1526
// Collection operators for system properties
16-
IFilter In(string propertyPath, params string[] values);
17-
IFilter NotIn(string propertyPath, params string[] values);
27+
/// <summary>
28+
/// Retrieves types where the specified system property is in the specified collection.
29+
/// </summary>
30+
IFilter In(TypeSystemProps propertyPath, params string[] values);
31+
/// <summary>
32+
/// Retrieves types where the specified system property is not in the specified collection.
33+
/// </summary>
34+
IFilter NotIn(TypeSystemProps propertyPath, params string[] values);
1835

1936
// Date range operators for system.last_modified
20-
IFilter Range(string propertyPath, DateTime lowerBound, DateTime upperBound);
21-
IFilter LessThan(string propertyPath, DateTime value);
22-
IFilter LessThanOrEqual(string propertyPath, DateTime value);
23-
IFilter GreaterThan(string propertyPath, DateTime value);
24-
IFilter GreaterThanOrEqual(string propertyPath, DateTime value);
37+
/// <summary>
38+
/// Retrieves types where the specified system property is within the specified range.
39+
/// </summary>
40+
IFilter Range(TypeSystemProps propertyPath, DateTime lowerBound, DateTime upperBound);
41+
/// <summary>
42+
/// Retrieves types where the specified system property is less than the specified value.
43+
/// </summary>
44+
IFilter LessThan(TypeSystemProps propertyPath, DateTime value);
45+
/// <summary>
46+
/// Retrieves types where the specified system property is less than or equal to the specified value.
47+
/// </summary>
48+
IFilter LessThanOrEqual(TypeSystemProps propertyPath, DateTime value);
49+
/// <summary>
50+
/// Retrieves types where the specified system property is greater than the specified value.
51+
/// </summary>
52+
IFilter GreaterThan(TypeSystemProps propertyPath, DateTime value);
53+
/// <summary>
54+
/// Retrieves types where the specified system property is greater than or equal to the specified value.
55+
/// </summary>
56+
IFilter GreaterThanOrEqual(TypeSystemProps propertyPath, DateTime value);
2557
}

0 commit comments

Comments
 (0)