@budibase/backend-core 2.28.3 → 2.28.5

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
@@ -55840,15 +55840,20 @@ function isWorker() {
55840
55840
  function isApps() {
55841
55841
  return environment.SERVICE_TYPE === "apps" /* APPS */;
55842
55842
  }
55843
+ function isQA() {
55844
+ return environment.BUDIBASE_ENVIRONMENT === "QA";
55845
+ }
55843
55846
  var environment = {
55844
55847
  isTest,
55845
55848
  isJest,
55846
55849
  isDev,
55847
55850
  isWorker,
55848
55851
  isApps,
55852
+ isQA,
55849
55853
  isProd: () => {
55850
55854
  return !isDev();
55851
55855
  },
55856
+ BUDIBASE_ENVIRONMENT: process.env.BUDIBASE_ENVIRONMENT,
55852
55857
  JS_BCRYPT: process.env.JS_BCRYPT,
55853
55858
  JWT_SECRET: process.env.JWT_SECRET,
55854
55859
  JWT_SECRET_FALLBACK: process.env.JWT_SECRET_FALLBACK,
@@ -55867,6 +55872,7 @@ var environment = {
55867
55872
  REDIS_CLUSTERED: process.env.REDIS_CLUSTERED,
55868
55873
  MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
55869
55874
  MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
55875
+ AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN,
55870
55876
  AWS_REGION: process.env.AWS_REGION,
55871
55877
  MINIO_URL: process.env.MINIO_URL,
55872
55878
  MINIO_ENABLED: process.env.MINIO_ENABLED || 1,
@@ -56550,7 +56556,13 @@ var DatabaseImpl = class _DatabaseImpl {
56550
56556
  async sqlDiskCleanup() {
56551
56557
  const dbName = this.name;
56552
56558
  const url = `/${dbName}/_cleanup`;
56553
- return await this._sqlQuery(url, "POST");
56559
+ try {
56560
+ await this._sqlQuery(url, "POST");
56561
+ } catch (err) {
56562
+ if (err.status !== 500) {
56563
+ throw err;
56564
+ }
56565
+ }
56554
56566
  }
56555
56567
  // removes a document from sqlite
56556
56568
  async sqlPurgeDocument(docIds) {
@@ -56568,17 +56580,13 @@ var DatabaseImpl = class _DatabaseImpl {
56568
56580
  });
56569
56581
  }
56570
56582
  async destroy() {
56583
+ if (environment_default.SQS_SEARCH_ENABLE && await this.exists(SQLITE_DESIGN_DOC_ID)) {
56584
+ const definition = await this.get(SQLITE_DESIGN_DOC_ID);
56585
+ definition.sql.tables = {};
56586
+ await this.put(definition);
56587
+ await this.sqlDiskCleanup();
56588
+ }
56571
56589
  try {
56572
- if (environment_default.SQS_SEARCH_ENABLE) {
56573
- try {
56574
- const definition = await this.get(
56575
- SQLITE_DESIGN_DOC_ID
56576
- );
56577
- await this.remove(SQLITE_DESIGN_DOC_ID, definition._rev);
56578
- } finally {
56579
- await this.sqlDiskCleanup();
56580
- }
56581
- }
56582
56590
  return await this.nano().db.destroy(this.name);
56583
56591
  } catch (err) {
56584
56592
  if (err.statusCode === 404) {
@@ -58608,6 +58616,9 @@ function ObjectStore(bucket, opts = { presigning: false }) {
58608
58616
  Bucket: sanitizeBucket(bucket)
58609
58617
  };
58610
58618
  }
58619
+ if (!environment_default.MINIO_ENABLED && environment_default.AWS_SESSION_TOKEN) {
58620
+ config.sessionToken = environment_default.AWS_SESSION_TOKEN;
58621
+ }
58611
58622
  if (environment_default.MINIO_URL) {
58612
58623
  if (opts.presigning && environment_default.MINIO_ENABLED) {
58613
58624
  config.endpoint = "minio-service";
@@ -59921,13 +59932,21 @@ __export(tenancy_exports, {
59921
59932
  addTenantToUrl: () => addTenantToUrl,
59922
59933
  getTenantDB: () => getTenantDB,
59923
59934
  getTenantIDFromCtx: () => getTenantIDFromCtx,
59924
- isUserInAppTenant: () => isUserInAppTenant
59935
+ isUserInAppTenant: () => isUserInAppTenant,
59936
+ saveTenantInfo: () => saveTenantInfo
59925
59937
  });
59926
59938
 
59927
59939
  // src/tenancy/db.ts
59928
59940
  function getTenantDB(tenantId) {
59929
59941
  return getDB(getGlobalDBName(tenantId));
59930
59942
  }
59943
+ async function saveTenantInfo(tenantInfo) {
59944
+ const db = getTenantDB(tenantInfo.tenantId);
59945
+ return await db.put({
59946
+ _id: "tenant_info",
59947
+ ...tenantInfo
59948
+ });
59949
+ }
59931
59950
 
59932
59951
  // src/tenancy/tenancy.ts
59933
59952
  function addTenantToUrl(url) {
@@ -61774,12 +61793,12 @@ var InMemoryQueue = class {
61774
61793
  * Same callback API as Bull, each callback passed to this will consume messages as they are
61775
61794
  * available. Please note this is a queue service, not a notification service, so each
61776
61795
  * consumer will receive different messages.
61777
- * @param func The callback function which will return a "Job", the same
61778
61796
  * as the Bull API, within this job the property "data" contains the JSON message. Please
61779
61797
  * note this is incredibly limited compared to Bull as in reality the Job would contain
61780
61798
  * a lot more information about the queue and current status of Bull cluster.
61781
61799
  */
61782
- async process(func) {
61800
+ async process(concurrencyOrFunc, func) {
61801
+ func = typeof concurrencyOrFunc === "number" ? func : concurrencyOrFunc;
61783
61802
  this._emitter.on("message", async () => {
61784
61803
  if (this._messages.length <= 0) {
61785
61804
  return;
@@ -62031,6 +62050,7 @@ var cleanupInterval;
62031
62050
  async function cleanup2() {
62032
62051
  for (let queue of QUEUES) {
62033
62052
  await queue.clean(CLEANUP_PERIOD_MS, "completed");
62053
+ await queue.clean(CLEANUP_PERIOD_MS, "failed");
62034
62054
  }
62035
62055
  }
62036
62056
  function createQueue(jobQueue, opts = {}) {