@etsoo/appscript 1.6.43 → 1.6.45
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.
|
@@ -50,4 +50,12 @@ export declare namespace BusinessUtils {
|
|
|
50
50
|
* @param target Target collection to restore resources to, null to clear cache
|
|
51
51
|
*/
|
|
52
52
|
function restoreResources(target?: DataTypes.StringRecord): void;
|
|
53
|
+
/**
|
|
54
|
+
* Setup paging keysets
|
|
55
|
+
* @param data Paging data
|
|
56
|
+
* @param lastItem Last item of the query
|
|
57
|
+
* @param idField Id field in data
|
|
58
|
+
* @param fields Fields map
|
|
59
|
+
*/
|
|
60
|
+
function setupPagingKeysets<T, K extends IdType = number>(data: QueryRQ<K>, lastItem: T | undefined, idField: keyof T & string, fields?: Record<string, string | null | undefined>): QueryRQ<K>;
|
|
53
61
|
}
|
|
@@ -123,4 +123,38 @@ var BusinessUtils;
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
BusinessUtils.restoreResources = restoreResources;
|
|
126
|
+
/**
|
|
127
|
+
* Setup paging keysets
|
|
128
|
+
* @param data Paging data
|
|
129
|
+
* @param lastItem Last item of the query
|
|
130
|
+
* @param idField Id field in data
|
|
131
|
+
* @param fields Fields map
|
|
132
|
+
*/
|
|
133
|
+
function setupPagingKeysets(data, lastItem, idField, fields) {
|
|
134
|
+
var _a;
|
|
135
|
+
// If the id field is not set for ordering, add it with descending
|
|
136
|
+
if (typeof data.queryPaging === "object") {
|
|
137
|
+
const orderBy = ((_a = data.queryPaging).orderBy ?? (_a.orderBy = []));
|
|
138
|
+
const idUpper = idField.toUpperCase();
|
|
139
|
+
if (!orderBy.find((o) => o.field.toUpperCase() === idUpper)) {
|
|
140
|
+
orderBy.push({ field: idField, desc: true, unique: true });
|
|
141
|
+
}
|
|
142
|
+
// Format order fields, like 'name' to 'Contact.Name' when 'Contact' is a reference table name in Entity Framework
|
|
143
|
+
if (fields) {
|
|
144
|
+
data.queryPaging.orderBy?.forEach((f) => {
|
|
145
|
+
f.field = fields[f.field] ?? f.field;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// Set the paging keysets
|
|
149
|
+
if (lastItem) {
|
|
150
|
+
const keysets = orderBy.map((o) => Reflect.get(lastItem, o.field));
|
|
151
|
+
data.queryPaging.keysets = keysets;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
data.queryPaging.keysets = undefined;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return data;
|
|
158
|
+
}
|
|
159
|
+
BusinessUtils.setupPagingKeysets = setupPagingKeysets;
|
|
126
160
|
})(BusinessUtils || (exports.BusinessUtils = BusinessUtils = {}));
|
|
@@ -50,4 +50,12 @@ export declare namespace BusinessUtils {
|
|
|
50
50
|
* @param target Target collection to restore resources to, null to clear cache
|
|
51
51
|
*/
|
|
52
52
|
function restoreResources(target?: DataTypes.StringRecord): void;
|
|
53
|
+
/**
|
|
54
|
+
* Setup paging keysets
|
|
55
|
+
* @param data Paging data
|
|
56
|
+
* @param lastItem Last item of the query
|
|
57
|
+
* @param idField Id field in data
|
|
58
|
+
* @param fields Fields map
|
|
59
|
+
*/
|
|
60
|
+
function setupPagingKeysets<T, K extends IdType = number>(data: QueryRQ<K>, lastItem: T | undefined, idField: keyof T & string, fields?: Record<string, string | null | undefined>): QueryRQ<K>;
|
|
53
61
|
}
|
|
@@ -120,4 +120,38 @@ export var BusinessUtils;
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
BusinessUtils.restoreResources = restoreResources;
|
|
123
|
+
/**
|
|
124
|
+
* Setup paging keysets
|
|
125
|
+
* @param data Paging data
|
|
126
|
+
* @param lastItem Last item of the query
|
|
127
|
+
* @param idField Id field in data
|
|
128
|
+
* @param fields Fields map
|
|
129
|
+
*/
|
|
130
|
+
function setupPagingKeysets(data, lastItem, idField, fields) {
|
|
131
|
+
var _a;
|
|
132
|
+
// If the id field is not set for ordering, add it with descending
|
|
133
|
+
if (typeof data.queryPaging === "object") {
|
|
134
|
+
const orderBy = ((_a = data.queryPaging).orderBy ?? (_a.orderBy = []));
|
|
135
|
+
const idUpper = idField.toUpperCase();
|
|
136
|
+
if (!orderBy.find((o) => o.field.toUpperCase() === idUpper)) {
|
|
137
|
+
orderBy.push({ field: idField, desc: true, unique: true });
|
|
138
|
+
}
|
|
139
|
+
// Format order fields, like 'name' to 'Contact.Name' when 'Contact' is a reference table name in Entity Framework
|
|
140
|
+
if (fields) {
|
|
141
|
+
data.queryPaging.orderBy?.forEach((f) => {
|
|
142
|
+
f.field = fields[f.field] ?? f.field;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// Set the paging keysets
|
|
146
|
+
if (lastItem) {
|
|
147
|
+
const keysets = orderBy.map((o) => Reflect.get(lastItem, o.field));
|
|
148
|
+
data.queryPaging.keysets = keysets;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
data.queryPaging.keysets = undefined;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return data;
|
|
155
|
+
}
|
|
156
|
+
BusinessUtils.setupPagingKeysets = setupPagingKeysets;
|
|
123
157
|
})(BusinessUtils || (BusinessUtils = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.45",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/ETSOO/AppScript#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@etsoo/notificationbase": "^1.1.
|
|
39
|
-
"@etsoo/restclient": "^1.1.
|
|
40
|
-
"@etsoo/shared": "^1.2.
|
|
38
|
+
"@etsoo/notificationbase": "^1.1.64",
|
|
39
|
+
"@etsoo/restclient": "^1.1.31",
|
|
40
|
+
"@etsoo/shared": "^1.2.76",
|
|
41
41
|
"crypto-js": "^4.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@babel/cli": "^7.28.
|
|
45
|
-
"@babel/core": "^7.28.
|
|
46
|
-
"@babel/plugin-transform-runtime": "^7.28.
|
|
47
|
-
"@babel/preset-env": "^7.28.
|
|
48
|
-
"@babel/runtime-corejs3": "^7.28.
|
|
44
|
+
"@babel/cli": "^7.28.3",
|
|
45
|
+
"@babel/core": "^7.28.4",
|
|
46
|
+
"@babel/plugin-transform-runtime": "^7.28.3",
|
|
47
|
+
"@babel/preset-env": "^7.28.3",
|
|
48
|
+
"@babel/runtime-corejs3": "^7.28.4",
|
|
49
49
|
"@types/crypto-js": "^4.2.2",
|
|
50
|
-
"@vitejs/plugin-react": "^
|
|
51
|
-
"jsdom": "^
|
|
52
|
-
"typescript": "^5.
|
|
50
|
+
"@vitejs/plugin-react": "^5.0.2",
|
|
51
|
+
"jsdom": "^27.0.0",
|
|
52
|
+
"typescript": "^5.9.2",
|
|
53
53
|
"vitest": "^3.2.4"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -142,4 +142,44 @@ export namespace BusinessUtils {
|
|
|
142
142
|
target[key] = resourcesCache[key];
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Setup paging keysets
|
|
148
|
+
* @param data Paging data
|
|
149
|
+
* @param lastItem Last item of the query
|
|
150
|
+
* @param idField Id field in data
|
|
151
|
+
* @param fields Fields map
|
|
152
|
+
*/
|
|
153
|
+
export function setupPagingKeysets<T, K extends IdType = number>(
|
|
154
|
+
data: QueryRQ<K>,
|
|
155
|
+
lastItem: T | undefined,
|
|
156
|
+
idField: keyof T & string,
|
|
157
|
+
fields?: Record<string, string | null | undefined>
|
|
158
|
+
) {
|
|
159
|
+
// If the id field is not set for ordering, add it with descending
|
|
160
|
+
if (typeof data.queryPaging === "object") {
|
|
161
|
+
const orderBy = (data.queryPaging.orderBy ??= []);
|
|
162
|
+
const idUpper = idField.toUpperCase();
|
|
163
|
+
if (!orderBy.find((o) => o.field.toUpperCase() === idUpper)) {
|
|
164
|
+
orderBy.push({ field: idField, desc: true, unique: true });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Format order fields, like 'name' to 'Contact.Name' when 'Contact' is a reference table name in Entity Framework
|
|
168
|
+
if (fields) {
|
|
169
|
+
data.queryPaging.orderBy?.forEach((f) => {
|
|
170
|
+
f.field = fields[f.field] ?? f.field;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Set the paging keysets
|
|
175
|
+
if (lastItem) {
|
|
176
|
+
const keysets = orderBy.map((o) => Reflect.get(lastItem, o.field));
|
|
177
|
+
data.queryPaging.keysets = keysets;
|
|
178
|
+
} else {
|
|
179
|
+
data.queryPaging.keysets = undefined;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return data;
|
|
184
|
+
}
|
|
145
185
|
}
|