@intellegens/cornerstone-client 0.0.9999-alpha-3 → 0.0.9999-alpha-5

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 (48) hide show
  1. package/adapters/CollectionViewAdapter/index.d.ts +36 -30
  2. package/adapters/CollectionViewAdapter/index.js +63 -42
  3. package/data/api/dto/read/ReadSelectedDefinitionDto.d.ts +2 -2
  4. package/data/api/dto/read/ReadSelectedNestedCollectionCriteriaDto.d.ts +22 -0
  5. package/data/api/dto/read/ReadSelectedNestedCollectionCriteriaDto.js +1 -0
  6. package/data/api/dto/read/ReadSelectedNestedCriteriaDto.d.ts +18 -0
  7. package/data/api/dto/read/ReadSelectedNestedCriteriaDto.js +1 -0
  8. package/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.d.ts +2 -2
  9. package/data/api/dto/read/ReadSelectedSearchDefinitionDto.d.ts +23 -8
  10. package/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.d.ts +14 -7
  11. package/data/api/dto/read/index.d.ts +2 -0
  12. package/data/api/dto/read/index.js +2 -0
  13. package/data/api/dto/response/ApiErrorDto.d.ts +12 -3
  14. package/data/api/dto/response/ApiErrorResponseDto.d.ts +11 -0
  15. package/data/api/dto/response/ApiErrorResponseDto.js +1 -0
  16. package/data/api/dto/response/ApiResponseDto.d.ts +3 -15
  17. package/data/api/dto/response/ApiSuccessResponseDto.d.ts +2 -1
  18. package/data/api/dto/response/MetadataDto.d.ts +25 -0
  19. package/data/api/dto/response/MetadataDto.js +1 -0
  20. package/data/api/dto/response/index.d.ts +2 -1
  21. package/data/api/dto/response/index.js +2 -1
  22. package/data/api/enum/read/ReadSelectedCollectionOperator.d.ts +16 -0
  23. package/data/api/enum/read/ReadSelectedCollectionOperator.js +17 -0
  24. package/data/api/enum/read/index.d.ts +1 -0
  25. package/data/api/enum/read/index.js +1 -0
  26. package/data/api/enum/response/ErrorCode.d.ts +13 -0
  27. package/data/api/enum/response/ErrorCode.js +14 -0
  28. package/data/api/enum/response/index.d.ts +1 -1
  29. package/data/api/enum/response/index.js +1 -1
  30. package/package.json +1 -1
  31. package/services/api/ApiCrudControllerClient/index.d.ts +4 -4
  32. package/services/api/ApiCrudControllerClient/index.js +39 -21
  33. package/services/api/ApiInitializationService/index.d.ts +27 -27
  34. package/services/api/ApiInitializationService/index.js +45 -41
  35. package/services/api/ApiReadControllerClient/index.d.ts +4 -4
  36. package/services/api/ApiReadControllerClient/index.js +38 -24
  37. package/services/api/UserManagementControllerClient/index.d.ts +5 -5
  38. package/services/api/UserManagementControllerClient/index.js +51 -29
  39. package/services/auth/client/AuthService/index.d.ts +4 -4
  40. package/services/auth/client/AuthService/index.js +44 -27
  41. package/services/auth/client/AuthorizationManagementControllerClient/index.d.ts +7 -5
  42. package/services/auth/client/AuthorizationManagementControllerClient/index.js +57 -31
  43. package/utils/index.d.ts +2 -37
  44. package/utils/index.js +2 -106
  45. package/utils/result/index.d.ts +21 -0
  46. package/utils/result/index.js +16 -0
  47. package/utils/search/index.d.ts +34 -0
  48. package/utils/search/index.js +106 -0
@@ -1,5 +1,4 @@
1
- import { IIdentifiable, ReadSelectedOrderingDirection, ReadSelectedSearchDefinitionDto } from '../../data';
2
- import { PropertyPathDto } from '../../data';
1
+ import { IIdentifiable, PropertyPathDto, ReadSelectedOrderingDirection, ReadSelectedSearchDefinitionDto } from '../../data';
3
2
  /**
4
3
  * Used with CollectionViewAdapter, a simplified configuration object for handling reading/writing from/to ReadSelectedDefinitionDto.
5
4
  *
@@ -12,38 +11,41 @@ import { PropertyPathDto } from '../../data';
12
11
  * @property {number} [pagination.pageSize] - Number of items/rows to be fetched for the current page.
13
12
  * @property {number} [pagination.pageNumber] - Current page index (skips fetching `(n-1) * pageSize` items/rows).
14
13
  *
15
- * @property {object} sorting - Sorting configuration
16
- * @property {PropertyPathDto[]} [sorting.sortByPath] - Array of column/property names that are sortable.
17
- * @property {ReadSelectedOrderingDirection} [sorting.sortDirection] - Enum for ascending/descending sort order.
14
+ * @property {object} ordering - Ordering configuration
15
+ * @property {string[]} [ordering.orderByPath] - Array of column/property names that are sortable.
16
+ * @property {ReadSelectedOrderingDirection} [ordering.orderDirection] - Enum for ascending/descending sort order.
18
17
  *
19
- * @property {object} searching - Search configuration
20
- * @property {PropertyPathDto[]} [searching.textSearchablePaths] - Array of column/property names that are searchable where the value type is string.
21
- * @property {PropertyPathDto[]} [searching.numericSearchablePaths] - Array of column/property names that are searchable where the value type is number.
22
- * @property {ReadSelectedSearchDefinitionDto} [searching.searchDefinition] - The search definition by which the collection will be filtered.
18
+ * @property {object} search - Search configuration
19
+ * @property {(keyof TDto)[]} [search.textSearchableProperties] - Array of column/property names that are searchable where the value type is string.
20
+ * @property {(keyof TDto)[]} [search.numericSearchableProperties] - Array of column/property names that are searchable where the value type is number.
21
+ * @property {ReadSelectedSearchDefinitionDto<TDto>} [search.searchDefinition] - The search definition by which the collection will be filtered.
23
22
  */
24
- export type CollectionViewAdapterOptions = {
23
+ export type CollectionViewAdapterOptions<TDto> = {
25
24
  pagination: {
26
25
  useTotalItemCount: boolean;
27
26
  pageSize?: number;
28
27
  pageNumber?: number;
29
28
  };
30
- sorting: {
31
- sortByPath?: PropertyPathDto[];
32
- sortDirection?: ReadSelectedOrderingDirection;
29
+ ordering: {
30
+ maxActiveOrderingColumns: number;
31
+ orderByPaths: {
32
+ orderByPath: PropertyPathDto;
33
+ orderDirection: ReadSelectedOrderingDirection;
34
+ }[];
33
35
  };
34
- searching: {
35
- textSearchablePaths?: PropertyPathDto[];
36
- numericSearchablePaths?: PropertyPathDto[];
37
- searchDefinition?: ReadSelectedSearchDefinitionDto;
36
+ search: {
37
+ textSearchableProperties?: (keyof TDto)[];
38
+ numericSearchableProperties?: (keyof TDto)[];
39
+ searchDefinition?: ReadSelectedSearchDefinitionDto<TDto>;
38
40
  };
39
41
  };
40
42
  /**
41
- * TS class for handling sorting, filtering and paginating collections
43
+ * TS class for handling ordering, filtering and paginating collections
42
44
  *
43
45
  * @param controllerName - specify the target endpoint controller name.
44
46
  * @param dataChangedCallback - Function invoked whenever the data changes.
45
47
  * Receives a loading state flag and the updated data collection.
46
- * @param options - Optional settings of type `CollectionViewAdapterOptions<TDto>` to customize the behavior of the adapter.
48
+ * @param options - Optional settings of type CollectionViewAdapter to customize the behavior of the adapter.
47
49
  */
48
50
  export declare class CollectionViewAdapter<TKey, TDto extends IIdentifiable<TKey>> {
49
51
  private _readClient;
@@ -52,25 +54,29 @@ export declare class CollectionViewAdapter<TKey, TDto extends IIdentifiable<TKey
52
54
  private _defaultOptions;
53
55
  private _initialOptions;
54
56
  private _currentOptions;
55
- constructor(controllerName: string, dataChangedCallback: (isLoading: boolean, data: TDto[] | undefined, error: string | undefined) => void, options?: CollectionViewAdapterOptions);
57
+ constructor(controllerName: string, dataChangedCallback: (isLoading: boolean, data: TDto[] | undefined, error: string | undefined) => void, options?: CollectionViewAdapterOptions<TDto>);
56
58
  /**
57
59
  * Allows for adding any filtering criteria. Label is required to distinguish custom search categories (e.g. searchTerm, dateRange, anyCustom ...)
58
60
  */
59
- setSearchDefinition(searchDefinition: ReadSelectedSearchDefinitionDto): Promise<TDto[]>;
61
+ setSearchDefinition(searchDefinition: ReadSelectedSearchDefinitionDto<TDto>): Promise<TDto[]>;
60
62
  /**
61
- * Public method for sorting the collection by property path / column name.
63
+ * Compares two PropertyPathDto arrays for equality
64
+ */
65
+ private _arePropertyPathsEqual;
66
+ /**
67
+ * Public method for ordering the collection by property path / column name.
62
68
  *
63
69
  * @param propertyPath - must match camel-cased property/column name being sorted
64
- * @param sortDirection - use `ReadSelectedOrderingDirection` enum choices
70
+ * @param orderDirection - use `ReadSelectedOrderingDirection` enum choices
65
71
  */
66
- setSorting(propertyPath: PropertyPathDto, sortDirection: ReadSelectedOrderingDirection): Promise<TDto[]>;
72
+ setOrdering(propertyPath: PropertyPathDto, orderDirection: ReadSelectedOrderingDirection): Promise<TDto[]>;
67
73
  /**
68
- * Returns the camel-cased property path of the current column/property on which sorting is applied, along with the `ReadSelectedOrderingDirection` direction
74
+ * Returns the property name of the current columns/properties on which ordering is applied, along with the `ReadSelectedOrderingDirection` direction
69
75
  */
70
- getCurrentSort(): {
71
- sortByPath: PropertyPathDto | undefined;
72
- sortDirection: ReadSelectedOrderingDirection | undefined;
73
- };
76
+ getCurrentOrdering(): {
77
+ orderByPath: PropertyPathDto;
78
+ orderDirection: ReadSelectedOrderingDirection;
79
+ }[];
74
80
  /**
75
81
  * Returns the current page's page number
76
82
  */
@@ -103,7 +109,7 @@ export declare class CollectionViewAdapter<TKey, TDto extends IIdentifiable<TKey
103
109
  * Callback function invoked whenever data changes.
104
110
  * Receives a loading state flag and the updated data collection.
105
111
  */
106
- private _dataChangedCallback;
112
+ private readonly _dataChangedCallback;
107
113
  /**
108
114
  * Timeout reference used to debounce calls to `_fetchCurrentPageData`.
109
115
  */
@@ -1,13 +1,12 @@
1
- import { ReadSelectedOrderingDirection } from '../../data';
2
1
  import { toPascalCase } from '../../utils';
3
2
  import { ApiReadControllerClient } from '../../services';
4
3
  /**
5
- * TS class for handling sorting, filtering and paginating collections
4
+ * TS class for handling ordering, filtering and paginating collections
6
5
  *
7
6
  * @param controllerName - specify the target endpoint controller name.
8
7
  * @param dataChangedCallback - Function invoked whenever the data changes.
9
8
  * Receives a loading state flag and the updated data collection.
10
- * @param options - Optional settings of type `CollectionViewAdapterOptions<TDto>` to customize the behavior of the adapter.
9
+ * @param options - Optional settings of type CollectionViewAdapter to customize the behavior of the adapter.
11
10
  */
12
11
  export class CollectionViewAdapter {
13
12
  _readClient;
@@ -19,13 +18,13 @@ export class CollectionViewAdapter {
19
18
  pageSize: 10,
20
19
  pageNumber: 1,
21
20
  },
22
- sorting: {
23
- sortByPath: [],
24
- sortDirection: ReadSelectedOrderingDirection.Ascending,
21
+ ordering: {
22
+ maxActiveOrderingColumns: 1,
23
+ orderByPaths: [],
25
24
  },
26
- searching: {
27
- textSearchablePaths: [],
28
- numericSearchablePaths: [],
25
+ search: {
26
+ textSearchableProperties: [],
27
+ numericSearchableProperties: [],
29
28
  },
30
29
  };
31
30
  _initialOptions;
@@ -37,54 +36,71 @@ export class CollectionViewAdapter {
37
36
  ...this._defaultOptions.pagination,
38
37
  ...options?.pagination,
39
38
  },
40
- sorting: {
41
- ...this._defaultOptions.sorting,
42
- ...options?.sorting,
39
+ ordering: {
40
+ ...this._defaultOptions.ordering,
41
+ ...options?.ordering,
43
42
  },
44
- searching: {
45
- ...this._defaultOptions.searching,
46
- ...options?.searching,
43
+ search: {
44
+ ...this._defaultOptions.search,
45
+ ...options?.search,
47
46
  },
48
47
  };
49
48
  this._currentOptions = {
50
49
  pagination: { ...this._initialOptions.pagination },
51
- sorting: { ...this._initialOptions.sorting },
52
- searching: { ...this._initialOptions.searching },
50
+ ordering: { ...this._initialOptions.ordering },
51
+ search: { ...this._initialOptions.search },
53
52
  };
54
53
  this._dataChangedCallback = dataChangedCallback;
55
54
  this._fetchCurrentPageData();
56
55
  }
57
- //#region SEARCHING ------------------------------------------
56
+ //#region SEARCH
58
57
  /**
59
58
  * Allows for adding any filtering criteria. Label is required to distinguish custom search categories (e.g. searchTerm, dateRange, anyCustom ...)
60
59
  */
61
60
  setSearchDefinition(searchDefinition) {
62
- this._currentOptions.searching.searchDefinition = searchDefinition;
61
+ this._currentOptions.search.searchDefinition = searchDefinition;
63
62
  this._currentOptions.pagination.pageNumber = 1; // Reset to first page
64
63
  return this._fetchCurrentPageData();
65
64
  }
66
- //#endregion -----------------------------------------------
67
- //#region SORTING ------------------------------------------
65
+ //#endregion
66
+ //#region ORDERING
68
67
  /**
69
- * Public method for sorting the collection by property path / column name.
68
+ * Compares two PropertyPathDto arrays for equality
69
+ */
70
+ _arePropertyPathsEqual(path1, path2) {
71
+ if (path1.length !== path2.length)
72
+ return false;
73
+ return path1.every((segment, index) => segment === path2[index]);
74
+ }
75
+ /**
76
+ * Public method for ordering the collection by property path / column name.
70
77
  *
71
78
  * @param propertyPath - must match camel-cased property/column name being sorted
72
- * @param sortDirection - use `ReadSelectedOrderingDirection` enum choices
79
+ * @param orderDirection - use `ReadSelectedOrderingDirection` enum choices
73
80
  */
74
- setSorting(propertyPath, sortDirection) {
75
- this._currentOptions.sorting.sortByPath = [propertyPath];
76
- this._currentOptions.sorting.sortDirection = sortDirection;
81
+ setOrdering(propertyPath, orderDirection) {
82
+ // Remove any existing ordering for this property path
83
+ this._currentOptions.ordering.orderByPaths = this._currentOptions.ordering.orderByPaths.filter(p => !this._arePropertyPathsEqual(p.orderByPath, propertyPath));
84
+ // Add the new ordering at the beginning
85
+ this._currentOptions.ordering.orderByPaths.unshift({
86
+ orderByPath: propertyPath,
87
+ orderDirection: orderDirection,
88
+ });
89
+ // Limit to maxActiveOrderingColumns
90
+ if (this._currentOptions.ordering.orderByPaths.length > this._currentOptions.ordering.maxActiveOrderingColumns) {
91
+ this._currentOptions.ordering.orderByPaths = this._currentOptions.ordering.orderByPaths.slice(0, this._currentOptions.ordering.maxActiveOrderingColumns);
92
+ }
77
93
  this._currentOptions.pagination.pageNumber = 1; // Reset to first page
78
94
  return this._fetchCurrentPageData();
79
95
  }
80
96
  /**
81
- * Returns the camel-cased property path of the current column/property on which sorting is applied, along with the `ReadSelectedOrderingDirection` direction
97
+ * Returns the property name of the current columns/properties on which ordering is applied, along with the `ReadSelectedOrderingDirection` direction
82
98
  */
83
- getCurrentSort() {
84
- return { sortByPath: this._currentOptions.sorting.sortByPath?.[0], sortDirection: this._currentOptions.sorting.sortDirection };
99
+ getCurrentOrdering() {
100
+ return this._currentOptions.ordering.orderByPaths;
85
101
  }
86
- //#endregion -----------------------------------------------
87
- //#region PAGINATION ---------------------------------------
102
+ //#endregion
103
+ //#region PAGINATION
88
104
  /**
89
105
  * Returns the current page's page number
90
106
  */
@@ -126,7 +142,7 @@ export class CollectionViewAdapter {
126
142
  get totalItemCount() {
127
143
  return this._totalItemCount;
128
144
  }
129
- //#endregion -----------------------------------------------
145
+ //#endregion
130
146
  /**
131
147
  * Callback function invoked whenever data changes.
132
148
  * Receives a loading state flag and the updated data collection.
@@ -198,10 +214,13 @@ export class CollectionViewAdapter {
198
214
  abortController = new AbortController();
199
215
  this._currentAbortController = abortController;
200
216
  const definition = this._parseOptionsToDefinition();
201
- const { result, metadata } = await this._readClient.readSelectedAsync(definition, abortController?.signal);
202
- this._pageData = result;
203
- if (this._currentOptions.pagination.useTotalItemCount && metadata.totalCount !== undefined) {
204
- this._totalItemCount = metadata.totalCount;
217
+ const response = await this._readClient.readSelectedAsync(definition, abortController?.signal);
218
+ if (!response.ok) {
219
+ throw response.error;
220
+ }
221
+ this._pageData = response.result;
222
+ if (this._currentOptions.pagination.useTotalItemCount && response.metadata.totalCount !== undefined) {
223
+ this._totalItemCount = response.metadata.totalCount;
205
224
  }
206
225
  else {
207
226
  const pageSize = this._currentOptions.pagination.pageSize;
@@ -245,16 +264,18 @@ export class CollectionViewAdapter {
245
264
  limit: this._currentOptions.pagination.pageSize,
246
265
  },
247
266
  };
248
- // Apply sorting
249
- const sortPaths = this._currentOptions.sorting.sortByPath;
250
- const sortDirection = this._currentOptions.sorting.sortDirection;
251
- if (sortPaths && sortPaths.length > 0) {
267
+ // Apply ordering
268
+ const orderByPaths = this._currentOptions.ordering.orderByPaths;
269
+ if (orderByPaths && orderByPaths.length > 0) {
252
270
  definition.orderingDefinition = {
253
- order: [{ propertyPath: sortPaths.map(path => toPascalCase(path)), direction: sortDirection ?? ReadSelectedOrderingDirection.Ascending }],
271
+ order: orderByPaths.map(orderPath => ({
272
+ propertyPath: orderPath.orderByPath.map(x => toPascalCase(x)),
273
+ direction: orderPath.orderDirection,
274
+ })),
254
275
  };
255
276
  }
256
277
  // Apply search
257
- definition.searchDefinition = this._currentOptions.searching.searchDefinition;
278
+ definition.searchDefinition = this._currentOptions.search.searchDefinition;
258
279
  return definition;
259
280
  }
260
281
  /**
@@ -2,7 +2,7 @@ import { ReadSelectedPaginationDefinitionDto, ReadSelectedOrderingDefinitionDto,
2
2
  /**
3
3
  * Defines the selection criteria for a controller to fetch multiple records
4
4
  */
5
- export type ReadSelectedDefinitionDto = {
5
+ export type ReadSelectedDefinitionDto<T> = {
6
6
  /**
7
7
  * Pagination definition
8
8
  */
@@ -14,5 +14,5 @@ export type ReadSelectedDefinitionDto = {
14
14
  /**
15
15
  * Search definition (supports both simple search and nested logical groups)
16
16
  */
17
- searchDefinition?: ReadSelectedSearchDefinitionDto;
17
+ searchDefinition?: ReadSelectedSearchDefinitionDto<T>;
18
18
  };
@@ -0,0 +1,22 @@
1
+ import { ReadSelectedCollectionOperator, ReadSelectedSearchDefinitionDto } from '../../..';
2
+ /**
3
+ * Defines criteria for searching within a collection navigation property using quantifiers (Any/All).
4
+ *
5
+ * This DTO allows navigation into a collection property and applying search criteria
6
+ * with a quantifier to determine if any or all elements match.
7
+ */
8
+ export type ReadSelectedNestedCollectionCriteriaDto<T, TPropertyName extends keyof T> = {
9
+ /**
10
+ * The name of the collection navigation property to navigate into.
11
+ */
12
+ propertyName: TPropertyName;
13
+ /**
14
+ * The quantifier operator determining whether any or all elements must match.
15
+ */
16
+ collectionOperator: ReadSelectedCollectionOperator;
17
+ /**
18
+ * The search criteria to apply to elements in the collection.
19
+ * Type should be ReadSelectedSearchDefinitionDto of the collection element type.
20
+ */
21
+ criteria: ReadSelectedSearchDefinitionDto<unknown>;
22
+ };
@@ -0,0 +1,18 @@
1
+ import { ReadSelectedSearchDefinitionDto } from '../../..';
2
+ /**
3
+ * Defines criteria for searching within a nested object property.
4
+ *
5
+ * This DTO allows navigation into a nested object property and applying search criteria
6
+ * to that nested object. The property name must refer to a navigation property (not a collection).
7
+ */
8
+ export type ReadSelectedNestedCriteriaDto<T, TPropertyName extends keyof T> = {
9
+ /**
10
+ * The name of the navigation property to navigate into.
11
+ */
12
+ propertyName: TPropertyName;
13
+ /**
14
+ * The search criteria to apply to the nested object.
15
+ * Type should be ReadSelectedSearchDefinitionDto of the nested object type.
16
+ */
17
+ criteria: ReadSelectedSearchDefinitionDto<unknown>;
18
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -6,9 +6,9 @@ export type ReadSelectedOrderingPropertyDefinitionDto = {
6
6
  /**
7
7
  * Gets or sets the property path.
8
8
  */
9
- propertyPath: PropertyPathDto[];
9
+ propertyPath: PropertyPathDto;
10
10
  /**
11
- * Gets or sets the sort direction.
11
+ * Gets or sets the ordering direction.
12
12
  */
13
13
  direction: ReadSelectedOrderingDirection;
14
14
  };
@@ -1,18 +1,33 @@
1
- import { ReadSelectedLogicalOperator, ReadSelectedSearchPropertyDefinitionDto } from '../../..';
1
+ import { ReadSelectedLogicalOperator, ReadSelectedNestedCollectionCriteriaDto, ReadSelectedNestedCriteriaDto, ReadSelectedSearchPropertyDefinitionDto } from '../../..';
2
2
  /**
3
- * Defines the filtering options for a controller, including the logical operator and an array of property definitions.
3
+ * Defines the search criteria for a controller using a recursive structure.
4
+ *
5
+ * This DTO supports complex search queries with:
6
+ * - Logical operators (AND/OR) to combine multiple criteria
7
+ * - Direct property value comparisons via `propertyCriteria`
8
+ * - Nested searches via `searches` for recursive query composition
9
+ * - Navigation into nested objects via `nestedCriteria`
10
+ * - Collection quantifier queries (Any/All) via `nestedCollectionCriteria`
4
11
  */
5
- export type ReadSelectedSearchDefinitionDto = {
12
+ export type ReadSelectedSearchDefinitionDto<T> = {
6
13
  /**
7
- * Logical operator to be used when applying the filters.
14
+ * The logical operator to combine all criteria at this level.
8
15
  */
9
16
  logicalOperator: ReadSelectedLogicalOperator;
10
17
  /**
11
- * Property-based search criteria.
18
+ * Recursive nested search definitions combined with the logical operator.
12
19
  */
13
- propertyCriteria?: ReadSelectedSearchPropertyDefinitionDto[];
20
+ searches?: ReadSelectedSearchDefinitionDto<T>[];
14
21
  /**
15
- * Nested search definitions for complex queries.
22
+ * Direct property value comparison criteria.
16
23
  */
17
- nestedSearchCriteria?: ReadSelectedSearchDefinitionDto[];
24
+ propertyCriteria?: ReadSelectedSearchPropertyDefinitionDto<T, keyof T>[];
25
+ /**
26
+ * Criteria for searching within nested object properties.
27
+ */
28
+ nestedCriteria?: ReadSelectedNestedCriteriaDto<T, keyof T>[];
29
+ /**
30
+ * Criteria for searching within collection properties using Any/All quantifiers.
31
+ */
32
+ nestedCollectionCriteria?: ReadSelectedNestedCollectionCriteriaDto<T, keyof T>[];
18
33
  };
@@ -1,16 +1,23 @@
1
- import { PropertyPathDto, ReadSelectedComparisonOperator, ReadSelectedPropertyType } from '../../..';
1
+ import { ReadSelectedComparisonOperator, ReadSelectedPropertyType } from '../../..';
2
2
  /**
3
- * Defines a property used for searching in a controller.
3
+ * Defines a direct property value comparison criteria for searching.
4
+ *
5
+ * This DTO represents a leaf-level search criterion that compares a single property
6
+ * against a value using a comparison operator. For nested property searches, use
7
+ * `ReadSelectedNestedCriteriaDto` or `ReadSelectedNestedCollectionCriteriaDto`.
4
8
  */
5
- export type ReadSelectedSearchPropertyDefinitionDto = Partial_ReadSelectedSearchPropertyDefinition_IndependentProperties & Partial_ReadSelectedSearchPropertyDefinition_TypedValueProperty & Partial_ReadSelectedSearchPropertyDefinition_TypedComparisonOperators;
9
+ export type ReadSelectedSearchPropertyDefinitionDto<T, TPropertyName extends keyof T> = Partial_ReadSelectedSearchPropertyDefinition_IndependentProperties<T, TPropertyName> & Partial_ReadSelectedSearchPropertyDefinition_TypedValueProperty & Partial_ReadSelectedSearchPropertyDefinition_TypedComparisonOperators;
6
10
  /**
7
11
  * Defines independent properties
8
12
  */
9
- type Partial_ReadSelectedSearchPropertyDefinition_IndependentProperties = {
13
+ type Partial_ReadSelectedSearchPropertyDefinition_IndependentProperties<T, TPropertyName extends keyof T> = {
10
14
  /**
11
- * The path to the property being searched.
15
+ * The name of the property to compare.
16
+ *
17
+ * This must be a direct property on the target type, not a nested property path.
18
+ * Use nested criteria DTOs for navigation.
12
19
  */
13
- propertyPath: PropertyPathDto;
20
+ propertyName: TPropertyName;
14
21
  /**
15
22
  * The comparison operator to use for the search.
16
23
  */
@@ -20,7 +27,7 @@ type Partial_ReadSelectedSearchPropertyDefinition_IndependentProperties = {
20
27
  */
21
28
  valueType: ReadSelectedPropertyType;
22
29
  /**
23
- * The value to use for the search.
30
+ * The value to compare against.
24
31
  */
25
32
  value: unknown;
26
33
  };
@@ -1,5 +1,7 @@
1
1
  export * from './ReadMetadataDto';
2
2
  export * from './ReadSelectedSearchPropertyDefinitionDto';
3
+ export * from './ReadSelectedNestedCriteriaDto';
4
+ export * from './ReadSelectedNestedCollectionCriteriaDto';
3
5
  export * from './ReadSelectedOrderingDefinitionDto';
4
6
  export * from './ReadSelectedOrderingPropertyDefinitionDto';
5
7
  export * from './ReadSelectedPaginationDefinitionDto';
@@ -1,5 +1,7 @@
1
1
  export * from './ReadMetadataDto';
2
2
  export * from './ReadSelectedSearchPropertyDefinitionDto';
3
+ export * from './ReadSelectedNestedCriteriaDto';
4
+ export * from './ReadSelectedNestedCollectionCriteriaDto';
3
5
  export * from './ReadSelectedOrderingDefinitionDto';
4
6
  export * from './ReadSelectedOrderingPropertyDefinitionDto';
5
7
  export * from './ReadSelectedPaginationDefinitionDto';
@@ -1,8 +1,17 @@
1
- import { ApiErrorCodes } from '../../..';
1
+ import { EmptyMetadataDto, ErrorCode, ValidationFailedMetadataDto } from '../../..';
2
2
  /**
3
3
  * Default, empty metadata.
4
4
  */
5
- export type ApiErrorDto = {
6
- code: ApiErrorCodes;
5
+ export type ApiErrorDto<TMetadata extends ApiErrorMetadataDto = ApiErrorMetadataDto> = {
7
6
  message: string;
7
+ details?: string;
8
+ traceId?: string;
9
+ timestamp?: string;
10
+ } & TMetadata;
11
+ export type ApiErrorMetadataDto = {
12
+ code: ErrorCode.ValidationFailed;
13
+ metadata: ValidationFailedMetadataDto;
14
+ } | {
15
+ code: Omit<number, ErrorCode.ValidationFailed>;
16
+ metadata: EmptyMetadataDto;
8
17
  };
@@ -0,0 +1,11 @@
1
+ import { ApiErrorDto, ApiErrorMetadataDto } from '../../..';
2
+ /**
3
+ * Represents an API response containing an error and empty metadata.
4
+ */
5
+ export type ApiErrorResponseDto<TErrorMetadata extends ApiErrorMetadataDto = ApiErrorMetadataDto> = {
6
+ ok: false;
7
+ /**
8
+ * The error object containing information about the error
9
+ */
10
+ error: ApiErrorDto<TErrorMetadata>;
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,15 +1,3 @@
1
- import { ApiErrorDto } from '../../..';
2
- /**
3
- * Represents an API response containing a result and metadata, or an error.
4
- *
5
- * @template T The type of result
6
- * @template TMetadata The type of metadata
7
- * @property {T} result - The result returned
8
- * @property {TMetadata} metadata - Metadata about the result
9
- */
10
- export type ApiResponseDto<T, TMetadata> = {
11
- success: boolean;
12
- result: T;
13
- metadata: TMetadata;
14
- error: ApiErrorDto;
15
- };
1
+ import { ApiErrorMetadataDto, ApiErrorResponseDto, ApiSuccessResponseDto } from '../../../../data';
2
+ import { Result } from '../../../../utils/result';
3
+ export type ApiResponseDto<T, TMetadata extends object, TErrorMetadata extends ApiErrorMetadataDto = ApiErrorMetadataDto> = Result<ApiSuccessResponseDto<T, TMetadata>, ApiErrorResponseDto<TErrorMetadata>>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Represents an successful API response containing a result and metadata.
2
+ * Represents a successful API response containing a result and metadata.
3
3
  *
4
4
  * @template T The type of result
5
5
  * @template TMetadata The type of metadata
@@ -7,6 +7,7 @@
7
7
  * @property {TMetadata} metadata - Metadata about the result
8
8
  */
9
9
  export type ApiSuccessResponseDto<T, TMetadata> = {
10
+ ok: true;
10
11
  result: T;
11
12
  metadata: TMetadata;
12
13
  };
@@ -0,0 +1,25 @@
1
+ declare const __brand: unique symbol;
2
+ /**
3
+ * Utility type for creating branded types that are nominally different but structurally identical.
4
+ * This enables compile-time type safety for values that would otherwise have the same runtime structure.
5
+ *
6
+ * @template T - The brand identifier string literal type
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * type UserId = Brand<'userId'>;
11
+ * type OrderId = Brand<'orderId'>;
12
+ *
13
+ * const userId: UserId = { [__brand]: 'userId' } as UserId;
14
+ * const orderId: OrderId = userId; // Type error! Different brands
15
+ * ```
16
+ */
17
+ export type Brand<T extends string> = {
18
+ [__brand]: T;
19
+ };
20
+ /**
21
+ * Default, empty metadata.
22
+ */
23
+ export type EmptyMetadataDto = Brand<'emptyMetadata'>;
24
+ export type ValidationFailedMetadataDto = Brand<'validationFailedMetadata'>;
25
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  export * from './ApiResponseDto';
2
2
  export * from './ApiSuccessResponseDto';
3
3
  export * from './ApiErrorDto';
4
- export * from './EmptyMetadataDto';
4
+ export * from './MetadataDto';
5
+ export * from './ApiErrorResponseDto';
@@ -1,4 +1,5 @@
1
1
  export * from './ApiResponseDto';
2
2
  export * from './ApiSuccessResponseDto';
3
3
  export * from './ApiErrorDto';
4
- export * from './EmptyMetadataDto';
4
+ export * from './MetadataDto';
5
+ export * from './ApiErrorResponseDto';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Represents the collection quantifier operators that can be used when searching collection properties.
3
+ *
4
+ * The `Any` operator matches if at least one element in the collection satisfies the criteria.
5
+ * The `All` operator matches if all elements in the collection satisfy the criteria.
6
+ */
7
+ export declare enum ReadSelectedCollectionOperator {
8
+ /**
9
+ * Matches if at least one element in the collection satisfies the criteria.
10
+ */
11
+ Any = 0,
12
+ /**
13
+ * Matches if all elements in the collection satisfy the criteria.
14
+ */
15
+ All = 1
16
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Represents the collection quantifier operators that can be used when searching collection properties.
3
+ *
4
+ * The `Any` operator matches if at least one element in the collection satisfies the criteria.
5
+ * The `All` operator matches if all elements in the collection satisfy the criteria.
6
+ */
7
+ export var ReadSelectedCollectionOperator;
8
+ (function (ReadSelectedCollectionOperator) {
9
+ /**
10
+ * Matches if at least one element in the collection satisfies the criteria.
11
+ */
12
+ ReadSelectedCollectionOperator[ReadSelectedCollectionOperator["Any"] = 0] = "Any";
13
+ /**
14
+ * Matches if all elements in the collection satisfy the criteria.
15
+ */
16
+ ReadSelectedCollectionOperator[ReadSelectedCollectionOperator["All"] = 1] = "All";
17
+ })(ReadSelectedCollectionOperator || (ReadSelectedCollectionOperator = {}));
@@ -1,3 +1,4 @@
1
+ export * from './ReadSelectedCollectionOperator';
1
2
  export * from './ReadSelectedComparisonOperator';
2
3
  export * from './ReadSelectedLogicalOperator';
3
4
  export * from './ReadSelectedOrderingDirection';