@objectstack/core 12.6.0 → 14.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4235,7 +4235,7 @@ async function tryFind(ql, object, where, limit = 100) {
4235
4235
  async function resolveAuthzContext(input) {
4236
4236
  const { ql, headers } = input;
4237
4237
  const ctx = {
4238
- roles: [],
4238
+ positions: [],
4239
4239
  permissions: [],
4240
4240
  systemPermissions: [],
4241
4241
  org_user_ids: []
@@ -4284,16 +4284,16 @@ async function resolveAuthzContext(input) {
4284
4284
  if (m.role && typeof m.role === "string") {
4285
4285
  for (const raw of m.role.split(",").map((s) => s.trim()).filter(Boolean)) {
4286
4286
  const r = (0, import_spec.mapMembershipRole)(raw);
4287
- if (!ctx.roles.includes(r)) ctx.roles.push(r);
4287
+ if (!ctx.positions.includes(r)) ctx.positions.push(r);
4288
4288
  }
4289
4289
  }
4290
4290
  }
4291
- const userRoleRows = await tryFind(ql, "sys_user_role", { user_id: userId }, 200);
4292
- for (const ur of userRoleRows) {
4291
+ const userPositionRows = await tryFind(ql, "sys_user_position", { user_id: userId }, 200);
4292
+ for (const ur of userPositionRows) {
4293
4293
  const org = ur.organization_id ?? null;
4294
4294
  if (org && tenantId && org !== tenantId) continue;
4295
- const r = ur.role;
4296
- if (typeof r === "string" && r && !ctx.roles.includes(r)) ctx.roles.push(r);
4295
+ const r = ur.position;
4296
+ if (typeof r === "string" && r && !ctx.positions.includes(r)) ctx.positions.push(r);
4297
4297
  }
4298
4298
  if (tenantId) {
4299
4299
  const orgMembers = await tryFind(ql, "sys_member", { organization_id: tenantId }, 1e3);
@@ -4316,11 +4316,12 @@ async function resolveAuthzContext(input) {
4316
4316
  upsRows.filter((r) => (r.organization_id ?? r.organizationId ?? null) === null).map((r) => r.permission_set_id ?? r.permissionSetId).filter(Boolean)
4317
4317
  );
4318
4318
  let hasPlatformAdminGrant = false;
4319
- if (ctx.roles.length > 0) {
4320
- const roleRows = await tryFind(ql, "sys_role", { name: { $in: ctx.roles } }, 100);
4321
- const roleIds = roleRows.map((r) => r.id).filter(Boolean);
4322
- if (roleIds.length > 0) {
4323
- const rpsRows = await tryFind(ql, "sys_role_permission_set", { role_id: { $in: roleIds } }, 500);
4319
+ if (!ctx.positions.includes("everyone")) ctx.positions.push("everyone");
4320
+ if (ctx.positions.length > 0) {
4321
+ const positionRows = await tryFind(ql, "sys_position", { name: { $in: ctx.positions } }, 100);
4322
+ const positionIds = positionRows.map((r) => r.id).filter(Boolean);
4323
+ if (positionIds.length > 0) {
4324
+ const rpsRows = await tryFind(ql, "sys_position_permission_set", { position_id: { $in: positionIds } }, 500);
4324
4325
  for (const r of rpsRows) {
4325
4326
  const id = r.permission_set_id ?? r.permissionSetId;
4326
4327
  if (id) psIds.add(id);
@@ -4353,8 +4354,8 @@ async function resolveAuthzContext(input) {
4353
4354
  }
4354
4355
  if (Object.keys(mergedTabs).length > 0) ctx.tabPermissions = mergedTabs;
4355
4356
  }
4356
- if (hasPlatformAdminGrant && !ctx.roles.includes(import_spec.BUILTIN_ROLE_PLATFORM_ADMIN)) {
4357
- ctx.roles.unshift(import_spec.BUILTIN_ROLE_PLATFORM_ADMIN);
4357
+ if (hasPlatformAdminGrant && !ctx.positions.includes(import_spec.BUILTIN_IDENTITY_PLATFORM_ADMIN)) {
4358
+ ctx.positions.unshift(import_spec.BUILTIN_IDENTITY_PLATFORM_ADMIN);
4358
4359
  }
4359
4360
  if (!ctx.permissions.includes("ai_seat")) {
4360
4361
  const aiAccess = (await getUserRow())?.ai_access;