@twin.org/api-models 0.0.1-next.5 → 0.0.1-next.7
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.
package/dist/cjs/index.cjs
CHANGED
|
@@ -121,6 +121,39 @@ class HttpParameterHelper {
|
|
|
121
121
|
return conditionsList.join(",");
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Convert the sort string to a list of sort properties.
|
|
126
|
+
* @param sortProperties The sort properties query string.
|
|
127
|
+
* @returns The list of sort properties.
|
|
128
|
+
*/
|
|
129
|
+
static sortPropertiesFromString(sortProperties) {
|
|
130
|
+
const sortParts = sortProperties?.split(",") ?? [];
|
|
131
|
+
const sortPropertyList = [];
|
|
132
|
+
for (const conditionPart of sortParts) {
|
|
133
|
+
const parts = conditionPart.split("|");
|
|
134
|
+
if (parts.length === 2) {
|
|
135
|
+
sortPropertyList.push({
|
|
136
|
+
property: parts[0],
|
|
137
|
+
sortDirection: parts[1]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return sortPropertyList.length === 0 ? undefined : sortPropertyList;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Convert the sort properties to a string parameter.
|
|
145
|
+
* @param sortProperties The sort properties to convert.
|
|
146
|
+
* @returns The string version of the sort properties.
|
|
147
|
+
*/
|
|
148
|
+
static sortPropertiesToString(sortProperties) {
|
|
149
|
+
if (core.Is.arrayValue(sortProperties)) {
|
|
150
|
+
const sortPropertyList = [];
|
|
151
|
+
for (const conditionPart of sortProperties) {
|
|
152
|
+
sortPropertyList.push(`${conditionPart.property}|${conditionPart.sortDirection}`);
|
|
153
|
+
}
|
|
154
|
+
return sortPropertyList.join(",");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
124
157
|
}
|
|
125
158
|
|
|
126
159
|
// Copyright 2024 IOTA Stiftung.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -119,6 +119,39 @@ class HttpParameterHelper {
|
|
|
119
119
|
return conditionsList.join(",");
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Convert the sort string to a list of sort properties.
|
|
124
|
+
* @param sortProperties The sort properties query string.
|
|
125
|
+
* @returns The list of sort properties.
|
|
126
|
+
*/
|
|
127
|
+
static sortPropertiesFromString(sortProperties) {
|
|
128
|
+
const sortParts = sortProperties?.split(",") ?? [];
|
|
129
|
+
const sortPropertyList = [];
|
|
130
|
+
for (const conditionPart of sortParts) {
|
|
131
|
+
const parts = conditionPart.split("|");
|
|
132
|
+
if (parts.length === 2) {
|
|
133
|
+
sortPropertyList.push({
|
|
134
|
+
property: parts[0],
|
|
135
|
+
sortDirection: parts[1]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return sortPropertyList.length === 0 ? undefined : sortPropertyList;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Convert the sort properties to a string parameter.
|
|
143
|
+
* @param sortProperties The sort properties to convert.
|
|
144
|
+
* @returns The string version of the sort properties.
|
|
145
|
+
*/
|
|
146
|
+
static sortPropertiesToString(sortProperties) {
|
|
147
|
+
if (Is.arrayValue(sortProperties)) {
|
|
148
|
+
const sortPropertyList = [];
|
|
149
|
+
for (const conditionPart of sortProperties) {
|
|
150
|
+
sortPropertyList.push(`${conditionPart.property}|${conditionPart.sortDirection}`);
|
|
151
|
+
}
|
|
152
|
+
return sortPropertyList.join(",");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
122
155
|
}
|
|
123
156
|
|
|
124
157
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IComparator } from "@twin.org/entity";
|
|
1
|
+
import type { IComparator, SortDirection } from "@twin.org/entity";
|
|
2
2
|
/**
|
|
3
3
|
* Class to help with handling http parameters.
|
|
4
4
|
*/
|
|
@@ -27,4 +27,22 @@ export declare class HttpParameterHelper {
|
|
|
27
27
|
* @returns The string version of the comparators.
|
|
28
28
|
*/
|
|
29
29
|
static conditionsToString(conditions?: IComparator[]): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Convert the sort string to a list of sort properties.
|
|
32
|
+
* @param sortProperties The sort properties query string.
|
|
33
|
+
* @returns The list of sort properties.
|
|
34
|
+
*/
|
|
35
|
+
static sortPropertiesFromString<T = unknown>(sortProperties?: string): {
|
|
36
|
+
property: keyof T;
|
|
37
|
+
sortDirection: SortDirection;
|
|
38
|
+
}[] | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Convert the sort properties to a string parameter.
|
|
41
|
+
* @param sortProperties The sort properties to convert.
|
|
42
|
+
* @returns The string version of the sort properties.
|
|
43
|
+
*/
|
|
44
|
+
static sortPropertiesToString<T = unknown>(sortProperties?: {
|
|
45
|
+
property: keyof T;
|
|
46
|
+
sortDirection: SortDirection;
|
|
47
|
+
}[]): string | undefined;
|
|
30
48
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -99,3 +99,51 @@ The conditions to convert.
|
|
|
99
99
|
`undefined` \| `string`
|
|
100
100
|
|
|
101
101
|
The string version of the comparators.
|
|
102
|
+
|
|
103
|
+
***
|
|
104
|
+
|
|
105
|
+
### sortPropertiesFromString()
|
|
106
|
+
|
|
107
|
+
> `static` **sortPropertiesFromString**\<`T`\>(`sortProperties`?): `undefined` \| `object`[]
|
|
108
|
+
|
|
109
|
+
Convert the sort string to a list of sort properties.
|
|
110
|
+
|
|
111
|
+
#### Type Parameters
|
|
112
|
+
|
|
113
|
+
• **T** = `unknown`
|
|
114
|
+
|
|
115
|
+
#### Parameters
|
|
116
|
+
|
|
117
|
+
• **sortProperties?**: `string`
|
|
118
|
+
|
|
119
|
+
The sort properties query string.
|
|
120
|
+
|
|
121
|
+
#### Returns
|
|
122
|
+
|
|
123
|
+
`undefined` \| `object`[]
|
|
124
|
+
|
|
125
|
+
The list of sort properties.
|
|
126
|
+
|
|
127
|
+
***
|
|
128
|
+
|
|
129
|
+
### sortPropertiesToString()
|
|
130
|
+
|
|
131
|
+
> `static` **sortPropertiesToString**\<`T`\>(`sortProperties`?): `undefined` \| `string`
|
|
132
|
+
|
|
133
|
+
Convert the sort properties to a string parameter.
|
|
134
|
+
|
|
135
|
+
#### Type Parameters
|
|
136
|
+
|
|
137
|
+
• **T** = `unknown`
|
|
138
|
+
|
|
139
|
+
#### Parameters
|
|
140
|
+
|
|
141
|
+
• **sortProperties?**: `object`[]
|
|
142
|
+
|
|
143
|
+
The sort properties to convert.
|
|
144
|
+
|
|
145
|
+
#### Returns
|
|
146
|
+
|
|
147
|
+
`undefined` \| `string`
|
|
148
|
+
|
|
149
|
+
The string version of the sort properties.
|