@intellegens/cornerstone-client 0.0.44 → 0.0.9999-alpha-1

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 (132) hide show
  1. package/LICENSE.md +0 -0
  2. package/README.md +133 -12
  3. package/adapters/CollectionViewAdapter/index.d.ts +154 -0
  4. package/adapters/CollectionViewAdapter/index.js +281 -0
  5. package/adapters/index.d.ts +1 -0
  6. package/adapters/index.js +1 -0
  7. package/data/api/dto/PropertyPathDto.d.ts +4 -0
  8. package/data/api/dto/{crud/CrudMetadata.js → PropertyPathDto.js} +0 -0
  9. package/data/api/dto/ReadOptionsDto.d.ts +8 -0
  10. package/data/api/dto/{read/ReadMetadata.js → ReadOptionsDto.js} +0 -0
  11. package/data/api/dto/ReadResultDto.d.ts +12 -0
  12. package/data/api/dto/{response/ApiError.js → ReadResultDto.js} +0 -0
  13. package/data/api/dto/ReadResultMetadataDto.d.ts +8 -0
  14. package/data/api/dto/{response/ApiResponse.js → ReadResultMetadataDto.js} +0 -0
  15. package/data/api/dto/crud/{CrudMetadata.d.ts → CrudMetadataDto.d.ts} +1 -1
  16. package/data/api/dto/{response/ApiSuccessResponse.js → crud/CrudMetadataDto.js} +0 -0
  17. package/data/api/dto/crud/index.d.ts +1 -1
  18. package/data/api/dto/crud/index.js +1 -1
  19. package/data/api/dto/index.d.ts +1 -0
  20. package/data/api/dto/index.js +1 -0
  21. package/data/api/dto/read/{ReadMetadata.d.ts → ReadMetadataDto.d.ts} +1 -1
  22. package/data/api/dto/{response/EmptyMetadata.js → read/ReadMetadataDto.js} +0 -0
  23. package/data/api/dto/read/ReadSelectedDefinitionDto.d.ts +0 -0
  24. package/data/api/dto/read/ReadSelectedDefinitionDto.js +0 -0
  25. package/data/api/dto/read/ReadSelectedOrderingDefinitionDto.d.ts +0 -0
  26. package/data/api/dto/read/ReadSelectedOrderingDefinitionDto.js +0 -0
  27. package/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.d.ts +2 -2
  28. package/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.js +0 -0
  29. package/data/api/dto/read/ReadSelectedPaginationDefinitionDto.d.ts +0 -0
  30. package/data/api/dto/read/ReadSelectedPaginationDefinitionDto.js +0 -0
  31. package/data/api/dto/read/ReadSelectedSearchDefinitionDto.d.ts +0 -0
  32. package/data/api/dto/read/ReadSelectedSearchDefinitionDto.js +0 -0
  33. package/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.d.ts +2 -2
  34. package/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.js +0 -0
  35. package/data/api/dto/read/index.d.ts +1 -1
  36. package/data/api/dto/read/index.js +1 -1
  37. package/data/api/dto/response/{ApiError.d.ts → ApiErrorDto.d.ts} +1 -1
  38. package/data/api/dto/response/ApiErrorDto.js +1 -0
  39. package/data/api/dto/response/{ApiResponse.d.ts → ApiResponseDto.d.ts} +3 -3
  40. package/data/api/dto/response/ApiResponseDto.js +1 -0
  41. package/data/api/dto/response/{ApiSuccessResponse.d.ts → ApiSuccessResponseDto.d.ts} +1 -1
  42. package/data/api/dto/response/ApiSuccessResponseDto.js +1 -0
  43. package/data/api/dto/response/EmptyMetadataDto.d.ts +4 -0
  44. package/data/api/dto/response/EmptyMetadataDto.js +1 -0
  45. package/data/api/dto/response/index.d.ts +4 -4
  46. package/data/api/dto/response/index.js +4 -4
  47. package/data/api/enum/index.d.ts +0 -0
  48. package/data/api/enum/index.js +0 -0
  49. package/data/api/enum/read/ReadSelectedComparisonOperator.d.ts +0 -0
  50. package/data/api/enum/read/ReadSelectedComparisonOperator.js +0 -0
  51. package/data/api/enum/read/ReadSelectedLogicalOperator.d.ts +0 -0
  52. package/data/api/enum/read/ReadSelectedLogicalOperator.js +0 -0
  53. package/data/api/enum/read/ReadSelectedOrderingDirection.d.ts +0 -0
  54. package/data/api/enum/read/ReadSelectedOrderingDirection.js +0 -0
  55. package/data/api/enum/read/ReadSelectedPropertyType.d.ts +0 -0
  56. package/data/api/enum/read/ReadSelectedPropertyType.js +0 -0
  57. package/data/api/enum/read/index.d.ts +0 -0
  58. package/data/api/enum/read/index.js +0 -0
  59. package/data/api/enum/response/ApiErrorCodes.d.ts +0 -0
  60. package/data/api/enum/response/ApiErrorCodes.js +0 -0
  61. package/data/api/enum/response/index.d.ts +0 -0
  62. package/data/api/enum/response/index.js +0 -0
  63. package/data/api/index.d.ts +0 -0
  64. package/data/api/index.js +0 -0
  65. package/data/api/interface/IConcurrencySafe.d.ts +9 -0
  66. package/data/api/interface/IConcurrencySafe.js +2 -0
  67. package/data/api/interface/IIdentifiable.d.ts +4 -3
  68. package/data/api/interface/IIdentifiable.js +0 -0
  69. package/data/api/interface/IIdentifiableSecondary.d.ts +3 -3
  70. package/data/api/interface/IIdentifiableSecondary.js +0 -0
  71. package/data/api/interface/index.d.ts +1 -0
  72. package/data/api/interface/index.js +1 -0
  73. package/data/auth/dto/ClaimDto.d.ts +0 -0
  74. package/data/auth/dto/ClaimDto.js +0 -0
  75. package/data/auth/dto/RegisterRequestDto.d.ts +0 -0
  76. package/data/auth/dto/RegisterRequestDto.js +0 -0
  77. package/data/auth/dto/RoleDto.d.ts +0 -0
  78. package/data/auth/dto/RoleDto.js +0 -0
  79. package/data/auth/dto/SignInRequestDto.d.ts +0 -0
  80. package/data/auth/dto/SignInRequestDto.js +0 -0
  81. package/data/auth/dto/TokensDto.d.ts +0 -0
  82. package/data/auth/dto/TokensDto.js +0 -0
  83. package/data/auth/dto/UserDto.d.ts +0 -0
  84. package/data/auth/dto/UserDto.js +0 -0
  85. package/data/auth/dto/UserInfoDto.d.ts +0 -0
  86. package/data/auth/dto/UserInfoDto.js +0 -0
  87. package/data/auth/dto/index.d.ts +0 -0
  88. package/data/auth/dto/index.js +0 -0
  89. package/data/auth/index.d.ts +0 -0
  90. package/data/auth/index.js +0 -0
  91. package/data/index.d.ts +0 -0
  92. package/data/index.js +0 -0
  93. package/index.d.ts +3 -0
  94. package/index.js +3 -0
  95. package/package.json +15 -10
  96. package/services/api/ApiCrudControllerClient/index.d.ts +9 -5
  97. package/services/api/ApiCrudControllerClient/index.js +15 -9
  98. package/services/api/ApiInitializationService/index.d.ts +21 -3
  99. package/services/api/ApiInitializationService/index.js +36 -7
  100. package/services/api/ApiReadControllerClient/index.d.ts +12 -13
  101. package/services/api/ApiReadControllerClient/index.js +17 -18
  102. package/services/api/HttpService/FetchHttpService.d.ts +1 -1
  103. package/services/api/HttpService/FetchHttpService.js +2 -1
  104. package/services/api/HttpService/HttpRequestConfig.d.ts +1 -0
  105. package/services/api/HttpService/HttpRequestConfig.js +0 -0
  106. package/services/api/HttpService/HttpResponse.d.ts +0 -0
  107. package/services/api/HttpService/HttpResponse.js +0 -0
  108. package/services/api/HttpService/IHttpService.d.ts +1 -1
  109. package/services/api/HttpService/IHttpService.js +0 -0
  110. package/services/api/HttpService/index.d.ts +0 -2
  111. package/services/api/HttpService/index.js +0 -2
  112. package/services/api/UserManagementControllerClient/index.d.ts +9 -5
  113. package/services/api/UserManagementControllerClient/index.js +20 -12
  114. package/services/api/index.d.ts +0 -0
  115. package/services/api/index.js +0 -0
  116. package/services/auth/client/AuthService/index.d.ts +5 -5
  117. package/services/auth/client/AuthService/index.js +9 -9
  118. package/services/auth/client/AuthorizationManagementControllerClient/index.d.ts +5 -5
  119. package/services/auth/client/AuthorizationManagementControllerClient/index.js +8 -8
  120. package/services/auth/client/index.d.ts +0 -0
  121. package/services/auth/client/index.js +0 -0
  122. package/services/auth/index.d.ts +0 -0
  123. package/services/auth/index.js +0 -0
  124. package/services/index.d.ts +0 -0
  125. package/services/index.js +0 -0
  126. package/utils/index.d.ts +37 -0
  127. package/utils/index.js +106 -0
  128. package/data/api/dto/response/EmptyMetadata.d.ts +0 -4
  129. package/services/api/HttpService/AngularHttpService.d.ts +0 -9
  130. package/services/api/HttpService/AngularHttpService.js +0 -86
  131. package/services/api/HttpService/AxiosHttpService.d.ts +0 -10
  132. package/services/api/HttpService/AxiosHttpService.js +0 -53
@@ -0,0 +1,37 @@
1
+ import { PropertyPathDto, ReadSelectedComparisonOperator, ReadSelectedLogicalOperator, ReadSelectedPropertyType, ReadSelectedSearchDefinitionDto } from '../data';
2
+ /**
3
+ * Creates a ReadSelectedSearchDefinitionDto ready to be used with the CollectionViewAdapter
4
+ *
5
+ * @param logicalOperator - specify `ReadSelectedLogicalOperator` that will apply to all `ReadSelectedSearchPropertyDefinitionDto` property definitions included in this search definition
6
+ * @param conditions - Variable number of condition objects containing:
7
+ * - path: The property name from the DTO to search on
8
+ * - operator: The `ReadSelectedComparisonOperator` enum
9
+ * - value: The value to compare against
10
+ * - valueType: The `ReadSelectedPropertyType` being compared
11
+ */
12
+ export declare function condition(logicalOperator: ReadSelectedLogicalOperator, ...conditions: Array<{
13
+ path: PropertyPathDto;
14
+ operator: ReadSelectedComparisonOperator;
15
+ value: any;
16
+ valueType: ReadSelectedPropertyType;
17
+ }>): ReadSelectedSearchDefinitionDto;
18
+ /**
19
+ * Combines multiple ReadSelectedSearchDefinitionDto with AND logic
20
+ */
21
+ export declare function and(...definitions: ReadSelectedSearchDefinitionDto[]): ReadSelectedSearchDefinitionDto;
22
+ /**
23
+ * Combines multiple ReadSelectedSearchDefinitionDto with OR logic
24
+ */
25
+ export declare function or(...definitions: ReadSelectedSearchDefinitionDto[]): ReadSelectedSearchDefinitionDto;
26
+ /**
27
+ * Preset implementation for filtering by `searchTerm`. String types will search by provided `textSearchablePaths` with `ReadSelectedComparisonOperator.Contains`. Numeric types will search by provided `numericSearchablePaths`, `parseInt` the search term and use `ReadSelectedComparisonOperator.Equal`.
28
+ */
29
+ export declare function searchTerm(searchTerm: string, textSearchablePaths: string[][], numericSearchablePaths: string[][]): void | ReadSelectedSearchDefinitionDto;
30
+ /**
31
+ * Preset implementation for filtering a date range. User may select desired `ReadSelectedComparisonOperator` and `ReadSelectedPropertyType` for the from and to dates. Valid object property must be provided for `searchablePath`.
32
+ */
33
+ export declare function dateInterval(fromDate: Date, toDate: Date, fromDateComparisonOperator: ReadSelectedComparisonOperator, toDateComparisonOperator: ReadSelectedComparisonOperator, valueType: ReadSelectedPropertyType, searchablePath: PropertyPathDto): void | ReadSelectedSearchDefinitionDto;
34
+ /**
35
+ * Converts the camel case used on the TS client to Pascal case expected by the API
36
+ */
37
+ export declare function toPascalCase(str: PropertyPathDto): PropertyPathDto;
package/utils/index.js ADDED
@@ -0,0 +1,106 @@
1
+ import { ReadSelectedComparisonOperator, ReadSelectedLogicalOperator, ReadSelectedPropertyType, } from '../data';
2
+ /**
3
+ * Creates a ReadSelectedSearchDefinitionDto ready to be used with the CollectionViewAdapter
4
+ *
5
+ * @param logicalOperator - specify `ReadSelectedLogicalOperator` that will apply to all `ReadSelectedSearchPropertyDefinitionDto` property definitions included in this search definition
6
+ * @param conditions - Variable number of condition objects containing:
7
+ * - path: The property name from the DTO to search on
8
+ * - operator: The `ReadSelectedComparisonOperator` enum
9
+ * - value: The value to compare against
10
+ * - valueType: The `ReadSelectedPropertyType` being compared
11
+ */
12
+ export function condition(logicalOperator, ...conditions) {
13
+ return {
14
+ logicalOperator: logicalOperator,
15
+ propertyCriteria: conditions.map(condition => ({
16
+ propertyPath: toPascalCase(condition.path),
17
+ comparisonOperator: condition.operator,
18
+ valueType: condition.valueType,
19
+ value: condition.value,
20
+ })),
21
+ };
22
+ }
23
+ /**
24
+ * Combines multiple ReadSelectedSearchDefinitionDto with AND logic
25
+ */
26
+ export function and(...definitions) {
27
+ return {
28
+ logicalOperator: ReadSelectedLogicalOperator.And,
29
+ nestedSearchCriteria: definitions,
30
+ };
31
+ }
32
+ /**
33
+ * Combines multiple ReadSelectedSearchDefinitionDto with OR logic
34
+ */
35
+ export function or(...definitions) {
36
+ return {
37
+ logicalOperator: ReadSelectedLogicalOperator.Or,
38
+ nestedSearchCriteria: definitions,
39
+ };
40
+ }
41
+ /**
42
+ * Preset implementation for filtering by `searchTerm`. String types will search by provided `textSearchablePaths` with `ReadSelectedComparisonOperator.Contains`. Numeric types will search by provided `numericSearchablePaths`, `parseInt` the search term and use `ReadSelectedComparisonOperator.Equal`.
43
+ */
44
+ export function searchTerm(searchTerm, textSearchablePaths, numericSearchablePaths) {
45
+ let comparisonOperator;
46
+ let valueType;
47
+ let searchablePaths;
48
+ let searchValue;
49
+ try {
50
+ const numericValue = parseInt(searchTerm);
51
+ if (!Number.isNaN(numericValue) && String(numericValue) === searchTerm.trim()) {
52
+ comparisonOperator = ReadSelectedComparisonOperator.Equal;
53
+ valueType = ReadSelectedPropertyType.Int;
54
+ searchablePaths = numericSearchablePaths;
55
+ searchValue = numericValue;
56
+ }
57
+ else {
58
+ comparisonOperator = ReadSelectedComparisonOperator.Contains;
59
+ valueType = ReadSelectedPropertyType.String;
60
+ searchablePaths = textSearchablePaths;
61
+ searchValue = searchTerm;
62
+ }
63
+ const searchConditions = searchablePaths.map(path => ({
64
+ path: toPascalCase(path),
65
+ operator: comparisonOperator,
66
+ value: searchValue,
67
+ valueType: valueType,
68
+ }));
69
+ return condition(ReadSelectedLogicalOperator.Or, ...searchConditions);
70
+ }
71
+ catch {
72
+ return;
73
+ }
74
+ }
75
+ /**
76
+ * Preset implementation for filtering a date range. User may select desired `ReadSelectedComparisonOperator` and `ReadSelectedPropertyType` for the from and to dates. Valid object property must be provided for `searchablePath`.
77
+ */
78
+ export function dateInterval(fromDate, toDate, fromDateComparisonOperator, toDateComparisonOperator, valueType, searchablePath) {
79
+ try {
80
+ if (!(valueType === ReadSelectedPropertyType.DateOnly ||
81
+ valueType === ReadSelectedPropertyType.DateTime ||
82
+ valueType === ReadSelectedPropertyType.DateTimeOffset)) {
83
+ return;
84
+ }
85
+ return condition(ReadSelectedLogicalOperator.And, {
86
+ path: toPascalCase(searchablePath),
87
+ operator: fromDateComparisonOperator,
88
+ value: fromDate,
89
+ valueType: valueType,
90
+ }, {
91
+ path: toPascalCase(searchablePath),
92
+ operator: toDateComparisonOperator,
93
+ value: toDate,
94
+ valueType: valueType,
95
+ });
96
+ }
97
+ catch {
98
+ return;
99
+ }
100
+ }
101
+ /**
102
+ * Converts the camel case used on the TS client to Pascal case expected by the API
103
+ */
104
+ export function toPascalCase(str) {
105
+ return str.map(part => part.charAt(0).toUpperCase() + part.slice(1));
106
+ }
@@ -1,4 +0,0 @@
1
- /**
2
- * Default, empty metadata.
3
- */
4
- export type EmptyMetadata = object;
@@ -1,9 +0,0 @@
1
- import { IHttpService, HttpRequestConfig, HttpResponse } from './index';
2
- /**
3
- * Angular HttpClient-based HTTP service implementation
4
- */
5
- export declare class AngularHttpService implements IHttpService {
6
- private httpClient;
7
- constructor(httpClient: any);
8
- request<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
9
- }
@@ -1,86 +0,0 @@
1
- // Ignore eslint any error in this file
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- /**
4
- * Angular HttpClient-based HTTP service implementation
5
- */
6
- export class AngularHttpService {
7
- httpClient;
8
- constructor(httpClient) {
9
- if (!httpClient) {
10
- throw new Error('Angular HttpClient instance is required');
11
- }
12
- this.httpClient = httpClient;
13
- }
14
- async request(url, config) {
15
- try {
16
- const method = config?.method || 'GET';
17
- const headers = config?.headers || {};
18
- const body = config?.body;
19
- const withCredentials = config?.credentials === 'include';
20
- const options = {
21
- headers,
22
- withCredentials,
23
- observe: 'response',
24
- responseType: 'json',
25
- };
26
- let response;
27
- switch (method.toUpperCase()) {
28
- case 'GET':
29
- response = await this.httpClient.get(url, options).toPromise();
30
- break;
31
- case 'POST':
32
- response = await this.httpClient.post(url, body ? JSON.parse(body) : null, options).toPromise();
33
- break;
34
- case 'PUT':
35
- response = await this.httpClient.put(url, body ? JSON.parse(body) : null, options).toPromise();
36
- break;
37
- case 'DELETE':
38
- response = await this.httpClient.delete(url, options).toPromise();
39
- break;
40
- case 'PATCH':
41
- response = await this.httpClient.patch(url, body ? JSON.parse(body) : null, options).toPromise();
42
- break;
43
- default:
44
- throw new Error(`Unsupported HTTP method: ${method}`);
45
- }
46
- // Convert Angular HttpResponse headers to plain object
47
- const responseHeaders = {};
48
- if (response.headers) {
49
- response.headers.keys().forEach((key) => {
50
- responseHeaders[key] = response.headers.get(key);
51
- });
52
- }
53
- return {
54
- ok: response.status >= 200 && response.status < 300,
55
- status: response.status,
56
- statusText: response.statusText || 'OK',
57
- headers: responseHeaders,
58
- json: async () => response.body,
59
- text: async () => (typeof response.body === 'string' ? response.body : JSON.stringify(response.body)),
60
- };
61
- }
62
- catch (error) {
63
- if (error.status !== undefined) {
64
- // Angular HttpErrorResponse
65
- const errorHeaders = {};
66
- if (error.headers) {
67
- error.headers.keys().forEach((key) => {
68
- errorHeaders[key] = error.headers.get(key);
69
- });
70
- }
71
- return {
72
- ok: false,
73
- status: error.status,
74
- statusText: error.statusText || 'Error',
75
- headers: errorHeaders,
76
- json: async () => error.error,
77
- text: async () => (typeof error.error === 'string' ? error.error : JSON.stringify(error.error)),
78
- };
79
- }
80
- else {
81
- // Other errors
82
- throw error;
83
- }
84
- }
85
- }
86
- }
@@ -1,10 +0,0 @@
1
- import { IHttpService, HttpRequestConfig, HttpResponse } from './index';
2
- /**
3
- * Axios-based HTTP service implementation
4
- * Note: This requires axios to be installed as a dependency
5
- */
6
- export declare class AxiosHttpService implements IHttpService {
7
- private readonly axios;
8
- constructor(axiosInstance?: any);
9
- request<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
10
- }
@@ -1,53 +0,0 @@
1
- // Ignore eslint any error in this file
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- /**
4
- * Axios-based HTTP service implementation
5
- * Note: This requires axios to be installed as a dependency
6
- */
7
- export class AxiosHttpService {
8
- axios;
9
- constructor(axiosInstance) {
10
- if (!axiosInstance) {
11
- throw new Error('Axios instance is required');
12
- }
13
- this.axios = axiosInstance;
14
- }
15
- async request(url, config) {
16
- try {
17
- const axiosConfig = {
18
- url,
19
- method: config?.method || 'GET',
20
- headers: config?.headers,
21
- data: config?.body,
22
- withCredentials: config?.credentials === 'include',
23
- };
24
- const response = await this.axios(axiosConfig);
25
- return {
26
- ok: response.status >= 200 && response.status < 300,
27
- status: response.status,
28
- statusText: response.statusText,
29
- headers: response.headers,
30
- json: async () => response.data,
31
- text: async () => (typeof response.data === 'string' ? response.data : JSON.stringify(response.data)),
32
- };
33
- }
34
- catch (error) {
35
- if (error.response) {
36
- // The request was made and the server responded with a status code
37
- // that falls out of the range of 2xx
38
- return {
39
- ok: false,
40
- status: error.response.status,
41
- statusText: error.response.statusText,
42
- headers: error.response.headers,
43
- json: async () => error.response.data,
44
- text: async () => (typeof error.response.data === 'string' ? error.response.data : JSON.stringify(error.response.data)),
45
- };
46
- }
47
- else {
48
- // Something happened in setting up the request that triggered an Error
49
- throw error;
50
- }
51
- }
52
- }
53
- }