@budibase/shared-core 2.31.3 → 2.31.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/filters.d.ts +1 -0
- package/dist/helpers/helpers.d.ts +2 -0
- package/dist/index.js +46 -10
- package/dist/index.js.map +3 -3
- package/dist/index.js.meta.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/filters.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare const getValidOperatorsForType: (fieldType: {
|
|
|
18
18
|
*/
|
|
19
19
|
export declare const NoEmptyFilterStrings: (keyof SearchQueryFields)[];
|
|
20
20
|
export declare function recurseLogicalOperators(filters: SearchFilters, fn: (f: SearchFilters) => SearchFilters): SearchFilters;
|
|
21
|
+
export declare function recurseSearchFilters(filters: SearchFilters, processFn: (filter: SearchFilters) => SearchFilters): SearchFilters;
|
|
21
22
|
/**
|
|
22
23
|
* Removes any fields that contain empty strings that would cause inconsistent
|
|
23
24
|
* behaviour with how backend tables are filtered (no value means no filter).
|
|
@@ -27,3 +27,5 @@ export declare const getUserColor: (user: User) => string;
|
|
|
27
27
|
* @param user the user
|
|
28
28
|
*/
|
|
29
29
|
export declare const getUserLabel: (user: User) => string;
|
|
30
|
+
export declare function cancelableTimeout(timeout: number): [Promise<unknown>, () => void];
|
|
31
|
+
export declare function withTimeout<T>(timeout: number, promise: Promise<T>): Promise<T>;
|
package/dist/index.js
CHANGED
|
@@ -1542,7 +1542,7 @@ var require_lodash = __commonJS({
|
|
|
1542
1542
|
if (typeof func != "function") {
|
|
1543
1543
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
1544
1544
|
}
|
|
1545
|
-
return
|
|
1545
|
+
return setTimeout2(function() {
|
|
1546
1546
|
func.apply(undefined2, args);
|
|
1547
1547
|
}, wait);
|
|
1548
1548
|
}
|
|
@@ -2322,7 +2322,7 @@ var require_lodash = __commonJS({
|
|
|
2322
2322
|
end = end === undefined2 ? length : end;
|
|
2323
2323
|
return !start && end >= length ? array : baseSlice(array, start, end);
|
|
2324
2324
|
}
|
|
2325
|
-
var
|
|
2325
|
+
var clearTimeout2 = ctxClearTimeout || function(id) {
|
|
2326
2326
|
return root.clearTimeout(id);
|
|
2327
2327
|
};
|
|
2328
2328
|
function cloneBuffer(buffer, isDeep) {
|
|
@@ -3373,7 +3373,7 @@ var require_lodash = __commonJS({
|
|
|
3373
3373
|
return object[key];
|
|
3374
3374
|
}
|
|
3375
3375
|
var setData = shortOut(baseSetData);
|
|
3376
|
-
var
|
|
3376
|
+
var setTimeout2 = ctxSetTimeout || function(func, wait) {
|
|
3377
3377
|
return root.setTimeout(func, wait);
|
|
3378
3378
|
};
|
|
3379
3379
|
var setToString = shortOut(baseSetToString);
|
|
@@ -4165,7 +4165,7 @@ var require_lodash = __commonJS({
|
|
|
4165
4165
|
}
|
|
4166
4166
|
function leadingEdge(time) {
|
|
4167
4167
|
lastInvokeTime = time;
|
|
4168
|
-
timerId =
|
|
4168
|
+
timerId = setTimeout2(timerExpired, wait);
|
|
4169
4169
|
return leading ? invokeFunc(time) : result2;
|
|
4170
4170
|
}
|
|
4171
4171
|
function remainingWait(time) {
|
|
@@ -4181,7 +4181,7 @@ var require_lodash = __commonJS({
|
|
|
4181
4181
|
if (shouldInvoke(time)) {
|
|
4182
4182
|
return trailingEdge(time);
|
|
4183
4183
|
}
|
|
4184
|
-
timerId =
|
|
4184
|
+
timerId = setTimeout2(timerExpired, remainingWait(time));
|
|
4185
4185
|
}
|
|
4186
4186
|
function trailingEdge(time) {
|
|
4187
4187
|
timerId = undefined2;
|
|
@@ -4193,7 +4193,7 @@ var require_lodash = __commonJS({
|
|
|
4193
4193
|
}
|
|
4194
4194
|
function cancel() {
|
|
4195
4195
|
if (timerId !== undefined2) {
|
|
4196
|
-
|
|
4196
|
+
clearTimeout2(timerId);
|
|
4197
4197
|
}
|
|
4198
4198
|
lastInvokeTime = 0;
|
|
4199
4199
|
lastArgs = lastCallTime = lastThis = timerId = undefined2;
|
|
@@ -4211,13 +4211,13 @@ var require_lodash = __commonJS({
|
|
|
4211
4211
|
return leadingEdge(lastCallTime);
|
|
4212
4212
|
}
|
|
4213
4213
|
if (maxing) {
|
|
4214
|
-
|
|
4215
|
-
timerId =
|
|
4214
|
+
clearTimeout2(timerId);
|
|
4215
|
+
timerId = setTimeout2(timerExpired, wait);
|
|
4216
4216
|
return invokeFunc(lastCallTime);
|
|
4217
4217
|
}
|
|
4218
4218
|
}
|
|
4219
4219
|
if (timerId === undefined2) {
|
|
4220
|
-
timerId =
|
|
4220
|
+
timerId = setTimeout2(timerExpired, wait);
|
|
4221
4221
|
}
|
|
4222
4222
|
return result2;
|
|
4223
4223
|
}
|
|
@@ -10408,6 +10408,7 @@ __export(filters_exports, {
|
|
|
10408
10408
|
hasFilters: () => hasFilters,
|
|
10409
10409
|
limit: () => limit,
|
|
10410
10410
|
recurseLogicalOperators: () => recurseLogicalOperators,
|
|
10411
|
+
recurseSearchFilters: () => recurseSearchFilters,
|
|
10411
10412
|
removeKeyNumbering: () => removeKeyNumbering,
|
|
10412
10413
|
runQuery: () => runQuery,
|
|
10413
10414
|
search: () => search,
|
|
@@ -10418,6 +10419,7 @@ var import_dayjs = __toESM(require_dayjs_min());
|
|
|
10418
10419
|
// src/helpers/index.ts
|
|
10419
10420
|
var helpers_exports = {};
|
|
10420
10421
|
__export(helpers_exports, {
|
|
10422
|
+
cancelableTimeout: () => cancelableTimeout,
|
|
10421
10423
|
cron: () => cron_exports,
|
|
10422
10424
|
deepGet: () => deepGet,
|
|
10423
10425
|
getUserColor: () => getUserColor,
|
|
@@ -10425,7 +10427,8 @@ __export(helpers_exports, {
|
|
|
10425
10427
|
getUserLabel: () => getUserLabel,
|
|
10426
10428
|
isGoogleSheets: () => isGoogleSheets,
|
|
10427
10429
|
isSQL: () => isSQL,
|
|
10428
|
-
schema: () => schema_exports
|
|
10430
|
+
schema: () => schema_exports,
|
|
10431
|
+
withTimeout: () => withTimeout
|
|
10429
10432
|
});
|
|
10430
10433
|
|
|
10431
10434
|
// src/helpers/helpers.ts
|
|
@@ -10482,6 +10485,28 @@ var getUserLabel = (user) => {
|
|
|
10482
10485
|
return email;
|
|
10483
10486
|
}
|
|
10484
10487
|
};
|
|
10488
|
+
function cancelableTimeout(timeout) {
|
|
10489
|
+
let timeoutId;
|
|
10490
|
+
return [
|
|
10491
|
+
new Promise((resolve, reject) => {
|
|
10492
|
+
timeoutId = setTimeout(() => {
|
|
10493
|
+
reject({
|
|
10494
|
+
status: 301,
|
|
10495
|
+
errno: "ETIME"
|
|
10496
|
+
});
|
|
10497
|
+
}, timeout);
|
|
10498
|
+
}),
|
|
10499
|
+
() => {
|
|
10500
|
+
clearTimeout(timeoutId);
|
|
10501
|
+
}
|
|
10502
|
+
];
|
|
10503
|
+
}
|
|
10504
|
+
async function withTimeout(timeout, promise) {
|
|
10505
|
+
const [timeoutPromise, cancel] = cancelableTimeout(timeout);
|
|
10506
|
+
const result = await Promise.race([promise, timeoutPromise]);
|
|
10507
|
+
cancel();
|
|
10508
|
+
return result;
|
|
10509
|
+
}
|
|
10485
10510
|
|
|
10486
10511
|
// src/helpers/integrations.ts
|
|
10487
10512
|
function isGoogleSheets(type) {
|
|
@@ -10647,6 +10672,17 @@ function recurseLogicalOperators(filters, fn) {
|
|
|
10647
10672
|
}
|
|
10648
10673
|
return filters;
|
|
10649
10674
|
}
|
|
10675
|
+
function recurseSearchFilters(filters, processFn) {
|
|
10676
|
+
filters = processFn(filters);
|
|
10677
|
+
for (const logical of Object.values(LogicalOperator)) {
|
|
10678
|
+
if (filters[logical]) {
|
|
10679
|
+
filters[logical].conditions = filters[logical].conditions.map(
|
|
10680
|
+
(condition) => recurseSearchFilters(condition, processFn)
|
|
10681
|
+
);
|
|
10682
|
+
}
|
|
10683
|
+
}
|
|
10684
|
+
return filters;
|
|
10685
|
+
}
|
|
10650
10686
|
var cleanupQuery = (query) => {
|
|
10651
10687
|
if (!query) {
|
|
10652
10688
|
return query;
|