@isrd-isi-edu/ermrestjs 2.6.1 → 2.8.0

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.
@@ -19,6 +19,7 @@ import {
19
19
  type Tuple,
20
20
  type VisibleColumn,
21
21
  } from '@isrd-isi-edu/ermrestjs/src/models/reference';
22
+ import ActiveListCondition from '@isrd-isi-edu/ermrestjs/src/models/active-list-condition';
22
23
 
23
24
  // services
24
25
  import $log from '@isrd-isi-edu/ermrestjs/src/services/logger';
@@ -1031,9 +1032,35 @@ export function generateColumnsList(
1031
1032
  }
1032
1033
  }
1033
1034
 
1035
+ applyNoSourceConditions(resultColumns, (col) => col.resolvedCondition);
1036
+
1034
1037
  return resultColumns;
1035
1038
  }
1036
1039
 
1040
+ /**
1041
+ * Splice items whose no-source condition evaluates to "hide". With-source
1042
+ * conditions are left in place (handled by chaise after the main read).
1043
+ * Mutates `items` in place.
1044
+ */
1045
+ export function applyNoSourceConditions<T>(items: T[], getCondition: (item: T) => ActiveListCondition | null | undefined): void {
1046
+ for (let i = 0; i < items.length; i++) {
1047
+ const cond = getCondition(items[i]);
1048
+ if (!cond || cond.column !== null) continue; // no condition, or with-source
1049
+
1050
+ let shouldShow = true;
1051
+ try {
1052
+ shouldShow = cond.evaluateCondition({}, null).shouldShow;
1053
+ } catch (e) {
1054
+ $log.warn('no-source condition evaluation failed; defaulting to show: ' + (e instanceof Error ? e.message : String(e)));
1055
+ }
1056
+
1057
+ if (!shouldShow) {
1058
+ items.splice(i, 1);
1059
+ i--;
1060
+ }
1061
+ }
1062
+ }
1063
+
1037
1064
  /**
1038
1065
  * Generate a list of facetColumns that should be used for the given reference.
1039
1066
  * will also attach _facetColumns to the reference.
@@ -1110,7 +1137,7 @@ export function generateFacetColumns(
1110
1137
 
1111
1138
  try {
1112
1139
  if ('and' in obj) {
1113
- const fow = new FacetObjectGroupWrapper(obj, reference.table, hasFilterOrFacet);
1140
+ const fow = new FacetObjectGroupWrapper(obj, reference, hasFilterOrFacet);
1114
1141
  // avoid duplicate groups
1115
1142
  if (fow.displayname.unformatted! in addedGroups) {
1116
1143
  throw new Error(`Duplicate facet group name: ${fow.displayname.unformatted}`);
@@ -1118,7 +1145,7 @@ export function generateFacetColumns(
1118
1145
  addedGroups[fow.displayname.unformatted!] = true;
1119
1146
  facetObjectWrappers.push(fow);
1120
1147
  } else {
1121
- const wrapper = helpers.sourceDefToFacetObjectWrapper(obj, reference.table, hasFilterOrFacet);
1148
+ const wrapper = helpers.sourceDefToFacetObjectWrapper(obj, reference, hasFilterOrFacet);
1122
1149
  facetObjectWrappers.push(wrapper);
1123
1150
  }
1124
1151
  } catch (exp) {
package/tsconfig.json CHANGED
@@ -9,9 +9,8 @@
9
9
  /* Bundler mode */
10
10
  "moduleResolution": "bundler",
11
11
  "allowImportingTsExtensions": true,
12
- "baseUrl": "./",
13
12
  "paths": {
14
- "@isrd-isi-edu/ermrestjs/*": ["*"]
13
+ "@isrd-isi-edu/ermrestjs/*": ["./*"]
15
14
  },
16
15
 
17
16
  "allowJs": true,