@budibase/backend-core 2.9.30-alpha.7 → 2.9.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/tests.js CHANGED
@@ -29,6 +29,28 @@ 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
+ };
32
54
 
33
55
  // ../types/src/sdk/automations/index.ts
34
56
  var init_automations = __esm({
@@ -649,13 +671,6 @@ var init_permissions = __esm({
649
671
  }
650
672
  });
651
673
 
652
- // ../types/src/sdk/row.ts
653
- var init_row = __esm({
654
- "../types/src/sdk/row.ts"() {
655
- "use strict";
656
- }
657
- });
658
-
659
674
  // ../types/src/sdk/index.ts
660
675
  var init_sdk = __esm({
661
676
  "../types/src/sdk/index.ts"() {
@@ -681,7 +696,6 @@ var init_sdk = __esm({
681
696
  init_cli();
682
697
  init_websocket();
683
698
  init_permissions();
684
- init_row();
685
699
  }
686
700
  });
687
701
 
@@ -856,7 +870,7 @@ var init_document = __esm({
856
870
  });
857
871
 
858
872
  // ../types/src/documents/app/row.ts
859
- var init_row2 = __esm({
873
+ var init_row = __esm({
860
874
  "../types/src/documents/app/row.ts"() {
861
875
  "use strict";
862
876
  }
@@ -911,7 +925,7 @@ var init_app3 = __esm({
911
925
  init_screen2();
912
926
  init_view2();
913
927
  init_document();
914
- init_row2();
928
+ init_row();
915
929
  init_user4();
916
930
  init_backup2();
917
931
  init_webhook();
@@ -1197,7 +1211,7 @@ var init_datasource3 = __esm({
1197
1211
  });
1198
1212
 
1199
1213
  // ../types/src/api/web/app/row.ts
1200
- var init_row3 = __esm({
1214
+ var init_row2 = __esm({
1201
1215
  "../types/src/api/web/app/row.ts"() {
1202
1216
  "use strict";
1203
1217
  }
@@ -1230,7 +1244,7 @@ var init_app4 = __esm({
1230
1244
  "use strict";
1231
1245
  init_backup3();
1232
1246
  init_datasource3();
1233
- init_row3();
1247
+ init_row2();
1234
1248
  init_view3();
1235
1249
  init_rows2();
1236
1250
  init_table4();
@@ -1323,13 +1337,6 @@ var init_pagination = __esm({
1323
1337
  }
1324
1338
  });
1325
1339
 
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
-
1333
1340
  // ../types/src/api/web/index.ts
1334
1341
  var init_web = __esm({
1335
1342
  "../types/src/api/web/index.ts"() {
@@ -1344,7 +1351,6 @@ var init_web = __esm({
1344
1351
  init_app4();
1345
1352
  init_global2();
1346
1353
  init_pagination();
1347
- init_searchFilter();
1348
1354
  }
1349
1355
  });
1350
1356
 
@@ -1653,15 +1659,12 @@ var init_identity = __esm({
1653
1659
  });
1654
1660
 
1655
1661
  // src/context/Context.ts
1656
- var import_async_hooks, Context;
1662
+ var import_async_hooks, _Context, Context;
1657
1663
  var init_Context = __esm({
1658
1664
  "src/context/Context.ts"() {
1659
1665
  "use strict";
1660
1666
  import_async_hooks = require("async_hooks");
1661
- Context = class _Context {
1662
- static {
1663
- this.storage = new import_async_hooks.AsyncLocalStorage();
1664
- }
1667
+ _Context = class _Context {
1665
1668
  static run(context, func) {
1666
1669
  return _Context.storage.run(context, () => func());
1667
1670
  }
@@ -1669,6 +1672,8 @@ var init_Context = __esm({
1669
1672
  return _Context.storage.getStore();
1670
1673
  }
1671
1674
  };
1675
+ _Context.storage = new import_async_hooks.AsyncLocalStorage();
1676
+ Context = _Context;
1672
1677
  }
1673
1678
  });
1674
1679
 
@@ -1687,17 +1692,18 @@ var init_connections = __esm({
1687
1692
  "use strict";
1688
1693
  init_environment2();
1689
1694
  getCouchInfo = (connection) => {
1695
+ var _a, _b;
1690
1696
  const urlInfo = getUrlInfo(connection);
1691
1697
  let username;
1692
1698
  let password;
1693
- if (urlInfo.auth?.username) {
1699
+ if ((_a = urlInfo.auth) == null ? void 0 : _a.username) {
1694
1700
  username = urlInfo.auth.username;
1695
1701
  } else if (environment_default.COUCH_DB_USERNAME) {
1696
1702
  username = environment_default.COUCH_DB_USERNAME;
1697
1703
  } else if (!environment_default.isTest()) {
1698
1704
  throw new Error("CouchDB username not set");
1699
1705
  }
1700
- if (urlInfo.auth?.password) {
1706
+ if ((_b = urlInfo.auth) == null ? void 0 : _b.password) {
1701
1707
  password = urlInfo.auth.password;
1702
1708
  } else if (environment_default.COUCH_DB_PASSWORD) {
1703
1709
  password = environment_default.COUCH_DB_PASSWORD;
@@ -1890,7 +1896,8 @@ var init_DatabaseImpl = __esm({
1890
1896
  return this.instanceNano || _DatabaseImpl.nano;
1891
1897
  }
1892
1898
  async checkSetup() {
1893
- let shouldCreate = !this.pouchOpts?.skip_setup;
1899
+ var _a;
1900
+ let shouldCreate = !((_a = this.pouchOpts) == null ? void 0 : _a.skip_setup);
1894
1901
  let exists = await this.exists();
1895
1902
  if (!shouldCreate && !exists) {
1896
1903
  throw new Error("DB does not exist");
@@ -1966,7 +1973,7 @@ var init_DatabaseImpl = __esm({
1966
1973
  document.createdAt = (/* @__PURE__ */ new Date()).toISOString();
1967
1974
  }
1968
1975
  document.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1969
- if (opts?.force && document._id) {
1976
+ if ((opts == null ? void 0 : opts.force) && document._id) {
1970
1977
  try {
1971
1978
  const existing = await this.get(document._id);
1972
1979
  if (existing) {
@@ -2135,7 +2142,7 @@ async function doInTenant(tenantId, task) {
2135
2142
  function getIdentity() {
2136
2143
  try {
2137
2144
  const context = Context.get();
2138
- return context?.identity;
2145
+ return context == null ? void 0 : context.identity;
2139
2146
  } catch (e) {
2140
2147
  }
2141
2148
  }
@@ -2144,7 +2151,7 @@ function getTenantId() {
2144
2151
  return DEFAULT_TENANT_ID;
2145
2152
  }
2146
2153
  const context = Context.get();
2147
- const tenantId = context?.tenantId;
2154
+ const tenantId = context == null ? void 0 : context.tenantId;
2148
2155
  if (!tenantId) {
2149
2156
  throw new Error("Tenant id not found");
2150
2157
  }
@@ -2152,11 +2159,11 @@ function getTenantId() {
2152
2159
  }
2153
2160
  function getAutomationId() {
2154
2161
  const context = Context.get();
2155
- return context?.automationId;
2162
+ return context == null ? void 0 : context.automationId;
2156
2163
  }
2157
2164
  function getAppId() {
2158
2165
  const context = Context.get();
2159
- const foundId = context?.appId;
2166
+ const foundId = context == null ? void 0 : context.appId;
2160
2167
  if (!foundId && environment_default.isTest() && TEST_APP_ID) {
2161
2168
  return TEST_APP_ID;
2162
2169
  } else {
@@ -2168,11 +2175,11 @@ function getGlobalDB() {
2168
2175
  if (!context || environment_default.MULTI_TENANCY && !context.tenantId) {
2169
2176
  throw new Error("Global DB not found");
2170
2177
  }
2171
- return getDB(baseGlobalDBName(context?.tenantId));
2178
+ return getDB(baseGlobalDBName(context == null ? void 0 : context.tenantId));
2172
2179
  }
2173
2180
  function isScim() {
2174
2181
  const context = Context.get();
2175
- const scimCall = context?.isScim;
2182
+ const scimCall = context == null ? void 0 : context.isScim;
2176
2183
  return !!scimCall;
2177
2184
  }
2178
2185
  var TEST_APP_ID;
@@ -2843,37 +2850,39 @@ async function runQuery(url, body, cookie) {
2843
2850
  }
2844
2851
  return output;
2845
2852
  }
2846
- var import_node_fetch2, QUERY_START_REGEX, QueryBuilder;
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;
2847
2854
  var init_lucene = __esm({
2848
2855
  "src/db/lucene.ts"() {
2849
2856
  "use strict";
2850
2857
  import_node_fetch2 = __toESM(require("node-fetch"));
2851
2858
  init_couch();
2852
- init_src();
2853
2859
  QUERY_START_REGEX = /\d[0-9]*:/g;
2854
- QueryBuilder = class _QueryBuilder {
2855
- #dbName;
2856
- #index;
2857
- #query;
2858
- #limit;
2859
- #sort;
2860
- #bookmark;
2861
- #sortOrder;
2862
- #sortType;
2863
- #includeDocs;
2864
- #version;
2865
- #indexBuilder;
2866
- #noEscaping = false;
2867
- #skip;
2868
- static {
2869
- this.maxLimit = 200;
2870
- }
2860
+ _QueryBuilder = class _QueryBuilder {
2871
2861
  constructor(dbName, index2, base) {
2872
- this.#dbName = dbName;
2873
- this.#index = index2;
2874
- this.#query = {
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, {
2875
2885
  allOr: false,
2876
- onEmptyFilter: "all" /* RETURN_ALL */,
2877
2886
  string: {},
2878
2887
  fuzzy: {},
2879
2888
  range: {},
@@ -2886,127 +2895,124 @@ var init_lucene = __esm({
2886
2895
  notContains: {},
2887
2896
  containsAny: {},
2888
2897
  ...base
2889
- };
2890
- this.#limit = 50;
2891
- this.#sortOrder = "ascending";
2892
- this.#sortType = "string";
2893
- this.#includeDocs = true;
2898
+ });
2899
+ __privateSet(this, _limit, 50);
2900
+ __privateSet(this, _sortOrder, "ascending");
2901
+ __privateSet(this, _sortType, "string");
2902
+ __privateSet(this, _includeDocs, true);
2894
2903
  }
2895
2904
  disableEscaping() {
2896
- this.#noEscaping = true;
2905
+ __privateSet(this, _noEscaping, true);
2897
2906
  return this;
2898
2907
  }
2899
2908
  setIndexBuilder(builderFn) {
2900
- this.#indexBuilder = builderFn;
2909
+ __privateSet(this, _indexBuilder, builderFn);
2901
2910
  return this;
2902
2911
  }
2903
2912
  setVersion(version) {
2904
2913
  if (version != null) {
2905
- this.#version = version;
2914
+ __privateSet(this, _version, version);
2906
2915
  }
2907
2916
  return this;
2908
2917
  }
2909
2918
  setTable(tableId) {
2910
- this.#query.equal.tableId = tableId;
2919
+ __privateGet(this, _query).equal.tableId = tableId;
2911
2920
  return this;
2912
2921
  }
2913
2922
  setLimit(limit) {
2914
2923
  if (limit != null) {
2915
- this.#limit = limit;
2924
+ __privateSet(this, _limit, limit);
2916
2925
  }
2917
2926
  return this;
2918
2927
  }
2919
2928
  setSort(sort) {
2920
2929
  if (sort != null) {
2921
- this.#sort = sort;
2930
+ __privateSet(this, _sort, sort);
2922
2931
  }
2923
2932
  return this;
2924
2933
  }
2925
2934
  setSortOrder(sortOrder) {
2926
2935
  if (sortOrder != null) {
2927
- this.#sortOrder = sortOrder;
2936
+ __privateSet(this, _sortOrder, sortOrder);
2928
2937
  }
2929
2938
  return this;
2930
2939
  }
2931
2940
  setSortType(sortType) {
2932
2941
  if (sortType != null) {
2933
- this.#sortType = sortType;
2942
+ __privateSet(this, _sortType, sortType);
2934
2943
  }
2935
2944
  return this;
2936
2945
  }
2937
2946
  setBookmark(bookmark) {
2938
2947
  if (bookmark != null) {
2939
- this.#bookmark = bookmark;
2948
+ __privateSet(this, _bookmark, bookmark);
2940
2949
  }
2941
2950
  return this;
2942
2951
  }
2943
2952
  setSkip(skip) {
2944
- this.#skip = skip;
2953
+ __privateSet(this, _skip, skip);
2945
2954
  return this;
2946
2955
  }
2947
2956
  excludeDocs() {
2948
- this.#includeDocs = false;
2957
+ __privateSet(this, _includeDocs, false);
2949
2958
  return this;
2950
2959
  }
2951
2960
  includeDocs() {
2952
- this.#includeDocs = true;
2961
+ __privateSet(this, _includeDocs, true);
2953
2962
  return this;
2954
2963
  }
2955
2964
  addString(key, partial) {
2956
- this.#query.string[key] = partial;
2965
+ __privateGet(this, _query).string[key] = partial;
2957
2966
  return this;
2958
2967
  }
2959
2968
  addFuzzy(key, fuzzy) {
2960
- this.#query.fuzzy[key] = fuzzy;
2969
+ __privateGet(this, _query).fuzzy[key] = fuzzy;
2961
2970
  return this;
2962
2971
  }
2963
2972
  addRange(key, low, high) {
2964
- this.#query.range[key] = {
2973
+ __privateGet(this, _query).range[key] = {
2965
2974
  low,
2966
2975
  high
2967
2976
  };
2968
2977
  return this;
2969
2978
  }
2970
2979
  addEqual(key, value) {
2971
- this.#query.equal[key] = value;
2980
+ __privateGet(this, _query).equal[key] = value;
2972
2981
  return this;
2973
2982
  }
2974
2983
  addNotEqual(key, value) {
2975
- this.#query.notEqual[key] = value;
2984
+ __privateGet(this, _query).notEqual[key] = value;
2976
2985
  return this;
2977
2986
  }
2978
2987
  addEmpty(key, value) {
2979
- this.#query.empty[key] = value;
2988
+ __privateGet(this, _query).empty[key] = value;
2980
2989
  return this;
2981
2990
  }
2982
2991
  addNotEmpty(key, value) {
2983
- this.#query.notEmpty[key] = value;
2992
+ __privateGet(this, _query).notEmpty[key] = value;
2984
2993
  return this;
2985
2994
  }
2986
2995
  addOneOf(key, value) {
2987
- this.#query.oneOf[key] = value;
2996
+ __privateGet(this, _query).oneOf[key] = value;
2988
2997
  return this;
2989
2998
  }
2990
2999
  addContains(key, value) {
2991
- this.#query.contains[key] = value;
3000
+ __privateGet(this, _query).contains[key] = value;
2992
3001
  return this;
2993
3002
  }
2994
3003
  addNotContains(key, value) {
2995
- this.#query.notContains[key] = value;
3004
+ __privateGet(this, _query).notContains[key] = value;
2996
3005
  return this;
2997
3006
  }
2998
3007
  addContainsAny(key, value) {
2999
- this.#query.containsAny[key] = value;
3008
+ __privateGet(this, _query).containsAny[key] = value;
3000
3009
  return this;
3001
3010
  }
3002
3011
  setAllOr() {
3003
- this.#query.allOr = true;
3004
- }
3005
- setOnEmptyFilter(value) {
3006
- this.#query.onEmptyFilter = value;
3012
+ __privateGet(this, _query).allOr = true;
3007
3013
  }
3008
3014
  handleSpaces(input) {
3009
- if (this.#noEscaping) {
3015
+ if (__privateGet(this, _noEscaping)) {
3010
3016
  return input;
3011
3017
  } else {
3012
3018
  return input.replace(/ /g, "_");
@@ -3020,12 +3026,12 @@ var init_lucene = __esm({
3020
3026
  * @returns {string|*}
3021
3027
  */
3022
3028
  preprocess(value, { escape, lowercase, wrap, type } = {}) {
3023
- const hasVersion = !!this.#version;
3029
+ const hasVersion = !!__privateGet(this, _version);
3024
3030
  const originalType = typeof value;
3025
3031
  if (value && lowercase) {
3026
3032
  value = value.toLowerCase ? value.toLowerCase() : value;
3027
3033
  }
3028
- if (!this.#noEscaping && escape && originalType === "string") {
3034
+ if (!__privateGet(this, _noEscaping) && escape && originalType === "string") {
3029
3035
  value = `${value}`.replace(/[ \/#+\-&|!(){}\]^"~*?:\\]/g, "\\$&");
3030
3036
  }
3031
3037
  if (originalType === "string" && !isNaN(value) && !type) {
@@ -3037,7 +3043,7 @@ var init_lucene = __esm({
3037
3043
  }
3038
3044
  isMultiCondition() {
3039
3045
  let count = 0;
3040
- for (let filters of Object.values(this.#query)) {
3046
+ for (let filters of Object.values(__privateGet(this, _query))) {
3041
3047
  if (typeof filters === "object") {
3042
3048
  count += Object.keys(filters).length;
3043
3049
  }
@@ -3063,14 +3069,13 @@ var init_lucene = __esm({
3063
3069
  }
3064
3070
  buildSearchQuery() {
3065
3071
  const builder = this;
3066
- let allOr = this.#query && this.#query.allOr;
3072
+ let allOr = __privateGet(this, _query) && __privateGet(this, _query).allOr;
3067
3073
  let query = allOr ? "" : "*:*";
3068
- let allFiltersEmpty = true;
3069
3074
  const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
3070
- let tableId = "";
3071
- if (this.#query.equal.tableId) {
3072
- tableId = this.#query.equal.tableId;
3073
- delete this.#query.equal.tableId;
3075
+ let tableId;
3076
+ if (__privateGet(this, _query).equal.tableId) {
3077
+ tableId = __privateGet(this, _query).equal.tableId;
3078
+ delete __privateGet(this, _query).equal.tableId;
3074
3079
  }
3075
3080
  const equal = (key, value) => {
3076
3081
  if (!value && value !== 0) {
@@ -3079,7 +3084,7 @@ var init_lucene = __esm({
3079
3084
  return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
3080
3085
  };
3081
3086
  const contains = (key, value, mode = "AND") => {
3082
- if (!value || Array.isArray(value) && value.length === 0) {
3087
+ if (Array.isArray(value) && value.length === 0) {
3083
3088
  return null;
3084
3089
  }
3085
3090
  if (!Array.isArray(value)) {
@@ -3144,22 +3149,19 @@ var init_lucene = __esm({
3144
3149
  continue;
3145
3150
  }
3146
3151
  if (built.length > 0 || query.length > 0) {
3147
- const mode = opts?.mode ? opts.mode : allOr ? "OR" : "AND";
3152
+ const mode = (opts == null ? void 0 : opts.mode) ? opts.mode : allOr ? "OR" : "AND";
3148
3153
  built += ` ${mode} `;
3149
3154
  }
3150
3155
  built += expression;
3151
- if (typeof value !== "string" && value != null || typeof value === "string" && value !== tableId && value !== "") {
3152
- allFiltersEmpty = false;
3153
- }
3154
3156
  }
3155
- if (opts?.returnBuilt) {
3157
+ if (opts == null ? void 0 : opts.returnBuilt) {
3156
3158
  return built;
3157
3159
  } else {
3158
3160
  query += built;
3159
3161
  }
3160
3162
  }
3161
- if (this.#query.string) {
3162
- build(this.#query.string, (key, value) => {
3163
+ if (__privateGet(this, _query).string) {
3164
+ build(__privateGet(this, _query).string, (key, value) => {
3163
3165
  if (!value) {
3164
3166
  return null;
3165
3167
  }
@@ -3171,8 +3173,8 @@ var init_lucene = __esm({
3171
3173
  return `${key}:${value}*`;
3172
3174
  });
3173
3175
  }
3174
- if (this.#query.range) {
3175
- build(this.#query.range, (key, value) => {
3176
+ if (__privateGet(this, _query).range) {
3177
+ build(__privateGet(this, _query).range, (key, value) => {
3176
3178
  if (!value) {
3177
3179
  return null;
3178
3180
  }
@@ -3187,14 +3189,14 @@ var init_lucene = __esm({
3187
3189
  return `${key}:[${low} TO ${high}]`;
3188
3190
  });
3189
3191
  }
3190
- if (this.#query.fuzzy) {
3191
- build(this.#query.fuzzy, fuzzy);
3192
+ if (__privateGet(this, _query).fuzzy) {
3193
+ build(__privateGet(this, _query).fuzzy, fuzzy);
3192
3194
  }
3193
- if (this.#query.equal) {
3194
- build(this.#query.equal, equal);
3195
+ if (__privateGet(this, _query).equal) {
3196
+ build(__privateGet(this, _query).equal, equal);
3195
3197
  }
3196
- if (this.#query.notEqual) {
3197
- build(this.#query.notEqual, (key, value) => {
3198
+ if (__privateGet(this, _query).notEqual) {
3199
+ build(__privateGet(this, _query).notEqual, (key, value) => {
3198
3200
  if (!value) {
3199
3201
  return null;
3200
3202
  }
@@ -3204,98 +3206,103 @@ var init_lucene = __esm({
3204
3206
  return `!${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
3205
3207
  });
3206
3208
  }
3207
- if (this.#query.empty) {
3208
- build(this.#query.empty, (key) => `(*:* -${key}:["" TO *])`);
3209
+ if (__privateGet(this, _query).empty) {
3210
+ build(__privateGet(this, _query).empty, (key) => `(*:* -${key}:["" TO *])`);
3209
3211
  }
3210
- if (this.#query.notEmpty) {
3211
- build(this.#query.notEmpty, (key) => `${key}:["" TO *]`);
3212
+ if (__privateGet(this, _query).notEmpty) {
3213
+ build(__privateGet(this, _query).notEmpty, (key) => `${key}:["" TO *]`);
3212
3214
  }
3213
- if (this.#query.oneOf) {
3214
- build(this.#query.oneOf, oneOf);
3215
+ if (__privateGet(this, _query).oneOf) {
3216
+ build(__privateGet(this, _query).oneOf, oneOf);
3215
3217
  }
3216
- if (this.#query.contains) {
3217
- build(this.#query.contains, contains);
3218
+ if (__privateGet(this, _query).contains) {
3219
+ build(__privateGet(this, _query).contains, contains);
3218
3220
  }
3219
- if (this.#query.notContains) {
3220
- build(this.compressFilters(this.#query.notContains), notContains);
3221
+ if (__privateGet(this, _query).notContains) {
3222
+ build(this.compressFilters(__privateGet(this, _query).notContains), notContains);
3221
3223
  }
3222
- if (this.#query.containsAny) {
3223
- build(this.#query.containsAny, containsAny);
3224
+ if (__privateGet(this, _query).containsAny) {
3225
+ build(__privateGet(this, _query).containsAny, containsAny);
3224
3226
  }
3225
3227
  if (tableId) {
3226
3228
  query = this.isMultiCondition() ? `(${query})` : query;
3227
3229
  allOr = false;
3228
3230
  build({ tableId }, equal);
3229
3231
  }
3230
- if (allFiltersEmpty) {
3231
- if (this.#query.onEmptyFilter === "none" /* RETURN_NONE */) {
3232
- return "";
3233
- } else if (this.#query?.allOr) {
3234
- return query.replace("()", "(*:*)");
3235
- }
3236
- }
3237
3232
  return query;
3238
3233
  }
3239
3234
  buildSearchBody() {
3240
3235
  let body = {
3241
3236
  q: this.buildSearchQuery(),
3242
- limit: Math.min(this.#limit, _QueryBuilder.maxLimit),
3243
- include_docs: this.#includeDocs
3237
+ limit: Math.min(__privateGet(this, _limit), _QueryBuilder.maxLimit),
3238
+ include_docs: __privateGet(this, _includeDocs)
3244
3239
  };
3245
- if (this.#bookmark) {
3246
- body.bookmark = this.#bookmark;
3240
+ if (__privateGet(this, _bookmark)) {
3241
+ body.bookmark = __privateGet(this, _bookmark);
3247
3242
  }
3248
- if (this.#sort) {
3249
- const order = this.#sortOrder === "descending" ? "-" : "";
3250
- const type = `<${this.#sortType}>`;
3251
- body.sort = `${order}${this.handleSpaces(this.#sort)}${type}`;
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}`;
3252
3247
  }
3253
3248
  return body;
3254
3249
  }
3255
3250
  async run() {
3256
- if (this.#skip) {
3257
- await this.#skipItems(this.#skip);
3251
+ if (__privateGet(this, _skip)) {
3252
+ await __privateMethod(this, _skipItems, skipItems_fn).call(this, __privateGet(this, _skip));
3258
3253
  }
3259
- return await this.#execute();
3254
+ return await __privateMethod(this, _execute, execute_fn).call(this);
3260
3255
  }
3261
- /**
3262
- * Lucene queries do not support pagination and use bookmarks instead.
3263
- * For the given builder, walk through pages using bookmarks until the desired
3264
- * page has been met.
3265
- */
3266
- async #skipItems(skip) {
3267
- const prevIncludeDocs = this.#includeDocs;
3268
- const prevLimit = this.#limit;
3269
- this.excludeDocs();
3270
- let skipRemaining = skip;
3271
- let iterationFetched = 0;
3272
- do {
3273
- const toSkip = Math.min(_QueryBuilder.maxLimit, skipRemaining);
3274
- this.setLimit(toSkip);
3275
- const { bookmark, rows } = await this.#execute();
3276
- this.setBookmark(bookmark);
3277
- iterationFetched = rows.length;
3278
- skipRemaining -= rows.length;
3279
- } while (skipRemaining > 0 && iterationFetched > 0);
3280
- this.#includeDocs = prevIncludeDocs;
3281
- this.#limit = prevLimit;
3282
- }
3283
- async #execute() {
3284
- const { url, cookie } = getCouchInfo();
3285
- const fullPath = `${url}/${this.#dbName}/_design/database/_search/${this.#index}`;
3286
- const body = this.buildSearchBody();
3287
- try {
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);
3288
3298
  return await runQuery(fullPath, body, cookie);
3289
- } catch (err) {
3290
- if (err.status === 404 && this.#indexBuilder) {
3291
- await this.#indexBuilder();
3292
- return await runQuery(fullPath, body, cookie);
3293
- } else {
3294
- throw err;
3295
- }
3299
+ } else {
3300
+ throw err;
3296
3301
  }
3297
3302
  }
3298
3303
  };
3304
+ _QueryBuilder.maxLimit = 200;
3305
+ QueryBuilder = _QueryBuilder;
3299
3306
  }
3300
3307
  });
3301
3308
 
@@ -3448,7 +3455,7 @@ function getFullPath(fileName) {
3448
3455
  }
3449
3456
  function getSingleFileMaxSizeInfo(totalMaxSize) {
3450
3457
  const regex = /(\d+)([A-Za-z])/;
3451
- const match = totalMaxSize?.match(regex);
3458
+ const match = totalMaxSize == null ? void 0 : totalMaxSize.match(regex);
3452
3459
  if (!match) {
3453
3460
  console.warn(`totalMaxSize does not have a valid value`, {
3454
3461
  totalMaxSize
@@ -3480,9 +3487,9 @@ function localFileDestination() {
3480
3487
  const fileInfo = getSingleFileMaxSizeInfo(environment_default.ROLLING_LOG_MAX_SIZE);
3481
3488
  const outFile = rfs.createStream(logsFileName, {
3482
3489
  // As we have a rolling size, we want to half the max size
3483
- size: fileInfo?.size,
3490
+ size: fileInfo == null ? void 0 : fileInfo.size,
3484
3491
  path: logsPath,
3485
- maxFiles: fileInfo?.totalHistoryFiles || 1,
3492
+ maxFiles: (fileInfo == null ? void 0 : fileInfo.totalHistoryFiles) || 1,
3486
3493
  immutable: true,
3487
3494
  history: budibaseLogsHistoryFileName,
3488
3495
  initialRotation: false
@@ -3557,8 +3564,8 @@ var init_logger = __esm({
3557
3564
  tenantId: getTenantId2(),
3558
3565
  appId: getAppId2(),
3559
3566
  automationId: getAutomationId2(),
3560
- identityId: identity?._id,
3561
- identityType: identity?.type,
3567
+ identityId: identity == null ? void 0 : identity._id,
3568
+ identityType: identity == null ? void 0 : identity.type,
3562
3569
  correlationId: getId()
3563
3570
  };
3564
3571
  const mergingObject = {
@@ -3622,30 +3629,30 @@ var init_logger = __esm({
3622
3629
  pinoInstance = destinations.length ? (0, import_pino.default)(pinoOptions, import_pino.default.multistream(destinations)) : (0, import_pino.default)(pinoOptions);
3623
3630
  console.log = (...arg) => {
3624
3631
  const [obj, msg] = getLogParams2(arg);
3625
- pinoInstance?.info(obj, msg);
3632
+ pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
3626
3633
  };
3627
3634
  console.info = (...arg) => {
3628
3635
  const [obj, msg] = getLogParams2(arg);
3629
- pinoInstance?.info(obj, msg);
3636
+ pinoInstance == null ? void 0 : pinoInstance.info(obj, msg);
3630
3637
  };
3631
3638
  console.warn = (...arg) => {
3632
3639
  const [obj, msg] = getLogParams2(arg);
3633
- pinoInstance?.warn(obj, msg);
3640
+ pinoInstance == null ? void 0 : pinoInstance.warn(obj, msg);
3634
3641
  };
3635
3642
  console.error = (...arg) => {
3636
3643
  const [obj, msg] = getLogParams2(arg);
3637
- pinoInstance?.error(obj, msg);
3644
+ pinoInstance == null ? void 0 : pinoInstance.error(obj, msg);
3638
3645
  };
3639
3646
  console.trace = (...arg) => {
3640
3647
  const [obj, msg] = getLogParams2(arg);
3641
3648
  if (!obj.err) {
3642
3649
  obj.err = new Error();
3643
3650
  }
3644
- pinoInstance?.trace(obj, msg);
3651
+ pinoInstance == null ? void 0 : pinoInstance.trace(obj, msg);
3645
3652
  };
3646
3653
  console.debug = (...arg) => {
3647
3654
  const [obj, msg] = getLogParams2(arg);
3648
- pinoInstance?.debug(obj, msg);
3655
+ pinoInstance == null ? void 0 : pinoInstance.debug(obj, msg);
3649
3656
  };
3650
3657
  const getTenantId2 = () => {
3651
3658
  let tenantId;
@@ -4131,6 +4138,7 @@ async function getSettingsConfigDoc() {
4131
4138
  async function getPlatformUrl(opts = {
4132
4139
  tenantAware: true
4133
4140
  }) {
4141
+ var _a;
4134
4142
  let platformUrl = environment_default.PLATFORM_URL || "http://localhost:10000";
4135
4143
  if (!environment_default.SELF_HOSTED && environment_default.MULTI_TENANCY && opts.tenantAware) {
4136
4144
  const tenantId = getTenantId();
@@ -4138,11 +4146,11 @@ async function getPlatformUrl(opts = {
4138
4146
  platformUrl = platformUrl.replace("://", `://${tenantId}.`);
4139
4147
  }
4140
4148
  } else if (environment_default.SELF_HOSTED) {
4141
- const config = opts?.config ? opts.config : (
4149
+ const config = (opts == null ? void 0 : opts.config) ? opts.config : (
4142
4150
  // direct to db to prevent infinite loop
4143
- (await getConfig("settings" /* SETTINGS */))?.config
4151
+ (_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
4144
4152
  );
4145
- if (config?.platformUrl) {
4153
+ if (config == null ? void 0 : config.platformUrl) {
4146
4154
  platformUrl = config.platformUrl;
4147
4155
  }
4148
4156
  }
@@ -4166,13 +4174,14 @@ var init_configs2 = __esm({
4166
4174
  "analyticsEnabled" /* ANALYTICS_ENABLED */,
4167
4175
  86400 /* ONE_DAY */,
4168
4176
  async () => {
4169
- const config = opts?.config ? opts.config : (
4177
+ var _a;
4178
+ const config = (opts == null ? void 0 : opts.config) ? opts.config : (
4170
4179
  // direct to db to prevent infinite loop
4171
- (await getConfig("settings" /* SETTINGS */))?.config
4180
+ (_a = await getConfig("settings" /* SETTINGS */)) == null ? void 0 : _a.config
4172
4181
  );
4173
- if (config?.analyticsEnabled === false) {
4182
+ if ((config == null ? void 0 : config.analyticsEnabled) === false) {
4174
4183
  return false;
4175
- } else if (config?.analyticsEnabled === true) {
4184
+ } else if ((config == null ? void 0 : config.analyticsEnabled) === true) {
4176
4185
  return true;
4177
4186
  }
4178
4187
  }
@@ -4674,6 +4683,7 @@ function handleStalled(queue, removeStalledCb) {
4674
4683
  });
4675
4684
  }
4676
4685
  function getLogParams(eventType, event, opts = {}, extra = {}) {
4686
+ var _a, _b, _c;
4677
4687
  const message = `[BULL] ${eventType}=${event}`;
4678
4688
  const err = opts.error;
4679
4689
  const bullLog = {
@@ -4681,11 +4691,11 @@ function getLogParams(eventType, event, opts = {}, extra = {}) {
4681
4691
  eventType,
4682
4692
  event,
4683
4693
  job: opts.job,
4684
- jobId: opts.jobId || opts.job?.id,
4694
+ jobId: opts.jobId || ((_a = opts.job) == null ? void 0 : _a.id),
4685
4695
  ...extra
4686
4696
  };
4687
4697
  let automationLog;
4688
- if (opts.job?.data?.automation) {
4698
+ if ((_c = (_b = opts.job) == null ? void 0 : _b.data) == null ? void 0 : _c.automation) {
4689
4699
  automationLog = {
4690
4700
  _logKey: "automation",
4691
4701
  trigger: opts.job ? opts.job.data.automation.definition.trigger.event : void 0
@@ -4694,9 +4704,11 @@ function getLogParams(eventType, event, opts = {}, extra = {}) {
4694
4704
  return [message, err, bullLog, automationLog];
4695
4705
  }
4696
4706
  function logging(queue, jobQueue) {
4707
+ var _a;
4697
4708
  const eventType = EventTypeMap[jobQueue];
4698
4709
  function doInJobContext(job, task) {
4699
- const appId = job.data.event?.appId;
4710
+ var _a2;
4711
+ const appId = (_a2 = job.data.event) == null ? void 0 : _a2.appId;
4700
4712
  if (appId) {
4701
4713
  return doInContext(appId, task);
4702
4714
  } else {
@@ -4710,7 +4722,7 @@ function logging(queue, jobQueue) {
4710
4722
  }).on("error" /* ERROR */, (error) => {
4711
4723
  console.error(...getLogParams(eventType, "error" /* ERROR */, { error }));
4712
4724
  });
4713
- if (process.env.NODE_DEBUG?.includes("bull")) {
4725
+ if ((_a = process.env.NODE_DEBUG) == null ? void 0 : _a.includes("bull")) {
4714
4726
  queue.on("waiting" /* WAITING */, (jobId) => {
4715
4727
  console.info(...getLogParams(eventType, "waiting" /* WAITING */, { jobId }));
4716
4728
  }).on("active" /* ACTIVE */, async (job, jobPromise) => {
@@ -4790,7 +4802,7 @@ function createQueue(jobQueue, opts = {}) {
4790
4802
  } else {
4791
4803
  queue = new inMemoryQueue_default(jobQueue, queueConfig);
4792
4804
  }
4793
- addListeners(queue, jobQueue, opts?.removeStalledCb);
4805
+ addListeners(queue, jobQueue, opts == null ? void 0 : opts.removeStalledCb);
4794
4806
  QUEUES.push(queue);
4795
4807
  if (!cleanupInterval && !environment_default.isTest()) {
4796
4808
  cleanupInterval = set(cleanup, CLEANUP_PERIOD_MS);
@@ -4825,7 +4837,7 @@ var init_queue2 = __esm({
4825
4837
  });
4826
4838
 
4827
4839
  // src/events/processors/AuditLogsProcessor.ts
4828
- var AuditLogsProcessor;
4840
+ var _AuditLogsProcessor, AuditLogsProcessor;
4829
4841
  var init_AuditLogsProcessor = __esm({
4830
4842
  "src/events/processors/AuditLogsProcessor.ts"() {
4831
4843
  "use strict";
@@ -4834,10 +4846,7 @@ var init_AuditLogsProcessor = __esm({
4834
4846
  init_queue2();
4835
4847
  init_utils6();
4836
4848
  init_environment2();
4837
- AuditLogsProcessor = class _AuditLogsProcessor {
4838
- static {
4839
- this.auditLogsEnabled = false;
4840
- }
4849
+ _AuditLogsProcessor = class _AuditLogsProcessor {
4841
4850
  // can't use constructor as need to return promise
4842
4851
  static init(fn) {
4843
4852
  _AuditLogsProcessor.auditLogsEnabled = true;
@@ -4889,9 +4898,12 @@ var init_AuditLogsProcessor = __esm({
4889
4898
  async identifyGroup(group, timestamp) {
4890
4899
  }
4891
4900
  shutdown() {
4892
- _AuditLogsProcessor.auditLogQueue?.close();
4901
+ var _a;
4902
+ (_a = _AuditLogsProcessor.auditLogQueue) == null ? void 0 : _a.close();
4893
4903
  }
4894
4904
  };
4905
+ _AuditLogsProcessor.auditLogsEnabled = false;
4906
+ AuditLogsProcessor = _AuditLogsProcessor;
4895
4907
  }
4896
4908
  });
4897
4909
 
@@ -5219,12 +5231,13 @@ __export(users_exports2, {
5219
5231
  isGlobalBuilder: () => isGlobalBuilder
5220
5232
  });
5221
5233
  function isBuilder(user2, appId) {
5234
+ var _a, _b, _c;
5222
5235
  if (!user2) {
5223
5236
  return false;
5224
5237
  }
5225
- if (user2.builder?.global) {
5238
+ if ((_a = user2.builder) == null ? void 0 : _a.global) {
5226
5239
  return true;
5227
- } else if (appId && user2.builder?.apps?.includes(getProdAppID2(appId))) {
5240
+ } else if (appId && ((_c = (_b = user2.builder) == null ? void 0 : _b.apps) == null ? void 0 : _c.includes(getProdAppID2(appId)))) {
5228
5241
  return true;
5229
5242
  }
5230
5243
  return false;
@@ -5242,24 +5255,27 @@ function isAdminOrBuilder(user2, appId) {
5242
5255
  return isBuilder(user2, appId) || isAdmin(user2);
5243
5256
  }
5244
5257
  function hasAppBuilderPermissions(user2) {
5258
+ var _a, _b, _c;
5245
5259
  if (!user2) {
5246
5260
  return false;
5247
5261
  }
5248
- const appLength = user2.builder?.apps?.length;
5249
- const isGlobalBuilder3 = !!user2.builder?.global;
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);
5250
5264
  return !isGlobalBuilder3 && appLength != null && appLength > 0;
5251
5265
  }
5252
5266
  function hasBuilderPermissions(user2) {
5267
+ var _a;
5253
5268
  if (!user2) {
5254
5269
  return false;
5255
5270
  }
5256
- return user2.builder?.global || hasAppBuilderPermissions(user2);
5271
+ return ((_a = user2.builder) == null ? void 0 : _a.global) || hasAppBuilderPermissions(user2);
5257
5272
  }
5258
5273
  function hasAdminPermissions(user2) {
5274
+ var _a;
5259
5275
  if (!user2) {
5260
5276
  return false;
5261
5277
  }
5262
- return !!user2.admin?.global;
5278
+ return !!((_a = user2.admin) == null ? void 0 : _a.global);
5263
5279
  }
5264
5280
  var init_users5 = __esm({
5265
5281
  "../shared-core/src/sdk/documents/users.ts"() {
@@ -5356,7 +5372,6 @@ var init_db6 = __esm({
5356
5372
  init_environment2();
5357
5373
  init_events3();
5358
5374
  init_accounts4();
5359
- init_accounts4();
5360
5375
  init_cache();
5361
5376
  init_context2();
5362
5377
  init_db4();
@@ -5365,6 +5380,7 @@ var init_db6 = __esm({
5365
5380
  init_sessions();
5366
5381
  init_users4();
5367
5382
  init_src();
5383
+ init_accounts4();
5368
5384
  init_utils8();
5369
5385
  init_lookup();
5370
5386
  init_utils6();
@@ -5507,8 +5523,8 @@ var init_identification2 = __esm({
5507
5523
  if (isSSOUser(user2)) {
5508
5524
  providerType3 = user2.providerType;
5509
5525
  }
5510
- const accountHolder = account2?.budibaseUserId === user2._id || false;
5511
- const verified2 = account2 && account2?.budibaseUserId === user2._id ? account2.verified : false;
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;
5512
5528
  const installationId = await getInstallationId();
5513
5529
  const hosting = account2 ? account2.hosting : getHostingFromEnv();
5514
5530
  const environment2 = getDeploymentEnvironment();
@@ -5675,7 +5691,7 @@ var init_backfill2 = __esm({
5675
5691
  };
5676
5692
  isBackfillingEvent = async (event) => {
5677
5693
  const backfill = await getBackfillMetadata();
5678
- const events2 = backfill?.eventWhitelist;
5694
+ const events2 = backfill == null ? void 0 : backfill.eventWhitelist;
5679
5695
  if (events2 && events2.includes(event)) {
5680
5696
  return true;
5681
5697
  } else {
@@ -6068,11 +6084,12 @@ var init_auth4 = __esm({
6068
6084
 
6069
6085
  // src/events/publishers/automation.ts
6070
6086
  async function created3(automation, timestamp) {
6087
+ var _a, _b, _c, _d;
6071
6088
  const properties = {
6072
6089
  appId: automation.appId,
6073
6090
  automationId: automation._id,
6074
- triggerId: automation.definition?.trigger?.id,
6075
- triggerType: automation.definition?.trigger?.stepId,
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,
6076
6093
  audited: {
6077
6094
  name: automation.name
6078
6095
  }
@@ -6080,20 +6097,22 @@ async function created3(automation, timestamp) {
6080
6097
  await publishEvent("automation:created" /* AUTOMATION_CREATED */, properties, timestamp);
6081
6098
  }
6082
6099
  async function triggerUpdated(automation) {
6100
+ var _a, _b, _c, _d;
6083
6101
  const properties = {
6084
6102
  appId: automation.appId,
6085
6103
  automationId: automation._id,
6086
- triggerId: automation.definition?.trigger?.id,
6087
- triggerType: automation.definition?.trigger?.stepId
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
6088
6106
  };
6089
6107
  await publishEvent("automation:trigger:updated" /* AUTOMATION_TRIGGER_UPDATED */, properties);
6090
6108
  }
6091
6109
  async function deleted3(automation) {
6110
+ var _a, _b, _c, _d;
6092
6111
  const properties = {
6093
6112
  appId: automation.appId,
6094
6113
  automationId: automation._id,
6095
- triggerId: automation.definition?.trigger?.id,
6096
- triggerType: automation.definition?.trigger?.stepId,
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,
6097
6116
  audited: {
6098
6117
  name: automation.name
6099
6118
  }
@@ -6101,20 +6120,22 @@ async function deleted3(automation) {
6101
6120
  await publishEvent("automation:deleted" /* AUTOMATION_DELETED */, properties);
6102
6121
  }
6103
6122
  async function tested(automation) {
6123
+ var _a, _b, _c, _d;
6104
6124
  const properties = {
6105
6125
  appId: automation.appId,
6106
6126
  automationId: automation._id,
6107
- triggerId: automation.definition?.trigger?.id,
6108
- triggerType: automation.definition?.trigger?.stepId
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
6109
6129
  };
6110
6130
  await publishEvent("automation:tested" /* AUTOMATION_TESTED */, properties);
6111
6131
  }
6112
6132
  async function stepCreated(automation, step, timestamp) {
6133
+ var _a, _b, _c, _d;
6113
6134
  const properties = {
6114
6135
  appId: automation.appId,
6115
6136
  automationId: automation._id,
6116
- triggerId: automation.definition?.trigger?.id,
6117
- triggerType: automation.definition?.trigger?.stepId,
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,
6118
6139
  stepId: step.id,
6119
6140
  stepType: step.stepId,
6120
6141
  audited: {
@@ -6124,11 +6145,12 @@ async function stepCreated(automation, step, timestamp) {
6124
6145
  await publishEvent("automation:step:created" /* AUTOMATION_STEP_CREATED */, properties, timestamp);
6125
6146
  }
6126
6147
  async function stepDeleted(automation, step) {
6148
+ var _a, _b, _c, _d;
6127
6149
  const properties = {
6128
6150
  appId: automation.appId,
6129
6151
  automationId: automation._id,
6130
- triggerId: automation.definition?.trigger?.id,
6131
- triggerType: automation.definition?.trigger?.stepId,
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,
6132
6154
  stepId: step.id,
6133
6155
  stepType: step.stepId,
6134
6156
  audited: {
@@ -6477,23 +6499,25 @@ var init_role3 = __esm({
6477
6499
 
6478
6500
  // src/events/publishers/screen.ts
6479
6501
  async function created8(screen, timestamp) {
6502
+ var _a;
6480
6503
  const properties = {
6481
6504
  layoutId: screen.layoutId,
6482
6505
  screenId: screen._id,
6483
6506
  roleId: screen.routing.roleId,
6484
6507
  audited: {
6485
- name: screen.routing?.route
6508
+ name: (_a = screen.routing) == null ? void 0 : _a.route
6486
6509
  }
6487
6510
  };
6488
6511
  await publishEvent("screen:created" /* SCREEN_CREATED */, properties, timestamp);
6489
6512
  }
6490
6513
  async function deleted8(screen) {
6514
+ var _a;
6491
6515
  const properties = {
6492
6516
  layoutId: screen.layoutId,
6493
6517
  screenId: screen._id,
6494
6518
  roleId: screen.routing.roleId,
6495
6519
  audited: {
6496
- name: screen.routing?.route
6520
+ name: (_a = screen.routing) == null ? void 0 : _a.route
6497
6521
  }
6498
6522
  };
6499
6523
  await publishEvent("screen:deleted" /* SCREEN_DELETED */, properties);
@@ -7362,7 +7386,6 @@ __export(licenses_exports, {
7362
7386
  useEnvironmentVariables: () => useEnvironmentVariables,
7363
7387
  useGroups: () => useGroups,
7364
7388
  useLicense: () => useLicense,
7365
- usePublicApiUserRoles: () => usePublicApiUserRoles,
7366
7389
  useScimIntegration: () => useScimIntegration,
7367
7390
  useSyncAutomations: () => useSyncAutomations,
7368
7391
  useUnlimited: () => useUnlimited
@@ -7424,9 +7447,6 @@ var useEnvironmentVariables = () => {
7424
7447
  var useAuditLogs = () => {
7425
7448
  return useFeature("auditLogs" /* AUDIT_LOGS */);
7426
7449
  };
7427
- var usePublicApiUserRoles = () => {
7428
- return useFeature("userRolePublicApi" /* USER_ROLE_PUBLIC_API */);
7429
- };
7430
7450
  var useScimIntegration = () => {
7431
7451
  return useFeature("scim" /* SCIM */);
7432
7452
  };
@@ -8167,6 +8187,7 @@ var appBuilderUser = (appId, userProps) => {
8167
8187
  };
8168
8188
  };
8169
8189
  function ssoUser(opts = {}) {
8190
+ var _a, _b, _c;
8170
8191
  const base = user(opts.user);
8171
8192
  delete base.password;
8172
8193
  if (!opts.details) {
@@ -8175,9 +8196,9 @@ function ssoUser(opts = {}) {
8175
8196
  return {
8176
8197
  ...base,
8177
8198
  forceResetPassword: false,
8178
- oauth2: opts.details?.oauth2,
8179
- provider: opts.details?.provider,
8180
- providerType: opts.details?.providerType,
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,
8181
8202
  thirdPartyProfile: {
8182
8203
  email: base.email,
8183
8204
  picture: base.pictureUrl
@@ -8343,7 +8364,7 @@ __export(testContainerUtils_exports, {
8343
8364
  var import_child_process = require("child_process");
8344
8365
  var dockerPsResult;
8345
8366
  function formatDockerPsResult(serverName, port) {
8346
- const lines = dockerPsResult?.split("\n");
8367
+ const lines = dockerPsResult == null ? void 0 : dockerPsResult.split("\n");
8347
8368
  let first = true;
8348
8369
  if (!lines) {
8349
8370
  return null;
@@ -8400,14 +8421,11 @@ function getContainerInfo(containerName, port) {
8400
8421
  function getCouchConfig() {
8401
8422
  return getContainerInfo("couchdb-service", 5984);
8402
8423
  }
8403
- function getMinioConfig() {
8404
- return getContainerInfo("minio-service", 9e3);
8405
- }
8406
8424
  function getRedisConfig() {
8407
8425
  return getContainerInfo("redis-service", 6379);
8408
8426
  }
8409
8427
  function setupEnv(...envs) {
8410
- const couch = getCouchConfig(), minio = getMinioConfig(), redis2 = getRedisConfig();
8428
+ const couch = getCouchConfig(), minio = getCouchConfig(), redis2 = getRedisConfig();
8411
8429
  const configs = [
8412
8430
  { key: "COUCH_DB_PORT", value: couch.port },
8413
8431
  { key: "COUCH_DB_URL", value: couch.url },