@budibase/shared-core 2.29.28 → 2.29.30

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 CHANGED
@@ -45,10 +45,16 @@ export declare class ColumnSplitter {
45
45
  tableIds: string[];
46
46
  relationshipColumnNames: string[];
47
47
  relationships: string[];
48
- constructor(tables: Table[]);
48
+ aliases?: Record<string, string>;
49
+ columnPrefix?: string;
50
+ constructor(tables: Table[], opts?: {
51
+ aliases?: Record<string, string>;
52
+ columnPrefix?: string;
53
+ });
49
54
  run(key: string): {
50
55
  numberPrefix?: string;
51
56
  relationshipPrefix?: string;
57
+ tableName?: string;
52
58
  column: string;
53
59
  };
54
60
  }
@@ -4,3 +4,5 @@ export declare function isDeprecatedSingleUserColumn(schema: Pick<FieldSchema, "
4
4
  subtype: BBReferenceFieldSubType.USER;
5
5
  };
6
6
  export declare function isRequired(constraints: FieldConstraints | undefined): boolean;
7
+ export declare function encodeNonAscii(str: string): string;
8
+ export declare function decodeNonAscii(str: string): string;
package/dist/index.js CHANGED
@@ -10538,6 +10538,8 @@ function validate(cronExpression) {
10538
10538
  // src/helpers/schema.ts
10539
10539
  var schema_exports = {};
10540
10540
  __export(schema_exports, {
10541
+ decodeNonAscii: () => decodeNonAscii,
10542
+ encodeNonAscii: () => encodeNonAscii,
10541
10543
  isDeprecatedSingleUserColumn: () => isDeprecatedSingleUserColumn,
10542
10544
  isRequired: () => isRequired
10543
10545
  });
@@ -10549,6 +10551,17 @@ function isRequired(constraints) {
10549
10551
  const isRequired2 = !!constraints && (typeof constraints.presence !== "boolean" && constraints.presence?.allowEmpty === false || constraints.presence === true);
10550
10552
  return isRequired2;
10551
10553
  }
10554
+ function encodeNonAscii(str) {
10555
+ return str.split("").map((char) => {
10556
+ return char.charCodeAt(0) > 127 ? "\\u" + char.charCodeAt(0).toString(16).padStart(4, "0") : char;
10557
+ }).join("");
10558
+ }
10559
+ function decodeNonAscii(str) {
10560
+ return str.replace(
10561
+ /\\u([0-9a-fA-F]{4})/g,
10562
+ (match, p1) => String.fromCharCode(parseInt(p1, 16))
10563
+ );
10564
+ }
10552
10565
 
10553
10566
  // src/filters.ts
10554
10567
  var import_lodash = __toESM(require_lodash());
@@ -10652,7 +10665,7 @@ var getKeyNumbering = (key) => {
10652
10665
  }
10653
10666
  };
10654
10667
  var ColumnSplitter = class {
10655
- constructor(tables) {
10668
+ constructor(tables, opts) {
10656
10669
  this.tableNames = tables.map((table) => table.name);
10657
10670
  this.tableIds = tables.map((table) => table._id);
10658
10671
  this.relationshipColumnNames = tables.flatMap(
@@ -10661,11 +10674,28 @@ var ColumnSplitter = class {
10661
10674
  )
10662
10675
  );
10663
10676
  this.relationships = this.tableNames.concat(this.tableIds).concat(this.relationshipColumnNames).sort((a, b) => b.length - a.length);
10677
+ if (opts?.aliases) {
10678
+ this.aliases = {};
10679
+ for (const [key, value] of Object.entries(opts.aliases)) {
10680
+ this.aliases[value] = key;
10681
+ }
10682
+ }
10683
+ this.columnPrefix = opts?.columnPrefix;
10664
10684
  }
10665
10685
  run(key) {
10666
10686
  let { prefix, key: splitKey } = getKeyNumbering(key);
10687
+ let tableName = void 0;
10688
+ if (this.aliases) {
10689
+ for (const possibleAlias of Object.keys(this.aliases || {})) {
10690
+ const withDot = `${possibleAlias}.`;
10691
+ if (splitKey.startsWith(withDot)) {
10692
+ tableName = this.aliases[possibleAlias];
10693
+ splitKey = splitKey.slice(withDot.length);
10694
+ }
10695
+ }
10696
+ }
10667
10697
  let relationship;
10668
- for (let possibleRelationship of this.relationships) {
10698
+ for (const possibleRelationship of this.relationships) {
10669
10699
  const withDot = `${possibleRelationship}.`;
10670
10700
  if (splitKey.startsWith(withDot)) {
10671
10701
  const finalKeyParts = splitKey.split(withDot);
@@ -10675,7 +10705,13 @@ var ColumnSplitter = class {
10675
10705
  break;
10676
10706
  }
10677
10707
  }
10708
+ if (this.columnPrefix) {
10709
+ if (splitKey.startsWith(this.columnPrefix)) {
10710
+ splitKey = decodeNonAscii(splitKey.slice(this.columnPrefix.length));
10711
+ }
10712
+ }
10678
10713
  return {
10714
+ tableName,
10679
10715
  numberPrefix: prefix,
10680
10716
  relationshipPrefix: relationship,
10681
10717
  column: splitKey