@budibase/shared-core 2.29.3 → 2.29.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/constants/index.d.ts +7 -3
- package/dist/constants/rows.d.ts +3 -0
- package/dist/filters.d.ts +25 -2
- package/dist/helpers/integrations.d.ts +1 -1
- package/dist/index.js +97 -12
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/table.d.ts +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./api";
|
|
2
2
|
export * from "./fields";
|
|
3
|
+
export * from "./rows";
|
|
3
4
|
export declare const OperatorOptions: {
|
|
4
5
|
Equals: {
|
|
5
6
|
value: string;
|
|
@@ -97,13 +98,16 @@ export declare const ValidSnippetNameRegex: RegExp;
|
|
|
97
98
|
export declare const REBOOT_CRON = "@reboot";
|
|
98
99
|
export declare const InvalidFileExtensions: string[];
|
|
99
100
|
export declare enum BpmCorrelationKey {
|
|
100
|
-
ONBOARDING = "budibase:onboarding:correlationkey"
|
|
101
|
+
ONBOARDING = "budibase:onboarding:correlationkey",
|
|
102
|
+
VERIFY_SSO_LOGIN = "budibase:verify_sso_login:correlationkey"
|
|
101
103
|
}
|
|
102
104
|
export declare enum BpmInstanceKey {
|
|
103
|
-
ONBOARDING = "budibase:onboarding:instancekey"
|
|
105
|
+
ONBOARDING = "budibase:onboarding:instancekey",
|
|
106
|
+
VERIFY_SSO_LOGIN = "budibase:verify_sso_login:instancekey"
|
|
104
107
|
}
|
|
105
108
|
export declare enum BpmStatusKey {
|
|
106
|
-
ONBOARDING = "budibase:onboarding:status"
|
|
109
|
+
ONBOARDING = "budibase:onboarding:status",
|
|
110
|
+
VERIFY_SSO_LOGIN = "budibase:verify_sso_login:status"
|
|
107
111
|
}
|
|
108
112
|
export declare enum BpmStatusValue {
|
|
109
113
|
STARTED = "started",
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const CONSTANT_INTERNAL_ROW_COLS: readonly ["_id", "_rev", "type", "createdAt", "updatedAt", "tableId"];
|
|
2
|
+
export declare const CONSTANT_EXTERNAL_ROW_COLS: readonly ["_id", "_rev", "tableId"];
|
|
3
|
+
export declare function isInternalColumnName(name: string): boolean;
|
package/dist/filters.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Datasource, BBReferenceFieldSubType, FieldType, FormulaType, SearchFilter, SearchFilters,
|
|
1
|
+
import { Datasource, BBReferenceFieldSubType, FieldType, FormulaType, SearchFilter, SearchFilters, SearchQueryFields, SortType, FieldConstraints, SortOrder, RowSearchParams, SearchResponse, Table } from "@budibase/types";
|
|
2
2
|
/**
|
|
3
3
|
* Returns the valid operator options for a certain data type
|
|
4
4
|
*/
|
|
@@ -16,11 +16,34 @@ export declare const getValidOperatorsForType: (fieldType: {
|
|
|
16
16
|
/**
|
|
17
17
|
* Operators which do not support empty strings as values
|
|
18
18
|
*/
|
|
19
|
-
export declare const NoEmptyFilterStrings: (
|
|
19
|
+
export declare const NoEmptyFilterStrings: (keyof SearchQueryFields)[];
|
|
20
20
|
/**
|
|
21
21
|
* Removes a numeric prefix on field names designed to give fields uniqueness
|
|
22
22
|
*/
|
|
23
23
|
export declare const removeKeyNumbering: (key: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the part of the keys, returning the numeric prefix and the field name
|
|
26
|
+
*/
|
|
27
|
+
export declare const getKeyNumbering: (key: string) => {
|
|
28
|
+
prefix?: string;
|
|
29
|
+
key: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Generates a splitter which can be used to split columns from a context into
|
|
33
|
+
* their components (number prefix, relationship column/table, column name)
|
|
34
|
+
*/
|
|
35
|
+
export declare class ColumnSplitter {
|
|
36
|
+
tableNames: string[];
|
|
37
|
+
tableIds: string[];
|
|
38
|
+
relationshipColumnNames: string[];
|
|
39
|
+
relationships: string[];
|
|
40
|
+
constructor(tables: Table[]);
|
|
41
|
+
run(key: string): {
|
|
42
|
+
numberPrefix?: string;
|
|
43
|
+
relationshipPrefix?: string;
|
|
44
|
+
column: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
24
47
|
/**
|
|
25
48
|
* Builds a JSON query from the filter structure generated in the builder
|
|
26
49
|
* @param filter the builder filter structure
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Datasource, SourceName } from "@budibase/types";
|
|
2
|
-
export declare function isGoogleSheets(type: SourceName):
|
|
2
|
+
export declare function isGoogleSheets(type: SourceName): type is SourceName.GOOGLE_SHEETS;
|
|
3
3
|
export declare function isSQL(datasource: Datasource): boolean;
|
package/dist/index.js
CHANGED
|
@@ -1044,10 +1044,10 @@ var require_lodash = __commonJS({
|
|
|
1044
1044
|
}();
|
|
1045
1045
|
var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
|
|
1046
1046
|
var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
|
|
1047
|
-
var DataView = getNative(context, "DataView"), Map = getNative(context, "Map"), Promise2 = getNative(context, "Promise"),
|
|
1047
|
+
var DataView = getNative(context, "DataView"), Map = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set2 = getNative(context, "Set"), WeakMap = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
|
|
1048
1048
|
var metaMap = WeakMap && new WeakMap();
|
|
1049
1049
|
var realNames = {};
|
|
1050
|
-
var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map), promiseCtorString = toSource(Promise2), setCtorString = toSource(
|
|
1050
|
+
var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap);
|
|
1051
1051
|
var symbolProto = Symbol2 ? Symbol2.prototype : undefined2, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined2, symbolToString = symbolProto ? symbolProto.toString : undefined2;
|
|
1052
1052
|
function lodash(value) {
|
|
1053
1053
|
if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
|
|
@@ -2801,8 +2801,8 @@ var require_lodash = __commonJS({
|
|
|
2801
2801
|
return func(number);
|
|
2802
2802
|
};
|
|
2803
2803
|
}
|
|
2804
|
-
var createSet = !(
|
|
2805
|
-
return new
|
|
2804
|
+
var createSet = !(Set2 && 1 / setToArray(new Set2([, -0]))[1] == INFINITY) ? noop : function(values3) {
|
|
2805
|
+
return new Set2(values3);
|
|
2806
2806
|
};
|
|
2807
2807
|
function createToPairs(keysFunc) {
|
|
2808
2808
|
return function(object) {
|
|
@@ -3101,7 +3101,7 @@ var require_lodash = __commonJS({
|
|
|
3101
3101
|
return result2;
|
|
3102
3102
|
};
|
|
3103
3103
|
var getTag = baseGetTag;
|
|
3104
|
-
if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag ||
|
|
3104
|
+
if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
|
|
3105
3105
|
getTag = function(value) {
|
|
3106
3106
|
var result2 = baseGetTag(value), Ctor = result2 == objectTag ? value.constructor : undefined2, ctorString = Ctor ? toSource(Ctor) : "";
|
|
3107
3107
|
if (ctorString) {
|
|
@@ -10013,6 +10013,8 @@ __export(src_exports, {
|
|
|
10013
10013
|
BpmStatusKey: () => BpmStatusKey,
|
|
10014
10014
|
BpmStatusValue: () => BpmStatusValue,
|
|
10015
10015
|
BuilderSocketEvent: () => BuilderSocketEvent,
|
|
10016
|
+
CONSTANT_EXTERNAL_ROW_COLS: () => CONSTANT_EXTERNAL_ROW_COLS,
|
|
10017
|
+
CONSTANT_INTERNAL_ROW_COLS: () => CONSTANT_INTERNAL_ROW_COLS,
|
|
10016
10018
|
DEFAULT_BB_DATASOURCE_ID: () => DEFAULT_BB_DATASOURCE_ID,
|
|
10017
10019
|
GridSocketEvent: () => GridSocketEvent,
|
|
10018
10020
|
Header: () => Header,
|
|
@@ -10029,7 +10031,9 @@ __export(src_exports, {
|
|
|
10029
10031
|
canBeDisplayColumn: () => canBeDisplayColumn,
|
|
10030
10032
|
canBeSortColumn: () => canBeSortColumn,
|
|
10031
10033
|
dataFilters: () => filters_exports,
|
|
10034
|
+
findDuplicateInternalColumns: () => findDuplicateInternalColumns,
|
|
10032
10035
|
helpers: () => helpers_exports,
|
|
10036
|
+
isInternalColumnName: () => isInternalColumnName,
|
|
10033
10037
|
sdk: () => sdk_exports,
|
|
10034
10038
|
utils: () => utils_exports
|
|
10035
10039
|
});
|
|
@@ -10176,6 +10180,20 @@ var SWITCHABLE_TYPES = {
|
|
|
10176
10180
|
["number" /* NUMBER */]: ["number" /* NUMBER */, "boolean" /* BOOLEAN */]
|
|
10177
10181
|
};
|
|
10178
10182
|
|
|
10183
|
+
// src/constants/rows.ts
|
|
10184
|
+
var CONSTANT_INTERNAL_ROW_COLS = [
|
|
10185
|
+
"_id",
|
|
10186
|
+
"_rev",
|
|
10187
|
+
"type",
|
|
10188
|
+
"createdAt",
|
|
10189
|
+
"updatedAt",
|
|
10190
|
+
"tableId"
|
|
10191
|
+
];
|
|
10192
|
+
var CONSTANT_EXTERNAL_ROW_COLS = ["_id", "_rev", "tableId"];
|
|
10193
|
+
function isInternalColumnName(name) {
|
|
10194
|
+
return CONSTANT_INTERNAL_ROW_COLS.includes(name);
|
|
10195
|
+
}
|
|
10196
|
+
|
|
10179
10197
|
// src/constants/index.ts
|
|
10180
10198
|
var OperatorOptions = {
|
|
10181
10199
|
Equals: {
|
|
@@ -10334,14 +10352,17 @@ var InvalidFileExtensions = [
|
|
|
10334
10352
|
];
|
|
10335
10353
|
var BpmCorrelationKey = /* @__PURE__ */ ((BpmCorrelationKey2) => {
|
|
10336
10354
|
BpmCorrelationKey2["ONBOARDING"] = "budibase:onboarding:correlationkey";
|
|
10355
|
+
BpmCorrelationKey2["VERIFY_SSO_LOGIN"] = "budibase:verify_sso_login:correlationkey";
|
|
10337
10356
|
return BpmCorrelationKey2;
|
|
10338
10357
|
})(BpmCorrelationKey || {});
|
|
10339
10358
|
var BpmInstanceKey = /* @__PURE__ */ ((BpmInstanceKey2) => {
|
|
10340
10359
|
BpmInstanceKey2["ONBOARDING"] = "budibase:onboarding:instancekey";
|
|
10360
|
+
BpmInstanceKey2["VERIFY_SSO_LOGIN"] = "budibase:verify_sso_login:instancekey";
|
|
10341
10361
|
return BpmInstanceKey2;
|
|
10342
10362
|
})(BpmInstanceKey || {});
|
|
10343
10363
|
var BpmStatusKey = /* @__PURE__ */ ((BpmStatusKey2) => {
|
|
10344
10364
|
BpmStatusKey2["ONBOARDING"] = "budibase:onboarding:status";
|
|
10365
|
+
BpmStatusKey2["VERIFY_SSO_LOGIN"] = "budibase:verify_sso_login:status";
|
|
10345
10366
|
return BpmStatusKey2;
|
|
10346
10367
|
})(BpmStatusKey || {});
|
|
10347
10368
|
var BpmStatusValue = /* @__PURE__ */ ((BpmStatusValue2) => {
|
|
@@ -10356,8 +10377,10 @@ var DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default";
|
|
|
10356
10377
|
// src/filters.ts
|
|
10357
10378
|
var filters_exports = {};
|
|
10358
10379
|
__export(filters_exports, {
|
|
10380
|
+
ColumnSplitter: () => ColumnSplitter,
|
|
10359
10381
|
NoEmptyFilterStrings: () => NoEmptyFilterStrings,
|
|
10360
10382
|
buildQuery: () => buildQuery,
|
|
10383
|
+
getKeyNumbering: () => getKeyNumbering,
|
|
10361
10384
|
getValidOperatorsForType: () => getValidOperatorsForType,
|
|
10362
10385
|
hasFilters: () => hasFilters,
|
|
10363
10386
|
limit: () => limit,
|
|
@@ -10593,12 +10616,46 @@ var cleanupQuery = (query) => {
|
|
|
10593
10616
|
return query;
|
|
10594
10617
|
};
|
|
10595
10618
|
var removeKeyNumbering = (key) => {
|
|
10619
|
+
return getKeyNumbering(key).key;
|
|
10620
|
+
};
|
|
10621
|
+
var getKeyNumbering = (key) => {
|
|
10596
10622
|
if (typeof key === "string" && key.match(/\d[0-9]*:/g) != null) {
|
|
10597
10623
|
const parts = key.split(":");
|
|
10598
|
-
parts.shift();
|
|
10599
|
-
return parts.join(":");
|
|
10624
|
+
const number = parts.shift();
|
|
10625
|
+
return { prefix: `${number}:`, key: parts.join(":") };
|
|
10600
10626
|
} else {
|
|
10601
|
-
return key;
|
|
10627
|
+
return { key };
|
|
10628
|
+
}
|
|
10629
|
+
};
|
|
10630
|
+
var ColumnSplitter = class {
|
|
10631
|
+
constructor(tables) {
|
|
10632
|
+
this.tableNames = tables.map((table) => table.name);
|
|
10633
|
+
this.tableIds = tables.map((table) => table._id);
|
|
10634
|
+
this.relationshipColumnNames = tables.flatMap(
|
|
10635
|
+
(table) => Object.keys(table.schema).filter(
|
|
10636
|
+
(columnName) => table.schema[columnName].type === "link" /* LINK */
|
|
10637
|
+
)
|
|
10638
|
+
);
|
|
10639
|
+
this.relationships = this.tableNames.concat(this.tableIds).concat(this.relationshipColumnNames).sort((a, b) => b.length - a.length);
|
|
10640
|
+
}
|
|
10641
|
+
run(key) {
|
|
10642
|
+
let { prefix, key: splitKey } = getKeyNumbering(key);
|
|
10643
|
+
let relationship;
|
|
10644
|
+
for (let possibleRelationship of this.relationships) {
|
|
10645
|
+
const withDot = `${possibleRelationship}.`;
|
|
10646
|
+
if (splitKey.startsWith(withDot)) {
|
|
10647
|
+
const finalKeyParts = splitKey.split(withDot);
|
|
10648
|
+
finalKeyParts.shift();
|
|
10649
|
+
relationship = withDot;
|
|
10650
|
+
splitKey = finalKeyParts.join(".");
|
|
10651
|
+
break;
|
|
10652
|
+
}
|
|
10653
|
+
}
|
|
10654
|
+
return {
|
|
10655
|
+
numberPrefix: prefix,
|
|
10656
|
+
relationshipPrefix: relationship,
|
|
10657
|
+
column: splitKey
|
|
10658
|
+
};
|
|
10602
10659
|
}
|
|
10603
10660
|
};
|
|
10604
10661
|
var buildQuery = (filter) => {
|
|
@@ -10682,12 +10739,16 @@ var buildQuery = (filter) => {
|
|
|
10682
10739
|
query.equal = query.equal || {};
|
|
10683
10740
|
query.equal[field] = true;
|
|
10684
10741
|
} else {
|
|
10685
|
-
query[queryOperator] =
|
|
10686
|
-
|
|
10742
|
+
query[queryOperator] = {
|
|
10743
|
+
...query[queryOperator],
|
|
10744
|
+
[field]: value
|
|
10745
|
+
};
|
|
10687
10746
|
}
|
|
10688
10747
|
} else {
|
|
10689
|
-
query[queryOperator] =
|
|
10690
|
-
|
|
10748
|
+
query[queryOperator] = {
|
|
10749
|
+
...query[queryOperator],
|
|
10750
|
+
[field]: value
|
|
10751
|
+
};
|
|
10691
10752
|
}
|
|
10692
10753
|
}
|
|
10693
10754
|
});
|
|
@@ -11215,6 +11276,26 @@ function canBeDisplayColumn(type) {
|
|
|
11215
11276
|
function canBeSortColumn(type) {
|
|
11216
11277
|
return !!allowSortColumnByType[type];
|
|
11217
11278
|
}
|
|
11279
|
+
function findDuplicateInternalColumns(table) {
|
|
11280
|
+
const casedKeys = Object.keys(table.schema);
|
|
11281
|
+
const uncasedKeys = casedKeys.map((colName) => colName.toLowerCase());
|
|
11282
|
+
const set = new Set(uncasedKeys);
|
|
11283
|
+
let duplicates = [];
|
|
11284
|
+
if (set.size !== uncasedKeys.length) {
|
|
11285
|
+
for (let key of set.keys()) {
|
|
11286
|
+
const count = uncasedKeys.filter((name) => name === key).length;
|
|
11287
|
+
if (count > 1) {
|
|
11288
|
+
duplicates.push(key);
|
|
11289
|
+
}
|
|
11290
|
+
}
|
|
11291
|
+
}
|
|
11292
|
+
for (let internalColumn of CONSTANT_INTERNAL_ROW_COLS) {
|
|
11293
|
+
if (casedKeys.find((key) => key === internalColumn)) {
|
|
11294
|
+
duplicates.push(internalColumn);
|
|
11295
|
+
}
|
|
11296
|
+
}
|
|
11297
|
+
return duplicates;
|
|
11298
|
+
}
|
|
11218
11299
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11219
11300
|
0 && (module.exports = {
|
|
11220
11301
|
BpmCorrelationKey,
|
|
@@ -11222,6 +11303,8 @@ function canBeSortColumn(type) {
|
|
|
11222
11303
|
BpmStatusKey,
|
|
11223
11304
|
BpmStatusValue,
|
|
11224
11305
|
BuilderSocketEvent,
|
|
11306
|
+
CONSTANT_EXTERNAL_ROW_COLS,
|
|
11307
|
+
CONSTANT_INTERNAL_ROW_COLS,
|
|
11225
11308
|
DEFAULT_BB_DATASOURCE_ID,
|
|
11226
11309
|
GridSocketEvent,
|
|
11227
11310
|
Header,
|
|
@@ -11238,7 +11321,9 @@ function canBeSortColumn(type) {
|
|
|
11238
11321
|
canBeDisplayColumn,
|
|
11239
11322
|
canBeSortColumn,
|
|
11240
11323
|
dataFilters,
|
|
11324
|
+
findDuplicateInternalColumns,
|
|
11241
11325
|
helpers,
|
|
11326
|
+
isInternalColumnName,
|
|
11242
11327
|
sdk,
|
|
11243
11328
|
utils
|
|
11244
11329
|
});
|