@budibase/server 2.7.15 → 2.7.17

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/index.js CHANGED
@@ -11,8 +11,8 @@ var __commonJS = (cb, mod) => function __require() {
11
11
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
12
  };
13
13
  var __export = (target, all) => {
14
- for (var name in all)
15
- __defProp(target, name, { get: all[name], enumerable: true });
14
+ for (var name2 in all)
15
+ __defProp(target, name2, { get: all[name2], enumerable: true });
16
16
  };
17
17
  var __copyProps = (to, from, except, desc) => {
18
18
  if (from && typeof from === "object" || typeof from === "function") {
@@ -563,13 +563,13 @@ var init_plan = __esm({
563
563
  var isStaticQuota, isMonthlyQuota, isConstantQuota;
564
564
  var init_quota = __esm({
565
565
  "../types/src/sdk/licensing/quota.ts"() {
566
- isStaticQuota = (quotaType, usageType, name) => {
566
+ isStaticQuota = (quotaType, usageType, name2) => {
567
567
  return quotaType === "usage" /* USAGE */ && usageType === "static" /* STATIC */;
568
568
  };
569
- isMonthlyQuota = (quotaType, usageType, name) => {
569
+ isMonthlyQuota = (quotaType, usageType, name2) => {
570
570
  return quotaType === "usage" /* USAGE */ && usageType === "monthly" /* MONTHLY */;
571
571
  };
572
- isConstantQuota = (quotaType, name) => {
572
+ isConstantQuota = (quotaType, name2) => {
573
573
  return quotaType === "constant" /* CONSTANT */;
574
574
  };
575
575
  }
@@ -679,8 +679,8 @@ var init_locks = __esm({
679
679
  var isDocument;
680
680
  var init_db = __esm({
681
681
  "../types/src/sdk/db.ts"() {
682
- isDocument = (doc) => {
683
- return typeof doc === "object" && doc._id && doc._rev;
682
+ isDocument = (doc2) => {
683
+ return typeof doc2 === "object" && doc2._id && doc2._rev;
684
684
  };
685
685
  }
686
686
  });
@@ -1979,12 +1979,12 @@ function getPouchDB(dbName, opts) {
1979
1979
  checkInitialised();
1980
1980
  const db2 = new Pouch(dbName, opts);
1981
1981
  const dbPut = db2.put;
1982
- db2.put = async (doc, options2 = {}) => {
1983
- if (!doc.createdAt) {
1984
- doc.createdAt = (/* @__PURE__ */ new Date()).toISOString();
1982
+ db2.put = async (doc2, options2 = {}) => {
1983
+ if (!doc2.createdAt) {
1984
+ doc2.createdAt = (/* @__PURE__ */ new Date()).toISOString();
1985
1985
  }
1986
- doc.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1987
- return dbPut(doc, options2);
1986
+ doc2.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1987
+ return dbPut(doc2, options2);
1988
1988
  };
1989
1989
  db2.exists = async () => {
1990
1990
  const info = await db2.info();
@@ -2154,7 +2154,7 @@ var init_DatabaseImpl = __esm({
2154
2154
  }
2155
2155
  return this.updateOutput(() => db2.get(id));
2156
2156
  }
2157
- async remove(idOrDoc, rev) {
2157
+ async remove(idOrDoc, rev2) {
2158
2158
  const db2 = await this.checkSetup();
2159
2159
  let _id;
2160
2160
  let _rev;
@@ -2163,7 +2163,7 @@ var init_DatabaseImpl = __esm({
2163
2163
  _rev = idOrDoc._rev;
2164
2164
  } else {
2165
2165
  _id = idOrDoc;
2166
- _rev = rev;
2166
+ _rev = rev2;
2167
2167
  }
2168
2168
  if (!_id || !_rev) {
2169
2169
  throw new Error("Unable to remove doc without a valid _id and _rev.");
@@ -3439,18 +3439,18 @@ async function newRedlock(opts = {}) {
3439
3439
  }
3440
3440
  function getLockName(opts) {
3441
3441
  const prefix = opts.systemLock ? "system" : getTenantId();
3442
- let name = `lock:${prefix}_${opts.name}`;
3442
+ let name2 = `lock:${prefix}_${opts.name}`;
3443
3443
  if (opts.resource) {
3444
- name = name + `_${opts.resource}`;
3444
+ name2 = name2 + `_${opts.resource}`;
3445
3445
  }
3446
- return name;
3446
+ return name2;
3447
3447
  }
3448
3448
  async function doWithLock(opts, task) {
3449
3449
  const redlock = await getClient(opts.type, opts.customOptions);
3450
3450
  let lock;
3451
3451
  try {
3452
- const name = getLockName(opts);
3453
- lock = await redlock.lock(name, opts.ttl);
3452
+ const name2 = getLockName(opts);
3453
+ lock = await redlock.lock(name2, opts.ttl);
3454
3454
  const result = await task();
3455
3455
  return { executed: true, result };
3456
3456
  } catch (e) {
@@ -4077,8 +4077,8 @@ var init_ids = __esm({
4077
4077
  generateDevInfoID = (userId) => {
4078
4078
  return `${"devinfo" /* DEV_INFO */}${SEPARATOR}${userId}`;
4079
4079
  };
4080
- generatePluginID = (name) => {
4081
- return `${"plg" /* PLUGIN */}${SEPARATOR}${name}`;
4080
+ generatePluginID = (name2) => {
4081
+ return `${"plg" /* PLUGIN */}${SEPARATOR}${name2}`;
4082
4082
  };
4083
4083
  }
4084
4084
  });
@@ -4168,8 +4168,8 @@ var init_params = __esm({
4168
4168
  isDatasourceId = (id) => {
4169
4169
  return id && id.startsWith(`${"datasource" /* DATASOURCE */}${SEPARATOR}`);
4170
4170
  };
4171
- getPluginParams = (pluginId, otherProps = {}) => {
4172
- return getDocParams("plg" /* PLUGIN */, pluginId, otherProps);
4171
+ getPluginParams = (pluginId2, otherProps = {}) => {
4172
+ return getDocParams("plg" /* PLUGIN */, pluginId2, otherProps);
4173
4173
  };
4174
4174
  }
4175
4175
  });
@@ -4306,7 +4306,7 @@ function pagination(data2, pageSize, {
4306
4306
  const hasNextPage = data2.length > pageSize;
4307
4307
  let nextPage = void 0;
4308
4308
  if (!getKey) {
4309
- getKey = (doc) => property ? doc == null ? void 0 : doc[property] : doc == null ? void 0 : doc._id;
4309
+ getKey = (doc2) => property ? doc2 == null ? void 0 : doc2[property] : doc2 == null ? void 0 : doc2._id;
4310
4310
  }
4311
4311
  if (hasNextPage) {
4312
4312
  nextPage = getKey(data2[pageSize]);
@@ -4524,8 +4524,8 @@ var init_Replication = __esm({
4524
4524
  * @param {String} source - the DB you want to replicate or rollback to
4525
4525
  * @param {String} target - the DB you want to replicate to, or rollback from
4526
4526
  */
4527
- constructor({ source, target }) {
4528
- this.source = getPouchDB(source);
4527
+ constructor({ source: source2, target }) {
4528
+ this.source = getPouchDB(source2);
4529
4529
  this.target = getPouchDB(target);
4530
4530
  }
4531
4531
  close() {
@@ -4560,8 +4560,8 @@ var init_Replication = __esm({
4560
4560
  }
4561
4561
  appReplicateOpts() {
4562
4562
  return {
4563
- filter: (doc) => {
4564
- return doc._id !== "app_metadata" /* APP_METADATA */;
4563
+ filter: (doc2) => {
4564
+ return doc2._id !== "app_metadata" /* APP_METADATA */;
4565
4565
  }
4566
4566
  };
4567
4567
  }
@@ -4742,9 +4742,9 @@ var init_lucene = __esm({
4742
4742
  __privateSet(this, _indexBuilder, builderFn);
4743
4743
  return this;
4744
4744
  }
4745
- setVersion(version) {
4746
- if (version != null) {
4747
- __privateSet(this, _version, version);
4745
+ setVersion(version2) {
4746
+ if (version2 != null) {
4747
+ __privateSet(this, _version, version2);
4748
4748
  }
4749
4749
  return this;
4750
4750
  }
@@ -5328,36 +5328,36 @@ async function populateFromDB2(appId) {
5328
5328
  { skip_setup: true }
5329
5329
  );
5330
5330
  }
5331
- function isInvalid(metadata) {
5332
- return !metadata || metadata.state === AppState.INVALID;
5331
+ function isInvalid(metadata2) {
5332
+ return !metadata2 || metadata2.state === AppState.INVALID;
5333
5333
  }
5334
5334
  async function getAppMetadata(appId) {
5335
5335
  const client3 = await getAppClient();
5336
- let metadata = await client3.get(appId);
5337
- if (!metadata) {
5336
+ let metadata2 = await client3.get(appId);
5337
+ if (!metadata2) {
5338
5338
  let expiry = EXPIRY_SECONDS2;
5339
5339
  try {
5340
- metadata = await populateFromDB2(appId);
5340
+ metadata2 = await populateFromDB2(appId);
5341
5341
  } catch (err) {
5342
5342
  if (err && err.status === 404) {
5343
- metadata = { state: AppState.INVALID };
5343
+ metadata2 = { state: AppState.INVALID };
5344
5344
  expiry = void 0;
5345
5345
  } else {
5346
5346
  throw err;
5347
5347
  }
5348
5348
  }
5349
- if (isInvalid(metadata)) {
5349
+ if (isInvalid(metadata2)) {
5350
5350
  const temp = await client3.get(appId);
5351
5351
  if (temp) {
5352
- metadata = temp;
5352
+ metadata2 = temp;
5353
5353
  }
5354
5354
  }
5355
- await client3.store(appId, metadata, expiry);
5355
+ await client3.store(appId, metadata2, expiry);
5356
5356
  }
5357
- if (isInvalid(metadata)) {
5357
+ if (isInvalid(metadata2)) {
5358
5358
  throw { status: 404, message: "No app metadata found" };
5359
5359
  }
5360
- return metadata;
5360
+ return metadata2;
5361
5361
  }
5362
5362
  async function invalidateAppMetadata(appId, newMetadata) {
5363
5363
  if (!appId) {
@@ -5396,18 +5396,18 @@ async function getCache() {
5396
5396
  function makeCacheKey(db2, key) {
5397
5397
  return db2.name + key;
5398
5398
  }
5399
- function makeCacheItem(doc, lastWrite = null) {
5400
- return { doc, lastWrite: lastWrite || Date.now() };
5399
+ function makeCacheItem(doc2, lastWrite = null) {
5400
+ return { doc: doc2, lastWrite: lastWrite || Date.now() };
5401
5401
  }
5402
- async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
5402
+ async function put(db2, doc2, writeRateMs = DEFAULT_WRITE_RATE_MS) {
5403
5403
  const cache2 = await getCache();
5404
- const key = doc._id;
5404
+ const key = doc2._id;
5405
5405
  let cacheItem;
5406
5406
  if (key) {
5407
5407
  cacheItem = await cache2.get(makeCacheKey(db2, key));
5408
5408
  }
5409
5409
  const updateDb = !cacheItem || cacheItem.lastWrite < Date.now() - writeRateMs;
5410
- let output = doc;
5410
+ let output = doc2;
5411
5411
  if (updateDb) {
5412
5412
  const lockResponse = await doWithLock(
5413
5413
  {
@@ -5420,13 +5420,13 @@ async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
5420
5420
  const writeDb = async (toWrite) => {
5421
5421
  const response2 = await db2.put(toWrite, { force: true });
5422
5422
  output = {
5423
- ...doc,
5423
+ ...doc2,
5424
5424
  _id: response2.id,
5425
5425
  _rev: response2.rev
5426
5426
  };
5427
5427
  };
5428
5428
  try {
5429
- await writeDb(doc);
5429
+ await writeDb(doc2);
5430
5430
  } catch (err) {
5431
5431
  if (err.status !== 409) {
5432
5432
  throw err;
@@ -5451,23 +5451,23 @@ async function get2(db2, id) {
5451
5451
  const cacheKey = makeCacheKey(db2, id);
5452
5452
  let cacheItem = await cache2.get(cacheKey);
5453
5453
  if (!cacheItem) {
5454
- const doc = await db2.get(id);
5455
- cacheItem = makeCacheItem(doc);
5454
+ const doc2 = await db2.get(id);
5455
+ cacheItem = makeCacheItem(doc2);
5456
5456
  await cache2.store(cacheKey, cacheItem);
5457
5457
  }
5458
5458
  return cacheItem.doc;
5459
5459
  }
5460
- async function remove(db2, docOrId, rev) {
5460
+ async function remove(db2, docOrId, rev2) {
5461
5461
  const cache2 = await getCache();
5462
5462
  if (!docOrId) {
5463
5463
  throw new Error("No ID/Rev provided.");
5464
5464
  }
5465
5465
  const id = typeof docOrId === "string" ? docOrId : docOrId._id;
5466
- rev = typeof docOrId === "string" ? rev : docOrId._rev;
5466
+ rev2 = typeof docOrId === "string" ? rev2 : docOrId._rev;
5467
5467
  try {
5468
5468
  await cache2.delete(makeCacheKey(db2, id));
5469
5469
  } finally {
5470
- await db2.remove(id, rev);
5470
+ await db2.remove(id, rev2);
5471
5471
  }
5472
5472
  }
5473
5473
  var DEFAULT_WRITE_RATE_MS, CACHE, Writethrough;
@@ -5485,14 +5485,14 @@ var init_writethrough = __esm({
5485
5485
  this.db = db2;
5486
5486
  this.writeRateMs = writeRateMs;
5487
5487
  }
5488
- async put(doc) {
5489
- return put(this.db, doc, this.writeRateMs);
5488
+ async put(doc2) {
5489
+ return put(this.db, doc2, this.writeRateMs);
5490
5490
  }
5491
5491
  async get(id) {
5492
5492
  return get2(this.db, id);
5493
5493
  }
5494
- async remove(docOrId, rev) {
5495
- return remove(this.db, docOrId, rev);
5494
+ async remove(docOrId, rev2) {
5495
+ return remove(this.db, docOrId, rev2);
5496
5496
  }
5497
5497
  };
5498
5498
  }
@@ -5991,7 +5991,7 @@ var init_LoggingProcessor = __esm({
5991
5991
  });
5992
5992
 
5993
5993
  // ../backend-core/src/utils/hashing.ts
5994
- async function hash(data2) {
5994
+ async function hash2(data2) {
5995
5995
  const salt = await bcrypt.genSalt(SALT_ROUNDS);
5996
5996
  return bcrypt.hash(data2, salt);
5997
5997
  }
@@ -6105,14 +6105,14 @@ function isValidInternalAPIKey(apiKey) {
6105
6105
  }
6106
6106
  return false;
6107
6107
  }
6108
- function getCookie(ctx, name) {
6109
- const cookie = ctx.cookies.get(name);
6108
+ function getCookie(ctx, name2) {
6109
+ const cookie = ctx.cookies.get(name2);
6110
6110
  if (!cookie) {
6111
6111
  return cookie;
6112
6112
  }
6113
6113
  return openJwt(cookie);
6114
6114
  }
6115
- function setCookie(ctx, value, name = "builder", opts = { sign: true }) {
6115
+ function setCookie(ctx, value, name2 = "builder", opts = { sign: true }) {
6116
6116
  if (value && opts && opts.sign) {
6117
6117
  value = jwt.sign(value, environment_default.JWT_SECRET);
6118
6118
  }
@@ -6125,10 +6125,10 @@ function setCookie(ctx, value, name = "builder", opts = { sign: true }) {
6125
6125
  if (environment_default.COOKIE_DOMAIN) {
6126
6126
  config.domain = environment_default.COOKIE_DOMAIN;
6127
6127
  }
6128
- ctx.cookies.set(name, value, config);
6128
+ ctx.cookies.set(name2, value, config);
6129
6129
  }
6130
- function clearCookie(ctx, name) {
6131
- setCookie(ctx, null, name);
6130
+ function clearCookie(ctx, name2) {
6131
+ setCookie(ctx, null, name2);
6132
6132
  }
6133
6133
  function isClient(ctx) {
6134
6134
  return ctx.headers["x-budibase-type" /* TYPE */] === "client";
@@ -6176,7 +6176,7 @@ __export(utils_exports2, {
6176
6176
  compare: () => compare,
6177
6177
  getAppIdFromCtx: () => getAppIdFromCtx,
6178
6178
  getCookie: () => getCookie,
6179
- hash: () => hash,
6179
+ hash: () => hash2,
6180
6180
  isAudited: () => isAudited,
6181
6181
  isClient: () => isClient,
6182
6182
  isPublicApiRequest: () => isPublicApiRequest,
@@ -6219,8 +6219,8 @@ var init_inMemoryQueue = __esm({
6219
6219
  * @param {object|null} opts This is not used by the in memory queue as there is no real use
6220
6220
  * case when in memory, but is the same API as Bull
6221
6221
  */
6222
- constructor(name, opts = null) {
6223
- this._name = name;
6222
+ constructor(name2, opts = null) {
6223
+ this._name = name2;
6224
6224
  this._opts = opts;
6225
6225
  this._messages = [];
6226
6226
  this._emitter = new import_events2.default.EventEmitter();
@@ -6717,13 +6717,13 @@ var init_installation = __esm({
6717
6717
  }
6718
6718
  );
6719
6719
  };
6720
- updateVersion = async (version) => {
6720
+ updateVersion = async (version2) => {
6721
6721
  try {
6722
6722
  await doWithDB(
6723
6723
  StaticDatabases.PLATFORM_INFO.name,
6724
6724
  async (platformDb) => {
6725
6725
  const install = await getInstall();
6726
- install.version = version;
6726
+ install.version = version2;
6727
6727
  await platformDb.put(install);
6728
6728
  await bustCache("installation" /* INSTALLATION */);
6729
6729
  }
@@ -6839,13 +6839,13 @@ var init_identification2 = __esm({
6839
6839
  const id = installId;
6840
6840
  const type = "installation" /* INSTALLATION */;
6841
6841
  const hosting = getHostingFromEnv();
6842
- const version = environment_default.VERSION;
6842
+ const version2 = environment_default.VERSION;
6843
6843
  const environment3 = getDeploymentEnvironment();
6844
6844
  const group2 = {
6845
6845
  id,
6846
6846
  type,
6847
6847
  hosting,
6848
- version,
6848
+ version: version2,
6849
6849
  environment: environment3
6850
6850
  };
6851
6851
  await identifyGroup(group2, timestamp);
@@ -7025,10 +7025,10 @@ var init_backfill2 = __esm({
7025
7025
  init_generic();
7026
7026
  init_generic();
7027
7027
  start = async (events2) => {
7028
- const metadata = {
7028
+ const metadata2 = {
7029
7029
  eventWhitelist: events2
7030
7030
  };
7031
- return saveBackfillMetadata(metadata);
7031
+ return saveBackfillMetadata(metadata2);
7032
7032
  };
7033
7033
  recordEvent2 = async (event, properties) => {
7034
7034
  const eventKey2 = getEventKey(event, properties);
@@ -7383,11 +7383,11 @@ var init_app5 = __esm({
7383
7383
  });
7384
7384
 
7385
7385
  // ../backend-core/src/events/publishers/auth.ts
7386
- async function login(source, email) {
7386
+ async function login(source2, email) {
7387
7387
  const identity = await identification_default.getCurrentIdentity();
7388
7388
  const properties = {
7389
7389
  userId: identity.id,
7390
- source,
7390
+ source: source2,
7391
7391
  audited: {
7392
7392
  email
7393
7393
  }
@@ -8267,9 +8267,9 @@ var init_view3 = __esm({
8267
8267
  });
8268
8268
 
8269
8269
  // ../backend-core/src/events/publishers/installation.ts
8270
- async function versionChecked(version) {
8270
+ async function versionChecked(version2) {
8271
8271
  const properties = {
8272
- currentVersion: version
8272
+ currentVersion: version2
8273
8273
  };
8274
8274
  await publishEvent("installation:version:checked" /* INSTALLATION_VERSION_CHECKED */, properties);
8275
8275
  }
@@ -8512,13 +8512,13 @@ async function appBackupRestored(backup) {
8512
8512
  };
8513
8513
  await publishEvent("app:backup:restored" /* APP_BACKUP_RESTORED */, properties);
8514
8514
  }
8515
- async function appBackupTriggered(appId, backupId, type, trigger3, name) {
8515
+ async function appBackupTriggered(appId, backupId, type, trigger3, name2) {
8516
8516
  const properties = {
8517
8517
  appId,
8518
8518
  backupId,
8519
8519
  type,
8520
8520
  trigger: trigger3,
8521
- name
8521
+ name: name2
8522
8522
  };
8523
8523
  await publishEvent("app:backup:triggered" /* APP_BACKUP_TRIGGERED */, properties);
8524
8524
  }
@@ -8535,16 +8535,16 @@ var init_backup4 = __esm({
8535
8535
  });
8536
8536
 
8537
8537
  // ../backend-core/src/events/publishers/environmentVariable.ts
8538
- async function created14(name, environments) {
8538
+ async function created14(name2, environments) {
8539
8539
  const properties = {
8540
- name,
8540
+ name: name2,
8541
8541
  environments
8542
8542
  };
8543
8543
  await publishEvent("environment_variable:created" /* ENVIRONMENT_VARIABLE_CREATED */, properties);
8544
8544
  }
8545
- async function deleted14(name) {
8545
+ async function deleted14(name2) {
8546
8546
  const properties = {
8547
- name
8547
+ name: name2
8548
8548
  };
8549
8549
  await publishEvent("environment_variable:deleted" /* ENVIRONMENT_VARIABLE_DELETED */, properties);
8550
8550
  }
@@ -8745,8 +8745,8 @@ var init_migrations2 = __esm({
8745
8745
  const lengthStatement = length > 1 ? `[${count}/${length}]` : "";
8746
8746
  const db2 = getDB(dbName);
8747
8747
  try {
8748
- const doc = await getMigrationsDoc(db2);
8749
- if (doc[migrationName]) {
8748
+ const doc2 = await getMigrationsDoc(db2);
8749
+ if (doc2[migrationName]) {
8750
8750
  if (options2.force && options2.force[migrationType] && options2.force[migrationType].includes(migrationName)) {
8751
8751
  log2(`[Migration: ${migrationName}] [DB: ${dbName}] Forcing`);
8752
8752
  } else {
@@ -8758,9 +8758,9 @@ var init_migrations2 = __esm({
8758
8758
  `[Migration: ${migrationName}] [DB: ${dbName}] Running ${lengthStatement}`
8759
8759
  );
8760
8760
  if (migration.preventRetry) {
8761
- doc[migrationName] = Date.now();
8762
- const response2 = await db2.put(doc);
8763
- doc._rev = response2.rev;
8761
+ doc2[migrationName] = Date.now();
8762
+ const response2 = await db2.put(doc2);
8763
+ doc2._rev = response2.rev;
8764
8764
  }
8765
8765
  if (migrationType === "app" /* APP */) {
8766
8766
  await doInAppContext(db2.name, async () => {
@@ -8771,8 +8771,8 @@ var init_migrations2 = __esm({
8771
8771
  }
8772
8772
  log2(`[Migration: ${migrationName}] [DB: ${dbName}] Complete`);
8773
8773
  }
8774
- doc[migrationName] = Date.now();
8775
- await db2.put(doc);
8774
+ doc2[migrationName] = Date.now();
8775
+ await db2.put(doc2);
8776
8776
  } catch (err) {
8777
8777
  console.error(
8778
8778
  `[Migration: ${migrationName}] [DB: ${dbName}] Error: `,
@@ -9059,7 +9059,7 @@ var init_users4 = __esm({
9059
9059
  let userList, property = "_id", getKey;
9060
9060
  if (appId) {
9061
9061
  userList = await searchGlobalUsersByApp(appId, opts);
9062
- getKey = (doc) => getGlobalUserByAppPage(appId, doc);
9062
+ getKey = (doc2) => getGlobalUserByAppPage(appId, doc2);
9063
9063
  } else if (email) {
9064
9064
  userList = await searchGlobalUsersByEmail(email, opts);
9065
9065
  property = "email";
@@ -9462,10 +9462,10 @@ var init_roles = __esm({
9462
9462
  BUILTIN_IDS.PUBLIC
9463
9463
  ];
9464
9464
  Role2 = class {
9465
- constructor(id, name, permissionId) {
9465
+ constructor(id, name2, permissionId) {
9466
9466
  this.permissions = {};
9467
9467
  this._id = id;
9468
- this.name = name;
9468
+ this.name = name2;
9469
9469
  this.permissionId = permissionId;
9470
9470
  }
9471
9471
  addInheritance(inherits) {
@@ -9831,12 +9831,12 @@ async function syncUser(user2, details) {
9831
9831
  if (details.profile) {
9832
9832
  const profile = details.profile;
9833
9833
  if (profile.name) {
9834
- const name = profile.name;
9835
- if (name.givenName) {
9836
- firstName = name.givenName;
9834
+ const name2 = profile.name;
9835
+ if (name2.givenName) {
9836
+ firstName = name2.givenName;
9837
9837
  }
9838
- if (name.familyName) {
9839
- lastName = name.familyName;
9838
+ if (name2.familyName) {
9839
+ lastName = name2.familyName;
9840
9840
  }
9841
9841
  }
9842
9842
  pictureUrl = await getProfilePictureUrl(user2, details);
@@ -10352,7 +10352,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
10352
10352
  const noAuthOptions = noAuthPatterns ? buildMatcherRegex(noAuthPatterns) : [];
10353
10353
  return async (ctx, next) => {
10354
10354
  let publicEndpoint = false;
10355
- const version = ctx.request.headers["x-budibase-api-version" /* API_VER */];
10355
+ const version2 = ctx.request.headers["x-budibase-api-version" /* API_VER */];
10356
10356
  const found = matches(ctx, noAuthOptions);
10357
10357
  if (found) {
10358
10358
  publicEndpoint = true;
@@ -10415,7 +10415,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
10415
10415
  if (!authenticated) {
10416
10416
  authenticated = false;
10417
10417
  }
10418
- finalise(ctx, { authenticated, user: user2, internal, version, publicEndpoint });
10418
+ finalise(ctx, { authenticated, user: user2, internal, version: version2, publicEndpoint });
10419
10419
  if (user2 && user2.email) {
10420
10420
  return doInUserContext(user2, ctx, next);
10421
10421
  } else {
@@ -10430,7 +10430,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
10430
10430
  ctx.throw(403, err.message);
10431
10431
  }
10432
10432
  if (opts && opts.publicAllowed || publicEndpoint) {
10433
- finalise(ctx, { authenticated: false, version, publicEndpoint });
10433
+ finalise(ctx, { authenticated: false, version: version2, publicEndpoint });
10434
10434
  return next();
10435
10435
  } else {
10436
10436
  ctx.throw(err.status || 403, err);
@@ -11244,7 +11244,7 @@ var init_objectStore = __esm({
11244
11244
  filename,
11245
11245
  path: path5,
11246
11246
  type,
11247
- metadata
11247
+ metadata: metadata2
11248
11248
  }) => {
11249
11249
  const extension = filename.split(".").pop();
11250
11250
  const fileBytes = import_fs3.default.readFileSync(path5);
@@ -11260,13 +11260,13 @@ var init_objectStore = __esm({
11260
11260
  Body: fileBytes,
11261
11261
  ContentType: contentType
11262
11262
  };
11263
- if (metadata && typeof metadata === "object") {
11264
- for (let key of Object.keys(metadata)) {
11265
- if (!metadata[key] || typeof metadata[key] !== "string") {
11266
- delete metadata[key];
11263
+ if (metadata2 && typeof metadata2 === "object") {
11264
+ for (let key of Object.keys(metadata2)) {
11265
+ if (!metadata2[key] || typeof metadata2[key] !== "string") {
11266
+ delete metadata2[key];
11267
11267
  }
11268
11268
  }
11269
- config.Metadata = metadata;
11269
+ config.Metadata = metadata2;
11270
11270
  }
11271
11271
  return objectStore.upload(config).promise();
11272
11272
  };
@@ -11420,12 +11420,12 @@ var init_objectStore = __esm({
11420
11420
  return deleteFolder(bucketName, folder);
11421
11421
  }
11422
11422
  };
11423
- uploadDirectory = async (bucketName, localPath, bucketPath) => {
11423
+ uploadDirectory = async (bucketName, localPath, bucketPath2) => {
11424
11424
  bucketName = sanitizeBucket(bucketName);
11425
11425
  let uploads = [];
11426
- const files = import_fs3.default.readdirSync(localPath, { withFileTypes: true });
11427
- for (let file of files) {
11428
- const path5 = sanitizeKey((0, import_path2.join)(bucketPath, file.name));
11426
+ const files2 = import_fs3.default.readdirSync(localPath, { withFileTypes: true });
11427
+ for (let file of files2) {
11428
+ const path5 = sanitizeKey((0, import_path2.join)(bucketPath2, file.name));
11429
11429
  const local = (0, import_path2.join)(localPath, file.name);
11430
11430
  if (file.isDirectory()) {
11431
11431
  uploads.push(uploadDirectory(bucketName, local, path5));
@@ -11434,7 +11434,7 @@ var init_objectStore = __esm({
11434
11434
  }
11435
11435
  }
11436
11436
  await Promise.all(uploads);
11437
- return files;
11437
+ return files2;
11438
11438
  };
11439
11439
  downloadTarballDirect = async (url, path5, headers = {}) => {
11440
11440
  path5 = sanitizeKey(path5);
@@ -11508,12 +11508,12 @@ var init_app6 = __esm({
11508
11508
  init_environment2();
11509
11509
  init_objectStore();
11510
11510
  init_cloudfront();
11511
- clientLibraryUrl = (appId, version) => {
11511
+ clientLibraryUrl = (appId, version2) => {
11512
11512
  if (environment_default.isProd()) {
11513
11513
  let file = `${sanitizeKey(appId)}/budibase-client.js`;
11514
11514
  if (environment_default.CLOUDFRONT_CDN) {
11515
- if (version) {
11516
- file += `?v=${version}`;
11515
+ if (version2) {
11516
+ file += `?v=${version2}`;
11517
11517
  }
11518
11518
  return getUrl(file);
11519
11519
  } else {
@@ -11541,8 +11541,8 @@ var init_global3 = __esm({
11541
11541
  init_context2();
11542
11542
  init_objectStore();
11543
11543
  init_cloudfront();
11544
- getGlobalFileUrl = (type, name, etag) => {
11545
- let file = getGlobalFileS3Key(type, name);
11544
+ getGlobalFileUrl = (type, name2, etag) => {
11545
+ let file = getGlobalFileS3Key(type, name2);
11546
11546
  if (environment_default.CLOUDFRONT_CDN) {
11547
11547
  if (etag) {
11548
11548
  file = `${file}?etag=${etag}`;
@@ -11552,8 +11552,8 @@ var init_global3 = __esm({
11552
11552
  return getPresignedUrl(environment_default.GLOBAL_BUCKET_NAME, file);
11553
11553
  }
11554
11554
  };
11555
- getGlobalFileS3Key = (type, name) => {
11556
- let file = `${type}/${name}`;
11555
+ getGlobalFileS3Key = (type, name2) => {
11556
+ let file = `${type}/${name2}`;
11557
11557
  if (environment_default.MULTI_TENANCY) {
11558
11558
  const tenantId = getTenantId();
11559
11559
  file = `${tenantId}/${file}`;
@@ -11603,11 +11603,11 @@ var init_plugins = __esm({
11603
11603
  return getPluginS3Key(plugin, "plugin.min.js");
11604
11604
  };
11605
11605
  getPluginIconKey = (plugin) => {
11606
- const iconFileName = plugin.iconUrl ? "icon.svg" : plugin.iconFileName;
11607
- if (!iconFileName) {
11606
+ const iconFileName2 = plugin.iconUrl ? "icon.svg" : plugin.iconFileName;
11607
+ if (!iconFileName2) {
11608
11608
  return;
11609
11609
  }
11610
- return getPluginS3Key(plugin, iconFileName);
11610
+ return getPluginS3Key(plugin, iconFileName2);
11611
11611
  };
11612
11612
  getPluginS3Key = (plugin, fileName) => {
11613
11613
  const s3Key = getPluginS3Dir(plugin.name);
@@ -12228,9 +12228,9 @@ var init_filesystem = __esm({
12228
12228
  if (!import_fs4.default.existsSync(startPath)) {
12229
12229
  return;
12230
12230
  }
12231
- const files = import_fs4.default.readdirSync(startPath);
12232
- for (let i = 0, len = files.length; i < len; i++) {
12233
- const filename = (0, import_path5.join)(startPath, files[i]);
12231
+ const files2 = import_fs4.default.readdirSync(startPath);
12232
+ for (let i = 0, len = files2.length; i < len; i++) {
12233
+ const filename = (0, import_path5.join)(startPath, files2[i]);
12234
12234
  const stat = import_fs4.default.lstatSync(filename);
12235
12235
  if (stat.isDirectory()) {
12236
12236
  return findFileRec(filename, filter2);
@@ -12418,7 +12418,7 @@ var init_app7 = __esm({
12418
12418
  // src/utilities/fileSystem/plugin.ts
12419
12419
  async function getPluginImpl(path5, plugin) {
12420
12420
  var _a2;
12421
- const hash2 = (_a2 = plugin.schema) == null ? void 0 : _a2.hash;
12421
+ const hash3 = (_a2 = plugin.schema) == null ? void 0 : _a2.hash;
12422
12422
  if (!import_fs7.default.existsSync(path5)) {
12423
12423
  import_fs7.default.mkdirSync(path5);
12424
12424
  }
@@ -12426,7 +12426,7 @@ async function getPluginImpl(path5, plugin) {
12426
12426
  const metadataName = `${filename}.bbmetadata`;
12427
12427
  if (import_fs7.default.existsSync(filename)) {
12428
12428
  const currentHash = import_fs7.default.readFileSync(metadataName, "utf8");
12429
- if (currentHash === hash2) {
12429
+ if (currentHash === hash3) {
12430
12430
  return require(filename);
12431
12431
  } else {
12432
12432
  console.log(`Updating plugin: ${plugin.name}`);
@@ -12440,7 +12440,7 @@ async function getPluginImpl(path5, plugin) {
12440
12440
  pluginKey
12441
12441
  );
12442
12442
  import_fs7.default.writeFileSync(filename, pluginJs);
12443
- import_fs7.default.writeFileSync(metadataName, hash2);
12443
+ import_fs7.default.writeFileSync(metadataName, hash3);
12444
12444
  return require(filename);
12445
12445
  }
12446
12446
  var import_fs7, import_path8, DATASOURCE_PATH, AUTOMATION_PATH, getPluginMetadata, getDatasourcePlugin, getAutomationPlugin;
@@ -12453,13 +12453,13 @@ var init_plugin5 = __esm({
12453
12453
  DATASOURCE_PATH = (0, import_path8.join)(budibaseTempDir2(), "datasource");
12454
12454
  AUTOMATION_PATH = (0, import_path8.join)(budibaseTempDir2(), "automation");
12455
12455
  getPluginMetadata = async (path5) => {
12456
- let metadata = {};
12456
+ let metadata2 = {};
12457
12457
  try {
12458
12458
  const pkg2 = import_fs7.default.readFileSync((0, import_path8.join)(path5, "package.json"), "utf8");
12459
12459
  const schema = import_fs7.default.readFileSync((0, import_path8.join)(path5, "schema.json"), "utf8");
12460
- metadata.schema = JSON.parse(schema);
12461
- metadata.package = JSON.parse(pkg2);
12462
- if (!metadata.package.name || !metadata.package.version || !metadata.package.description) {
12460
+ metadata2.schema = JSON.parse(schema);
12461
+ metadata2.package = JSON.parse(pkg2);
12462
+ if (!metadata2.package.name || !metadata2.package.version || !metadata2.package.description) {
12463
12463
  throw new Error(
12464
12464
  "package.json is missing one of 'name', 'version' or 'description'."
12465
12465
  );
@@ -12469,7 +12469,7 @@ var init_plugin5 = __esm({
12469
12469
  `Unable to process schema.json/package.json in plugin. ${err.message}`
12470
12470
  );
12471
12471
  }
12472
- return { metadata, directory: path5 };
12472
+ return { metadata: metadata2, directory: path5 };
12473
12473
  };
12474
12474
  getDatasourcePlugin = async (plugin) => {
12475
12475
  return getPluginImpl(DATASOURCE_PATH, plugin);
@@ -12486,9 +12486,9 @@ var init_template = __esm({
12486
12486
  "src/utilities/fileSystem/template.ts"() {
12487
12487
  init_constants4();
12488
12488
  init_src2();
12489
- downloadTemplate = async (type, name) => {
12489
+ downloadTemplate = async (type, name2) => {
12490
12490
  const DEFAULT_TEMPLATES_BUCKET2 = "prod-budi-templates.s3-eu-west-1.amazonaws.com";
12491
- const templateUrl = `https://${DEFAULT_TEMPLATES_BUCKET2}/templates/${type}/${name}.tar.gz`;
12491
+ const templateUrl = `https://${DEFAULT_TEMPLATES_BUCKET2}/templates/${type}/${name2}.tar.gz`;
12492
12492
  return objectStore_exports2.downloadTarball(
12493
12493
  templateUrl,
12494
12494
  ObjectStoreBuckets2.TEMPLATES,
@@ -12857,11 +12857,11 @@ var init_utils10 = __esm({
12857
12857
  }
12858
12858
  usage.monthly.current = usage.monthly[currentMonth];
12859
12859
  };
12860
- getBreakdownName = (name, id) => {
12861
- if (!id || !name) {
12860
+ getBreakdownName = (name2, id) => {
12861
+ if (!id || !name2) {
12862
12862
  return;
12863
12863
  }
12864
- switch (name) {
12864
+ switch (name2) {
12865
12865
  case "automations" /* AUTOMATIONS */:
12866
12866
  return "automations" /* AUTOMATIONS */;
12867
12867
  case "queries" /* QUERIES */:
@@ -12923,17 +12923,17 @@ var init_quotas2 = __esm({
12923
12923
  delete usage.usageQuota.developers;
12924
12924
  return usage;
12925
12925
  };
12926
- setUsage = async (value, name, type) => {
12927
- return setAllUsage(name, type, { total: value });
12926
+ setUsage = async (value, name2, type) => {
12927
+ return setAllUsage(name2, type, { total: value });
12928
12928
  };
12929
- setUsagePerApp = async (appValues, name, type) => {
12929
+ setUsagePerApp = async (appValues, name2, type) => {
12930
12930
  const db2 = getDB2();
12931
12931
  let quotaUsage = await getQuotaUsage();
12932
12932
  const total = Object.values(appValues).reduce((sum, num) => sum + num, 0);
12933
12933
  for (let [appId, value] of Object.entries(appValues)) {
12934
12934
  quotaUsage = coreUsageUpdate(
12935
12935
  quotaUsage,
12936
- name,
12936
+ name2,
12937
12937
  type,
12938
12938
  {
12939
12939
  total,
@@ -12948,8 +12948,8 @@ var init_quotas2 = __esm({
12948
12948
  quotaUsage._rev = response2.rev;
12949
12949
  return quotaUsage;
12950
12950
  };
12951
- setBreakdown = (monthUsage, name, id, values) => {
12952
- const breakdownName = getBreakdownName(name, id);
12951
+ setBreakdown = (monthUsage, name2, id, values) => {
12952
+ const breakdownName = getBreakdownName(name2, id);
12953
12953
  if (!breakdownName || !(values == null ? void 0 : values.breakdown)) {
12954
12954
  return monthUsage;
12955
12955
  }
@@ -12958,7 +12958,7 @@ var init_quotas2 = __esm({
12958
12958
  }
12959
12959
  if (!monthUsage.breakdown[breakdownName]) {
12960
12960
  monthUsage.breakdown[breakdownName] = {
12961
- parent: name,
12961
+ parent: name2,
12962
12962
  values: {}
12963
12963
  };
12964
12964
  }
@@ -12966,14 +12966,14 @@ var init_quotas2 = __esm({
12966
12966
  breakdown.values[id] = values.breakdown;
12967
12967
  return monthUsage;
12968
12968
  };
12969
- setAppUsageValue = (quotaUsage, name, type, opts = {}, values) => {
12969
+ setAppUsageValue = (quotaUsage, name2, type, opts = {}, values) => {
12970
12970
  var _a2;
12971
12971
  let appId;
12972
12972
  try {
12973
12973
  appId = db_exports.getProdAppID((opts == null ? void 0 : opts.appId) || context_exports.getAppId());
12974
12974
  } catch (err) {
12975
12975
  }
12976
- if (!appId || !values.app || !APP_QUOTA_NAMES.includes(name)) {
12976
+ if (!appId || !values.app || !APP_QUOTA_NAMES.includes(name2)) {
12977
12977
  return quotaUsage;
12978
12978
  }
12979
12979
  if (!((_a2 = quotaUsage.apps) == null ? void 0 : _a2[appId])) {
@@ -12985,11 +12985,11 @@ var init_quotas2 = __esm({
12985
12985
  const appUsage = quotaUsage.apps[appId];
12986
12986
  switch (type) {
12987
12987
  case "static" /* STATIC */:
12988
- appUsage.usageQuota[name] = values.app;
12988
+ appUsage.usageQuota[name2] = values.app;
12989
12989
  break;
12990
12990
  case "monthly" /* MONTHLY */:
12991
12991
  const currentMonth = getCurrentMonthString();
12992
- const monthlyName = name;
12992
+ const monthlyName = name2;
12993
12993
  let monthUsage = appUsage.monthly[currentMonth];
12994
12994
  if (!monthUsage) {
12995
12995
  appUsage.monthly[currentMonth] = generateNewMonthlyQuotas();
@@ -13003,9 +13003,9 @@ var init_quotas2 = __esm({
13003
13003
  }
13004
13004
  return quotaUsage;
13005
13005
  };
13006
- getAppUsageValue = (quotaUsage, type, name, id) => {
13006
+ getAppUsageValue = (quotaUsage, type, name2, id) => {
13007
13007
  var _a2, _b2, _c, _d, _e;
13008
- if (!APP_QUOTA_NAMES.includes(name)) {
13008
+ if (!APP_QUOTA_NAMES.includes(name2)) {
13009
13009
  return {};
13010
13010
  }
13011
13011
  let appId;
@@ -13019,13 +13019,13 @@ var init_quotas2 = __esm({
13019
13019
  const appUsage = quotaUsage.apps[appId];
13020
13020
  switch (type) {
13021
13021
  case "static" /* STATIC */:
13022
- if ((_a2 = appUsage.usageQuota) == null ? void 0 : _a2[name]) {
13023
- return { app: appUsage.usageQuota[name] };
13022
+ if ((_a2 = appUsage.usageQuota) == null ? void 0 : _a2[name2]) {
13023
+ return { app: appUsage.usageQuota[name2] };
13024
13024
  }
13025
13025
  break;
13026
13026
  case "monthly" /* MONTHLY */:
13027
13027
  const currentMonth = getCurrentMonthString();
13028
- const monthlyName = name;
13028
+ const monthlyName = name2;
13029
13029
  if (!((_c = (_b2 = appUsage.monthly) == null ? void 0 : _b2[currentMonth]) == null ? void 0 : _c[monthlyName])) {
13030
13030
  break;
13031
13031
  }
@@ -13040,68 +13040,68 @@ var init_quotas2 = __esm({
13040
13040
  }
13041
13041
  return { app: 0 };
13042
13042
  };
13043
- setStaticTriggers = (name, quotaUsage, triggers) => {
13043
+ setStaticTriggers = (name2, quotaUsage, triggers) => {
13044
13044
  if (!quotaUsage.usageQuota.triggers) {
13045
13045
  quotaUsage.usageQuota.triggers = {};
13046
13046
  }
13047
13047
  if (triggers) {
13048
- quotaUsage.usageQuota.triggers[name] = triggers;
13048
+ quotaUsage.usageQuota.triggers[name2] = triggers;
13049
13049
  }
13050
13050
  };
13051
- setMonthlyTriggers = (name, currentMonth, quotaUsage, triggers) => {
13051
+ setMonthlyTriggers = (name2, currentMonth, quotaUsage, triggers) => {
13052
13052
  if (!quotaUsage.monthly[currentMonth].triggers) {
13053
13053
  quotaUsage.monthly[currentMonth].triggers = {};
13054
13054
  }
13055
13055
  if (triggers) {
13056
- quotaUsage.monthly[currentMonth].triggers[name] = triggers;
13056
+ quotaUsage.monthly[currentMonth].triggers[name2] = triggers;
13057
13057
  }
13058
13058
  };
13059
- coreUsageUpdate = (quotaUsage, name, type, values, opts = {}) => {
13059
+ coreUsageUpdate = (quotaUsage, name2, type, values, opts = {}) => {
13060
13060
  if (type === "static" /* STATIC */) {
13061
- name = name;
13062
- quotaUsage.usageQuota[name] = values.total;
13063
- setStaticTriggers(name, quotaUsage, values.triggers);
13061
+ name2 = name2;
13062
+ quotaUsage.usageQuota[name2] = values.total;
13063
+ setStaticTriggers(name2, quotaUsage, values.triggers);
13064
13064
  } else if (type === "monthly" /* MONTHLY */) {
13065
- name = name;
13065
+ name2 = name2;
13066
13066
  const currentMonth = getCurrentMonthString();
13067
- quotaUsage.monthly[currentMonth][name] = values.total;
13068
- setMonthlyTriggers(name, currentMonth, quotaUsage, values.triggers);
13067
+ quotaUsage.monthly[currentMonth][name2] = values.total;
13068
+ setMonthlyTriggers(name2, currentMonth, quotaUsage, values.triggers);
13069
13069
  } else {
13070
13070
  throw new Error(`Invalid usage type: ${type}`);
13071
13071
  }
13072
- return setAppUsageValue(quotaUsage, name, type, opts, values);
13072
+ return setAppUsageValue(quotaUsage, name2, type, opts, values);
13073
13073
  };
13074
- setAllUsage = async (name, type, values, opts = {}) => {
13074
+ setAllUsage = async (name2, type, values, opts = {}) => {
13075
13075
  const db2 = getDB2();
13076
13076
  let quotaUsage = await getQuotaUsage();
13077
- quotaUsage = coreUsageUpdate(quotaUsage, name, type, values, opts);
13077
+ quotaUsage = coreUsageUpdate(quotaUsage, name2, type, values, opts);
13078
13078
  const response2 = await db2.put(quotaUsage);
13079
13079
  quotaUsage._rev = response2.rev;
13080
13080
  return quotaUsage;
13081
13081
  };
13082
- getCurrentUsageValues = async (type, name, id) => {
13082
+ getCurrentUsageValues = async (type, name2, id) => {
13083
13083
  const quotaUsage = await getQuotaUsage();
13084
13084
  let total = 0, appValues = {};
13085
13085
  switch (type) {
13086
13086
  case "static" /* STATIC */:
13087
- if (quotaUsage.usageQuota[name]) {
13088
- const staticName = name;
13087
+ if (quotaUsage.usageQuota[name2]) {
13088
+ const staticName = name2;
13089
13089
  total = quotaUsage.usageQuota[staticName];
13090
- appValues = getAppUsageValue(quotaUsage, type, name, id);
13090
+ appValues = getAppUsageValue(quotaUsage, type, name2, id);
13091
13091
  }
13092
13092
  break;
13093
13093
  case "monthly" /* MONTHLY */:
13094
13094
  const currentMonth = getCurrentMonthString();
13095
- const monthlyName = name;
13095
+ const monthlyName = name2;
13096
13096
  if (quotaUsage.monthly[currentMonth][monthlyName]) {
13097
13097
  total = quotaUsage.monthly[currentMonth][monthlyName];
13098
- appValues = getAppUsageValue(quotaUsage, type, name, id);
13098
+ appValues = getAppUsageValue(quotaUsage, type, name2, id);
13099
13099
  }
13100
13100
  break;
13101
13101
  default:
13102
13102
  throw new Error(`Invalid usage type: ${type}`);
13103
13103
  }
13104
- if (APP_QUOTA_NAMES.includes(name) && !(appValues.app || appValues.breakdown)) {
13104
+ if (APP_QUOTA_NAMES.includes(name2) && !(appValues.app || appValues.breakdown)) {
13105
13105
  appValues.app = appValues.app || 0;
13106
13106
  appValues.breakdown = appValues.breakdown || 0;
13107
13107
  }
@@ -13323,9 +13323,9 @@ async function getGroupUsers(groupId, params2) {
13323
13323
  createGroupUserLookupView,
13324
13324
  { arrayResponse: true }
13325
13325
  );
13326
- const users2 = userDocs.map((doc) => ({
13327
- _id: doc.userId,
13328
- email: doc.email
13326
+ const users2 = userDocs.map((doc2) => ({
13327
+ _id: doc2.userId,
13328
+ email: doc2.email
13329
13329
  })) || [];
13330
13330
  return users2;
13331
13331
  }
@@ -13414,12 +13414,12 @@ async function destroy3(groupId, revision) {
13414
13414
  await cleanupUsers(group2);
13415
13415
  return resp;
13416
13416
  }
13417
- async function getByName(name) {
13417
+ async function getByName(name2) {
13418
13418
  try {
13419
13419
  const groups = await db_exports.directCouchFind(tenancy.getGlobalDBName(), {
13420
13420
  selector: {
13421
13421
  name: {
13422
- $regex: `^(?i)${name}$`
13422
+ $regex: `^(?i)${name2}$`
13423
13423
  }
13424
13424
  },
13425
13425
  limit: 1
@@ -13746,11 +13746,11 @@ var init_version2 = __esm({
13746
13746
  }
13747
13747
  };
13748
13748
  getProVersion = () => {
13749
- const version = environment_default.VERSION;
13750
- if (!version) {
13749
+ const version2 = environment_default.VERSION;
13750
+ if (!version2) {
13751
13751
  throw new Error("No budibase pro version was specified");
13752
13752
  }
13753
- return version;
13753
+ return version2;
13754
13754
  };
13755
13755
  }
13756
13756
  });
@@ -13894,15 +13894,15 @@ async function fetchAppBackups(appId, opts = {}) {
13894
13894
  }
13895
13895
  return pageData;
13896
13896
  }
13897
- async function storeAppBackupMetadata(metadata, opts = {}) {
13897
+ async function storeAppBackupMetadata(metadata2, opts = {}) {
13898
13898
  const db2 = tenancy.getGlobalDB();
13899
- const prodAppId = db_exports.getProdAppID(metadata.appId);
13900
- let _id = generateAppBackupID(prodAppId, metadata.timestamp);
13899
+ const prodAppId = db_exports.getProdAppID(metadata2.appId);
13900
+ let _id = generateAppBackupID(prodAppId, metadata2.timestamp);
13901
13901
  const appBackupDoc = {
13902
- ...metadata,
13902
+ ...metadata2,
13903
13903
  _id,
13904
13904
  appId: prodAppId,
13905
- name: metadata.name
13905
+ name: metadata2.name
13906
13906
  };
13907
13907
  if (opts.filename) {
13908
13908
  appBackupDoc.filename = opts.filename;
@@ -13911,18 +13911,18 @@ async function storeAppBackupMetadata(metadata, opts = {}) {
13911
13911
  appBackupDoc._id = opts.docId;
13912
13912
  appBackupDoc._rev = opts.docRev;
13913
13913
  }
13914
- if (metadata.createdBy) {
13914
+ if (metadata2.createdBy) {
13915
13915
  appBackupDoc.createdBy = db_exports.getGlobalIDFromUserMetadataID(
13916
- metadata.createdBy
13916
+ metadata2.createdBy
13917
13917
  );
13918
13918
  }
13919
13919
  return await db2.put(appBackupDoc);
13920
13920
  }
13921
- async function updateAppBackupMetadata(backupId, name) {
13921
+ async function updateAppBackupMetadata(backupId, name2) {
13922
13922
  const db2 = tenancy.getGlobalDB();
13923
- const metadata = await db2.get(backupId);
13924
- metadata.name = name;
13925
- return await db2.put(metadata);
13923
+ const metadata2 = await db2.get(backupId);
13924
+ metadata2.name = name2;
13925
+ return await db2.put(metadata2);
13926
13926
  }
13927
13927
  async function deleteAppBackupMetadata(backupId) {
13928
13928
  const db2 = tenancy.getGlobalDB();
@@ -13957,9 +13957,9 @@ __export(environmentVariables_exports, {
13957
13957
  function getEnvVarID() {
13958
13958
  return StaticDatabases.GLOBAL.docs.environmentVariables;
13959
13959
  }
13960
- function getCacheEnvVarID(rev) {
13960
+ function getCacheEnvVarID(rev2) {
13961
13961
  const tenantId = tenancy.getTenantId();
13962
- return `${tenantId}/${getEnvVarID()}/${rev || ""}`;
13962
+ return `${tenantId}/${getEnvVarID()}/${rev2 || ""}`;
13963
13963
  }
13964
13964
  async function get5() {
13965
13965
  const id = getEnvVarID();
@@ -13999,14 +13999,14 @@ async function get5() {
13999
13999
  cache.set(cacheKey, finalDoc);
14000
14000
  return finalDoc;
14001
14001
  }
14002
- async function update(doc) {
14002
+ async function update(doc2) {
14003
14003
  const id = getEnvVarID();
14004
14004
  const db2 = tenancy.getGlobalDB();
14005
14005
  return await db2.put({
14006
- _id: doc._id || id,
14007
- _rev: doc._rev || void 0,
14006
+ _id: doc2._id || id,
14007
+ _rev: doc2._rev || void 0,
14008
14008
  variables: encryption_exports.encrypt(
14009
- JSON.stringify(doc.variables),
14009
+ JSON.stringify(doc2.variables),
14010
14010
  encryption_exports.SecretOption.ENCRYPTION
14011
14011
  )
14012
14012
  });
@@ -14489,14 +14489,14 @@ var init_quotas5 = __esm({
14489
14489
  init_db7();
14490
14490
  init_src2();
14491
14491
  init_quotas3();
14492
- increment = (name, type, opts) => {
14493
- return tryIncrement(1, name, type, opts);
14492
+ increment = (name2, type, opts) => {
14493
+ return tryIncrement(1, name2, type, opts);
14494
14494
  };
14495
- incrementMany = (change, name, type, opts) => {
14496
- return tryIncrement(change, name, type, opts);
14495
+ incrementMany = (change, name2, type, opts) => {
14496
+ return tryIncrement(change, name2, type, opts);
14497
14497
  };
14498
- tryIncrement = async (change, name, type, opts = {}) => {
14499
- await updateUsage(change, name, type, {
14498
+ tryIncrement = async (change, name2, type, opts = {}) => {
14499
+ await updateUsage(change, name2, type, {
14500
14500
  dryRun: true,
14501
14501
  suppressErrorLog: opts.suppressErrorLog,
14502
14502
  id: opts.id
@@ -14505,7 +14505,7 @@ var init_quotas5 = __esm({
14505
14505
  if (opts.fn) {
14506
14506
  result = await opts.fn();
14507
14507
  }
14508
- await updateUsage(change, name, type, {
14508
+ await updateUsage(change, name2, type, {
14509
14509
  dryRun: false,
14510
14510
  valueFn: opts.valueFn,
14511
14511
  suppressErrorLog: opts.suppressErrorLog,
@@ -14513,32 +14513,32 @@ var init_quotas5 = __esm({
14513
14513
  });
14514
14514
  return result;
14515
14515
  };
14516
- decrement = (name, type, opts = {}) => {
14517
- return updateUsage(-1, name, type, opts);
14516
+ decrement = (name2, type, opts = {}) => {
14517
+ return updateUsage(-1, name2, type, opts);
14518
14518
  };
14519
- decrementMany = (change, name, type, opts = {}) => {
14520
- return updateUsage(-change, name, type, opts);
14519
+ decrementMany = (change, name2, type, opts = {}) => {
14520
+ return updateUsage(-change, name2, type, opts);
14521
14521
  };
14522
- set2 = async (name, type, value) => {
14523
- return quotas_exports.setUsage(value, name, type);
14522
+ set2 = async (name2, type, value) => {
14523
+ return quotas_exports.setUsage(value, name2, type);
14524
14524
  };
14525
- getExistingTriggers = (type, name, quotaUsage) => {
14525
+ getExistingTriggers = (type, name2, quotaUsage) => {
14526
14526
  if (type == "static" /* STATIC */) {
14527
14527
  const triggers = quotaUsage.usageQuota.triggers;
14528
- return triggers ? triggers[name] || {} : {};
14528
+ return triggers ? triggers[name2] || {} : {};
14529
14529
  } else {
14530
14530
  const currentMonthString = quotas_exports.utils.getCurrentMonthString();
14531
14531
  const triggers = quotaUsage.monthly[currentMonthString].triggers;
14532
- return triggers ? triggers[name] || {} : {};
14532
+ return triggers ? triggers[name2] || {} : {};
14533
14533
  }
14534
14534
  };
14535
- triggerQuota2 = async (name, quota, percentage, resetDate) => {
14535
+ triggerQuota2 = async (name2, quota, percentage, resetDate) => {
14536
14536
  try {
14537
14537
  await redlockImpl_exports.doWithLock(
14538
14538
  {
14539
14539
  type: "try_once" /* TRY_ONCE */,
14540
14540
  name: "trigger_quota" /* TRIGGER_QUOTA */,
14541
- resource: name,
14541
+ resource: name2,
14542
14542
  // use the quota name for extra uniqueness on the lock
14543
14543
  ttl: 1e4
14544
14544
  // auto expire after 10 seconds
@@ -14558,10 +14558,10 @@ var init_quotas5 = __esm({
14558
14558
  logging_exports.logAlert("Error triggering quota", e);
14559
14559
  }
14560
14560
  };
14561
- checkTriggers = async (type, name, totalValue, quota) => {
14561
+ checkTriggers = async (type, name2, totalValue, quota) => {
14562
14562
  const usage = await getQuotaUsage();
14563
14563
  const resetDate = type === "monthly" /* MONTHLY */ ? usage.quotaReset : void 0;
14564
- const triggers = await getExistingTriggers(type, name, usage);
14564
+ const triggers = await getExistingTriggers(type, name2, usage);
14565
14565
  const quotaTriggers = quota.triggers;
14566
14566
  let percentage = totalValue / quota.value * 100;
14567
14567
  if (percentage > 100) {
@@ -14577,7 +14577,7 @@ var init_quotas5 = __esm({
14577
14577
  const isAtTrigger = percentage === triggerPercentage;
14578
14578
  const sendNotification = !nextIsTriggered || isAtTrigger;
14579
14579
  if (sendNotification) {
14580
- await triggerQuota2(name, quota, percentage, resetDate);
14580
+ await triggerQuota2(name2, quota, percentage, resetDate);
14581
14581
  }
14582
14582
  }
14583
14583
  } else {
@@ -14586,23 +14586,23 @@ var init_quotas5 = __esm({
14586
14586
  }
14587
14587
  return triggers;
14588
14588
  };
14589
- updateUsage = async (usageChange, name, type, opts = {}) => {
14589
+ updateUsage = async (usageChange, name2, type, opts = {}) => {
14590
14590
  let appId = null;
14591
14591
  try {
14592
14592
  appId = context_exports.getAppId();
14593
14593
  } catch (err) {
14594
14594
  }
14595
- const isAppQuota = APP_QUOTA_NAMES.includes(name);
14595
+ const isAppQuota = APP_QUOTA_NAMES.includes(name2);
14596
14596
  if (isAppQuota && !appId) {
14597
14597
  throw new Error("App context required for quota update");
14598
14598
  }
14599
14599
  try {
14600
- const licensedQuota = await getLicensedQuota("usage" /* USAGE */, name, type);
14600
+ const licensedQuota = await getLicensedQuota("usage" /* USAGE */, name2, type);
14601
14601
  let {
14602
14602
  total: totalValue,
14603
14603
  app: appValue,
14604
14604
  breakdown: breakdownValue
14605
- } = await quotas_exports.getCurrentUsageValues(type, name, opts.id);
14605
+ } = await quotas_exports.getCurrentUsageValues(type, name2, opts.id);
14606
14606
  totalValue += usageChange;
14607
14607
  if (appValue != null) {
14608
14608
  appValue += usageChange;
@@ -14612,7 +14612,7 @@ var init_quotas5 = __esm({
14612
14612
  }
14613
14613
  let triggers = {};
14614
14614
  if (!opts.dryRun) {
14615
- triggers = await checkTriggers(type, name, totalValue, licensedQuota);
14615
+ triggers = await checkTriggers(type, name2, totalValue, licensedQuota);
14616
14616
  }
14617
14617
  if (licensedQuota.value !== quotas_exports2.UNLIMITED && totalValue > licensedQuota.value && usageChange > 0) {
14618
14618
  throw new UsageLimitError(
@@ -14635,7 +14635,7 @@ var init_quotas5 = __esm({
14635
14635
  appValue = totalValue;
14636
14636
  }
14637
14637
  await quotas_exports.setAllUsage(
14638
- name,
14638
+ name2,
14639
14639
  type,
14640
14640
  {
14641
14641
  total: totalValue,
@@ -14647,30 +14647,30 @@ var init_quotas5 = __esm({
14647
14647
  );
14648
14648
  } catch (err) {
14649
14649
  if (!opts.suppressErrorLog) {
14650
- console.error(`Error updating usage quotas for ${name}`, err);
14650
+ console.error(`Error updating usage quotas for ${name2}`, err);
14651
14651
  }
14652
14652
  throw err;
14653
14653
  }
14654
14654
  };
14655
- getLicensedQuota = async (quotaType, name, usageType) => {
14655
+ getLicensedQuota = async (quotaType, name2, usageType) => {
14656
14656
  const license = await cache_exports2.getCachedLicense();
14657
14657
  if (!license) {
14658
14658
  const tenantId = tenancy.getTenantId();
14659
14659
  throw new Error("License not found for tenant id " + tenantId);
14660
14660
  }
14661
- if (usageType && isStaticQuota(quotaType, usageType, name)) {
14662
- return license.quotas[quotaType][usageType][name];
14663
- } else if (usageType && isMonthlyQuota(quotaType, usageType, name)) {
14664
- return license.quotas[quotaType][usageType][name];
14665
- } else if (isConstantQuota(quotaType, name)) {
14666
- return license.quotas[quotaType][name];
14661
+ if (usageType && isStaticQuota(quotaType, usageType, name2)) {
14662
+ return license.quotas[quotaType][usageType][name2];
14663
+ } else if (usageType && isMonthlyQuota(quotaType, usageType, name2)) {
14664
+ return license.quotas[quotaType][usageType][name2];
14665
+ } else if (isConstantQuota(quotaType, name2)) {
14666
+ return license.quotas[quotaType][name2];
14667
14667
  } else {
14668
14668
  throw new Error("Invalid quota type");
14669
14669
  }
14670
14670
  };
14671
- usageLimitIsExceeded = async (name, type) => {
14671
+ usageLimitIsExceeded = async (name2, type) => {
14672
14672
  try {
14673
- await updateUsage(1, name, type, { dryRun: true });
14673
+ await updateUsage(1, name2, type, { dryRun: true });
14674
14674
  return false;
14675
14675
  } catch (e) {
14676
14676
  if (e.code === "usage_limit_exceeded" /* USAGE_LIMIT_EXCEEDED */) {
@@ -15209,7 +15209,7 @@ async function getLogsByView(startDate, endDate, viewParams = {}) {
15209
15209
  async function writeLog(automation, results) {
15210
15210
  const db2 = context_exports.getProdAppDB();
15211
15211
  const automationId = automation._id;
15212
- const name = automation.name;
15212
+ const name2 = automation.name;
15213
15213
  const status2 = getStatus2(results);
15214
15214
  const isoDate = (/* @__PURE__ */ new Date()).toISOString();
15215
15215
  const id = generateAutomationLogID(isoDate, status2, automationId);
@@ -15218,7 +15218,7 @@ async function writeLog(automation, results) {
15218
15218
  ...results,
15219
15219
  automationId,
15220
15220
  status: status2,
15221
- automationName: name,
15221
+ automationName: name2,
15222
15222
  createdAt: isoDate,
15223
15223
  _id: id
15224
15224
  };
@@ -15228,13 +15228,13 @@ async function writeLog(automation, results) {
15228
15228
  async function updateAppMetadataWithErrors(logIds, { clearing } = { clearing: false }) {
15229
15229
  const db2 = context_exports.getProdAppDB();
15230
15230
  await backOff(async () => {
15231
- const metadata = await db2.get(db_exports.DocumentType.APP_METADATA);
15231
+ const metadata2 = await db2.get(db_exports.DocumentType.APP_METADATA);
15232
15232
  for (let logId of logIds) {
15233
15233
  const parts = logId.split(db_exports.SEPARATOR);
15234
15234
  const autoId = `${parts[parts.length - 3]}${db_exports.SEPARATOR}${parts[parts.length - 2]}`;
15235
15235
  let errors = {};
15236
- if (metadata.automationErrors) {
15237
- errors = metadata.automationErrors;
15236
+ if (metadata2.automationErrors) {
15237
+ errors = metadata2.automationErrors;
15238
15238
  }
15239
15239
  if (!Array.isArray(errors[autoId])) {
15240
15240
  errors[autoId] = [];
@@ -15248,10 +15248,10 @@ async function updateAppMetadataWithErrors(logIds, { clearing } = { clearing: fa
15248
15248
  if (errors[autoId].length === 0) {
15249
15249
  delete errors[autoId];
15250
15250
  }
15251
- metadata.automationErrors = errors;
15251
+ metadata2.automationErrors = errors;
15252
15252
  }
15253
- await db2.put(metadata);
15254
- await cache_exports.app.invalidateAppMetadata(metadata.appId, metadata);
15253
+ await db2.put(metadata2);
15254
+ await cache_exports.app.invalidateAppMetadata(metadata2.appId, metadata2);
15255
15255
  }, "Failed to update app metadata with automation log error");
15256
15256
  }
15257
15257
  async function getExpiredLogs() {
@@ -15273,16 +15273,16 @@ async function clearOldHistory() {
15273
15273
  if (!expired.data || expired.data.length === 0) {
15274
15274
  return;
15275
15275
  }
15276
- const toDelete = expired.data.map((doc) => ({
15277
- _id: doc.id,
15278
- _rev: doc.value.rev,
15276
+ const toDelete = expired.data.map((doc2) => ({
15277
+ _id: doc2.id,
15278
+ _rev: doc2.value.rev,
15279
15279
  _deleted: true
15280
15280
  }));
15281
- const errorLogIds = expired.data.filter((doc) => {
15282
- const parts = doc.id.split(db_exports.SEPARATOR);
15281
+ const errorLogIds = expired.data.filter((doc2) => {
15282
+ const parts = doc2.id.split(db_exports.SEPARATOR);
15283
15283
  const status2 = parts[parts.length - 1];
15284
15284
  return status2 === "error" /* ERROR */;
15285
- }).map((doc) => doc.id);
15285
+ }).map((doc2) => doc2.id);
15286
15286
  await db2.bulkDocs(toDelete);
15287
15287
  if (errorLogIds.length) {
15288
15288
  await updateAppMetadataWithErrors(errorLogIds, { clearing: true });
@@ -15502,10 +15502,10 @@ async function get6(id) {
15502
15502
  async function getBulk2(ids, opts = { enriched: true }) {
15503
15503
  return await groups_exports.getBulk(ids, opts);
15504
15504
  }
15505
- async function guardNameAvailility(name) {
15506
- const existingGroup = await groups_exports.getByName(name);
15505
+ async function guardNameAvailility(name2) {
15506
+ const existingGroup = await groups_exports.getByName(name2);
15507
15507
  if (existingGroup) {
15508
- throw new GroupNameUnavailableError(name);
15508
+ throw new GroupNameUnavailableError(name2);
15509
15509
  }
15510
15510
  }
15511
15511
  async function save4(group2) {
@@ -15664,8 +15664,8 @@ var init_groups6 = __esm({
15664
15664
  });
15665
15665
 
15666
15666
  // ../pro/packages/pro/src/utilities/fileSystem.ts
15667
- function loadJSFile(directory, name) {
15668
- return import_fs10.default.readFileSync((0, import_path11.join)(directory, name), "utf8");
15667
+ function loadJSFile(directory2, name2) {
15668
+ return import_fs10.default.readFileSync((0, import_path11.join)(directory2, name2), "utf8");
15669
15669
  }
15670
15670
  var import_fs10, import_path11;
15671
15671
  var init_fileSystem2 = __esm({
@@ -15683,8 +15683,8 @@ __export(plugins_exports, {
15683
15683
  storePlugin: () => storePlugin
15684
15684
  });
15685
15685
  async function storePlugin(metadata, directory, source) {
15686
- const db2 = tenancy.getGlobalDB();
15687
- const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description, hash2 = metadata.schema.hash;
15686
+ const db = tenancy.getGlobalDB();
15687
+ const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description, hash = metadata.schema.hash;
15688
15688
  const bucketPath = objectStore_exports2.getPluginS3Dir(name);
15689
15689
  const files = await objectStore_exports2.uploadDirectory(
15690
15690
  objectStore_exports2.ObjectStoreBuckets.PLUGINS,
@@ -15699,8 +15699,7 @@ async function storePlugin(metadata, directory, source) {
15699
15699
  if (metadata.schema.type === "datasource" /* DATASOURCE */) {
15700
15700
  const js = loadJSFile(directory, jsFile.name);
15701
15701
  try {
15702
- ;
15703
- (0, eval)(js);
15702
+ eval(js);
15704
15703
  } catch (err) {
15705
15704
  const message = (err == null ? void 0 : err.message) ? err.message : JSON.stringify(err);
15706
15705
  throw new Error(`JS invalid: ${message}`);
@@ -15710,7 +15709,7 @@ async function storePlugin(metadata, directory, source) {
15710
15709
  const pluginId = db_exports.generatePluginID(name);
15711
15710
  let rev;
15712
15711
  try {
15713
- const existing = await db2.get(pluginId);
15712
+ const existing = await db.get(pluginId);
15714
15713
  rev = existing._rev;
15715
15714
  } catch (err) {
15716
15715
  rev = void 0;
@@ -15721,7 +15720,7 @@ async function storePlugin(metadata, directory, source) {
15721
15720
  ...metadata,
15722
15721
  name,
15723
15722
  version,
15724
- hash: hash2,
15723
+ hash,
15725
15724
  description
15726
15725
  };
15727
15726
  if (iconFileName) {
@@ -15733,8 +15732,8 @@ async function storePlugin(metadata, directory, source) {
15733
15732
  source
15734
15733
  };
15735
15734
  }
15736
- const write7 = async () => {
15737
- const response2 = await db2.put(doc);
15735
+ const write = async () => {
15736
+ const response2 = await db.put(doc);
15738
15737
  await events_exports.plugin.imported(doc);
15739
15738
  return {
15740
15739
  ...doc,
@@ -15742,21 +15741,21 @@ async function storePlugin(metadata, directory, source) {
15742
15741
  };
15743
15742
  };
15744
15743
  if (!rev) {
15745
- return await addPlugin(write7);
15744
+ return await addPlugin(write);
15746
15745
  } else {
15747
- return await write7();
15746
+ return await write();
15748
15747
  }
15749
15748
  }
15750
- async function deletePlugin(pluginId) {
15749
+ async function deletePlugin(pluginId2) {
15751
15750
  const db2 = tenancy.getGlobalDB();
15752
15751
  try {
15753
- const plugin = await db2.get(pluginId);
15754
- const bucketPath = objectStore_exports2.getPluginS3Dir(plugin.name);
15752
+ const plugin = await db2.get(pluginId2);
15753
+ const bucketPath2 = objectStore_exports2.getPluginS3Dir(plugin.name);
15755
15754
  await objectStore_exports2.deleteFolder(
15756
15755
  objectStore_exports2.ObjectStoreBuckets.PLUGINS,
15757
- bucketPath
15756
+ bucketPath2
15758
15757
  );
15759
- await db2.remove(pluginId, plugin._rev);
15758
+ await db2.remove(pluginId2, plugin._rev);
15760
15759
  await events_exports.plugin.deleted(plugin);
15761
15760
  await removePlugin();
15762
15761
  } catch (err) {
@@ -15790,12 +15789,12 @@ function isEncryptionKeyAvailable() {
15790
15789
  return !!environment_default.ENCRYPTION_KEY;
15791
15790
  }
15792
15791
  async function fetch10() {
15793
- const doc = await environmentVariables_exports.get();
15794
- return Object.keys(doc.variables);
15792
+ const doc2 = await environmentVariables_exports.get();
15793
+ return Object.keys(doc2.variables);
15795
15794
  }
15796
15795
  async function fetchValues(environment3) {
15797
- const doc = await environmentVariables_exports.get();
15798
- const decrypted = doc.variables;
15796
+ const doc2 = await environmentVariables_exports.get();
15797
+ const decrypted = doc2.variables;
15799
15798
  const output = {};
15800
15799
  for (let [key, value] of Object.entries(decrypted)) {
15801
15800
  switch (environment3) {
@@ -15817,9 +15816,9 @@ async function changeValues(cb) {
15817
15816
  "User does not have access to environment variables feature."
15818
15817
  );
15819
15818
  }
15820
- const doc = await environmentVariables_exports.get();
15821
- doc.variables = cb(doc.variables);
15822
- await environmentVariables_exports.update(doc);
15819
+ const doc2 = await environmentVariables_exports.get();
15820
+ doc2.variables = cb(doc2.variables);
15821
+ await environmentVariables_exports.update(doc2);
15823
15822
  }
15824
15823
  async function update2(varName, value) {
15825
15824
  const checkName = isValid(varName);
@@ -15870,15 +15869,15 @@ var init_environmentVariables6 = __esm({
15870
15869
  function generateAuditLogID(timestamp) {
15871
15870
  return `${"al" /* AUDIT_LOG */}${SEPARATOR}${timestamp}${SEPARATOR}${utils_exports2.newid()}`;
15872
15871
  }
15873
- async function save5(doc) {
15874
- if (!doc._id) {
15875
- doc._id = generateAuditLogID(doc.timestamp);
15872
+ async function save5(doc2) {
15873
+ if (!doc2._id) {
15874
+ doc2._id = generateAuditLogID(doc2.timestamp);
15876
15875
  }
15877
15876
  try {
15878
15877
  const db2 = context_exports.getAuditLogsDB();
15879
- const response2 = await db2.put(doc);
15878
+ const response2 = await db2.put(doc2);
15880
15879
  return {
15881
- ...doc,
15880
+ ...doc2,
15882
15881
  _rev: response2.rev
15883
15882
  };
15884
15883
  } catch (err) {
@@ -15906,9 +15905,9 @@ function dump(params2) {
15906
15905
  const db2 = context_exports.getAuditLogsDB();
15907
15906
  const stream3 = new MemoryStream();
15908
15907
  const promise = db2.dump(stream3, {
15909
- filter: (doc) => {
15908
+ filter: (doc2) => {
15910
15909
  var _a2;
15911
- const auditLog = doc;
15910
+ const auditLog = doc2;
15912
15911
  if (!((_a2 = auditLog._id) == null ? void 0 : _a2.startsWith("al" /* AUDIT_LOG */))) {
15913
15912
  return false;
15914
15913
  }
@@ -15926,7 +15925,7 @@ function dump(params2) {
15926
15925
  allMatched = allMatched && auditLog.timestamp >= params2.startDate && auditLog.timestamp <= params2.endDate;
15927
15926
  }
15928
15927
  if (params2.fullSearch) {
15929
- const json2 = JSON.stringify(doc);
15928
+ const json2 = JSON.stringify(doc2);
15930
15929
  allMatched = allMatched && json2.includes(params2.fullSearch);
15931
15930
  }
15932
15931
  return allMatched;
@@ -15937,8 +15936,8 @@ function dump(params2) {
15937
15936
  const json2 = JSON.parse(Buffer.from(data2).toString());
15938
15937
  if (Array.isArray(json2.docs)) {
15939
15938
  let str = "";
15940
- for (let doc of json2.docs) {
15941
- str += JSON.stringify(doc) + "\n";
15939
+ for (let doc2 of json2.docs) {
15940
+ str += JSON.stringify(doc2) + "\n";
15942
15941
  }
15943
15942
  returnStream.write(str);
15944
15943
  }
@@ -15963,8 +15962,8 @@ var init_auditLogs4 = __esm({
15963
15962
  var require_Helper = __commonJS({
15964
15963
  "../string-templates/src/helpers/Helper.js"(exports2, module2) {
15965
15964
  var Helper = class {
15966
- constructor(name, fn2, useValueFallback = true) {
15967
- this.name = name;
15965
+ constructor(name2, fn2, useValueFallback = true) {
15966
+ this.name = name2;
15968
15967
  this.fn = fn2;
15969
15968
  this.useValueFallback = useValueFallback;
15970
15969
  }
@@ -16133,18 +16132,18 @@ var require_external = __commonJS({
16133
16132
  exports2.externalCollections = EXTERNAL_FUNCTION_COLLECTIONS;
16134
16133
  exports2.addedHelpers = ADDED_HELPERS;
16135
16134
  exports2.registerAll = (handlebars) => {
16136
- for (let [name, helper] of Object.entries(ADDED_HELPERS)) {
16137
- handlebars.registerHelper(name, helper);
16135
+ for (let [name2, helper] of Object.entries(ADDED_HELPERS)) {
16136
+ handlebars.registerHelper(name2, helper);
16138
16137
  }
16139
16138
  let externalNames = [];
16140
16139
  for (let collection of EXTERNAL_FUNCTION_COLLECTIONS) {
16141
16140
  let hbsHelperInfo = helpers[collection]();
16142
16141
  for (let entry of Object.entries(hbsHelperInfo)) {
16143
- const name = entry[0];
16144
- if (HelperFunctionBuiltin.indexOf(name) !== -1 || externalNames.indexOf(name) !== -1) {
16142
+ const name2 = entry[0];
16143
+ if (HelperFunctionBuiltin.indexOf(name2) !== -1 || externalNames.indexOf(name2) !== -1) {
16145
16144
  continue;
16146
16145
  }
16147
- externalNames.push(name);
16146
+ externalNames.push(name2);
16148
16147
  }
16149
16148
  helpers[collection]({
16150
16149
  handlebars
@@ -16153,11 +16152,11 @@ var require_external = __commonJS({
16153
16152
  exports2.externalHelperNames = externalNames.concat(Object.keys(ADDED_HELPERS));
16154
16153
  };
16155
16154
  exports2.unregisterAll = (handlebars) => {
16156
- for (let name of Object.keys(ADDED_HELPERS)) {
16157
- handlebars.unregisterHelper(name);
16155
+ for (let name2 of Object.keys(ADDED_HELPERS)) {
16156
+ handlebars.unregisterHelper(name2);
16158
16157
  }
16159
- for (let name of module2.exports.externalHelperNames) {
16160
- handlebars.unregisterHelper(name);
16158
+ for (let name2 of module2.exports.externalHelperNames) {
16159
+ handlebars.unregisterHelper(name2);
16161
16160
  }
16162
16161
  exports2.externalHelperNames = [];
16163
16162
  };
@@ -16271,12 +16270,12 @@ var require_javascript = __commonJS({
16271
16270
  throw new Error("JS disabled in environment.");
16272
16271
  }
16273
16272
  try {
16274
- const js = `function run(){${atob(handlebars)}};run();`;
16273
+ const js2 = `function run(){${atob(handlebars)}};run();`;
16275
16274
  const sandboxContext = {
16276
16275
  $: (path5) => getContextValue(path5, cloneDeep18(context)),
16277
16276
  helpers: getHelperList()
16278
16277
  };
16279
- const res = { data: runJS(js, sandboxContext) };
16278
+ const res = { data: runJS(js2, sandboxContext) };
16280
16279
  return `{{${LITERAL_MARKER} js_result-${JSON.stringify(res)}}}`;
16281
16280
  } catch (error2) {
16282
16281
  return "Error while executing JS";
@@ -16389,8 +16388,8 @@ var require_preprocessor = __commonJS({
16389
16388
  FINALISE: "finalise"
16390
16389
  };
16391
16390
  var Preprocessor = class {
16392
- constructor(name, fn2) {
16393
- this.name = name;
16391
+ constructor(name2, fn2) {
16392
+ this.name = name2;
16394
16393
  this.fn = fn2;
16395
16394
  }
16396
16395
  process(fullString, statement, opts) {
@@ -16454,8 +16453,8 @@ var require_postprocessor = __commonJS({
16454
16453
  CONVERT_LITERALS: "convert-literals"
16455
16454
  };
16456
16455
  var Postprocessor = class {
16457
- constructor(name, fn2) {
16458
- this.name = name;
16456
+ constructor(name2, fn2) {
16457
+ this.name = name2;
16459
16458
  this.fn = fn2;
16460
16459
  }
16461
16460
  process(statement) {
@@ -18097,10 +18096,10 @@ var require_src = __commonJS({
18097
18096
  };
18098
18097
  module2.exports.convertToJS = (hbs) => {
18099
18098
  const blocks = exports2.findHBSBlocks(hbs);
18100
- let js = "return `", prevBlock = null;
18099
+ let js2 = "return `", prevBlock = null;
18101
18100
  const variables = {};
18102
18101
  if (blocks.length === 0) {
18103
- js += hbs;
18102
+ js2 += hbs;
18104
18103
  }
18105
18104
  let count = 1;
18106
18105
  for (let block of blocks) {
@@ -18112,15 +18111,15 @@ var require_src = __commonJS({
18112
18111
  prevBlock = block;
18113
18112
  const { variable, value } = convertHBSBlock(block, count++);
18114
18113
  variables[variable] = value;
18115
- js += `${stringPart.split()}\${${variable}}`;
18114
+ js2 += `${stringPart.split()}\${${variable}}`;
18116
18115
  }
18117
18116
  let varBlock = "";
18118
18117
  for (let [variable, value] of Object.entries(variables)) {
18119
18118
  varBlock += `const ${variable} = ${value};
18120
18119
  `;
18121
18120
  }
18122
- js += "`;";
18123
- return `${varBlock}${js}`;
18121
+ js2 += "`;";
18122
+ return `${varBlock}${js2}`;
18124
18123
  };
18125
18124
  }
18126
18125
  });
@@ -18147,12 +18146,12 @@ var require_src2 = __commonJS({
18147
18146
  if (!process.env.NO_JS) {
18148
18147
  const { VM: VM2 } = require("vm2");
18149
18148
  const { setJSRunner } = require_javascript();
18150
- setJSRunner((js, context) => {
18149
+ setJSRunner((js2, context) => {
18151
18150
  const vm = new VM2({
18152
18151
  sandbox: context,
18153
18152
  timeout: 1e3
18154
18153
  });
18155
- return vm.run(js);
18154
+ return vm.run(js2);
18156
18155
  });
18157
18156
  }
18158
18157
  }
@@ -18246,12 +18245,12 @@ async function auditLogsEnabled() {
18246
18245
  const license = await licensing_exports.cache.getCachedLicense();
18247
18246
  return license.features.includes("auditLogs" /* AUDIT_LOGS */);
18248
18247
  }
18249
- function getEventFriendlyName(event, metadata) {
18248
+ function getEventFriendlyName(event, metadata2) {
18250
18249
  const friendly = AuditedEventFriendlyName[event];
18251
18250
  if (!friendly) {
18252
18251
  throw new Error("No friendly name found.");
18253
18252
  }
18254
- let processed = processStringSync(friendly, metadata);
18253
+ let processed = processStringSync(friendly, metadata2);
18255
18254
  if (processed.includes(`""`)) {
18256
18255
  processed = removeTemplateStrings(friendly);
18257
18256
  }
@@ -18273,29 +18272,29 @@ var init_utils11 = __esm({
18273
18272
  });
18274
18273
 
18275
18274
  // ../pro/packages/pro/src/sdk/auditLogs/auditLogs.ts
18276
- async function write(event, metadata, opts) {
18275
+ async function write2(event, metadata2, opts) {
18277
18276
  if (!await auditLogsEnabled() || !utils_exports2.isAudited(event)) {
18278
18277
  return;
18279
18278
  }
18280
- const friendly = getEventFriendlyName(event, metadata);
18279
+ const friendly = getEventFriendlyName(event, metadata2);
18281
18280
  let date = /* @__PURE__ */ new Date();
18282
18281
  if (opts == null ? void 0 : opts.timestamp) {
18283
18282
  date = new Date(opts.timestamp);
18284
18283
  }
18285
- const doc = {
18284
+ const doc2 = {
18286
18285
  timestamp: date.toISOString(),
18287
18286
  event,
18288
18287
  name: friendly,
18289
18288
  userId: (opts == null ? void 0 : opts.userId) || AuditLogSystemUser,
18290
18289
  metadata: {
18291
- ...metadata,
18290
+ ...metadata2,
18292
18291
  ...opts == null ? void 0 : opts.hostInfo
18293
18292
  }
18294
18293
  };
18295
18294
  const fallback = {};
18296
18295
  try {
18297
18296
  if (opts == null ? void 0 : opts.appId) {
18298
- doc.appId = db_exports.getProdAppID(opts.appId);
18297
+ doc2.appId = db_exports.getProdAppID(opts.appId);
18299
18298
  const appMetadata = await cache_exports.app.getAppMetadata(opts.appId);
18300
18299
  fallback.appName = appMetadata.name;
18301
18300
  }
@@ -18309,8 +18308,8 @@ async function write(event, metadata, opts) {
18309
18308
  err
18310
18309
  );
18311
18310
  }
18312
- doc.fallback = fallback;
18313
- return await save5(doc);
18311
+ doc2.fallback = fallback;
18312
+ return await save5(doc2);
18314
18313
  }
18315
18314
  async function enrich(logs) {
18316
18315
  const allUserIds = logs.map((log2) => log2.userId);
@@ -18382,7 +18381,7 @@ __export(auditLogs_exports2, {
18382
18381
  definitions: () => definitions,
18383
18382
  download: () => download,
18384
18383
  fetch: () => fetch11,
18385
- write: () => write
18384
+ write: () => write2
18386
18385
  });
18387
18386
  var init_auditLogs6 = __esm({
18388
18387
  "../pro/packages/pro/src/sdk/auditLogs/index.ts"() {
@@ -18405,8 +18404,8 @@ var init_queue4 = __esm({
18405
18404
  });
18406
18405
 
18407
18406
  // ../pro/packages/pro/src/sdk/backups/backup.ts
18408
- async function storeAppBackupMetadata2(metadata, opts = {}) {
18409
- return backups_exports.storeAppBackupMetadata(metadata, opts);
18407
+ async function storeAppBackupMetadata2(metadata2, opts = {}) {
18408
+ return backups_exports.storeAppBackupMetadata(metadata2, opts);
18410
18409
  }
18411
18410
  function getTimestamps(status2) {
18412
18411
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
@@ -18420,7 +18419,7 @@ function getTimestamps(status2) {
18420
18419
  return { timestamp, createdAt: timestamp };
18421
18420
  }
18422
18421
  }
18423
- async function updateBackupStatus(id, rev, status2, contents, filename) {
18422
+ async function updateBackupStatus(id, rev2, status2, contents, filename) {
18424
18423
  const backup = await getAppBackup(id);
18425
18424
  return await backups_exports.storeAppBackupMetadata(
18426
18425
  {
@@ -18430,10 +18429,10 @@ async function updateBackupStatus(id, rev, status2, contents, filename) {
18430
18429
  status: status2,
18431
18430
  type: "backup" /* BACKUP */
18432
18431
  },
18433
- { filename, docId: id, docRev: rev }
18432
+ { filename, docId: id, docRev: rev2 }
18434
18433
  );
18435
18434
  }
18436
- async function updateRestoreStatus(id, rev, status2) {
18435
+ async function updateRestoreStatus(id, rev2, status2) {
18437
18436
  const restore = await getAppBackup(id);
18438
18437
  return await backups_exports.storeAppBackupMetadata(
18439
18438
  {
@@ -18443,7 +18442,7 @@ async function updateRestoreStatus(id, rev, status2) {
18443
18442
  type: "restore" /* RESTORE */,
18444
18443
  trigger: "manual" /* MANUAL */
18445
18444
  },
18446
- { docId: id, docRev: rev }
18445
+ { docId: id, docRev: rev2 }
18447
18446
  );
18448
18447
  }
18449
18448
  async function getAppBackup(backupId) {
@@ -18453,11 +18452,11 @@ async function updateAppBackup(backupId, backupName) {
18453
18452
  return backups_exports.updateAppBackupMetadata(backupId, backupName);
18454
18453
  }
18455
18454
  async function deleteAppBackup(backupId) {
18456
- const metadata = await backups_exports.getAppBackupMetadata(backupId);
18457
- if (metadata.filename) {
18455
+ const metadata2 = await backups_exports.getAppBackupMetadata(backupId);
18456
+ if (metadata2.filename) {
18458
18457
  await objectStore_exports2.deleteFile(
18459
18458
  objectStore_exports2.ObjectStoreBuckets.BACKUPS,
18460
- metadata.filename
18459
+ metadata2.filename
18461
18460
  );
18462
18461
  }
18463
18462
  return backups_exports.deleteAppBackupMetadata(backupId);
@@ -18466,15 +18465,15 @@ async function fetchAppBackups2(appId, opts) {
18466
18465
  return backups_exports.fetchAppBackups(appId, opts);
18467
18466
  }
18468
18467
  async function downloadAppBackup(backupId) {
18469
- const metadata = await backups_exports.getAppBackupMetadata(backupId);
18470
- if (!metadata.filename) {
18468
+ const metadata2 = await backups_exports.getAppBackupMetadata(backupId);
18469
+ if (!metadata2.filename) {
18471
18470
  throw new Error("Backup incomplete - cannot download.");
18472
18471
  }
18473
18472
  const path5 = await objectStore_exports2.retrieveToTmp(
18474
18473
  objectStore_exports2.ObjectStoreBuckets.BACKUPS,
18475
- metadata.filename
18474
+ metadata2.filename
18476
18475
  );
18477
- return { metadata, path: path5 };
18476
+ return { metadata: metadata2, path: path5 };
18478
18477
  }
18479
18478
  async function triggerAppBackup(appId, trigger3, opts = {}) {
18480
18479
  let backup;
@@ -18513,7 +18512,7 @@ async function triggerAppBackup(appId, trigger3, opts = {}) {
18513
18512
  return backup.id;
18514
18513
  }
18515
18514
  async function triggerAppRestore(appId, backupId, nameForBackup, createdBy) {
18516
- const metadata = await getAppBackup(backupId);
18515
+ const metadata2 = await getAppBackup(backupId);
18517
18516
  let restore;
18518
18517
  try {
18519
18518
  restore = await storeAppBackupMetadata2({
@@ -18540,7 +18539,7 @@ async function triggerAppRestore(appId, backupId, nameForBackup, createdBy) {
18540
18539
  createdBy
18541
18540
  }
18542
18541
  });
18543
- return { restoreId: restore.id, metadata };
18542
+ return { restoreId: restore.id, metadata: metadata2 };
18544
18543
  }
18545
18544
  var pkg, backup_default2;
18546
18545
  var init_backup5 = __esm({
@@ -18653,7 +18652,7 @@ async function importProcessor(job, opts) {
18653
18652
  const tenantId = tenancy.getTenantIDFromAppID(appId);
18654
18653
  return tenancy.doInTenant(tenantId, async () => {
18655
18654
  const devAppId = db_exports.getDevAppID(appId);
18656
- const { rev } = await backup_default2.updateRestoreStatus(
18655
+ const { rev: rev2 } = await backup_default2.updateRestoreStatus(
18657
18656
  data2.docId,
18658
18657
  data2.docRev,
18659
18658
  "started" /* STARTED */
@@ -18678,23 +18677,23 @@ async function importProcessor(job, opts) {
18678
18677
  logging_exports.logAlert("App restore error", err);
18679
18678
  status2 = "failed" /* FAILED */;
18680
18679
  }
18681
- await backup_default2.updateRestoreStatus(data2.docId, rev, status2);
18680
+ await backup_default2.updateRestoreStatus(data2.docId, rev2, status2);
18682
18681
  });
18683
18682
  }
18684
18683
  async function exportProcessor(job, opts) {
18685
18684
  const data2 = job.data;
18686
- const appId = data2.appId, trigger3 = data2.export.trigger, name = data2.export.name;
18685
+ const appId = data2.appId, trigger3 = data2.export.trigger, name2 = data2.export.name;
18687
18686
  const tenantId = tenancy.getTenantIDFromAppID(appId);
18688
18687
  await tenancy.doInTenant(tenantId, async () => {
18689
- const { rev } = await backup_default2.updateBackupStatus(
18688
+ const { rev: rev2 } = await backup_default2.updateBackupStatus(
18690
18689
  data2.docId,
18691
18690
  data2.docRev,
18692
18691
  "started" /* STARTED */
18693
18692
  );
18694
18693
  return runBackup(trigger3, tenantId, appId, {
18695
18694
  processing: opts,
18696
- doc: { id: data2.docId, rev },
18697
- name
18695
+ doc: { id: data2.docId, rev: rev2 },
18696
+ name: name2
18698
18697
  });
18699
18698
  });
18700
18699
  }
@@ -19042,9 +19041,9 @@ var init_groups7 = __esm({
19042
19041
  ctx.body = { data: await fetch9() };
19043
19042
  };
19044
19043
  destroy4 = async (ctx) => {
19045
- const { id, rev } = ctx.params;
19044
+ const { id, rev: rev2 } = ctx.params;
19046
19045
  try {
19047
- await remove2(id, rev);
19046
+ await remove2(id, rev2);
19048
19047
  ctx.body = { message: "Group deleted successfully" };
19049
19048
  } catch (err) {
19050
19049
  ctx.throw(err.status, err);
@@ -19090,13 +19089,13 @@ async function fetch13(ctx) {
19090
19089
  };
19091
19090
  }
19092
19091
  async function create3(ctx) {
19093
- const { name, production, development } = ctx.request.body;
19094
- await environmentVariables_exports2.update(name, { production, development });
19092
+ const { name: name2, production, development } = ctx.request.body;
19093
+ await environmentVariables_exports2.update(name2, { production, development });
19095
19094
  const environments = ["production" /* PRODUCTION */];
19096
19095
  if (production !== development) {
19097
19096
  environments.push("development" /* DEVELOPMENT */);
19098
19097
  }
19099
- await events_exports.environmentVariable.created(name, environments);
19098
+ await events_exports.environmentVariable.created(name2, environments);
19100
19099
  ctx.status = 200;
19101
19100
  }
19102
19101
  async function update4(ctx) {
@@ -19386,8 +19385,8 @@ async function downloadBackup(ctx) {
19386
19385
  const appId = ctx.params.appId;
19387
19386
  await checkAppID(ctx, appId);
19388
19387
  const backupId = ctx.params.backupId;
19389
- const { metadata, path: path5 } = await backups_default.downloadAppBackup(backupId);
19390
- ctx.attachment(`backup-${metadata.timestamp}.tar.gz`);
19388
+ const { metadata: metadata2, path: path5 } = await backups_default.downloadAppBackup(backupId);
19389
+ ctx.attachment(`backup-${metadata2.timestamp}.tar.gz`);
19391
19390
  ctx.body = import_fs12.default.createReadStream(path5);
19392
19391
  }
19393
19392
  var import_fs12;
@@ -19529,8 +19528,8 @@ var init_schedules2 = __esm({
19529
19528
  });
19530
19529
 
19531
19530
  // ../pro/packages/pro/src/api/controllers/global/scim/users.ts
19532
- function tryGetQueryAsNumber(ctx, name) {
19533
- const value = ctx.request.query[name];
19531
+ function tryGetQueryAsNumber(ctx, name2) {
19532
+ const value = ctx.request.query[name2];
19534
19533
  if (value === void 0) {
19535
19534
  return void 0;
19536
19535
  }
@@ -19922,11 +19921,11 @@ var init_filters = __esm({
19922
19921
  return docs;
19923
19922
  }
19924
19923
  query3 = cleanupQuery(query3);
19925
- const match = (type, failFn) => (doc) => {
19924
+ const match = (type, failFn) => (doc2) => {
19926
19925
  const filters = Object.entries(query3[type] || {});
19927
19926
  for (let i = 0; i < filters.length; i++) {
19928
19927
  const [key, testValue] = filters[i];
19929
- const docValue = deepGet(doc, removeKeyNumbering2(key));
19928
+ const docValue = deepGet(doc2, removeKeyNumbering2(key));
19930
19929
  if (failFn(docValue, testValue)) {
19931
19930
  return false;
19932
19931
  }
@@ -19987,8 +19986,8 @@ var init_filters = __esm({
19987
19986
  return testValue == null ? void 0 : testValue.every((item) => docValue == null ? void 0 : docValue.includes(item));
19988
19987
  }
19989
19988
  );
19990
- const docMatch = (doc) => {
19991
- return stringMatch(doc) && fuzzyMatch(doc) && rangeMatch(doc) && equalMatch(doc) && notEqualMatch(doc) && emptyMatch(doc) && notEmptyMatch(doc) && oneOf(doc) && contains(doc) && containsAny(doc) && notContains(doc);
19989
+ const docMatch = (doc2) => {
19990
+ return stringMatch(doc2) && fuzzyMatch(doc2) && rangeMatch(doc2) && equalMatch(doc2) && notEqualMatch(doc2) && emptyMatch(doc2) && notEmptyMatch(doc2) && oneOf(doc2) && contains(doc2) && containsAny(doc2) && notContains(doc2);
19992
19991
  };
19993
19992
  return docs.filter(docMatch);
19994
19993
  };
@@ -20647,20 +20646,20 @@ async function createLinkView() {
20647
20646
  const db2 = context_exports.getAppDB();
20648
20647
  const designDoc = await db2.get("_design/database");
20649
20648
  const view2 = {
20650
- map: function(doc) {
20651
- if (doc.type === "link") {
20652
- let doc1 = doc.doc1;
20653
- let doc2 = doc.doc2;
20649
+ map: function(doc2) {
20650
+ if (doc2.type === "link") {
20651
+ let doc1 = doc2.doc1;
20652
+ let doc22 = doc2.doc2;
20654
20653
  emit([doc1.tableId, doc1.rowId], {
20655
- id: doc2.rowId,
20654
+ id: doc22.rowId,
20656
20655
  thisId: doc1.rowId,
20657
20656
  fieldName: doc1.fieldName
20658
20657
  });
20659
- if (doc1.tableId !== doc2.tableId) {
20660
- emit([doc2.tableId, doc2.rowId], {
20658
+ if (doc1.tableId !== doc22.tableId) {
20659
+ emit([doc22.tableId, doc22.rowId], {
20661
20660
  id: doc1.rowId,
20662
- thisId: doc2.rowId,
20663
- fieldName: doc2.fieldName
20661
+ thisId: doc22.rowId,
20662
+ fieldName: doc22.fieldName
20664
20663
  });
20665
20664
  }
20666
20665
  }
@@ -20706,7 +20705,7 @@ async function searchIndex(indexName, fnString) {
20706
20705
  async function createAllSearchIndex() {
20707
20706
  await searchIndex(
20708
20707
  "rows" /* ROWS */,
20709
- function(doc) {
20708
+ function(doc2) {
20710
20709
  function idx(input, prev) {
20711
20710
  for (let key of Object.keys(input)) {
20712
20711
  let idxKey = prev != null ? `${prev}.${key}` : key;
@@ -20729,9 +20728,9 @@ async function createAllSearchIndex() {
20729
20728
  }
20730
20729
  }
20731
20730
  }
20732
- if (doc._id.startsWith("ro_")) {
20733
- index("default", doc._id);
20734
- idx(doc);
20731
+ if (doc2._id.startsWith("ro_")) {
20732
+ index("default", doc2._id);
20733
+ idx(doc2);
20735
20734
  }
20736
20735
  }.toString()
20737
20736
  );
@@ -21052,11 +21051,11 @@ var init_LinkController = __esm({
21052
21051
  );
21053
21052
  }
21054
21053
  }
21055
- let toDeleteDocs = thisFieldLinkDocs.filter((doc) => {
21056
- let correctDoc = doc.doc1.fieldName === fieldName ? doc.doc2 : doc.doc1;
21054
+ let toDeleteDocs = thisFieldLinkDocs.filter((doc2) => {
21055
+ let correctDoc = doc2.doc1.fieldName === fieldName ? doc2.doc2 : doc2.doc1;
21057
21056
  return rowField.indexOf(correctDoc.rowId) === -1;
21058
- }).map((doc) => {
21059
- return { ...doc, _deleted: true };
21057
+ }).map((doc2) => {
21058
+ return { ...doc2, _deleted: true };
21060
21059
  });
21061
21060
  operations.push(...toDeleteDocs);
21062
21061
  delete row2[fieldName];
@@ -21077,9 +21076,9 @@ var init_LinkController = __esm({
21077
21076
  if (linkDocs.length === 0) {
21078
21077
  return null;
21079
21078
  }
21080
- const toDelete = linkDocs.map((doc) => {
21079
+ const toDelete = linkDocs.map((doc2) => {
21081
21080
  return {
21082
- ...doc,
21081
+ ...doc2,
21083
21082
  _deleted: true
21084
21083
  };
21085
21084
  });
@@ -21100,9 +21099,9 @@ var init_LinkController = __esm({
21100
21099
  return correctFieldName === fieldName;
21101
21100
  });
21102
21101
  await this._db.bulkDocs(
21103
- toDelete.map((doc) => {
21102
+ toDelete.map((doc2) => {
21104
21103
  return {
21105
- ...doc,
21104
+ ...doc2,
21106
21105
  _deleted: true
21107
21106
  };
21108
21107
  })
@@ -21200,9 +21199,9 @@ var init_LinkController = __esm({
21200
21199
  if (linkDocs.length === 0) {
21201
21200
  return null;
21202
21201
  }
21203
- const toDelete = linkDocs.map((doc) => {
21202
+ const toDelete = linkDocs.map((doc2) => {
21204
21203
  return {
21205
- ...doc,
21204
+ ...doc2,
21206
21205
  _deleted: true
21207
21206
  };
21208
21207
  });
@@ -21686,10 +21685,10 @@ async function cleanupAttachments(table2, {
21686
21685
  return;
21687
21686
  }
21688
21687
  }
21689
- let files = [];
21688
+ let files2 = [];
21690
21689
  function addFiles(row3, key) {
21691
21690
  if (row3[key]) {
21692
- files = files.concat(row3[key].map((attachment) => attachment.key));
21691
+ files2 = files2.concat(row3[key].map((attachment) => attachment.key));
21693
21692
  }
21694
21693
  }
21695
21694
  const schemaToUse = oldTable ? oldTable.schema : table2.schema;
@@ -21700,15 +21699,15 @@ async function cleanupAttachments(table2, {
21700
21699
  if (rows2 && oldTable && !table2.schema[key]) {
21701
21700
  rows2.forEach((row3) => addFiles(row3, key));
21702
21701
  } else if (oldRow && row2) {
21703
- files = files.concat(getRemovedAttachmentKeys(oldRow, row2, key));
21702
+ files2 = files2.concat(getRemovedAttachmentKeys(oldRow, row2, key));
21704
21703
  } else if (row2) {
21705
21704
  addFiles(row2, key);
21706
21705
  } else if (rows2) {
21707
21706
  rows2.forEach((row3) => addFiles(row3, key));
21708
21707
  }
21709
21708
  }
21710
- if (files.length > 0) {
21711
- await objectStore_exports2.deleteFiles(ObjectStoreBuckets2.APPS, files);
21709
+ if (files2.length > 0) {
21710
+ await objectStore_exports2.deleteFiles(ObjectStoreBuckets2.APPS, files2);
21712
21711
  }
21713
21712
  }
21714
21713
  var cloneDeep3, BASE_AUTO_ID;
@@ -21730,17 +21729,17 @@ var init_rowProcessor = __esm({
21730
21729
  // src/utilities/users.ts
21731
21730
  async function getFullUser(ctx, userId) {
21732
21731
  const global = await getGlobalUser(userId);
21733
- let metadata = {};
21732
+ let metadata2 = {};
21734
21733
  delete global._id;
21735
21734
  delete global._rev;
21736
21735
  try {
21737
21736
  const db2 = context_exports.getAppDB();
21738
- metadata = await db2.get(userId);
21737
+ metadata2 = await db2.get(userId);
21739
21738
  } catch (err) {
21740
21739
  }
21741
- delete metadata.csrfToken;
21740
+ delete metadata2.csrfToken;
21742
21741
  return {
21743
- ...metadata,
21742
+ ...metadata2,
21744
21743
  ...global,
21745
21744
  roleId: global.roleId || roles_exports.BUILTIN_ROLE_IDS.PUBLIC,
21746
21745
  tableId: InternalTables.USER_METADATA,
@@ -21800,11 +21799,11 @@ async function fetchSelf(ctx) {
21800
21799
  if (user2.roleId === PUBLIC_ROLE) {
21801
21800
  response2 = {};
21802
21801
  } else if (err.status === 404) {
21803
- const metadata = {
21802
+ const metadata2 = {
21804
21803
  ...user2,
21805
21804
  _id: userId
21806
21805
  };
21807
- const dbResp = await db2.put(metadata);
21806
+ const dbResp = await db2.put(metadata2);
21808
21807
  user2._rev = dbResp.rev;
21809
21808
  response2 = user2;
21810
21809
  } else {
@@ -21960,12 +21959,12 @@ async function updateAppUpdatedAt(ctx) {
21960
21959
  await db_exports.doWithDB(appId, async (db2) => {
21961
21960
  var _a2;
21962
21961
  try {
21963
- const metadata = await db2.get(DocumentType2.APP_METADATA);
21964
- metadata.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
21965
- metadata.updatedBy = getGlobalIDFromUserMetadataID2((_a2 = ctx.user) == null ? void 0 : _a2.userId);
21966
- const response2 = await db2.put(metadata);
21967
- metadata._rev = response2.rev;
21968
- await cache_exports.app.invalidateAppMetadata(appId, metadata);
21962
+ const metadata2 = await db2.get(DocumentType2.APP_METADATA);
21963
+ metadata2.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
21964
+ metadata2.updatedBy = getGlobalIDFromUserMetadataID2((_a2 = ctx.user) == null ? void 0 : _a2.userId);
21965
+ const response2 = await db2.put(metadata2);
21966
+ metadata2._rev = response2.rev;
21967
+ await cache_exports.app.invalidateAppMetadata(appId, metadata2);
21969
21968
  await setDebounce(appId, DEBOUNCE_TIME_SEC);
21970
21969
  } catch (err) {
21971
21970
  if ((err == null ? void 0 : err.status) === 409) {
@@ -22558,14 +22557,14 @@ async function getViews() {
22558
22557
  const response2 = [];
22559
22558
  if (environment_default2.SELF_HOSTED) {
22560
22559
  const designDoc = await db2.get("_design/database");
22561
- for (let name of Object.keys(designDoc.views)) {
22560
+ for (let name2 of Object.keys(designDoc.views)) {
22562
22561
  const viewNames = Object.values(ViewName3);
22563
- if (viewNames.indexOf(name) !== -1) {
22562
+ if (viewNames.indexOf(name2) !== -1) {
22564
22563
  continue;
22565
22564
  }
22566
22565
  response2.push({
22567
- name,
22568
- ...designDoc.views[name]
22566
+ name: name2,
22567
+ ...designDoc.views[name2]
22569
22568
  });
22570
22569
  }
22571
22570
  } else {
@@ -22682,9 +22681,9 @@ async function clearColumns(table2, columnNames) {
22682
22681
  })
22683
22682
  );
22684
22683
  return await db2.bulkDocs(
22685
- rows2.rows.map(({ doc }) => {
22686
- columnNames.forEach((colName) => delete doc[colName]);
22687
- return doc;
22684
+ rows2.rows.map(({ doc: doc2 }) => {
22685
+ columnNames.forEach((colName) => delete doc2[colName]);
22686
+ return doc2;
22688
22687
  })
22689
22688
  );
22690
22689
  }
@@ -22704,7 +22703,7 @@ async function checkForColumnUpdates(oldTable, updatedTable) {
22704
22703
  include_docs: true
22705
22704
  })
22706
22705
  );
22707
- const rawRows = rows2.rows.map(({ doc }) => doc);
22706
+ const rawRows = rows2.rows.map(({ doc: doc2 }) => doc2);
22708
22707
  updatedRows = rawRows.map((row2) => {
22709
22708
  row2 = (0, import_fp.cloneDeep)(row2);
22710
22709
  if (rename) {
@@ -22774,18 +22773,18 @@ async function handleDataImport(user2, table2, rows2, identifierFields = []) {
22774
22773
  include_docs: true
22775
22774
  })
22776
22775
  );
22777
- allDocs.rows.map((existingRow) => existingRow.doc).forEach((doc) => {
22776
+ allDocs.rows.map((existingRow) => existingRow.doc).forEach((doc2) => {
22778
22777
  finalData.forEach((finalItem) => {
22779
22778
  let match = true;
22780
22779
  for (const field of identifierFields) {
22781
- if (finalItem[field] !== doc[field]) {
22780
+ if (finalItem[field] !== doc2[field]) {
22782
22781
  match = false;
22783
22782
  break;
22784
22783
  }
22785
22784
  }
22786
22785
  if (match) {
22787
- finalItem._id = doc._id;
22788
- finalItem._rev = doc._rev;
22786
+ finalItem._id = doc2._id;
22787
+ finalItem._rev = doc2._rev;
22789
22788
  }
22790
22789
  });
22791
22790
  });
@@ -24216,44 +24215,44 @@ function checkSlashesInUrl2(url) {
24216
24215
  async function updateEntityMetadata(type, entityId, updateFn) {
24217
24216
  const db2 = context_exports.getAppDB();
24218
24217
  const id = generateMetadataID(type, entityId);
24219
- let rev, metadata;
24218
+ let rev2, metadata2;
24220
24219
  try {
24221
24220
  const oldMetadata = await db2.get(id);
24222
- rev = oldMetadata._rev;
24223
- metadata = updateFn(oldMetadata);
24221
+ rev2 = oldMetadata._rev;
24222
+ metadata2 = updateFn(oldMetadata);
24224
24223
  } catch (err) {
24225
- rev = null;
24226
- metadata = updateFn({});
24224
+ rev2 = null;
24225
+ metadata2 = updateFn({});
24227
24226
  }
24228
- metadata._id = id;
24229
- if (rev) {
24230
- metadata._rev = rev;
24227
+ metadata2._id = id;
24228
+ if (rev2) {
24229
+ metadata2._rev = rev2;
24231
24230
  }
24232
- const response2 = await db2.put(metadata);
24231
+ const response2 = await db2.put(metadata2);
24233
24232
  return {
24234
- ...metadata,
24233
+ ...metadata2,
24235
24234
  _id: id,
24236
24235
  _rev: response2.rev
24237
24236
  };
24238
24237
  }
24239
- async function saveEntityMetadata(type, entityId, metadata) {
24238
+ async function saveEntityMetadata(type, entityId, metadata2) {
24240
24239
  return updateEntityMetadata(type, entityId, () => {
24241
- return metadata;
24240
+ return metadata2;
24242
24241
  });
24243
24242
  }
24244
24243
  async function deleteEntityMetadata(type, entityId) {
24245
24244
  const db2 = context_exports.getAppDB();
24246
24245
  const id = generateMetadataID(type, entityId);
24247
- let rev;
24246
+ let rev2;
24248
24247
  try {
24249
- const metadata = await db2.get(id);
24250
- if (metadata) {
24251
- rev = metadata._rev;
24248
+ const metadata2 = await db2.get(id);
24249
+ if (metadata2) {
24250
+ rev2 = metadata2._rev;
24252
24251
  }
24253
24252
  } catch (err) {
24254
24253
  }
24255
- if (id && rev) {
24256
- await db2.remove(id, rev);
24254
+ if (id && rev2) {
24255
+ await db2.remove(id, rev2);
24257
24256
  }
24258
24257
  }
24259
24258
  function escapeDangerousCharacters(string) {
@@ -24924,7 +24923,7 @@ __export(exports_exports, {
24924
24923
  exportDB: () => exportDB,
24925
24924
  streamExportApp: () => streamExportApp
24926
24925
  });
24927
- function tarFilesToTmp(tmpDir, files) {
24926
+ function tarFilesToTmp(tmpDir, files2) {
24928
24927
  const exportFile = (0, import_path12.join)(budibaseTempDir2(), `${uuid3()}.tar.gz`);
24929
24928
  tar3.create(
24930
24929
  {
@@ -24934,7 +24933,7 @@ function tarFilesToTmp(tmpDir, files) {
24934
24933
  recursive: true,
24935
24934
  cwd: tmpDir
24936
24935
  },
24937
- files
24936
+ files2
24938
24937
  );
24939
24938
  return exportFile;
24940
24939
  }
@@ -24970,7 +24969,7 @@ function defineFilter(excludeRows, excludeLogs) {
24970
24969
  if (excludeLogs) {
24971
24970
  ids.push(AUTOMATION_LOG_PREFIX);
24972
24971
  }
24973
- return (doc) => !ids.map((key) => doc._id.includes(key)).reduce((prev, curr) => prev || curr);
24972
+ return (doc2) => !ids.map((key) => doc2._id.includes(key)).reduce((prev, curr) => prev || curr);
24974
24973
  }
24975
24974
  async function exportApp(appId, config) {
24976
24975
  const prodAppId = db_exports.getProdAppID(appId);
@@ -25114,9 +25113,9 @@ async function getTemplateStream(template) {
25114
25113
  if (template.file) {
25115
25114
  return import_fs14.default.createReadStream(template.file.path);
25116
25115
  } else if (template.key) {
25117
- const [type, name] = template.key.split("/");
25118
- const tmpPath = await downloadTemplate(type, name);
25119
- return import_fs14.default.createReadStream((0, import_path13.join)(tmpPath, name, "db", "dump.txt"));
25116
+ const [type, name2] = template.key.split("/");
25117
+ const tmpPath = await downloadTemplate(type, name2);
25118
+ return import_fs14.default.createReadStream((0, import_path13.join)(tmpPath, name2, "db", "dump.txt"));
25120
25119
  }
25121
25120
  }
25122
25121
  function untarFile(file) {
@@ -25429,22 +25428,34 @@ function finaliseExternalTables(tables, entities) {
25429
25428
  let finalTables = {};
25430
25429
  const errors = {};
25431
25430
  const tableIds = Object.values(tables).map((table2) => table2._id);
25432
- for (let [name, table2] of Object.entries(tables)) {
25431
+ for (let [name2, table2] of Object.entries(tables)) {
25433
25432
  const schemaFields = Object.keys(table2.schema);
25434
25433
  if (table2.primary == null || table2.primary.length === 0) {
25435
- errors[name] = "no_key" /* NO_KEY */;
25434
+ errors[name2] = "no_key" /* NO_KEY */;
25436
25435
  continue;
25437
25436
  } else if (schemaFields.find(
25438
25437
  (field) => invalidColumns.includes(field)
25439
25438
  )) {
25440
- errors[name] = "invalid_column" /* INVALID_COLUMN */;
25439
+ errors[name2] = "invalid_column" /* INVALID_COLUMN */;
25441
25440
  continue;
25442
25441
  }
25443
- finalTables[name] = copyExistingPropsOver(name, table2, entities, tableIds);
25442
+ finalTables[name2] = copyExistingPropsOver(name2, table2, entities, tableIds);
25444
25443
  }
25445
25444
  finalTables = Object.entries(finalTables).sort(([a], [b]) => a.localeCompare(b)).reduce((r, [k, v]) => ({ ...r, [k]: v }), {});
25446
25445
  return { tables: finalTables, errors };
25447
25446
  }
25447
+ function getPrimaryDisplay(testValue) {
25448
+ if (testValue instanceof Date) {
25449
+ return testValue.toISOString();
25450
+ }
25451
+ if (Array.isArray(testValue) && testValue[0] && typeof testValue[0] !== "object") {
25452
+ return testValue.join(", ");
25453
+ }
25454
+ if (typeof testValue === "object") {
25455
+ return void 0;
25456
+ }
25457
+ return testValue;
25458
+ }
25448
25459
  var DOUBLE_SEPARATOR, ROW_ID_REGEX, ENCODED_SPACE, SQL_NUMBER_TYPE_MAP, SQL_DATE_TYPE_MAP, SQL_DATE_ONLY_TYPES, SQL_TIME_ONLY_TYPES, SQL_STRING_TYPE_MAP, SQL_BOOLEAN_TYPE_MAP, SQL_MISC_TYPE_MAP, SQL_TYPE_MAP;
25449
25460
  var init_utils19 = __esm({
25450
25461
  "src/integrations/utils.ts"() {
@@ -27335,21 +27346,21 @@ var init_mongodb = __esm({
27335
27346
  const collection = db2.collection(query3.extra.collection);
27336
27347
  let response2 = [];
27337
27348
  if (((_a2 = query3.extra) == null ? void 0 : _a2.actionType) === "pipeline") {
27338
- for await (const doc of collection.aggregate(
27349
+ for await (const doc2 of collection.aggregate(
27339
27350
  query3.steps.map(({ key, value }) => {
27340
27351
  let temp = {};
27341
27352
  temp[key] = JSON.parse(value.value);
27342
27353
  return this.createObjectIds(temp);
27343
27354
  })
27344
27355
  )) {
27345
- response2.push(doc);
27356
+ response2.push(doc2);
27346
27357
  }
27347
27358
  } else {
27348
27359
  const stages = query3.json;
27349
- for await (const doc of collection.aggregate(
27360
+ for await (const doc2 of collection.aggregate(
27350
27361
  stages ? this.createObjectIds(stages) : []
27351
27362
  )) {
27352
- response2.push(doc);
27363
+ response2.push(doc2);
27353
27364
  }
27354
27365
  }
27355
27366
  return response2;
@@ -27660,9 +27671,9 @@ var init_couchdb = __esm({
27660
27671
  });
27661
27672
  }
27662
27673
  async delete(query3) {
27663
- const doc = await this.query("get", "Cannot find doc to be deleted", query3);
27674
+ const doc2 = await this.query("get", "Cannot find doc to be deleted", query3);
27664
27675
  return this.query("remove", "Error deleting couchDB document", {
27665
- json: doc
27676
+ json: doc2
27666
27677
  });
27667
27678
  }
27668
27679
  };
@@ -27848,7 +27859,7 @@ var init_microsoftSqlServer = __esm({
27848
27859
  throw "Unable to get list of tables in database";
27849
27860
  }
27850
27861
  const schema = this.config.schema || DEFAULT_SCHEMA;
27851
- const tableNames = tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((name) => this.MASTER_TABLES.indexOf(name) === -1);
27862
+ const tableNames = tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((name2) => this.MASTER_TABLES.indexOf(name2) === -1);
27852
27863
  const tables = {};
27853
27864
  for (let tableName of tableNames) {
27854
27865
  const definition26 = await this.runSQL(this.getDefinitionSQL(tableName));
@@ -27863,16 +27874,16 @@ var init_microsoftSqlServer = __esm({
27863
27874
  const requiredColumns = columns.filter((col) => col.IS_NULLABLE === "NO").map((col) => col.COLUMN_NAME);
27864
27875
  let schema2 = {};
27865
27876
  for (let def of definition26) {
27866
- const name = def.COLUMN_NAME;
27867
- if (typeof name !== "string") {
27877
+ const name2 = def.COLUMN_NAME;
27878
+ if (typeof name2 !== "string") {
27868
27879
  continue;
27869
27880
  }
27870
27881
  const hasDefault = def.COLUMN_DEFAULT;
27871
- const isAuto = !!autoColumns.find((col) => col === name);
27872
- const required = !!requiredColumns.find((col) => col === name);
27873
- schema2[name] = {
27882
+ const isAuto = !!autoColumns.find((col) => col === name2);
27883
+ const required = !!requiredColumns.find((col) => col === name2);
27884
+ schema2[name2] = {
27874
27885
  autocolumn: isAuto,
27875
- name,
27886
+ name: name2,
27876
27887
  constraints: {
27877
27888
  presence: required && !isAuto && !hasDefault
27878
27889
  },
@@ -27894,7 +27905,7 @@ var init_microsoftSqlServer = __esm({
27894
27905
  async queryTableNames() {
27895
27906
  let tableInfo = await this.runSQL(this.TABLES_SQL);
27896
27907
  const schema = this.config.schema || DEFAULT_SCHEMA;
27897
- return tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((name) => this.MASTER_TABLES.indexOf(name) === -1);
27908
+ return tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((name2) => this.MASTER_TABLES.indexOf(name2) === -1);
27898
27909
  }
27899
27910
  async getTableNames() {
27900
27911
  await this.connect();
@@ -28328,7 +28339,12 @@ function bindingTypeCoerce(bindings) {
28328
28339
  if (matches2 && matches2[0] !== "" && !isNaN(Number(matches2[0]))) {
28329
28340
  bindings[i] = parseFloat(binding);
28330
28341
  } else if (/^\d/.test(binding) && (0, import_dayjs.default)(binding).isValid() && !binding.includes(",")) {
28331
- bindings[i] = (0, import_dayjs.default)(binding).toDate();
28342
+ let value;
28343
+ value = new Date(binding);
28344
+ if (isNaN(value)) {
28345
+ value = binding;
28346
+ }
28347
+ bindings[i] = value;
28332
28348
  }
28333
28349
  }
28334
28350
  return bindings;
@@ -29311,13 +29327,13 @@ var init_googlesheets = __esm({
29311
29327
  }
29312
29328
  return rowObject;
29313
29329
  }
29314
- async createTable(name) {
29315
- if (!name) {
29330
+ async createTable(name2) {
29331
+ if (!name2) {
29316
29332
  throw new Error("Must provide name for new sheet.");
29317
29333
  }
29318
29334
  try {
29319
29335
  await this.connect();
29320
- return await this.client.addSheet({ title: name, headerValues: [name] });
29336
+ return await this.client.addSheet({ title: name2, headerValues: [name2] });
29321
29337
  } catch (err) {
29322
29338
  console.error("Error creating new table in google sheets", err);
29323
29339
  throw err;
@@ -29643,7 +29659,7 @@ var init_firebase = __esm({
29643
29659
  snapshot = await collectionRef.get();
29644
29660
  }
29645
29661
  const result = [];
29646
- snapshot.forEach((doc) => result.push(doc.data()));
29662
+ snapshot.forEach((doc2) => result.push(doc2.data()));
29647
29663
  return result;
29648
29664
  } catch (err) {
29649
29665
  console.error("Error querying Firestore", err);
@@ -30305,13 +30321,13 @@ var init_oracle = __esm({
30305
30321
  });
30306
30322
 
30307
30323
  // src/integrations/index.ts
30308
- async function getDefinition(source) {
30309
- const definition26 = DEFINITIONS2[source];
30324
+ async function getDefinition(source2) {
30325
+ const definition26 = DEFINITIONS2[source2];
30310
30326
  if (definition26) {
30311
30327
  return definition26;
30312
30328
  }
30313
30329
  const allDefinitions = await getDefinitions();
30314
- return allDefinitions[source];
30330
+ return allDefinitions[source2];
30315
30331
  }
30316
30332
  async function getDefinitions() {
30317
30333
  const pluginSchemas = {};
@@ -30647,10 +30663,10 @@ __export(webhook_exports2, {
30647
30663
  function isWebhookID(id) {
30648
30664
  return id.startsWith(db_exports.DocumentType.WEBHOOK);
30649
30665
  }
30650
- function newDoc(name, type, target) {
30666
+ function newDoc(name2, type, target) {
30651
30667
  return {
30652
30668
  live: true,
30653
- name,
30669
+ name: name2,
30654
30670
  action: {
30655
30671
  type,
30656
30672
  target
@@ -30668,12 +30684,12 @@ async function save8(webhook) {
30668
30684
  webhook._rev = response2.rev;
30669
30685
  return webhook;
30670
30686
  }
30671
- async function destroy7(id, rev) {
30687
+ async function destroy7(id, rev2) {
30672
30688
  const db2 = context_exports.getAppDB();
30673
30689
  if (!id || !isWebhookID(id)) {
30674
30690
  throw new Error("Provided webhook ID is not valid.");
30675
30691
  }
30676
- return await db2.remove(id, rev);
30692
+ return await db2.remove(id, rev2);
30677
30693
  }
30678
30694
  var init_webhook3 = __esm({
30679
30695
  "src/sdk/app/automations/webhook.ts"() {
@@ -30737,9 +30753,9 @@ async function syncUsersToApp(appId, users2, groups) {
30737
30753
  if (roleId === roles_exports.BUILTIN_ROLE_IDS.PUBLIC) {
30738
30754
  roleId = void 0;
30739
30755
  }
30740
- let metadata;
30756
+ let metadata2;
30741
30757
  try {
30742
- metadata = await db2.get(metadataId);
30758
+ metadata2 = await db2.get(metadataId);
30743
30759
  } catch (err) {
30744
30760
  if (err.status !== 404) {
30745
30761
  throw err;
@@ -30747,19 +30763,19 @@ async function syncUsersToApp(appId, users2, groups) {
30747
30763
  if (!roleId) {
30748
30764
  continue;
30749
30765
  } else if (!deletedUser) {
30750
- metadata = {
30766
+ metadata2 = {
30751
30767
  tableId: InternalTables.USER_METADATA
30752
30768
  };
30753
30769
  }
30754
30770
  }
30755
30771
  if (deletedUser || !roleId) {
30756
- await db2.remove(metadata);
30772
+ await db2.remove(metadata2);
30757
30773
  continue;
30758
30774
  }
30759
30775
  if (roleId) {
30760
- metadata.roleId = roleId;
30776
+ metadata2.roleId = roleId;
30761
30777
  }
30762
- let combined = sdk_default.users.combineMetadataAndUser(ctxUser, metadata);
30778
+ let combined = sdk_default.users.combineMetadataAndUser(ctxUser, metadata2);
30763
30779
  if (combined) {
30764
30780
  await db2.put(combined);
30765
30781
  }
@@ -30816,7 +30832,7 @@ async function syncApp(appId, opts) {
30816
30832
  try {
30817
30833
  const replOpts = replication.appReplicateOpts();
30818
30834
  if (opts == null ? void 0 : opts.automationOnly) {
30819
- replOpts.filter = (doc) => doc._id.startsWith(db_exports.DocumentType.AUTOMATION);
30835
+ replOpts.filter = (doc2) => doc2._id.startsWith(db_exports.DocumentType.AUTOMATION);
30820
30836
  }
30821
30837
  await replication.replicate(replOpts);
30822
30838
  } catch (err) {
@@ -31043,9 +31059,9 @@ __export(utils_exports8, {
31043
31059
  rawUserMetadata: () => rawUserMetadata,
31044
31060
  syncGlobalUsers: () => syncGlobalUsers
31045
31061
  });
31046
- function combineMetadataAndUser(user2, metadata) {
31062
+ function combineMetadataAndUser(user2, metadata2) {
31047
31063
  const metadataId = generateUserMetadataID2(user2._id);
31048
- const found = Array.isArray(metadata) ? metadata.find((doc) => doc._id === metadataId) : metadata;
31064
+ const found = Array.isArray(metadata2) ? metadata2.find((doc2) => doc2._id === metadataId) : metadata2;
31049
31065
  if (user2.roleId == null || user2.roleId === roles_exports.BUILTIN_ROLE_IDS.PUBLIC) {
31050
31066
  if (found == null ? void 0 : found._id) {
31051
31067
  return { ...found, _deleted: true };
@@ -31090,16 +31106,16 @@ async function syncGlobalUsers() {
31090
31106
  }
31091
31107
  const resp = await Promise.all([getGlobalUsers(), rawUserMetadata(db2)]);
31092
31108
  const users2 = resp[0];
31093
- const metadata = resp[1];
31109
+ const metadata2 = resp[1];
31094
31110
  const toWrite = [];
31095
31111
  for (let user2 of users2) {
31096
- const combined = combineMetadataAndUser(user2, metadata);
31112
+ const combined = combineMetadataAndUser(user2, metadata2);
31097
31113
  if (combined) {
31098
31114
  toWrite.push(combined);
31099
31115
  }
31100
31116
  }
31101
31117
  let foundEmails = [];
31102
- for (let data2 of metadata) {
31118
+ for (let data2 of metadata2) {
31103
31119
  if (!data2._id) {
31104
31120
  continue;
31105
31121
  }
@@ -31392,10 +31408,10 @@ var init_client2 = __esm({
31392
31408
  // src/api/controllers/user.ts
31393
31409
  async function fetchMetadata(ctx) {
31394
31410
  const global = await getGlobalUsers();
31395
- const metadata = await sdk_default.users.rawUserMetadata();
31411
+ const metadata2 = await sdk_default.users.rawUserMetadata();
31396
31412
  const users2 = [];
31397
31413
  for (let user2 of global) {
31398
- const info = metadata.find((meta) => meta._id.includes(user2._id));
31414
+ const info = metadata2.find((meta) => meta._id.includes(user2._id));
31399
31415
  users2.push({
31400
31416
  ...user2,
31401
31417
  ...info,
@@ -31417,11 +31433,11 @@ async function updateMetadata(ctx) {
31417
31433
  const db2 = context_exports.getAppDB();
31418
31434
  const user2 = ctx.request.body;
31419
31435
  delete user2.roles;
31420
- const metadata = {
31436
+ const metadata2 = {
31421
31437
  tableId: InternalTables.USER_METADATA,
31422
31438
  ...user2
31423
31439
  };
31424
- ctx.body = await db2.put(metadata);
31440
+ ctx.body = await db2.put(metadata2);
31425
31441
  }
31426
31442
  async function destroyMetadata(ctx) {
31427
31443
  const db2 = context_exports.getAppDB();
@@ -31446,14 +31462,14 @@ async function setFlag(ctx) {
31446
31462
  }
31447
31463
  const flagDocId = generateUserFlagID(userId);
31448
31464
  const db2 = context_exports.getAppDB();
31449
- let doc;
31465
+ let doc2;
31450
31466
  try {
31451
- doc = await db2.get(flagDocId);
31467
+ doc2 = await db2.get(flagDocId);
31452
31468
  } catch (err) {
31453
- doc = { _id: flagDocId };
31469
+ doc2 = { _id: flagDocId };
31454
31470
  }
31455
- doc[flag] = value || true;
31456
- await db2.put(doc);
31471
+ doc2[flag] = value || true;
31472
+ await db2.put(doc2);
31457
31473
  ctx.body = { message: "Flag set successfully" };
31458
31474
  }
31459
31475
  async function getFlags(ctx) {
@@ -31461,13 +31477,13 @@ async function getFlags(ctx) {
31461
31477
  const userId = (_a2 = ctx.user) == null ? void 0 : _a2._id;
31462
31478
  const docId = generateUserFlagID(userId);
31463
31479
  const db2 = context_exports.getAppDB();
31464
- let doc;
31480
+ let doc2;
31465
31481
  try {
31466
- doc = await db2.get(docId);
31482
+ doc2 = await db2.get(docId);
31467
31483
  } catch (err) {
31468
- doc = { _id: docId };
31484
+ doc2 = { _id: docId };
31469
31485
  }
31470
- ctx.body = doc;
31486
+ ctx.body = doc2;
31471
31487
  }
31472
31488
  var init_user10 = __esm({
31473
31489
  "src/api/controllers/user.ts"() {
@@ -31864,16 +31880,16 @@ async function fetch17(type) {
31864
31880
  return plugins2;
31865
31881
  }
31866
31882
  }
31867
- async function processUploaded(plugin, source) {
31883
+ async function processUploaded(plugin, source2) {
31868
31884
  var _a2, _b2;
31869
- const { metadata, directory } = await fileUpload(plugin);
31870
- plugin_exports.validate(metadata == null ? void 0 : metadata.schema);
31871
- if (!environment_default2.SELF_HOSTED && ((_a2 = metadata == null ? void 0 : metadata.schema) == null ? void 0 : _a2.type) !== "component" /* COMPONENT */) {
31885
+ const { metadata: metadata2, directory: directory2 } = await fileUpload(plugin);
31886
+ plugin_exports.validate(metadata2 == null ? void 0 : metadata2.schema);
31887
+ if (!environment_default2.SELF_HOSTED && ((_a2 = metadata2 == null ? void 0 : metadata2.schema) == null ? void 0 : _a2.type) !== "component" /* COMPONENT */) {
31872
31888
  throw new Error("Only component plugins are supported outside of self-host");
31873
31889
  }
31874
- const doc = await sdk_exports.plugins.storePlugin(metadata, directory, source);
31875
- (_b2 = clientAppSocket) == null ? void 0 : _b2.emit("plugin-update", { name: doc.name, hash: doc.hash });
31876
- return doc;
31890
+ const doc2 = await sdk_exports.plugins.storePlugin(metadata2, directory2, source2);
31891
+ (_b2 = clientAppSocket) == null ? void 0 : _b2.emit("plugin-update", { name: doc2.name, hash: doc2.hash });
31892
+ return doc2;
31877
31893
  }
31878
31894
  var init_plugins4 = __esm({
31879
31895
  "src/sdk/plugins/plugins.ts"() {
@@ -32174,7 +32190,7 @@ async function runView(view, calculation, group, data) {
32174
32190
  _rev: void 0
32175
32191
  }))
32176
32192
  );
32177
- let fn = (doc, emit2) => emit2(doc._id);
32193
+ let fn = (doc2, emit2) => emit2(doc2._id);
32178
32194
  eval("fn = " + ((_a2 = view == null ? void 0 : view.map) == null ? void 0 : _a2.replace("function (doc)", "function (doc, emit)")));
32179
32195
  const queryFns = {
32180
32196
  meta: view.meta,
@@ -32802,7 +32818,7 @@ function cleanupConfig(config, table2) {
32802
32818
  const fieldNames = Object.entries(table2.schema).filter((schema) => primaryOptions.find((val) => val === schema[1].type)).map(([fieldName]) => fieldName);
32803
32819
  const iterateObject = (obj) => {
32804
32820
  for (let [field, value] of Object.entries(obj)) {
32805
- if (fieldNames.find((name) => name === field) && isRowId(value)) {
32821
+ if (fieldNames.find((name2) => name2 === field) && isRowId(value)) {
32806
32822
  obj[field] = convertRowId(value);
32807
32823
  }
32808
32824
  }
@@ -33013,7 +33029,10 @@ var init_ExternalRequest = __esm({
33013
33029
  }
33014
33030
  }
33015
33031
  relatedRow = processFormulas(linkedTable, relatedRow);
33016
- const relatedDisplay = display ? relatedRow[display] : void 0;
33032
+ let relatedDisplay;
33033
+ if (display) {
33034
+ relatedDisplay = getPrimaryDisplay(relatedRow[display]);
33035
+ }
33017
33036
  row2[relationship.column][key] = {
33018
33037
  primaryDisplay: relatedDisplay || "Invalid display column",
33019
33038
  _id: relatedRow._id
@@ -34573,7 +34592,7 @@ var init_internal2 = __esm({
34573
34592
 
34574
34593
  // src/api/controllers/datasource.ts
34575
34594
  function getErrorTables(errors, errorType) {
34576
- return Object.entries(errors).filter((entry) => entry[1] === errorType).map(([name]) => name);
34595
+ return Object.entries(errors).filter((entry) => entry[1] === errorType).map(([name2]) => name2);
34577
34596
  }
34578
34597
  function updateError(error2, newError, tables) {
34579
34598
  if (!error2) {
@@ -34773,9 +34792,9 @@ async function update7(ctx) {
34773
34792
  await events_exports.datasource.updated(datasource2);
34774
34793
  datasource2._rev = response2.rev;
34775
34794
  if (datasource2.source && !isBudibaseSource) {
34776
- const source = await getIntegration(datasource2.source);
34777
- if (source && source.pool) {
34778
- await source.pool.end();
34795
+ const source2 = await getIntegration(datasource2.source);
34796
+ if (source2 && source2.pool) {
34797
+ await source2.pool.end();
34779
34798
  }
34780
34799
  }
34781
34800
  ctx.status = 200;
@@ -34806,9 +34825,9 @@ async function save13(ctx) {
34806
34825
  await events_exports.datasource.created(datasource2);
34807
34826
  datasource2._rev = dbResp.rev;
34808
34827
  if (datasource2.source) {
34809
- const source = await getIntegration(datasource2.source);
34810
- if (source && source.pool) {
34811
- await source.pool.end();
34828
+ const source2 = await getIntegration(datasource2.source);
34829
+ if (source2 && source2.pool) {
34830
+ await source2.pool.end();
34812
34831
  }
34813
34832
  }
34814
34833
  const response2 = {
@@ -34959,7 +34978,7 @@ var init_base2 = __esm({
34959
34978
  })(MethodToVerb || {});
34960
34979
  ImportSource = class {
34961
34980
  constructor() {
34962
- this.constructQuery = (datasourceId, name, method, path5, url, queryString, headers = {}, parameters = [], body2 = void 0) => {
34981
+ this.constructQuery = (datasourceId, name2, method, path5, url, queryString, headers = {}, parameters = [], body2 = void 0) => {
34963
34982
  const readable = true;
34964
34983
  const queryVerb = this.verbFromMethod(method);
34965
34984
  const transformer = "return data";
@@ -34980,7 +34999,7 @@ var init_base2 = __esm({
34980
34999
  const requestBody = JSON.stringify(body2, null, 2);
34981
35000
  const query3 = {
34982
35001
  datasourceId,
34983
- name,
35002
+ name: name2,
34984
35003
  parameters,
34985
35004
  fields: {
34986
35005
  headers,
@@ -35097,9 +35116,9 @@ var init_openapi2 = __esm({
35097
35116
  return new import_url2.URL(`${scheme}://${host}${basePath}`);
35098
35117
  };
35099
35118
  this.getInfo = async () => {
35100
- const name = this.document.info.title || "Swagger Import";
35119
+ const name2 = this.document.info.title || "Swagger Import";
35101
35120
  return {
35102
- name
35121
+ name: name2
35103
35122
  };
35104
35123
  };
35105
35124
  this.getQueries = async (datasourceId) => {
@@ -35115,7 +35134,7 @@ var init_openapi2 = __esm({
35115
35134
  }
35116
35135
  const operation = opOrParams;
35117
35136
  const methodName = key;
35118
- const name = operation.operationId || path5;
35137
+ const name2 = operation.operationId || path5;
35119
35138
  let queryString = "";
35120
35139
  const headers = {};
35121
35140
  let requestBody = void 0;
@@ -35160,7 +35179,7 @@ var init_openapi2 = __esm({
35160
35179
  }
35161
35180
  const query3 = this.constructQuery(
35162
35181
  datasourceId,
35163
- name,
35182
+ name2,
35164
35183
  methodName,
35165
35184
  path5,
35166
35185
  url,
@@ -35252,9 +35271,9 @@ var init_openapi3 = __esm({
35252
35271
  }
35253
35272
  };
35254
35273
  this.getInfo = async () => {
35255
- const name = this.document.info.title || "OpenAPI Import";
35274
+ const name2 = this.document.info.title || "OpenAPI Import";
35256
35275
  return {
35257
- name
35276
+ name: name2
35258
35277
  };
35259
35278
  };
35260
35279
  this.getQueries = async (datasourceId) => {
@@ -35281,7 +35300,7 @@ var init_openapi3 = __esm({
35281
35300
  }
35282
35301
  const operation = opOrParams;
35283
35302
  const methodName = key;
35284
- const name = operation.operationId || path5;
35303
+ const name2 = operation.operationId || path5;
35285
35304
  let queryString = "";
35286
35305
  const headers = {};
35287
35306
  let requestBody = getRequestBody(operation);
@@ -35320,7 +35339,7 @@ var init_openapi3 = __esm({
35320
35339
  }
35321
35340
  const query3 = this.constructQuery(
35322
35341
  datasourceId,
35323
- name,
35342
+ name2,
35324
35343
  methodName,
35325
35344
  path5,
35326
35345
  url,
@@ -35401,7 +35420,7 @@ var init_curl = __esm({
35401
35420
  };
35402
35421
  this.getQueries = async (datasourceId) => {
35403
35422
  const url = this.getUrl();
35404
- const name = url.pathname;
35423
+ const name2 = url.pathname;
35405
35424
  const path5 = url.origin + url.pathname;
35406
35425
  const method = this.curl.method;
35407
35426
  const queryString = url.search;
@@ -35413,7 +35432,7 @@ var init_curl = __esm({
35413
35432
  }
35414
35433
  const query3 = this.constructQuery(
35415
35434
  datasourceId,
35416
- name,
35435
+ name2,
35417
35436
  method,
35418
35437
  path5,
35419
35438
  void 0,
@@ -35445,9 +35464,9 @@ var init_import = __esm({
35445
35464
  RestImporter = class {
35446
35465
  constructor(data2) {
35447
35466
  this.init = async () => {
35448
- for (let source of this.sources) {
35449
- if (await source.isSupported(this.data)) {
35450
- this.source = source;
35467
+ for (let source2 of this.sources) {
35468
+ if (await source2.isSupported(this.data)) {
35469
+ this.source = source2;
35451
35470
  break;
35452
35471
  }
35453
35472
  }
@@ -37640,7 +37659,7 @@ function rowEmission({
37640
37659
  appId,
37641
37660
  row: row2,
37642
37661
  table: table2,
37643
- metadata
37662
+ metadata: metadata2
37644
37663
  }) {
37645
37664
  let event = {
37646
37665
  row: row2,
@@ -37654,8 +37673,8 @@ function rowEmission({
37654
37673
  if (row2 == null ? void 0 : row2._rev) {
37655
37674
  event.revision = row2._rev;
37656
37675
  }
37657
- if (metadata) {
37658
- event.metadata = metadata;
37676
+ if (metadata2) {
37677
+ event.metadata = metadata2;
37659
37678
  }
37660
37679
  emitter2.emit(eventName, event);
37661
37680
  }
@@ -37664,7 +37683,7 @@ function tableEmission({
37664
37683
  eventName,
37665
37684
  appId,
37666
37685
  table: table2,
37667
- metadata
37686
+ metadata: metadata2
37668
37687
  }) {
37669
37688
  const tableId = table2 == null ? void 0 : table2._id;
37670
37689
  const inputTable = table2;
@@ -37680,8 +37699,8 @@ function tableEmission({
37680
37699
  if (table2 == null ? void 0 : table2._rev) {
37681
37700
  event.revision = table2._rev;
37682
37701
  }
37683
- if (metadata) {
37684
- event.metadata = metadata;
37702
+ if (metadata2) {
37703
+ event.metadata = metadata2;
37685
37704
  }
37686
37705
  emitter2.emit(eventName, event);
37687
37706
  }
@@ -37856,11 +37875,11 @@ async function storeLog2(automation, results) {
37856
37875
  }
37857
37876
  async function checkAppMetadata(apps2) {
37858
37877
  const maxStartDate = await automations_exports.logs.oldestLogDate();
37859
- for (let metadata of apps2) {
37860
- if (!metadata.automationErrors) {
37878
+ for (let metadata2 of apps2) {
37879
+ if (!metadata2.automationErrors) {
37861
37880
  continue;
37862
37881
  }
37863
- for (let [key, errors] of Object.entries(metadata.automationErrors)) {
37882
+ for (let [key, errors] of Object.entries(metadata2.automationErrors)) {
37864
37883
  const updated9 = [];
37865
37884
  for (let error2 of errors) {
37866
37885
  if (!error2) {
@@ -37871,7 +37890,7 @@ async function checkAppMetadata(apps2) {
37871
37890
  updated9.push(error2);
37872
37891
  }
37873
37892
  }
37874
- metadata.automationErrors[key] = updated9;
37893
+ metadata2.automationErrors[key] = updated9;
37875
37894
  }
37876
37895
  }
37877
37896
  return apps2;
@@ -37959,8 +37978,8 @@ var init_automation4 = __esm({
37959
37978
  constructor(job) {
37960
37979
  let automation = job.data.automation;
37961
37980
  let triggerOutput = job.data.event;
37962
- const metadata = triggerOutput.metadata;
37963
- this._chainCount = metadata ? metadata.automationChainCount : 0;
37981
+ const metadata2 = triggerOutput.metadata;
37982
+ this._chainCount = metadata2 ? metadata2.automationChainCount : 0;
37964
37983
  this._appId = triggerOutput.appId;
37965
37984
  this._job = job;
37966
37985
  const triggerStepId = automation.definition.trigger.stepId;
@@ -37990,16 +38009,16 @@ var init_automation4 = __esm({
37990
38009
  async getMetadata() {
37991
38010
  const metadataId = generateAutomationMetadataID(this._automation._id);
37992
38011
  const db2 = context_exports.getAppDB();
37993
- let metadata;
38012
+ let metadata2;
37994
38013
  try {
37995
- metadata = await db2.get(metadataId);
38014
+ metadata2 = await db2.get(metadataId);
37996
38015
  } catch (err) {
37997
- metadata = {
38016
+ metadata2 = {
37998
38017
  _id: metadataId,
37999
38018
  errorCount: 0
38000
38019
  };
38001
38020
  }
38002
- return metadata;
38021
+ return metadata2;
38003
38022
  }
38004
38023
  async stopCron(reason) {
38005
38024
  if (!this._job.opts.repeat) {
@@ -38022,34 +38041,34 @@ var init_automation4 = __esm({
38022
38041
  );
38023
38042
  await storeLog2(automation, this.executionOutput);
38024
38043
  }
38025
- async checkIfShouldStop(metadata) {
38026
- if (!metadata.errorCount || !this._job.opts.repeat) {
38044
+ async checkIfShouldStop(metadata2) {
38045
+ if (!metadata2.errorCount || !this._job.opts.repeat) {
38027
38046
  return false;
38028
38047
  }
38029
- if (metadata.errorCount >= MAX_AUTOMATION_RECURRING_ERRORS) {
38048
+ if (metadata2.errorCount >= MAX_AUTOMATION_RECURRING_ERRORS) {
38030
38049
  await this.stopCron("errors");
38031
38050
  return true;
38032
38051
  }
38033
38052
  return false;
38034
38053
  }
38035
- async updateMetadata(metadata) {
38054
+ async updateMetadata(metadata2) {
38036
38055
  const output = this.executionOutput, automation = this._automation;
38037
38056
  if (!output || !isRecurring(automation)) {
38038
38057
  return;
38039
38058
  }
38040
- const count = metadata.errorCount;
38059
+ const count = metadata2.errorCount;
38041
38060
  const isError = isErrorInOutput(output);
38042
38061
  if (!count && !isError) {
38043
38062
  return;
38044
38063
  }
38045
38064
  if (isError) {
38046
- metadata.errorCount = count ? count + 1 : 1;
38065
+ metadata2.errorCount = count ? count + 1 : 1;
38047
38066
  } else {
38048
- metadata.errorCount = 0;
38067
+ metadata2.errorCount = 0;
38049
38068
  }
38050
38069
  const db2 = context_exports.getAppDB();
38051
38070
  try {
38052
- await db2.put(metadata);
38071
+ await db2.put(metadata2);
38053
38072
  } catch (err) {
38054
38073
  logging_exports.logAlertWithInfo(
38055
38074
  "Failed to write automation metadata",
@@ -38100,13 +38119,13 @@ var init_automation4 = __esm({
38100
38119
  let stepCount = 0;
38101
38120
  let loopStepNumber = void 0;
38102
38121
  let loopSteps = [];
38103
- let metadata;
38122
+ let metadata2;
38104
38123
  let timeoutFlag = false;
38105
38124
  let wasLoopStep = false;
38106
38125
  let timeout2 = this._job.data.event.timeout;
38107
38126
  if (isProdAppID2(this._appId) && isRecurring(automation)) {
38108
- metadata = await this.getMetadata();
38109
- const shouldStop = await this.checkIfShouldStop(metadata);
38127
+ metadata2 = await this.getMetadata();
38128
+ const shouldStop = await this.checkIfShouldStop(metadata2);
38110
38129
  if (shouldStop) {
38111
38130
  return;
38112
38131
  }
@@ -38310,8 +38329,8 @@ var init_automation4 = __esm({
38310
38329
  }
38311
38330
  logging_exports.logAlert("Error writing automation log", e);
38312
38331
  }
38313
- if (isProdAppID2(this._appId) && isRecurring(automation) && metadata) {
38314
- await this.updateMetadata(metadata);
38332
+ if (isProdAppID2(this._appId) && isRecurring(automation) && metadata2) {
38333
+ await this.updateMetadata(metadata2);
38315
38334
  }
38316
38335
  return this.executionOutput;
38317
38336
  }
@@ -38404,15 +38423,15 @@ async function updateTestHistory(appId, automation, history) {
38404
38423
  return updateEntityMetadata(
38405
38424
  "automationTestHistory" /* AUTOMATION_TEST_HISTORY */,
38406
38425
  automation._id,
38407
- (metadata) => {
38408
- if (metadata && Array.isArray(metadata.history)) {
38409
- metadata.history.push(history);
38426
+ (metadata2) => {
38427
+ if (metadata2 && Array.isArray(metadata2.history)) {
38428
+ metadata2.history.push(history);
38410
38429
  } else {
38411
- metadata = {
38430
+ metadata2 = {
38412
38431
  history: [history]
38413
38432
  };
38414
38433
  }
38415
- return metadata;
38434
+ return metadata2;
38416
38435
  }
38417
38436
  );
38418
38437
  }
@@ -38454,8 +38473,8 @@ async function clearMetadata() {
38454
38473
  include_docs: true
38455
38474
  })
38456
38475
  )).rows.map((row2) => row2.doc);
38457
- for (let metadata of automationMetadata) {
38458
- metadata._deleted = true;
38476
+ for (let metadata2 of automationMetadata) {
38477
+ metadata2._deleted = true;
38459
38478
  }
38460
38479
  await db2.bulkDocs(automationMetadata);
38461
38480
  }
@@ -38661,14 +38680,14 @@ function checkAppUrl(ctx, apps2, url, currentAppId) {
38661
38680
  ctx.throw(400, "App URL is already in use.");
38662
38681
  }
38663
38682
  }
38664
- function checkAppName(ctx, apps2, name, currentAppId) {
38665
- if (!name) {
38683
+ function checkAppName(ctx, apps2, name2, currentAppId) {
38684
+ if (!name2) {
38666
38685
  ctx.throw(400, "Name is required");
38667
38686
  }
38668
38687
  if (currentAppId) {
38669
38688
  apps2 = apps2.filter((app2) => app2.appId !== currentAppId);
38670
38689
  }
38671
- if (apps2.some((app2) => app2.name === name)) {
38690
+ if (apps2.some((app2) => app2.name === name2)) {
38672
38691
  ctx.throw(400, "App name is already in use.");
38673
38692
  }
38674
38693
  }
@@ -38754,9 +38773,9 @@ async function fetchAppPackage(ctx) {
38754
38773
  }
38755
38774
  async function performAppCreate(ctx) {
38756
38775
  const apps2 = await db_exports.getAllApps({ dev: true });
38757
- const name = ctx.request.body.name, possibleUrl = ctx.request.body.url;
38758
- checkAppName(ctx, apps2, name);
38759
- const url = sdk_default.applications.getAppUrl({ name, url: possibleUrl });
38776
+ const name2 = ctx.request.body.name, possibleUrl = ctx.request.body.url;
38777
+ checkAppName(ctx, apps2, name2);
38778
+ const url = sdk_default.applications.getAppUrl({ name: name2, url: possibleUrl });
38760
38779
  checkAppUrl(ctx, apps2, url);
38761
38780
  const { useTemplate, templateKey, templateString } = ctx.request.body;
38762
38781
  const instanceConfig = {
@@ -38779,7 +38798,7 @@ async function performAppCreate(ctx) {
38779
38798
  type: "app",
38780
38799
  version: environment_default.VERSION,
38781
38800
  componentLibraries: ["@budibase/standard-components"],
38782
- name,
38801
+ name: name2,
38783
38802
  url,
38784
38803
  template: templateKey,
38785
38804
  instance,
@@ -38789,7 +38808,7 @@ async function performAppCreate(ctx) {
38789
38808
  status: AppStatus.DEV,
38790
38809
  navigation: {
38791
38810
  navigation: "Top",
38792
- title: name,
38811
+ title: name2,
38793
38812
  navWidth: "Large",
38794
38813
  navBackground: "var(--spectrum-global-color-gray-100)",
38795
38814
  links: [
@@ -38888,11 +38907,11 @@ async function create6(ctx) {
38888
38907
  }
38889
38908
  async function update8(ctx) {
38890
38909
  const apps2 = await db_exports.getAllApps({ dev: true });
38891
- const name = ctx.request.body.name, possibleUrl = ctx.request.body.url;
38892
- if (name) {
38893
- checkAppName(ctx, apps2, name, ctx.params.appId);
38910
+ const name2 = ctx.request.body.name, possibleUrl = ctx.request.body.url;
38911
+ if (name2) {
38912
+ checkAppName(ctx, apps2, name2, ctx.params.appId);
38894
38913
  }
38895
- const url = sdk_default.applications.getAppUrl({ name, url: possibleUrl });
38914
+ const url = sdk_default.applications.getAppUrl({ name: name2, url: possibleUrl });
38896
38915
  if (url) {
38897
38916
  checkAppUrl(ctx, apps2, url, ctx.params.appId);
38898
38917
  ctx.request.body.url = url;
@@ -39036,14 +39055,14 @@ async function migrateAppNavigation() {
39036
39055
  screen.width = (layout2 == null ? void 0 : layout2.props.width) || "Large";
39037
39056
  await db2.put(screen);
39038
39057
  }
39039
- const { name, customTheme } = existing;
39058
+ const { name: name2, customTheme } = existing;
39040
39059
  const layout = layouts == null ? void 0 : layouts.find(
39041
39060
  (layout2) => layout2._id === BASE_LAYOUT_PROP_IDS.PRIVATE
39042
39061
  );
39043
39062
  if (layout && !existing.navigation) {
39044
39063
  let navigationSettings = {
39045
39064
  navigation: "Top",
39046
- title: name,
39065
+ title: name2,
39047
39066
  navWidth: "Large",
39048
39067
  navBackground: (customTheme == null ? void 0 : customTheme.navBackground) || "var(--spectrum-global-color-gray-50)",
39049
39068
  navTextColor: (customTheme == null ? void 0 : customTheme.navTextColor) || "var(--spectrum-global-color-gray-800)"
@@ -39051,7 +39070,7 @@ async function migrateAppNavigation() {
39051
39070
  if (layout) {
39052
39071
  navigationSettings.hideLogo = layout.props.hideLogo;
39053
39072
  navigationSettings.hideTitle = layout.props.hideTitle;
39054
- navigationSettings.title = layout.props.title || name;
39073
+ navigationSettings.title = layout.props.title || name2;
39055
39074
  navigationSettings.logoUrl = layout.props.logoUrl;
39056
39075
  navigationSettings.links = layout.props.links;
39057
39076
  navigationSettings.navigation = layout.props.navigation || "Top";
@@ -40467,14 +40486,14 @@ async function clearLogError(ctx) {
40467
40486
  const { automationId, appId } = ctx.request.body;
40468
40487
  await context_exports.doInAppContext(appId, async () => {
40469
40488
  const db2 = context_exports.getProdAppDB();
40470
- const metadata = await db2.get(DocumentType2.APP_METADATA);
40489
+ const metadata2 = await db2.get(DocumentType2.APP_METADATA);
40471
40490
  if (!automationId) {
40472
- delete metadata.automationErrors;
40473
- } else if (metadata.automationErrors && metadata.automationErrors[automationId]) {
40474
- delete metadata.automationErrors[automationId];
40491
+ delete metadata2.automationErrors;
40492
+ } else if (metadata2.automationErrors && metadata2.automationErrors[automationId]) {
40493
+ delete metadata2.automationErrors[automationId];
40475
40494
  }
40476
- await db2.put(metadata);
40477
- await cache_exports.app.invalidateAppMetadata(metadata.appId, metadata);
40495
+ await db2.put(metadata2);
40496
+ await cache_exports.app.invalidateAppMetadata(metadata2.appId, metadata2);
40478
40497
  ctx.body = { message: `Error logs cleared.` };
40479
40498
  });
40480
40499
  }
@@ -40828,7 +40847,7 @@ async function find12(ctx) {
40828
40847
  }
40829
40848
  async function save20(ctx) {
40830
40849
  const db2 = context_exports.getAppDB();
40831
- let { _id, name, inherits, permissionId } = ctx.request.body;
40850
+ let { _id, name: name2, inherits, permissionId } = ctx.request.body;
40832
40851
  let isCreate = false;
40833
40852
  if (!_id) {
40834
40853
  _id = generateRoleID2();
@@ -40836,7 +40855,7 @@ async function save20(ctx) {
40836
40855
  } else if (roles_exports.isBuiltin(_id)) {
40837
40856
  ctx.throw(400, "Cannot update builtin roles.");
40838
40857
  }
40839
- const role = new roles_exports.Role(_id, name, permissionId).addInheritance(inherits);
40858
+ const role = new roles_exports.Role(_id, name2, permissionId).addInheritance(inherits);
40840
40859
  if (ctx.request.body._rev) {
40841
40860
  role._rev = ctx.request.body._rev;
40842
40861
  }
@@ -40946,10 +40965,10 @@ async function getBuilderMainDoc() {
40946
40965
  };
40947
40966
  }
40948
40967
  }
40949
- async function setBuilderMainDoc(doc) {
40950
- doc._id = KEYS_DOC;
40968
+ async function setBuilderMainDoc(doc2) {
40969
+ doc2._id = KEYS_DOC;
40951
40970
  const db2 = tenancy.getGlobalDB();
40952
- return db2.put(doc);
40971
+ return db2.put(doc2);
40953
40972
  }
40954
40973
  async function fetch36(ctx) {
40955
40974
  try {
@@ -41021,10 +41040,10 @@ async function fetch37(ctx) {
41021
41040
  }
41022
41041
  }
41023
41042
  async function downloadTemplate2(ctx) {
41024
- const { type, name } = ctx.params;
41025
- await downloadTemplate(type, name);
41043
+ const { type, name: name2 } = ctx.params;
41044
+ await downloadTemplate(type, name2);
41026
41045
  ctx.body = {
41027
- message: `template ${type}:${name} downloaded successfully.`
41046
+ message: `template ${type}:${name2} downloaded successfully.`
41028
41047
  };
41029
41048
  }
41030
41049
  var import_node_fetch17, DEFAULT_TEMPLATES_BUCKET;
@@ -41832,11 +41851,11 @@ async function revert(ctx) {
41832
41851
  }
41833
41852
  }
41834
41853
  async function getBudibaseVersion(ctx) {
41835
- const version = environment_default.VERSION;
41854
+ const version2 = environment_default.VERSION;
41836
41855
  ctx.body = {
41837
- version
41856
+ version: version2
41838
41857
  };
41839
- await events_exports.installation.versionChecked(version);
41858
+ await events_exports.installation.versionChecked(version2);
41840
41859
  }
41841
41860
  var import_node_fetch18;
41842
41861
  var init_dev = __esm({
@@ -42009,17 +42028,17 @@ var init_appUrls = __esm({
42009
42028
  init_src2();
42010
42029
  init_sdk3();
42011
42030
  run27 = async (appDb) => {
42012
- let metadata;
42031
+ let metadata2;
42013
42032
  try {
42014
- metadata = await appDb.get(db_exports.DocumentType.APP_METADATA);
42033
+ metadata2 = await appDb.get(db_exports.DocumentType.APP_METADATA);
42015
42034
  } catch (e) {
42016
42035
  console.error("Error retrieving app metadata. Skipping", e);
42017
42036
  return;
42018
42037
  }
42019
- if (!metadata.url) {
42020
- metadata.url = sdk_default.applications.getAppUrl({ name: metadata.name });
42021
- console.log(`Adding url to app: ${metadata.url}`);
42022
- await appDb.put(metadata);
42038
+ if (!metadata2.url) {
42039
+ metadata2.url = sdk_default.applications.getAppUrl({ name: metadata2.name });
42040
+ console.log(`Adding url to app: ${metadata2.url}`);
42041
+ await appDb.put(metadata2);
42023
42042
  }
42024
42043
  };
42025
42044
  }
@@ -42961,9 +42980,9 @@ var init_migrations6 = __esm({
42961
42980
  });
42962
42981
 
42963
42982
  // src/api/controllers/plugin/utils.ts
42964
- async function downloadUnzipTarball(url, name, headers = {}) {
42983
+ async function downloadUnzipTarball(url, name2, headers = {}) {
42965
42984
  try {
42966
- const path5 = createTempFolder(name);
42985
+ const path5 = createTempFolder(name2);
42967
42986
  await objectStore_exports2.downloadTarballDirect(url, path5, headers);
42968
42987
  return path5;
42969
42988
  } catch (e) {
@@ -42986,7 +43005,7 @@ async function request2(url, headers, err) {
42986
43005
  }
42987
43006
  return response2.json();
42988
43007
  }
42989
- async function githubUpload(url, name = "", token = "") {
43008
+ async function githubUpload(url, name2 = "", token = "") {
42990
43009
  var _a2;
42991
43010
  let githubUrl = url;
42992
43011
  if (!githubUrl.includes("https://github.com/")) {
@@ -43005,7 +43024,7 @@ async function githubUpload(url, name = "", token = "") {
43005
43024
  headers,
43006
43025
  "Repository not found"
43007
43026
  );
43008
- const pluginName = pluginDetails.name || name;
43027
+ const pluginName = pluginDetails.name || name2;
43009
43028
  const pluginLatestReleaseUrl = (pluginDetails == null ? void 0 : pluginDetails["releases_url"]) ? pluginDetails == null ? void 0 : pluginDetails["releases_url"].replace("{/id}", "/latest") : void 0;
43010
43029
  if (!pluginLatestReleaseUrl) {
43011
43030
  throw new Error("Github release not found");
@@ -43047,10 +43066,10 @@ var init_github = __esm({
43047
43066
  });
43048
43067
 
43049
43068
  // src/api/controllers/plugin/npm.ts
43050
- async function npmUpload(url, name, headers = {}) {
43069
+ async function npmUpload(url, name2, headers = {}) {
43051
43070
  var _a2, _b2, _c;
43052
43071
  let npmTarballUrl = url;
43053
- let pluginName = name;
43072
+ let pluginName = name2;
43054
43073
  if (!npmTarballUrl.includes("https://www.npmjs.com") && !npmTarballUrl.includes("https://registry.npmjs.org")) {
43055
43074
  throw new Error("The plugin origin must be from NPM");
43056
43075
  }
@@ -43095,11 +43114,11 @@ var init_npm = __esm({
43095
43114
  });
43096
43115
 
43097
43116
  // src/api/controllers/plugin/url.ts
43098
- async function urlUpload(url, name = "", headers = {}) {
43117
+ async function urlUpload(url, name2 = "", headers = {}) {
43099
43118
  if (!url.includes(".tar.gz")) {
43100
43119
  throw new Error("Plugin must be compressed into a gzipped tarball.");
43101
43120
  }
43102
- const path5 = await downloadUnzipTarball(url, name, headers);
43121
+ const path5 = await downloadUnzipTarball(url, name2, headers);
43103
43122
  return await getPluginMetadata(path5);
43104
43123
  }
43105
43124
  var init_url = __esm({
@@ -43125,8 +43144,8 @@ async function upload2(ctx) {
43125
43144
  try {
43126
43145
  let docs = [];
43127
43146
  for (let plugin of plugins2) {
43128
- const doc = await sdk_default.plugins.processUploaded(plugin, "File Upload" /* FILE */);
43129
- docs.push(doc);
43147
+ const doc2 = await sdk_default.plugins.processUploaded(plugin, "File Upload" /* FILE */);
43148
+ docs.push(doc2);
43130
43149
  }
43131
43150
  ctx.body = {
43132
43151
  message: "Plugin(s) uploaded successfully",
@@ -43139,42 +43158,42 @@ async function upload2(ctx) {
43139
43158
  }
43140
43159
  async function create8(ctx) {
43141
43160
  var _a2, _b2;
43142
- const { source, url, headers, githubToken } = ctx.request.body;
43161
+ const { source: source2, url, headers, githubToken } = ctx.request.body;
43143
43162
  try {
43144
- let metadata;
43145
- let directory;
43146
- let name = "PLUGIN_" + Math.floor(1e5 + Math.random() * 9e5);
43147
- switch (source) {
43163
+ let metadata2;
43164
+ let directory2;
43165
+ let name2 = "PLUGIN_" + Math.floor(1e5 + Math.random() * 9e5);
43166
+ switch (source2) {
43148
43167
  case "NPM" /* NPM */:
43149
- const { metadata: metadataNpm, directory: directoryNpm } = await npmUpload(url, name);
43150
- metadata = metadataNpm;
43151
- directory = directoryNpm;
43168
+ const { metadata: metadataNpm, directory: directoryNpm } = await npmUpload(url, name2);
43169
+ metadata2 = metadataNpm;
43170
+ directory2 = directoryNpm;
43152
43171
  break;
43153
43172
  case "Github" /* GITHUB */:
43154
- const { metadata: metadataGithub, directory: directoryGithub } = await githubUpload(url, name, githubToken);
43155
- metadata = metadataGithub;
43156
- directory = directoryGithub;
43173
+ const { metadata: metadataGithub, directory: directoryGithub } = await githubUpload(url, name2, githubToken);
43174
+ metadata2 = metadataGithub;
43175
+ directory2 = directoryGithub;
43157
43176
  break;
43158
43177
  case "URL" /* URL */:
43159
43178
  const headersObj = headers || {};
43160
- const { metadata: metadataUrl, directory: directoryUrl } = await urlUpload(url, name, headersObj);
43161
- metadata = metadataUrl;
43162
- directory = directoryUrl;
43179
+ const { metadata: metadataUrl, directory: directoryUrl } = await urlUpload(url, name2, headersObj);
43180
+ metadata2 = metadataUrl;
43181
+ directory2 = directoryUrl;
43163
43182
  break;
43164
43183
  }
43165
- plugin_exports.validate(metadata == null ? void 0 : metadata.schema);
43166
- if (!environment_default2.SELF_HOSTED && ((_a2 = metadata == null ? void 0 : metadata.schema) == null ? void 0 : _a2.type) !== "component" /* COMPONENT */) {
43184
+ plugin_exports.validate(metadata2 == null ? void 0 : metadata2.schema);
43185
+ if (!environment_default2.SELF_HOSTED && ((_a2 = metadata2 == null ? void 0 : metadata2.schema) == null ? void 0 : _a2.type) !== "component" /* COMPONENT */) {
43167
43186
  throw new Error(
43168
43187
  "Only component plugins are supported outside of self-host"
43169
43188
  );
43170
43189
  }
43171
- const doc = await sdk_exports.plugins.storePlugin(metadata, directory, source);
43172
- (_b2 = clientAppSocket) == null ? void 0 : _b2.emit("plugins-update", { name, hash: doc.hash });
43190
+ const doc2 = await sdk_exports.plugins.storePlugin(metadata2, directory2, source2);
43191
+ (_b2 = clientAppSocket) == null ? void 0 : _b2.emit("plugins-update", { name: name2, hash: doc2.hash });
43173
43192
  ctx.body = {
43174
43193
  message: "Plugin uploaded successfully",
43175
- plugins: [doc]
43194
+ plugins: [doc2]
43176
43195
  };
43177
- ctx.body = { plugin: doc };
43196
+ ctx.body = { plugin: doc2 };
43178
43197
  } catch (err) {
43179
43198
  const errMsg = (err == null ? void 0 : err.message) ? err == null ? void 0 : err.message : err;
43180
43199
  ctx.throw(400, `Failed to import plugin: ${errMsg}`);
@@ -43184,9 +43203,9 @@ async function fetch44(ctx) {
43184
43203
  ctx.body = await sdk_default.plugins.fetch();
43185
43204
  }
43186
43205
  async function destroy22(ctx) {
43187
- const { pluginId } = ctx.params;
43206
+ const { pluginId: pluginId2 } = ctx.params;
43188
43207
  try {
43189
- await sdk_exports.plugins.deletePlugin(pluginId);
43208
+ await sdk_exports.plugins.deletePlugin(pluginId2);
43190
43209
  ctx.body = { message: `Plugin ${ctx.params.pluginId} deleted.` };
43191
43210
  } catch (err) {
43192
43211
  ctx.throw(400, err.message);
@@ -43281,10 +43300,10 @@ var init_ops2 = __esm({
43281
43300
  });
43282
43301
 
43283
43302
  // src/api/controllers/static/index.ts
43284
- async function prepareUpload({ s3Key, bucket, metadata, file }) {
43303
+ async function prepareUpload({ s3Key, bucket, metadata: metadata2, file }) {
43285
43304
  const response2 = await objectStore_exports2.upload({
43286
43305
  bucket,
43287
- metadata,
43306
+ metadata: metadata2,
43288
43307
  filename: s3Key,
43289
43308
  path: file.path,
43290
43309
  type: file.type
@@ -43341,8 +43360,8 @@ var init_static = __esm({
43341
43360
  await send2(ctx, ctx.file, { root: builderPath });
43342
43361
  };
43343
43362
  uploadFile = async function(ctx) {
43344
- let files = ctx.request.files.file.length > 1 ? Array.from(ctx.request.files.file) : [ctx.request.files.file];
43345
- const uploads = files.map(async (file) => {
43363
+ let files2 = ctx.request.files.file.length > 1 ? Array.from(ctx.request.files.file) : [ctx.request.files.file];
43364
+ const uploads = files2.map(async (file) => {
43346
43365
  const fileExtension = [...file.name.split(".")].pop();
43347
43366
  const processedFileName = `${uuid5.v4()}.${fileExtension}`;
43348
43367
  return prepareUpload({
@@ -43547,13 +43566,13 @@ function search6(docs, value, key = "name") {
43547
43566
  }
43548
43567
  value = value.toLowerCase();
43549
43568
  const filtered2 = [];
43550
- for (let doc of docs) {
43551
- if (typeof doc[key] !== "string") {
43569
+ for (let doc2 of docs) {
43570
+ if (typeof doc2[key] !== "string") {
43552
43571
  continue;
43553
43572
  }
43554
- const toTest = doc[key].toLowerCase();
43573
+ const toTest = doc2[key].toLowerCase();
43555
43574
  if (toTest.startsWith(value)) {
43556
- filtered2.push(doc);
43575
+ filtered2.push(doc2);
43557
43576
  }
43558
43577
  }
43559
43578
  return filtered2;
@@ -43591,9 +43610,9 @@ async function setResponseApp(ctx) {
43591
43610
  }
43592
43611
  }
43593
43612
  async function search7(ctx, next) {
43594
- const { name } = ctx.request.body;
43613
+ const { name: name2 } = ctx.request.body;
43595
43614
  const apps2 = await db_exports.getAllApps({ all: true });
43596
- ctx.body = search6(apps2, name);
43615
+ ctx.body = search6(apps2, name2);
43597
43616
  await next();
43598
43617
  }
43599
43618
  async function create9(ctx, next) {
@@ -43701,29 +43720,29 @@ var init_Endpoint = __esm({
43701
43720
  });
43702
43721
 
43703
43722
  // src/api/routes/public/applications.ts
43704
- var nameValidator2, applicationValidator2, read2, write2, applications_default3;
43723
+ var nameValidator2, applicationValidator2, read2, write3, applications_default3;
43705
43724
  var init_applications3 = __esm({
43706
43725
  "src/api/routes/public/applications.ts"() {
43707
43726
  init_applications2();
43708
43727
  init_Endpoint();
43709
43728
  ({ nameValidator: nameValidator2, applicationValidator: applicationValidator2 } = (init_validators(), __toCommonJS(validators_exports)));
43710
43729
  read2 = [];
43711
- write2 = [];
43712
- write2.push(
43730
+ write3 = [];
43731
+ write3.push(
43713
43732
  new Endpoint_default("post", "/applications", applications_default2.create).addMiddleware(
43714
43733
  applicationValidator2()
43715
43734
  )
43716
43735
  );
43717
- write2.push(
43736
+ write3.push(
43718
43737
  new Endpoint_default("put", "/applications/:appId", applications_default2.update).addMiddleware(
43719
43738
  applicationValidator2()
43720
43739
  )
43721
43740
  );
43722
- write2.push(new Endpoint_default("delete", "/applications/:appId", applications_default2.destroy));
43723
- write2.push(
43741
+ write3.push(new Endpoint_default("delete", "/applications/:appId", applications_default2.destroy));
43742
+ write3.push(
43724
43743
  new Endpoint_default("post", "/applications/:appId/unpublish", applications_default2.unpublish)
43725
43744
  );
43726
- write2.push(
43745
+ write3.push(
43727
43746
  new Endpoint_default("post", "/applications/:appId/publish", applications_default2.publish)
43728
43747
  );
43729
43748
  read2.push(new Endpoint_default("get", "/applications/:appId", applications_default2.read));
@@ -43732,7 +43751,7 @@ var init_applications3 = __esm({
43732
43751
  nameValidator2()
43733
43752
  )
43734
43753
  );
43735
- applications_default3 = { read: read2, write: write2 };
43754
+ applications_default3 = { read: read2, write: write3 };
43736
43755
  }
43737
43756
  });
43738
43757
 
@@ -43942,8 +43961,8 @@ var init_metrics2 = __esm({
43942
43961
  // src/api/controllers/public/queries.ts
43943
43962
  async function search8(ctx, next) {
43944
43963
  await fetch23(ctx);
43945
- const { name } = ctx.request.body;
43946
- ctx.body = search6(ctx.body, name);
43964
+ const { name: name2 } = ctx.request.body;
43965
+ ctx.body = search6(ctx.body, name2);
43947
43966
  await next();
43948
43967
  }
43949
43968
  async function execute3(ctx, next) {
@@ -43963,21 +43982,21 @@ var init_queries5 = __esm({
43963
43982
  });
43964
43983
 
43965
43984
  // src/api/routes/public/queries.ts
43966
- var read4, write3, queries_default3;
43985
+ var read4, write4, queries_default3;
43967
43986
  var init_queries6 = __esm({
43968
43987
  "src/api/routes/public/queries.ts"() {
43969
43988
  init_queries5();
43970
43989
  init_Endpoint();
43971
43990
  init_validators();
43972
43991
  read4 = [];
43973
- write3 = [];
43974
- write3.push(new Endpoint_default("post", "/queries/:queryId", queries_default2.execute));
43992
+ write4 = [];
43993
+ write4.push(new Endpoint_default("post", "/queries/:queryId", queries_default2.execute));
43975
43994
  read4.push(
43976
43995
  new Endpoint_default("post", "/queries/search", queries_default2.search).addMiddleware(
43977
43996
  nameValidator()
43978
43997
  )
43979
43998
  );
43980
- queries_default3 = { read: read4, write: write3 };
43999
+ queries_default3 = { read: read4, write: write4 };
43981
44000
  }
43982
44001
  });
43983
44002
 
@@ -43995,9 +44014,9 @@ function fixTable(table2, params2) {
43995
44014
  return table2;
43996
44015
  }
43997
44016
  async function search9(ctx, next) {
43998
- const { name } = ctx.request.body;
44017
+ const { name: name2 } = ctx.request.body;
43999
44018
  await fetch29(ctx);
44000
- ctx.body = search6(ctx.body, name);
44019
+ ctx.body = search6(ctx.body, name2);
44001
44020
  await next();
44002
44021
  }
44003
44022
  async function create10(ctx, next) {
@@ -44037,32 +44056,32 @@ var init_tables3 = __esm({
44037
44056
  });
44038
44057
 
44039
44058
  // src/api/routes/public/tables.ts
44040
- var read6, write4, tables_default3;
44059
+ var read6, write5, tables_default3;
44041
44060
  var init_tables4 = __esm({
44042
44061
  "src/api/routes/public/tables.ts"() {
44043
44062
  init_tables3();
44044
44063
  init_Endpoint();
44045
44064
  init_validators();
44046
44065
  read6 = [];
44047
- write4 = [];
44048
- write4.push(
44066
+ write5 = [];
44067
+ write5.push(
44049
44068
  new Endpoint_default("post", "/tables", tables_default2.create).addMiddleware(
44050
44069
  tableValidator()
44051
44070
  )
44052
44071
  );
44053
- write4.push(
44072
+ write5.push(
44054
44073
  new Endpoint_default("put", "/tables/:tableId", tables_default2.update).addMiddleware(
44055
44074
  tableValidator()
44056
44075
  )
44057
44076
  );
44058
- write4.push(new Endpoint_default("delete", "/tables/:tableId", tables_default2.destroy));
44077
+ write5.push(new Endpoint_default("delete", "/tables/:tableId", tables_default2.destroy));
44059
44078
  read6.push(new Endpoint_default("get", "/tables/:tableId", tables_default2.read));
44060
44079
  read6.push(
44061
44080
  new Endpoint_default("post", "/tables/search", tables_default2.search).addMiddleware(
44062
44081
  nameValidator()
44063
44082
  )
44064
44083
  );
44065
- tables_default3 = { read: read6, write: write4 };
44084
+ tables_default3 = { read: read6, write: write5 };
44066
44085
  }
44067
44086
  });
44068
44087
 
@@ -44141,19 +44160,19 @@ var init_rows7 = __esm({
44141
44160
  });
44142
44161
 
44143
44162
  // src/api/routes/public/rows.ts
44144
- var read8, write5, rows_default4;
44163
+ var read8, write6, rows_default4;
44145
44164
  var init_rows8 = __esm({
44146
44165
  "src/api/routes/public/rows.ts"() {
44147
44166
  init_rows7();
44148
44167
  init_Endpoint();
44149
44168
  init_validators();
44150
44169
  read8 = [];
44151
- write5 = [];
44152
- write5.push(new Endpoint_default("post", "/tables/:tableId/rows", rows_default3.create));
44153
- write5.push(
44170
+ write6 = [];
44171
+ write6.push(new Endpoint_default("post", "/tables/:tableId/rows", rows_default3.create));
44172
+ write6.push(
44154
44173
  new Endpoint_default("put", "/tables/:tableId/rows/:rowId", rows_default3.update)
44155
44174
  );
44156
- write5.push(
44175
+ write6.push(
44157
44176
  new Endpoint_default("delete", "/tables/:tableId/rows/:rowId", rows_default3.destroy)
44158
44177
  );
44159
44178
  read8.push(new Endpoint_default("get", "/tables/:tableId/rows/:rowId", rows_default3.read));
@@ -44164,7 +44183,7 @@ var init_rows8 = __esm({
44164
44183
  rows_default3.search
44165
44184
  ).addMiddleware(externalSearchValidator())
44166
44185
  );
44167
- rows_default4 = { read: read8, write: write5 };
44186
+ rows_default4 = { read: read8, write: write6 };
44168
44187
  }
44169
44188
  });
44170
44189
 
@@ -44185,9 +44204,9 @@ function getUser2(ctx, userId) {
44185
44204
  return readGlobalUser(ctx);
44186
44205
  }
44187
44206
  async function search11(ctx, next) {
44188
- const { name } = ctx.request.body;
44207
+ const { name: name2 } = ctx.request.body;
44189
44208
  const users2 = await allGlobalUsers(ctx);
44190
- ctx.body = search6(users2, name, "email");
44209
+ ctx.body = search6(users2, name2, "email");
44191
44210
  await next();
44192
44211
  }
44193
44212
  async function create12(ctx, next) {
@@ -44241,24 +44260,24 @@ var init_users14 = __esm({
44241
44260
  });
44242
44261
 
44243
44262
  // src/api/routes/public/users.ts
44244
- var read10, write6, users_default3;
44263
+ var read10, write7, users_default3;
44245
44264
  var init_users15 = __esm({
44246
44265
  "src/api/routes/public/users.ts"() {
44247
44266
  init_users14();
44248
44267
  init_Endpoint();
44249
44268
  init_validators();
44250
44269
  read10 = [];
44251
- write6 = [];
44252
- write6.push(new Endpoint_default("post", "/users", users_default2.create));
44253
- write6.push(new Endpoint_default("put", "/users/:userId", users_default2.update));
44254
- write6.push(new Endpoint_default("delete", "/users/:userId", users_default2.destroy));
44270
+ write7 = [];
44271
+ write7.push(new Endpoint_default("post", "/users", users_default2.create));
44272
+ write7.push(new Endpoint_default("put", "/users/:userId", users_default2.update));
44273
+ write7.push(new Endpoint_default("delete", "/users/:userId", users_default2.destroy));
44255
44274
  read10.push(new Endpoint_default("get", "/users/:userId", users_default2.read));
44256
44275
  read10.push(
44257
44276
  new Endpoint_default("post", "/users/search", users_default2.search).addMiddleware(
44258
44277
  nameValidator()
44259
44278
  )
44260
44279
  );
44261
- users_default3 = { read: read10, write: write6 };
44280
+ users_default3 = { read: read10, write: write7 };
44262
44281
  }
44263
44282
  });
44264
44283
 
@@ -44830,9 +44849,9 @@ function watch() {
44830
44849
  await tenancy.doInTenant(constants_exports.DEFAULT_TENANT_ID, async () => {
44831
44850
  try {
44832
44851
  const split = path5.split("/");
44833
- const name = split[split.length - 1];
44852
+ const name2 = split[split.length - 1];
44834
44853
  console.log("Importing plugin:", path5);
44835
- await plugins_default.processUploaded({ name, path: path5 });
44854
+ await plugins_default.processUploaded({ name: name2, path: path5 });
44836
44855
  } catch (err) {
44837
44856
  const message = (err == null ? void 0 : err.message) ? err == null ? void 0 : err.message : err;
44838
44857
  console.error("Failed to import plugin:", message);