@budibase/backend-core 2.29.25 → 2.29.26

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
@@ -42652,9 +42652,9 @@ var require_schema_obj = __commonJS({
42652
42652
  }
42653
42653
  });
42654
42654
 
42655
- // ../../node_modules/json-schema-traverse/index.js
42655
+ // ../../node_modules/ajv/node_modules/json-schema-traverse/index.js
42656
42656
  var require_json_schema_traverse = __commonJS({
42657
- "../../node_modules/json-schema-traverse/index.js"(exports, module2) {
42657
+ "../../node_modules/ajv/node_modules/json-schema-traverse/index.js"(exports, module2) {
42658
42658
  "use strict";
42659
42659
  var traverse = module2.exports = function(schema, opts, cb) {
42660
42660
  if (typeof opts == "function") {
@@ -54561,6 +54561,7 @@ var AutomationTriggerStepId = /* @__PURE__ */ ((AutomationTriggerStepId2) => {
54561
54561
  AutomationTriggerStepId2["WEBHOOK"] = "WEBHOOK";
54562
54562
  AutomationTriggerStepId2["APP"] = "APP";
54563
54563
  AutomationTriggerStepId2["CRON"] = "CRON";
54564
+ AutomationTriggerStepId2["ROW_ACTION"] = "ROW_ACTION";
54564
54565
  return AutomationTriggerStepId2;
54565
54566
  })(AutomationTriggerStepId || {});
54566
54567
  var AutomationActionStepId = /* @__PURE__ */ ((AutomationActionStepId2) => {
@@ -55564,6 +55565,7 @@ function hasSchema(test) {
55564
55565
  var sdk_exports = {};
55565
55566
  __export(sdk_exports, {
55566
55567
  applications: () => applications_exports,
55568
+ automations: () => automations_exports,
55567
55569
  users: () => users_exports
55568
55570
  });
55569
55571
 
@@ -55600,6 +55602,21 @@ function getProdAppID(appId) {
55600
55602
  return `${APP_PREFIX}${rest}`;
55601
55603
  }
55602
55604
 
55605
+ // ../shared-core/src/sdk/documents/automations.ts
55606
+ var automations_exports = {};
55607
+ __export(automations_exports, {
55608
+ isAppAction: () => isAppAction,
55609
+ isRowAction: () => isRowAction
55610
+ });
55611
+ function isRowAction(automation) {
55612
+ const result = automation.definition.trigger?.stepId === "ROW_ACTION" /* ROW_ACTION */;
55613
+ return result;
55614
+ }
55615
+ function isAppAction(automation) {
55616
+ const result = automation.definition.trigger?.stepId === "APP" /* APP */;
55617
+ return result;
55618
+ }
55619
+
55603
55620
  // ../shared-core/src/sdk/documents/users.ts
55604
55621
  var users_exports = {};
55605
55622
  __export(users_exports, {
@@ -58722,14 +58739,16 @@ var createPlatformUserView = async () => {
58722
58739
  }`;
58723
58740
  await createPlatformView(viewJs, "platform_users_lowercase_2" /* PLATFORM_USERS_LOWERCASE */);
58724
58741
  };
58725
- var queryPlatformView = async (viewName, params2, opts) => {
58742
+ var queryPlatformView = async (viewName, params2) => {
58726
58743
  const CreateFuncByName2 = {
58727
58744
  ["account_by_email" /* ACCOUNT_BY_EMAIL */]: createPlatformAccountEmailView,
58728
58745
  ["platform_users_lowercase_2" /* PLATFORM_USERS_LOWERCASE */]: createPlatformUserView
58729
58746
  };
58730
58747
  return doWithDB(StaticDatabases.PLATFORM_INFO.name, async (db) => {
58731
58748
  const createFn = CreateFuncByName2[viewName];
58732
- return queryView(viewName, params2, db, createFn, opts);
58749
+ return queryView(viewName, params2, db, createFn, {
58750
+ arrayResponse: true
58751
+ });
58733
58752
  });
58734
58753
  };
58735
58754
  var CreateFuncByName = {
@@ -60479,7 +60498,8 @@ __export(users_exports2, {
60479
60498
  addUser: () => addUser,
60480
60499
  getUserDoc: () => getUserDoc,
60481
60500
  lookupTenantId: () => lookupTenantId,
60482
- removeUser: () => removeUser
60501
+ removeUser: () => removeUser,
60502
+ updateUserDoc: () => updateUserDoc
60483
60503
  });
60484
60504
 
60485
60505
  // src/platform/platformDb.ts
@@ -60499,6 +60519,10 @@ async function getUserDoc(emailOrId) {
60499
60519
  const db = getPlatformDB();
60500
60520
  return db.get(emailOrId);
60501
60521
  }
60522
+ async function updateUserDoc(platformUser) {
60523
+ const db = getPlatformDB();
60524
+ await db.put(platformUser);
60525
+ }
60502
60526
  function newUserIdDoc(id, tenantId) {
60503
60527
  return {
60504
60528
  _id: id,
@@ -61133,9 +61157,10 @@ __export(users_exports3, {
61133
61157
  getExistingAccounts: () => getExistingAccounts,
61134
61158
  getExistingPlatformUsers: () => getExistingPlatformUsers,
61135
61159
  getExistingTenantUsers: () => getExistingTenantUsers,
61160
+ getFirstPlatformUser: () => getFirstPlatformUser,
61136
61161
  getGlobalUserByAppPage: () => getGlobalUserByAppPage,
61137
61162
  getGlobalUserByEmail: () => getGlobalUserByEmail,
61138
- getPlatformUser: () => getPlatformUser,
61163
+ getPlatformUsers: () => getPlatformUsers,
61139
61164
  getUserCount: () => getUserCount,
61140
61165
  hasAdminPermissions: () => hasAdminPermissions2,
61141
61166
  hasAppBuilderPermissions: () => hasAppBuilderPermissions2,
@@ -61238,12 +61263,16 @@ async function searchExistingEmails(emails) {
61238
61263
  matchedEmails.push(...invitedEmails.map((invite) => invite.email));
61239
61264
  return [...new Set(matchedEmails.map((email) => email.toLowerCase()))];
61240
61265
  }
61241
- async function getPlatformUser(identifier) {
61266
+ async function getPlatformUsers(identifier) {
61242
61267
  return await queryPlatformView("platform_users_lowercase_2" /* PLATFORM_USERS_LOWERCASE */, {
61243
61268
  keys: [identifier.toLowerCase()],
61244
61269
  include_docs: true
61245
61270
  });
61246
61271
  }
61272
+ async function getFirstPlatformUser(identifier) {
61273
+ const platformUserDocs = await getPlatformUsers(identifier);
61274
+ return platformUserDocs[0] ?? null;
61275
+ }
61247
61276
  async function getExistingTenantUsers(emails) {
61248
61277
  const lcEmails = emails.map((email) => email.toLowerCase());
61249
61278
  const params2 = {
@@ -61266,13 +61295,9 @@ async function getExistingPlatformUsers(emails) {
61266
61295
  keys: lcEmails,
61267
61296
  include_docs: true
61268
61297
  };
61269
- const opts = {
61270
- arrayResponse: true
61271
- };
61272
61298
  return await queryPlatformView(
61273
61299
  "platform_users_lowercase_2" /* PLATFORM_USERS_LOWERCASE */,
61274
- params2,
61275
- opts
61300
+ params2
61276
61301
  );
61277
61302
  }
61278
61303
  async function getExistingAccounts(emails) {
@@ -61281,14 +61306,7 @@ async function getExistingAccounts(emails) {
61281
61306
  keys: lcEmails,
61282
61307
  include_docs: true
61283
61308
  };
61284
- const opts = {
61285
- arrayResponse: true
61286
- };
61287
- return await queryPlatformView(
61288
- "account_by_email" /* ACCOUNT_BY_EMAIL */,
61289
- params2,
61290
- opts
61291
- );
61309
+ return await queryPlatformView("account_by_email" /* ACCOUNT_BY_EMAIL */, params2);
61292
61310
  }
61293
61311
 
61294
61312
  // src/errors/index.ts
@@ -61862,7 +61880,7 @@ async function isCreatorByGroupMembership(user) {
61862
61880
  }
61863
61881
  async function validateUniqueUser(email, tenantId) {
61864
61882
  if (environment_default.MULTI_TENANCY) {
61865
- const tenantUser = await getPlatformUser(email);
61883
+ const tenantUser = await getFirstPlatformUser(email);
61866
61884
  if (tenantUser != null && tenantUser.tenantId !== tenantId) {
61867
61885
  throw new EmailUnavailableError(email);
61868
61886
  }
@@ -64863,9 +64881,26 @@ var UserDB = class _UserDB {
64863
64881
  const creatorsToDeleteCount = creatorsEval.filter(
64864
64882
  (creator) => !!creator
64865
64883
  ).length;
64884
+ const ssoUsersToDelete = [];
64866
64885
  for (let user of usersToDelete) {
64886
+ const platformUser = await getFirstPlatformUser(
64887
+ user._id
64888
+ );
64889
+ const ssoId = platformUser.ssoId;
64890
+ if (ssoId) {
64891
+ const ssoUsers = await getPlatformUsers(
64892
+ ssoId
64893
+ );
64894
+ ssoUsers.filter((user2) => user2.ssoId == null).forEach((user2) => {
64895
+ ssoUsersToDelete.push({
64896
+ ...user2,
64897
+ _deleted: true
64898
+ });
64899
+ });
64900
+ }
64867
64901
  await bulkDeleteProcessing(user);
64868
64902
  }
64903
+ await getPlatformDB().bulkDocs(ssoUsersToDelete);
64869
64904
  await _UserDB.quotas.removeUsers(toDelete.length, creatorsToDeleteCount);
64870
64905
  const userIndex = {};
64871
64906
  usersToDelete.reduce((prev, current) => {