@budibase/backend-core 2.9.22 → 2.9.24-alpha.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.
package/dist/tests.js CHANGED
@@ -29,28 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  mod
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
- var __accessCheck = (obj, member, msg) => {
33
- if (!member.has(obj))
34
- throw TypeError("Cannot " + msg);
35
- };
36
- var __privateGet = (obj, member, getter) => {
37
- __accessCheck(obj, member, "read from private field");
38
- return getter ? getter.call(obj) : member.get(obj);
39
- };
40
- var __privateAdd = (obj, member, value) => {
41
- if (member.has(obj))
42
- throw TypeError("Cannot add the same private member more than once");
43
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
44
- };
45
- var __privateSet = (obj, member, value, setter) => {
46
- __accessCheck(obj, member, "write to private field");
47
- setter ? setter.call(obj, value) : member.set(obj, value);
48
- return value;
49
- };
50
- var __privateMethod = (obj, member, method) => {
51
- __accessCheck(obj, member, "access private method");
52
- return method;
53
- };
54
32
 
55
33
  // ../types/src/sdk/automations/index.ts
56
34
  var init_automations = __esm({
@@ -671,6 +649,13 @@ var init_permissions = __esm({
671
649
  }
672
650
  });
673
651
 
652
+ // ../types/src/sdk/row.ts
653
+ var init_row = __esm({
654
+ "../types/src/sdk/row.ts"() {
655
+ "use strict";
656
+ }
657
+ });
658
+
674
659
  // ../types/src/sdk/index.ts
675
660
  var init_sdk = __esm({
676
661
  "../types/src/sdk/index.ts"() {
@@ -696,6 +681,7 @@ var init_sdk = __esm({
696
681
  init_cli();
697
682
  init_websocket();
698
683
  init_permissions();
684
+ init_row();
699
685
  }
700
686
  });
701
687
 
@@ -870,7 +856,7 @@ var init_document = __esm({
870
856
  });
871
857
 
872
858
  // ../types/src/documents/app/row.ts
873
- var init_row = __esm({
859
+ var init_row2 = __esm({
874
860
  "../types/src/documents/app/row.ts"() {
875
861
  "use strict";
876
862
  }
@@ -925,7 +911,7 @@ var init_app3 = __esm({
925
911
  init_screen2();
926
912
  init_view2();
927
913
  init_document();
928
- init_row();
914
+ init_row2();
929
915
  init_user4();
930
916
  init_backup2();
931
917
  init_webhook();
@@ -1211,7 +1197,7 @@ var init_datasource3 = __esm({
1211
1197
  });
1212
1198
 
1213
1199
  // ../types/src/api/web/app/row.ts
1214
- var init_row2 = __esm({
1200
+ var init_row3 = __esm({
1215
1201
  "../types/src/api/web/app/row.ts"() {
1216
1202
  "use strict";
1217
1203
  }
@@ -1244,7 +1230,7 @@ var init_app4 = __esm({
1244
1230
  "use strict";
1245
1231
  init_backup3();
1246
1232
  init_datasource3();
1247
- init_row2();
1233
+ init_row3();
1248
1234
  init_view3();
1249
1235
  init_rows2();
1250
1236
  init_table4();
@@ -1337,6 +1323,13 @@ var init_pagination = __esm({
1337
1323
  }
1338
1324
  });
1339
1325
 
1326
+ // ../types/src/api/web/searchFilter.ts
1327
+ var init_searchFilter = __esm({
1328
+ "../types/src/api/web/searchFilter.ts"() {
1329
+ "use strict";
1330
+ }
1331
+ });
1332
+
1340
1333
  // ../types/src/api/web/index.ts
1341
1334
  var init_web = __esm({
1342
1335
  "../types/src/api/web/index.ts"() {
@@ -1351,6 +1344,7 @@ var init_web = __esm({
1351
1344
  init_app4();
1352
1345
  init_global2();
1353
1346
  init_pagination();
1347
+ init_searchFilter();
1354
1348
  }
1355
1349
  });
1356
1350
 
@@ -1659,12 +1653,15 @@ var init_identity = __esm({
1659
1653
  });
1660
1654
 
1661
1655
  // src/context/Context.ts
1662
- var import_async_hooks, _Context, Context;
1656
+ var import_async_hooks, Context;
1663
1657
  var init_Context = __esm({
1664
1658
  "src/context/Context.ts"() {
1665
1659
  "use strict";
1666
1660
  import_async_hooks = require("async_hooks");
1667
- _Context = class _Context {
1661
+ Context = class _Context {
1662
+ static {
1663
+ this.storage = new import_async_hooks.AsyncLocalStorage();
1664
+ }
1668
1665
  static run(context, func) {
1669
1666
  return _Context.storage.run(context, () => func());
1670
1667
  }
@@ -1672,8 +1669,6 @@ var init_Context = __esm({
1672
1669
  return _Context.storage.getStore();
1673
1670
  }
1674
1671
  };
1675
- _Context.storage = new import_async_hooks.AsyncLocalStorage();
1676
- Context = _Context;
1677
1672
  }
1678
1673
  });
1679
1674
 
@@ -1692,18 +1687,17 @@ var init_connections = __esm({
1692
1687
  "use strict";
1693
1688
  init_environment2();
1694
1689
  getCouchInfo = (connection) => {
1695
- var _a, _b;
1696
1690
  const urlInfo = getUrlInfo(connection);
1697
1691
  let username;
1698
1692
  let password;
1699
- if ((_a = urlInfo.auth) == null ? void 0 : _a.username) {
1693
+ if (urlInfo.auth?.username) {
1700
1694
  username = urlInfo.auth.username;
1701
1695
  } else if (environment_default.COUCH_DB_USERNAME) {
1702
1696
  username = environment_default.COUCH_DB_USERNAME;
1703
1697
  } else if (!environment_default.isTest()) {
1704
1698
  throw new Error("CouchDB username not set");
1705
1699
  }
1706
- if ((_b = urlInfo.auth) == null ? void 0 : _b.password) {
1700
+ if (urlInfo.auth?.password) {
1707
1701
  password = urlInfo.auth.password;
1708
1702
  } else if (environment_default.COUCH_DB_PASSWORD) {
1709
1703
  password = environment_default.COUCH_DB_PASSWORD;
@@ -1896,8 +1890,7 @@ var init_DatabaseImpl = __esm({
1896
1890
  return this.instanceNano || _DatabaseImpl.nano;
1897
1891
  }
1898
1892
  async checkSetup() {
1899
- var _a;
1900
- let shouldCreate = !((_a = this.pouchOpts) == null ? void 0 : _a.skip_setup);
1893
+ let shouldCreate = !this.pouchOpts?.skip_setup;
1901
1894
  let exists = await this.exists();
1902
1895
  if (!shouldCreate && !exists) {
1903
1896
  throw new Error("DB does not exist");
@@ -1973,7 +1966,7 @@ var init_DatabaseImpl = __esm({
1973
1966
  document.createdAt = (/* @__PURE__ */ new Date()).toISOString();
1974
1967
  }
1975
1968
  document.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1976
- if ((opts == null ? void 0 : opts.force) && document._id) {
1969
+ if (opts?.force && document._id) {
1977
1970
  try {
1978
1971
  const existing = await this.get(document._id);
1979
1972
  if (existing) {
@@ -2142,7 +2135,7 @@ async function doInTenant(tenantId, task) {
2142
2135
  function getIdentity() {
2143
2136
  try {
2144
2137
  const context = Context.get();
2145
- return context == null ? void 0 : context.identity;
2138
+ return context?.identity;
2146
2139
  } catch (e) {
2147
2140
  }
2148
2141
  }
@@ -2151,7 +2144,7 @@ function getTenantId() {
2151
2144
  return DEFAULT_TENANT_ID;
2152
2145
  }
2153
2146
  const context = Context.get();
2154
- const tenantId = context == null ? void 0 : context.tenantId;
2147
+ const tenantId = context?.tenantId;
2155
2148
  if (!tenantId) {
2156
2149
  throw new Error("Tenant id not found");
2157
2150
  }
@@ -2159,11 +2152,11 @@ function getTenantId() {
2159
2152
  }
2160
2153
  function getAutomationId() {
2161
2154
  const context = Context.get();
2162
- return context == null ? void 0 : context.automationId;
2155
+ return context?.automationId;
2163
2156
  }
2164
2157
  function getAppId() {
2165
2158
  const context = Context.get();
2166
- const foundId = context == null ? void 0 : context.appId;
2159
+ const foundId = context?.appId;
2167
2160
  if (!foundId && environment_default.isTest() && TEST_APP_ID) {
2168
2161
  return TEST_APP_ID;
2169
2162
  } else {
@@ -2175,11 +2168,11 @@ function getGlobalDB() {
2175
2168
  if (!context || environment_default.MULTI_TENANCY && !context.tenantId) {
2176
2169
  throw new Error("Global DB not found");
2177
2170
  }
2178
- return getDB(baseGlobalDBName(context == null ? void 0 : context.tenantId));
2171
+ return getDB(baseGlobalDBName(context?.tenantId));
2179
2172
  }
2180
2173
  function isScim() {
2181
2174
  const context = Context.get();
2182
- const scimCall = context == null ? void 0 : context.isScim;
2175
+ const scimCall = context?.isScim;
2183
2176
  return !!scimCall;
2184
2177
  }
2185
2178
  var TEST_APP_ID;
@@ -2850,38 +2843,34 @@ async function runQuery(url, body, cookie) {
2850
2843
  }
2851
2844
  return output;
2852
2845
  }
2853
- var import_node_fetch2, QUERY_START_REGEX, _dbName, _index, _query, _limit, _sort, _bookmark, _sortOrder, _sortType, _includeDocs, _version, _indexBuilder, _noEscaping, _skip, _skipItems, skipItems_fn, _execute, execute_fn, _QueryBuilder, QueryBuilder;
2846
+ var import_node_fetch2, QUERY_START_REGEX, QueryBuilder;
2854
2847
  var init_lucene = __esm({
2855
2848
  "src/db/lucene.ts"() {
2856
2849
  "use strict";
2857
2850
  import_node_fetch2 = __toESM(require("node-fetch"));
2858
2851
  init_couch();
2859
2852
  QUERY_START_REGEX = /\d[0-9]*:/g;
2860
- _QueryBuilder = class _QueryBuilder {
2853
+ QueryBuilder = class _QueryBuilder {
2854
+ #dbName;
2855
+ #index;
2856
+ #query;
2857
+ #limit;
2858
+ #sort;
2859
+ #bookmark;
2860
+ #sortOrder;
2861
+ #sortType;
2862
+ #includeDocs;
2863
+ #version;
2864
+ #indexBuilder;
2865
+ #noEscaping = false;
2866
+ #skip;
2867
+ static {
2868
+ this.maxLimit = 200;
2869
+ }
2861
2870
  constructor(dbName, index2, base) {
2862
- /**
2863
- * Lucene queries do not support pagination and use bookmarks instead.
2864
- * For the given builder, walk through pages using bookmarks until the desired
2865
- * page has been met.
2866
- */
2867
- __privateAdd(this, _skipItems);
2868
- __privateAdd(this, _execute);
2869
- __privateAdd(this, _dbName, void 0);
2870
- __privateAdd(this, _index, void 0);
2871
- __privateAdd(this, _query, void 0);
2872
- __privateAdd(this, _limit, void 0);
2873
- __privateAdd(this, _sort, void 0);
2874
- __privateAdd(this, _bookmark, void 0);
2875
- __privateAdd(this, _sortOrder, void 0);
2876
- __privateAdd(this, _sortType, void 0);
2877
- __privateAdd(this, _includeDocs, void 0);
2878
- __privateAdd(this, _version, void 0);
2879
- __privateAdd(this, _indexBuilder, void 0);
2880
- __privateAdd(this, _noEscaping, false);
2881
- __privateAdd(this, _skip, void 0);
2882
- __privateSet(this, _dbName, dbName);
2883
- __privateSet(this, _index, index2);
2884
- __privateSet(this, _query, {
2871
+ this.#dbName = dbName;
2872
+ this.#index = index2;
2873
+ this.#query = {
2885
2874
  allOr: false,
2886
2875
  string: {},
2887
2876
  fuzzy: {},
@@ -2895,124 +2884,124 @@ var init_lucene = __esm({
2895
2884
  notContains: {},
2896
2885
  containsAny: {},
2897
2886
  ...base
2898
- });
2899
- __privateSet(this, _limit, 50);
2900
- __privateSet(this, _sortOrder, "ascending");
2901
- __privateSet(this, _sortType, "string");
2902
- __privateSet(this, _includeDocs, true);
2887
+ };
2888
+ this.#limit = 50;
2889
+ this.#sortOrder = "ascending";
2890
+ this.#sortType = "string";
2891
+ this.#includeDocs = true;
2903
2892
  }
2904
2893
  disableEscaping() {
2905
- __privateSet(this, _noEscaping, true);
2894
+ this.#noEscaping = true;
2906
2895
  return this;
2907
2896
  }
2908
2897
  setIndexBuilder(builderFn) {
2909
- __privateSet(this, _indexBuilder, builderFn);
2898
+ this.#indexBuilder = builderFn;
2910
2899
  return this;
2911
2900
  }
2912
2901
  setVersion(version) {
2913
2902
  if (version != null) {
2914
- __privateSet(this, _version, version);
2903
+ this.#version = version;
2915
2904
  }
2916
2905
  return this;
2917
2906
  }
2918
2907
  setTable(tableId) {
2919
- __privateGet(this, _query).equal.tableId = tableId;
2908
+ this.#query.equal.tableId = tableId;
2920
2909
  return this;
2921
2910
  }
2922
2911
  setLimit(limit) {
2923
2912
  if (limit != null) {
2924
- __privateSet(this, _limit, limit);
2913
+ this.#limit = limit;
2925
2914
  }
2926
2915
  return this;
2927
2916
  }
2928
2917
  setSort(sort) {
2929
2918
  if (sort != null) {
2930
- __privateSet(this, _sort, sort);
2919
+ this.#sort = sort;
2931
2920
  }
2932
2921
  return this;
2933
2922
  }
2934
2923
  setSortOrder(sortOrder) {
2935
2924
  if (sortOrder != null) {
2936
- __privateSet(this, _sortOrder, sortOrder);
2925
+ this.#sortOrder = sortOrder;
2937
2926
  }
2938
2927
  return this;
2939
2928
  }
2940
2929
  setSortType(sortType) {
2941
2930
  if (sortType != null) {
2942
- __privateSet(this, _sortType, sortType);
2931
+ this.#sortType = sortType;
2943
2932
  }
2944
2933
  return this;
2945
2934
  }
2946
2935
  setBookmark(bookmark) {
2947
2936
  if (bookmark != null) {
2948
- __privateSet(this, _bookmark, bookmark);
2937
+ this.#bookmark = bookmark;
2949
2938
  }
2950
2939
  return this;
2951
2940
  }
2952
2941
  setSkip(skip) {
2953
- __privateSet(this, _skip, skip);
2942
+ this.#skip = skip;
2954
2943
  return this;
2955
2944
  }
2956
2945
  excludeDocs() {
2957
- __privateSet(this, _includeDocs, false);
2946
+ this.#includeDocs = false;
2958
2947
  return this;
2959
2948
  }
2960
2949
  includeDocs() {
2961
- __privateSet(this, _includeDocs, true);
2950
+ this.#includeDocs = true;
2962
2951
  return this;
2963
2952
  }
2964
2953
  addString(key, partial) {
2965
- __privateGet(this, _query).string[key] = partial;
2954
+ this.#query.string[key] = partial;
2966
2955
  return this;
2967
2956
  }
2968
2957
  addFuzzy(key, fuzzy) {
2969
- __privateGet(this, _query).fuzzy[key] = fuzzy;
2958
+ this.#query.fuzzy[key] = fuzzy;
2970
2959
  return this;
2971
2960
  }
2972
2961
  addRange(key, low, high) {
2973
- __privateGet(this, _query).range[key] = {
2962
+ this.#query.range[key] = {
2974
2963
  low,
2975
2964
  high
2976
2965
  };
2977
2966
  return this;
2978
2967
  }
2979
2968
  addEqual(key, value) {
2980
- __privateGet(this, _query).equal[key] = value;
2969
+ this.#query.equal[key] = value;
2981
2970
  return this;
2982
2971
  }
2983
2972
  addNotEqual(key, value) {
2984
- __privateGet(this, _query).notEqual[key] = value;
2973
+ this.#query.notEqual[key] = value;
2985
2974
  return this;
2986
2975
  }
2987
2976
  addEmpty(key, value) {
2988
- __privateGet(this, _query).empty[key] = value;
2977
+ this.#query.empty[key] = value;
2989
2978
  return this;
2990
2979
  }
2991
2980
  addNotEmpty(key, value) {
2992
- __privateGet(this, _query).notEmpty[key] = value;
2981
+ this.#query.notEmpty[key] = value;
2993
2982
  return this;
2994
2983
  }
2995
2984
  addOneOf(key, value) {
2996
- __privateGet(this, _query).oneOf[key] = value;
2985
+ this.#query.oneOf[key] = value;
2997
2986
  return this;
2998
2987
  }
2999
2988
  addContains(key, value) {
3000
- __privateGet(this, _query).contains[key] = value;
2989
+ this.#query.contains[key] = value;
3001
2990
  return this;
3002
2991
  }
3003
2992
  addNotContains(key, value) {
3004
- __privateGet(this, _query).notContains[key] = value;
2993
+ this.#query.notContains[key] = value;
3005
2994
  return this;
3006
2995
  }
3007
2996
  addContainsAny(key, value) {
3008
- __privateGet(this, _query).containsAny[key] = value;
2997
+ this.#query.containsAny[key] = value;
3009
2998
  return this;
3010
2999
  }
3011
3000
  setAllOr() {
3012
- __privateGet(this, _query).allOr = true;
3001
+ this.#query.allOr = true;
3013
3002
  }
3014
3003
  handleSpaces(input) {
3015
- if (__privateGet(this, _noEscaping)) {
3004
+ if (this.#noEscaping) {
3016
3005
  return input;
3017
3006
  } else {
3018
3007
  return input.replace(/ /g, "_");
@@ -3026,12 +3015,12 @@ var init_lucene = __esm({
3026
3015
  * @returns {string|*}
3027
3016
  */
3028
3017
  preprocess(value, { escape, lowercase, wrap, type } = {}) {
3029
- const hasVersion = !!__privateGet(this, _version);
3018
+ const hasVersion = !!this.#version;
3030
3019
  const originalType = typeof value;
3031
3020
  if (value && lowercase) {
3032
3021
  value = value.toLowerCase ? value.toLowerCase() : value;
3033
3022
  }
3034
- if (!__privateGet(this, _noEscaping) && escape && originalType === "string") {
3023
+ if (!this.#noEscaping && escape && originalType === "string") {
3035
3024
  value = `${value}`.replace(/[ \/#+\-&|!(){}\]^"~*?:\\]/g, "\\$&");
3036
3025
  }
3037
3026
  if (originalType === "string" && !isNaN(value) && !type) {
@@ -3043,7 +3032,7 @@ var init_lucene = __esm({
3043
3032
  }
3044
3033
  isMultiCondition() {
3045
3034
  let count = 0;
3046
- for (let filters of Object.values(__privateGet(this, _query))) {
3035
+ for (let filters of Object.values(this.#query)) {
3047
3036
  if (typeof filters === "object") {
3048
3037
  count += Object.keys(filters).length;
3049
3038
  }
@@ -3069,13 +3058,13 @@ var init_lucene = __esm({
3069
3058
  }
3070
3059
  buildSearchQuery() {
3071
3060
  const builder = this;
3072
- let allOr = __privateGet(this, _query) && __privateGet(this, _query).allOr;
3061
+ let allOr = this.#query && this.#query.allOr;
3073
3062
  let query = allOr ? "" : "*:*";
3074
3063
  const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
3075
3064
  let tableId;
3076
- if (__privateGet(this, _query).equal.tableId) {
3077
- tableId = __privateGet(this, _query).equal.tableId;
3078
- delete __privateGet(this, _query).equal.tableId;
3065
+ if (this.#query.equal.tableId) {
3066
+ tableId = this.#query.equal.tableId;
3067
+ delete this.#query.equal.tableId;
3079
3068
  }
3080
3069
  const equal = (key, value) => {
3081
3070
  if (!value && value !== 0) {
@@ -3149,19 +3138,19 @@ var init_lucene = __esm({
3149
3138
  continue;
3150
3139
  }
3151
3140
  if (built.length > 0 || query.length > 0) {
3152
- const mode = (opts == null ? void 0 : opts.mode) ? opts.mode : allOr ? "OR" : "AND";
3141
+ const mode = opts?.mode ? opts.mode : allOr ? "OR" : "AND";
3153
3142
  built += ` ${mode} `;
3154
3143
  }
3155
3144
  built += expression;
3156
3145
  }
3157
- if (opts == null ? void 0 : opts.returnBuilt) {
3146
+ if (opts?.returnBuilt) {
3158
3147
  return built;
3159
3148
  } else {
3160
3149
  query += built;
3161
3150
  }
3162
3151
  }
3163
- if (__privateGet(this, _query).string) {
3164
- build(__privateGet(this, _query).string, (key, value) => {
3152
+ if (this.#query.string) {
3153
+ build(this.#query.string, (key, value) => {
3165
3154
  if (!value) {
3166
3155
  return null;
3167
3156
  }
@@ -3173,8 +3162,8 @@ var init_lucene = __esm({
3173
3162
  return `${key}:${value}*`;
3174
3163
  });
3175
3164
  }
3176
- if (__privateGet(this, _query).range) {
3177
- build(__privateGet(this, _query).range, (key, value) => {
3165
+ if (this.#query.range) {
3166
+ build(this.#query.range, (key, value) => {
3178
3167
  if (!value) {
3179
3168
  return null;
3180
3169
  }
@@ -3189,14 +3178,14 @@ var init_lucene = __esm({
3189
3178
  return `${key}:[${low} TO ${high}]`;
3190
3179
  });
3191
3180
  }
3192
- if (__privateGet(this, _query).fuzzy) {
3193
- build(__privateGet(this, _query).fuzzy, fuzzy);
3181
+ if (this.#query.fuzzy) {
3182
+ build(this.#query.fuzzy, fuzzy);
3194
3183
  }
3195
- if (__privateGet(this, _query).equal) {
3196
- build(__privateGet(this, _query).equal, equal);
3184
+ if (this.#query.equal) {
3185
+ build(this.#query.equal, equal);
3197
3186
  }
3198
- if (__privateGet(this, _query).notEqual) {
3199
- build(__privateGet(this, _query).notEqual, (key, value) => {
3187
+ if (this.#query.notEqual) {
3188
+ build(this.#query.notEqual, (key, value) => {
3200
3189
  if (!value) {
3201
3190
  return null;
3202
3191
  }
@@ -3206,23 +3195,23 @@ var init_lucene = __esm({
3206
3195
  return `!${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
3207
3196
  });
3208
3197
  }
3209
- if (__privateGet(this, _query).empty) {
3210
- build(__privateGet(this, _query).empty, (key) => `(*:* -${key}:["" TO *])`);
3198
+ if (this.#query.empty) {
3199
+ build(this.#query.empty, (key) => `(*:* -${key}:["" TO *])`);
3211
3200
  }
3212
- if (__privateGet(this, _query).notEmpty) {
3213
- build(__privateGet(this, _query).notEmpty, (key) => `${key}:["" TO *]`);
3201
+ if (this.#query.notEmpty) {
3202
+ build(this.#query.notEmpty, (key) => `${key}:["" TO *]`);
3214
3203
  }
3215
- if (__privateGet(this, _query).oneOf) {
3216
- build(__privateGet(this, _query).oneOf, oneOf);
3204
+ if (this.#query.oneOf) {
3205
+ build(this.#query.oneOf, oneOf);
3217
3206
  }
3218
- if (__privateGet(this, _query).contains) {
3219
- build(__privateGet(this, _query).contains, contains);
3207
+ if (this.#query.contains) {
3208
+ build(this.#query.contains, contains);
3220
3209
  }
3221
- if (__privateGet(this, _query).notContains) {
3222
- build(this.compressFilters(__privateGet(this, _query).notContains), notContains);
3210
+ if (this.#query.notContains) {
3211
+ build(this.compressFilters(this.#query.notContains), notContains);
3223
3212
  }
3224
- if (__privateGet(this, _query).containsAny) {
3225
- build(__privateGet(this, _query).containsAny, containsAny);
3213
+ if (this.#query.containsAny) {
3214
+ build(this.#query.containsAny, containsAny);
3226
3215
  }
3227
3216
  if (tableId) {
3228
3217
  query = this.isMultiCondition() ? `(${query})` : query;
@@ -3234,75 +3223,63 @@ var init_lucene = __esm({
3234
3223
  buildSearchBody() {
3235
3224
  let body = {
3236
3225
  q: this.buildSearchQuery(),
3237
- limit: Math.min(__privateGet(this, _limit), _QueryBuilder.maxLimit),
3238
- include_docs: __privateGet(this, _includeDocs)
3226
+ limit: Math.min(this.#limit, _QueryBuilder.maxLimit),
3227
+ include_docs: this.#includeDocs
3239
3228
  };
3240
- if (__privateGet(this, _bookmark)) {
3241
- body.bookmark = __privateGet(this, _bookmark);
3229
+ if (this.#bookmark) {
3230
+ body.bookmark = this.#bookmark;
3242
3231
  }
3243
- if (__privateGet(this, _sort)) {
3244
- const order = __privateGet(this, _sortOrder) === "descending" ? "-" : "";
3245
- const type = `<${__privateGet(this, _sortType)}>`;
3246
- body.sort = `${order}${this.handleSpaces(__privateGet(this, _sort))}${type}`;
3232
+ if (this.#sort) {
3233
+ const order = this.#sortOrder === "descending" ? "-" : "";
3234
+ const type = `<${this.#sortType}>`;
3235
+ body.sort = `${order}${this.handleSpaces(this.#sort)}${type}`;
3247
3236
  }
3248
3237
  return body;
3249
3238
  }
3250
3239
  async run() {
3251
- if (__privateGet(this, _skip)) {
3252
- await __privateMethod(this, _skipItems, skipItems_fn).call(this, __privateGet(this, _skip));
3240
+ if (this.#skip) {
3241
+ await this.#skipItems(this.#skip);
3253
3242
  }
3254
- return await __privateMethod(this, _execute, execute_fn).call(this);
3243
+ return await this.#execute();
3255
3244
  }
3256
- };
3257
- _dbName = new WeakMap();
3258
- _index = new WeakMap();
3259
- _query = new WeakMap();
3260
- _limit = new WeakMap();
3261
- _sort = new WeakMap();
3262
- _bookmark = new WeakMap();
3263
- _sortOrder = new WeakMap();
3264
- _sortType = new WeakMap();
3265
- _includeDocs = new WeakMap();
3266
- _version = new WeakMap();
3267
- _indexBuilder = new WeakMap();
3268
- _noEscaping = new WeakMap();
3269
- _skip = new WeakMap();
3270
- _skipItems = new WeakSet();
3271
- skipItems_fn = async function(skip) {
3272
- const prevIncludeDocs = __privateGet(this, _includeDocs);
3273
- const prevLimit = __privateGet(this, _limit);
3274
- this.excludeDocs();
3275
- let skipRemaining = skip;
3276
- let iterationFetched = 0;
3277
- do {
3278
- const toSkip = Math.min(_QueryBuilder.maxLimit, skipRemaining);
3279
- this.setLimit(toSkip);
3280
- const { bookmark, rows } = await __privateMethod(this, _execute, execute_fn).call(this);
3281
- this.setBookmark(bookmark);
3282
- iterationFetched = rows.length;
3283
- skipRemaining -= rows.length;
3284
- } while (skipRemaining > 0 && iterationFetched > 0);
3285
- __privateSet(this, _includeDocs, prevIncludeDocs);
3286
- __privateSet(this, _limit, prevLimit);
3287
- };
3288
- _execute = new WeakSet();
3289
- execute_fn = async function() {
3290
- const { url, cookie } = getCouchInfo();
3291
- const fullPath = `${url}/${__privateGet(this, _dbName)}/_design/database/_search/${__privateGet(this, _index)}`;
3292
- const body = this.buildSearchBody();
3293
- try {
3294
- return await runQuery(fullPath, body, cookie);
3295
- } catch (err) {
3296
- if (err.status === 404 && __privateGet(this, _indexBuilder)) {
3297
- await __privateGet(this, _indexBuilder).call(this);
3245
+ /**
3246
+ * Lucene queries do not support pagination and use bookmarks instead.
3247
+ * For the given builder, walk through pages using bookmarks until the desired
3248
+ * page has been met.
3249
+ */
3250
+ async #skipItems(skip) {
3251
+ const prevIncludeDocs = this.#includeDocs;
3252
+ const prevLimit = this.#limit;
3253
+ this.excludeDocs();
3254
+ let skipRemaining = skip;
3255
+ let iterationFetched = 0;
3256
+ do {
3257
+ const toSkip = Math.min(_QueryBuilder.maxLimit, skipRemaining);
3258
+ this.setLimit(toSkip);
3259
+ const { bookmark, rows } = await this.#execute();
3260
+ this.setBookmark(bookmark);
3261
+ iterationFetched = rows.length;
3262
+ skipRemaining -= rows.length;
3263
+ } while (skipRemaining > 0 && iterationFetched > 0);
3264
+ this.#includeDocs = prevIncludeDocs;
3265
+ this.#limit = prevLimit;
3266
+ }
3267
+ async #execute() {
3268
+ const { url, cookie } = getCouchInfo();
3269
+ const fullPath = `${url}/${this.#dbName}/_design/database/_search/${this.#index}`;
3270
+ const body = this.buildSearchBody();
3271
+ try {
3298
3272
  return await runQuery(fullPath, body, cookie);
3299
- } else {
3300
- throw err;
3273
+ } catch (err) {
3274
+ if (err.status === 404 && this.#indexBuilder) {
3275
+ await this.#indexBuilder();
3276
+ return await runQuery(fullPath, body, cookie);
3277
+ } else {
3278
+ throw err;
3279
+ }
3301
3280
  }
3302
3281
  }
3303
3282
  };
3304
- _QueryBuilder.maxLimit = 200;
3305
- QueryBuilder = _QueryBuilder;
3306
3283
  }
3307
3284
  });
3308
3285
 
@@ -3455,7 +3432,7 @@ function getFullPath(fileName) {
3455
3432
  }
3456
3433
  function getSingleFileMaxSizeInfo(totalMaxSize) {
3457
3434
  const regex = /(\d+)([A-Za-z])/;
3458
- const match = totalMaxSize == null ? void 0 : totalMaxSize.match(regex);
3435
+ const match = totalMaxSize?.match(regex);
3459
3436
  if (!match) {
3460
3437
  console.warn(`totalMaxSize does not have a valid value`, {
3461
3438
  totalMaxSize
@@ -3487,9 +3464,9 @@ function localFileDestination() {
3487
3464
  const fileInfo = getSingleFileMaxSizeInfo(environment_default.ROLLING_LOG_MAX_SIZE);
3488
3465
  const outFile = rfs.createStream(logsFileName, {
3489
3466
  // As we have a rolling size, we want to half the max size
3490
- size: fileInfo == null ? void 0 : fileInfo.size,
3467
+ size: fileInfo?.size,
3491
3468
  path: logsPath,
3492
- maxFiles: (fileInfo == null ? void 0 : fileInfo.totalHistoryFiles) || 1,
3469
+ maxFiles: fileInfo?.totalHistoryFiles || 1,
3493
3470
  immutable: true,
3494
3471
  history: budibaseLogsHistoryFileName,
3495
3472
  initialRotation: false
@@ -3564,8 +3541,8 @@ var init_logger = __esm({
3564
3541
  tenantId: getTenantId2(),
3565
3542
  appId: getAppId2(),
3566
3543
  automationId: getAutomationId2(),
3567
- identityId: identity == null ? void 0 : identity._id,
3568
- identityType: identity == null ? void 0 : identity.type,
3544
+ identityId: identity?._id,
3545
+ identityType: identity?.type,
3569
3546
  correlationId: getId()
3570
3547
  };
3571
3548
  const mergingObject = {
@@ -3629,30 +3606,30 @@ var init_logger = __esm({
3629
3606
  pinoInstance = destinations.length ? (0, import_pino.default)(pinoOptions, import_pino.default.multistream(destinations)) : (0, import_pino.default)(pinoOptions);
3630
3607
  console.log = (...arg) => {
3631
3608
  const [obj, msg] = getLogParams2(arg);
3632
- pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
3609
+ pinoInstance?.info(obj, msg);
3633
3610
  };
3634
3611
  console.info = (...arg) => {
3635
3612
  const [obj, msg] = getLogParams2(arg);
3636
- pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
3613
+ pinoInstance?.info(obj, msg);
3637
3614
  };
3638
3615
  console.warn = (...arg) => {
3639
3616
  const [obj, msg] = getLogParams2(arg);
3640
- pinoInstance == null ? void 0 : pinoInstance.warn(obj, msg);
3617
+ pinoInstance?.warn(obj, msg);
3641
3618
  };
3642
3619
  console.error = (...arg) => {
3643
3620
  const [obj, msg] = getLogParams2(arg);
3644
- pinoInstance == null ? void 0 : pinoInstance.error(obj, msg);
3621
+ pinoInstance?.error(obj, msg);
3645
3622
  };
3646
3623
  console.trace = (...arg) => {
3647
3624
  const [obj, msg] = getLogParams2(arg);
3648
3625
  if (!obj.err) {
3649
3626
  obj.err = new Error();
3650
3627
  }
3651
- pinoInstance == null ? void 0 : pinoInstance.trace(obj, msg);
3628
+ pinoInstance?.trace(obj, msg);
3652
3629
  };
3653
3630
  console.debug = (...arg) => {
3654
3631
  const [obj, msg] = getLogParams2(arg);
3655
- pinoInstance == null ? void 0 : pinoInstance.debug(obj, msg);
3632
+ pinoInstance?.debug(obj, msg);
3656
3633
  };
3657
3634
  const getTenantId2 = () => {
3658
3635
  let tenantId;
@@ -4138,7 +4115,6 @@ async function getSettingsConfigDoc() {
4138
4115
  async function getPlatformUrl(opts = {
4139
4116
  tenantAware: true
4140
4117
  }) {
4141
- var _a;
4142
4118
  let platformUrl = environment_default.PLATFORM_URL || "http://localhost:10000";
4143
4119
  if (!environment_default.SELF_HOSTED && environment_default.MULTI_TENANCY && opts.tenantAware) {
4144
4120
  const tenantId = getTenantId();
@@ -4146,11 +4122,11 @@ async function getPlatformUrl(opts = {
4146
4122
  platformUrl = platformUrl.replace("://", `://${tenantId}.`);
4147
4123
  }
4148
4124
  } else if (environment_default.SELF_HOSTED) {
4149
- const config = (opts == null ? void 0 : opts.config) ? opts.config : (
4125
+ const config = opts?.config ? opts.config : (
4150
4126
  // direct to db to prevent infinite loop
4151
- (_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
4127
+ (await getConfig("settings" /* SETTINGS */))?.config
4152
4128
  );
4153
- if (config == null ? void 0 : config.platformUrl) {
4129
+ if (config?.platformUrl) {
4154
4130
  platformUrl = config.platformUrl;
4155
4131
  }
4156
4132
  }
@@ -4174,14 +4150,13 @@ var init_configs2 = __esm({
4174
4150
  "analyticsEnabled" /* ANALYTICS_ENABLED */,
4175
4151
  86400 /* ONE_DAY */,
4176
4152
  async () => {
4177
- var _a;
4178
- const config = (opts == null ? void 0 : opts.config) ? opts.config : (
4153
+ const config = opts?.config ? opts.config : (
4179
4154
  // direct to db to prevent infinite loop
4180
- (_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
4155
+ (await getConfig("settings" /* SETTINGS */))?.config
4181
4156
  );
4182
- if ((config == null ? void 0 : config.analyticsEnabled) === false) {
4157
+ if (config?.analyticsEnabled === false) {
4183
4158
  return false;
4184
- } else if ((config == null ? void 0 : config.analyticsEnabled) === true) {
4159
+ } else if (config?.analyticsEnabled === true) {
4185
4160
  return true;
4186
4161
  }
4187
4162
  }
@@ -4683,7 +4658,6 @@ function handleStalled(queue, removeStalledCb) {
4683
4658
  });
4684
4659
  }
4685
4660
  function getLogParams(eventType, event, opts = {}, extra = {}) {
4686
- var _a, _b, _c;
4687
4661
  const message = `[BULL] ${eventType}=${event}`;
4688
4662
  const err = opts.error;
4689
4663
  const bullLog = {
@@ -4691,11 +4665,11 @@ function getLogParams(eventType, event, opts = {}, extra = {}) {
4691
4665
  eventType,
4692
4666
  event,
4693
4667
  job: opts.job,
4694
- jobId: opts.jobId || ((_a = opts.job) == null ? void 0 : _a.id),
4668
+ jobId: opts.jobId || opts.job?.id,
4695
4669
  ...extra
4696
4670
  };
4697
4671
  let automationLog;
4698
- if ((_c = (_b = opts.job) == null ? void 0 : _b.data) == null ? void 0 : _c.automation) {
4672
+ if (opts.job?.data?.automation) {
4699
4673
  automationLog = {
4700
4674
  _logKey: "automation",
4701
4675
  trigger: opts.job ? opts.job.data.automation.definition.trigger.event : void 0
@@ -4704,11 +4678,9 @@ function getLogParams(eventType, event, opts = {}, extra = {}) {
4704
4678
  return [message, err, bullLog, automationLog];
4705
4679
  }
4706
4680
  function logging(queue, jobQueue) {
4707
- var _a;
4708
4681
  const eventType = EventTypeMap[jobQueue];
4709
4682
  function doInJobContext(job, task) {
4710
- var _a2;
4711
- const appId = (_a2 = job.data.event) == null ? void 0 : _a2.appId;
4683
+ const appId = job.data.event?.appId;
4712
4684
  if (appId) {
4713
4685
  return doInContext(appId, task);
4714
4686
  } else {
@@ -4722,7 +4694,7 @@ function logging(queue, jobQueue) {
4722
4694
  }).on("error" /* ERROR */, (error) => {
4723
4695
  console.error(...getLogParams(eventType, "error" /* ERROR */, { error }));
4724
4696
  });
4725
- if ((_a = process.env.NODE_DEBUG) == null ? void 0 : _a.includes("bull")) {
4697
+ if (process.env.NODE_DEBUG?.includes("bull")) {
4726
4698
  queue.on("waiting" /* WAITING */, (jobId) => {
4727
4699
  console.info(...getLogParams(eventType, "waiting" /* WAITING */, { jobId }));
4728
4700
  }).on("active" /* ACTIVE */, async (job, jobPromise) => {
@@ -4802,7 +4774,7 @@ function createQueue(jobQueue, opts = {}) {
4802
4774
  } else {
4803
4775
  queue = new inMemoryQueue_default(jobQueue, queueConfig);
4804
4776
  }
4805
- addListeners(queue, jobQueue, opts == null ? void 0 : opts.removeStalledCb);
4777
+ addListeners(queue, jobQueue, opts?.removeStalledCb);
4806
4778
  QUEUES.push(queue);
4807
4779
  if (!cleanupInterval && !environment_default.isTest()) {
4808
4780
  cleanupInterval = set(cleanup, CLEANUP_PERIOD_MS);
@@ -4837,7 +4809,7 @@ var init_queue2 = __esm({
4837
4809
  });
4838
4810
 
4839
4811
  // src/events/processors/AuditLogsProcessor.ts
4840
- var _AuditLogsProcessor, AuditLogsProcessor;
4812
+ var AuditLogsProcessor;
4841
4813
  var init_AuditLogsProcessor = __esm({
4842
4814
  "src/events/processors/AuditLogsProcessor.ts"() {
4843
4815
  "use strict";
@@ -4846,7 +4818,10 @@ var init_AuditLogsProcessor = __esm({
4846
4818
  init_queue2();
4847
4819
  init_utils6();
4848
4820
  init_environment2();
4849
- _AuditLogsProcessor = class _AuditLogsProcessor {
4821
+ AuditLogsProcessor = class _AuditLogsProcessor {
4822
+ static {
4823
+ this.auditLogsEnabled = false;
4824
+ }
4850
4825
  // can't use constructor as need to return promise
4851
4826
  static init(fn) {
4852
4827
  _AuditLogsProcessor.auditLogsEnabled = true;
@@ -4898,12 +4873,9 @@ var init_AuditLogsProcessor = __esm({
4898
4873
  async identifyGroup(group, timestamp) {
4899
4874
  }
4900
4875
  shutdown() {
4901
- var _a;
4902
- (_a = _AuditLogsProcessor.auditLogQueue) == null ? void 0 : _a.close();
4876
+ _AuditLogsProcessor.auditLogQueue?.close();
4903
4877
  }
4904
4878
  };
4905
- _AuditLogsProcessor.auditLogsEnabled = false;
4906
- AuditLogsProcessor = _AuditLogsProcessor;
4907
4879
  }
4908
4880
  });
4909
4881
 
@@ -5231,13 +5203,12 @@ __export(users_exports2, {
5231
5203
  isGlobalBuilder: () => isGlobalBuilder
5232
5204
  });
5233
5205
  function isBuilder(user2, appId) {
5234
- var _a, _b, _c;
5235
5206
  if (!user2) {
5236
5207
  return false;
5237
5208
  }
5238
- if ((_a = user2.builder) == null ? void 0 : _a.global) {
5209
+ if (user2.builder?.global) {
5239
5210
  return true;
5240
- } else if (appId && ((_c = (_b = user2.builder) == null ? void 0 : _b.apps) == null ? void 0 : _c.includes(getProdAppID2(appId)))) {
5211
+ } else if (appId && user2.builder?.apps?.includes(getProdAppID2(appId))) {
5241
5212
  return true;
5242
5213
  }
5243
5214
  return false;
@@ -5255,27 +5226,24 @@ function isAdminOrBuilder(user2, appId) {
5255
5226
  return isBuilder(user2, appId) || isAdmin(user2);
5256
5227
  }
5257
5228
  function hasAppBuilderPermissions(user2) {
5258
- var _a, _b, _c;
5259
5229
  if (!user2) {
5260
5230
  return false;
5261
5231
  }
5262
- const appLength = (_b = (_a = user2.builder) == null ? void 0 : _a.apps) == null ? void 0 : _b.length;
5263
- const isGlobalBuilder3 = !!((_c = user2.builder) == null ? void 0 : _c.global);
5232
+ const appLength = user2.builder?.apps?.length;
5233
+ const isGlobalBuilder3 = !!user2.builder?.global;
5264
5234
  return !isGlobalBuilder3 && appLength != null && appLength > 0;
5265
5235
  }
5266
5236
  function hasBuilderPermissions(user2) {
5267
- var _a;
5268
5237
  if (!user2) {
5269
5238
  return false;
5270
5239
  }
5271
- return ((_a = user2.builder) == null ? void 0 : _a.global) || hasAppBuilderPermissions(user2);
5240
+ return user2.builder?.global || hasAppBuilderPermissions(user2);
5272
5241
  }
5273
5242
  function hasAdminPermissions(user2) {
5274
- var _a;
5275
5243
  if (!user2) {
5276
5244
  return false;
5277
5245
  }
5278
- return !!((_a = user2.admin) == null ? void 0 : _a.global);
5246
+ return !!user2.admin?.global;
5279
5247
  }
5280
5248
  var init_users5 = __esm({
5281
5249
  "../shared-core/src/sdk/documents/users.ts"() {
@@ -5523,8 +5491,8 @@ var init_identification2 = __esm({
5523
5491
  if (isSSOUser(user2)) {
5524
5492
  providerType3 = user2.providerType;
5525
5493
  }
5526
- const accountHolder = (account2 == null ? void 0 : account2.budibaseUserId) === user2._id || false;
5527
- const verified2 = account2 && (account2 == null ? void 0 : account2.budibaseUserId) === user2._id ? account2.verified : false;
5494
+ const accountHolder = account2?.budibaseUserId === user2._id || false;
5495
+ const verified2 = account2 && account2?.budibaseUserId === user2._id ? account2.verified : false;
5528
5496
  const installationId = await getInstallationId();
5529
5497
  const hosting = account2 ? account2.hosting : getHostingFromEnv();
5530
5498
  const environment2 = getDeploymentEnvironment();
@@ -5691,7 +5659,7 @@ var init_backfill2 = __esm({
5691
5659
  };
5692
5660
  isBackfillingEvent = async (event) => {
5693
5661
  const backfill = await getBackfillMetadata();
5694
- const events2 = backfill == null ? void 0 : backfill.eventWhitelist;
5662
+ const events2 = backfill?.eventWhitelist;
5695
5663
  if (events2 && events2.includes(event)) {
5696
5664
  return true;
5697
5665
  } else {
@@ -6084,12 +6052,11 @@ var init_auth4 = __esm({
6084
6052
 
6085
6053
  // src/events/publishers/automation.ts
6086
6054
  async function created3(automation, timestamp) {
6087
- var _a, _b, _c, _d;
6088
6055
  const properties = {
6089
6056
  appId: automation.appId,
6090
6057
  automationId: automation._id,
6091
- triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
6092
- triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
6058
+ triggerId: automation.definition?.trigger?.id,
6059
+ triggerType: automation.definition?.trigger?.stepId,
6093
6060
  audited: {
6094
6061
  name: automation.name
6095
6062
  }
@@ -6097,22 +6064,20 @@ async function created3(automation, timestamp) {
6097
6064
  await publishEvent("automation:created" /* AUTOMATION_CREATED */, properties, timestamp);
6098
6065
  }
6099
6066
  async function triggerUpdated(automation) {
6100
- var _a, _b, _c, _d;
6101
6067
  const properties = {
6102
6068
  appId: automation.appId,
6103
6069
  automationId: automation._id,
6104
- triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
6105
- triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId
6070
+ triggerId: automation.definition?.trigger?.id,
6071
+ triggerType: automation.definition?.trigger?.stepId
6106
6072
  };
6107
6073
  await publishEvent("automation:trigger:updated" /* AUTOMATION_TRIGGER_UPDATED */, properties);
6108
6074
  }
6109
6075
  async function deleted3(automation) {
6110
- var _a, _b, _c, _d;
6111
6076
  const properties = {
6112
6077
  appId: automation.appId,
6113
6078
  automationId: automation._id,
6114
- triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
6115
- triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
6079
+ triggerId: automation.definition?.trigger?.id,
6080
+ triggerType: automation.definition?.trigger?.stepId,
6116
6081
  audited: {
6117
6082
  name: automation.name
6118
6083
  }
@@ -6120,22 +6085,20 @@ async function deleted3(automation) {
6120
6085
  await publishEvent("automation:deleted" /* AUTOMATION_DELETED */, properties);
6121
6086
  }
6122
6087
  async function tested(automation) {
6123
- var _a, _b, _c, _d;
6124
6088
  const properties = {
6125
6089
  appId: automation.appId,
6126
6090
  automationId: automation._id,
6127
- triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
6128
- triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId
6091
+ triggerId: automation.definition?.trigger?.id,
6092
+ triggerType: automation.definition?.trigger?.stepId
6129
6093
  };
6130
6094
  await publishEvent("automation:tested" /* AUTOMATION_TESTED */, properties);
6131
6095
  }
6132
6096
  async function stepCreated(automation, step, timestamp) {
6133
- var _a, _b, _c, _d;
6134
6097
  const properties = {
6135
6098
  appId: automation.appId,
6136
6099
  automationId: automation._id,
6137
- triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
6138
- triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
6100
+ triggerId: automation.definition?.trigger?.id,
6101
+ triggerType: automation.definition?.trigger?.stepId,
6139
6102
  stepId: step.id,
6140
6103
  stepType: step.stepId,
6141
6104
  audited: {
@@ -6145,12 +6108,11 @@ async function stepCreated(automation, step, timestamp) {
6145
6108
  await publishEvent("automation:step:created" /* AUTOMATION_STEP_CREATED */, properties, timestamp);
6146
6109
  }
6147
6110
  async function stepDeleted(automation, step) {
6148
- var _a, _b, _c, _d;
6149
6111
  const properties = {
6150
6112
  appId: automation.appId,
6151
6113
  automationId: automation._id,
6152
- triggerId: (_b = (_a = automation.definition) == null ? void 0 : _a.trigger) == null ? void 0 : _b.id,
6153
- triggerType: (_d = (_c = automation.definition) == null ? void 0 : _c.trigger) == null ? void 0 : _d.stepId,
6114
+ triggerId: automation.definition?.trigger?.id,
6115
+ triggerType: automation.definition?.trigger?.stepId,
6154
6116
  stepId: step.id,
6155
6117
  stepType: step.stepId,
6156
6118
  audited: {
@@ -6499,25 +6461,23 @@ var init_role3 = __esm({
6499
6461
 
6500
6462
  // src/events/publishers/screen.ts
6501
6463
  async function created8(screen, timestamp) {
6502
- var _a;
6503
6464
  const properties = {
6504
6465
  layoutId: screen.layoutId,
6505
6466
  screenId: screen._id,
6506
6467
  roleId: screen.routing.roleId,
6507
6468
  audited: {
6508
- name: (_a = screen.routing) == null ? void 0 : _a.route
6469
+ name: screen.routing?.route
6509
6470
  }
6510
6471
  };
6511
6472
  await publishEvent("screen:created" /* SCREEN_CREATED */, properties, timestamp);
6512
6473
  }
6513
6474
  async function deleted8(screen) {
6514
- var _a;
6515
6475
  const properties = {
6516
6476
  layoutId: screen.layoutId,
6517
6477
  screenId: screen._id,
6518
6478
  roleId: screen.routing.roleId,
6519
6479
  audited: {
6520
- name: (_a = screen.routing) == null ? void 0 : _a.route
6480
+ name: screen.routing?.route
6521
6481
  }
6522
6482
  };
6523
6483
  await publishEvent("screen:deleted" /* SCREEN_DELETED */, properties);
@@ -8187,7 +8147,6 @@ var appBuilderUser = (appId, userProps) => {
8187
8147
  };
8188
8148
  };
8189
8149
  function ssoUser(opts = {}) {
8190
- var _a, _b, _c;
8191
8150
  const base = user(opts.user);
8192
8151
  delete base.password;
8193
8152
  if (!opts.details) {
@@ -8196,9 +8155,9 @@ function ssoUser(opts = {}) {
8196
8155
  return {
8197
8156
  ...base,
8198
8157
  forceResetPassword: false,
8199
- oauth2: (_a = opts.details) == null ? void 0 : _a.oauth2,
8200
- provider: (_b = opts.details) == null ? void 0 : _b.provider,
8201
- providerType: (_c = opts.details) == null ? void 0 : _c.providerType,
8158
+ oauth2: opts.details?.oauth2,
8159
+ provider: opts.details?.provider,
8160
+ providerType: opts.details?.providerType,
8202
8161
  thirdPartyProfile: {
8203
8162
  email: base.email,
8204
8163
  picture: base.pictureUrl
@@ -8364,7 +8323,7 @@ __export(testContainerUtils_exports, {
8364
8323
  var import_child_process = require("child_process");
8365
8324
  var dockerPsResult;
8366
8325
  function formatDockerPsResult(serverName, port) {
8367
- const lines = dockerPsResult == null ? void 0 : dockerPsResult.split("\n");
8326
+ const lines = dockerPsResult?.split("\n");
8368
8327
  let first = true;
8369
8328
  if (!lines) {
8370
8329
  return null;
@@ -8421,11 +8380,14 @@ function getContainerInfo(containerName, port) {
8421
8380
  function getCouchConfig() {
8422
8381
  return getContainerInfo("couchdb-service", 5984);
8423
8382
  }
8383
+ function getMinioConfig() {
8384
+ return getContainerInfo("minio-service", 9e3);
8385
+ }
8424
8386
  function getRedisConfig() {
8425
8387
  return getContainerInfo("redis-service", 6379);
8426
8388
  }
8427
8389
  function setupEnv(...envs) {
8428
- const couch = getCouchConfig(), minio = getCouchConfig(), redis2 = getRedisConfig();
8390
+ const couch = getCouchConfig(), minio = getMinioConfig(), redis2 = getRedisConfig();
8429
8391
  const configs = [
8430
8392
  { key: "COUCH_DB_PORT", value: couch.port },
8431
8393
  { key: "COUCH_DB_URL", value: couch.url },