// src/data/operations/control/membership/membership-workspace-projection.ts
import { normalizeLabel } from "@openhi/types";
var MISSING_NAME_SENTINEL = "-";
function buildMembershipWorkspaceProjectionSk(params) {
  const normalizedUserName = typeof params.denormalizedUserName === "string" && params.denormalizedUserName.length > 0 ? normalizeLabel(params.denormalizedUserName) : MISSING_NAME_SENTINEL;
  return `MEMBERSHIP#${normalizedUserName}#USER#${params.userId}#${params.membershipId}`;
}
function buildMembershipWorkspaceProjectionItem(input) {
  if (!input.workspaceId || input.workspaceId.length === 0) {
    return void 0;
  }
  if (!input.userId || input.userId.length === 0) {
    return void 0;
  }
  const sk = buildMembershipWorkspaceProjectionSk({
    userId: input.userId,
    membershipId: input.membershipId,
    denormalizedUserName: input.denormalizedUserName
  });
  return {
    tenantId: input.tenantId,
    workspaceId: input.workspaceId,
    sk,
    userId: input.userId,
    membershipId: input.membershipId,
    summary: input.summary,
    vid: input.vid,
    lastUpdated: input.lastUpdated,
    denormalizedUserName: input.denormalizedUserName
  };
}

// src/data/operations/control/roleassignment/roleassignment-user-projection.ts
import { normalizeLabel as normalizeLabel2 } from "@openhi/types";
var MISSING_NAME_SENTINEL2 = "-";
function buildRoleAssignmentUserProjectionSkTenantLane(params) {
  const normalizedRoleName = typeof params.denormalizedRoleName === "string" && params.denormalizedRoleName.length > 0 ? normalizeLabel2(params.denormalizedRoleName) : MISSING_NAME_SENTINEL2;
  return `ROLEASSIGNMENT#TENANT#${normalizedRoleName}#${params.roleId}#TID#${params.tenantId}#${params.roleAssignmentId}`;
}
function buildRoleAssignmentUserProjectionSkWorkspaceLane(params) {
  const normalizedRoleName = typeof params.denormalizedRoleName === "string" && params.denormalizedRoleName.length > 0 ? normalizeLabel2(params.denormalizedRoleName) : MISSING_NAME_SENTINEL2;
  return `ROLEASSIGNMENT#WORKSPACE#${normalizedRoleName}#${params.roleId}#TID#${params.tenantId}#WID#${params.workspaceId}#${params.roleAssignmentId}`;
}
function buildRoleAssignmentUserProjectionItem(input) {
  if (!input.userId || input.userId.length === 0) {
    return void 0;
  }
  if (!input.roleId || input.roleId.length === 0) {
    return void 0;
  }
  const hasWorkspace = typeof input.workspaceId === "string" && input.workspaceId.length > 0;
  const sk = hasWorkspace ? buildRoleAssignmentUserProjectionSkWorkspaceLane({
    tenantId: input.tenantId,
    workspaceId: input.workspaceId,
    roleId: input.roleId,
    roleAssignmentId: input.roleAssignmentId,
    denormalizedRoleName: input.denormalizedRoleName
  }) : buildRoleAssignmentUserProjectionSkTenantLane({
    tenantId: input.tenantId,
    roleId: input.roleId,
    roleAssignmentId: input.roleAssignmentId,
    denormalizedRoleName: input.denormalizedRoleName
  });
  return {
    userId: input.userId,
    sk,
    tenantId: input.tenantId,
    workspaceId: hasWorkspace ? input.workspaceId : void 0,
    roleId: input.roleId,
    roleAssignmentId: input.roleAssignmentId,
    summary: input.summary,
    vid: input.vid,
    lastUpdated: input.lastUpdated,
    denormalizedTenantName: input.denormalizedTenantName,
    denormalizedUserName: input.denormalizedUserName,
    denormalizedRoleName: input.denormalizedRoleName
  };
}
function extractReferenceSlug(resource, fieldName) {
  const field = resource[fieldName];
  if (!field || typeof field !== "object") {
    return void 0;
  }
  const reference = field.reference;
  if (typeof reference !== "string" || reference.length === 0) {
    return void 0;
  }
  const slash = reference.lastIndexOf("/");
  const tail = slash >= 0 ? reference.slice(slash + 1) : reference;
  return tail.length > 0 ? tail : void 0;
}

// src/data/operations/control/roleassignment/roleassignment-workspace-projection.ts
import { normalizeLabel as normalizeLabel3 } from "@openhi/types";
var MISSING_NAME_SENTINEL3 = "-";
function buildRoleAssignmentWorkspaceProjectionSk(params) {
  const normalizedUserName = typeof params.denormalizedUserName === "string" && params.denormalizedUserName.length > 0 ? normalizeLabel3(params.denormalizedUserName) : MISSING_NAME_SENTINEL3;
  return `ROLEASSIGNMENT#${params.roleId}#${normalizedUserName}#USER#${params.userId}#${params.roleAssignmentId}`;
}
function buildRoleAssignmentWorkspaceProjectionItem(input) {
  if (!input.workspaceId || input.workspaceId.length === 0) {
    return void 0;
  }
  if (!input.userId || input.userId.length === 0) {
    return void 0;
  }
  if (!input.roleId || input.roleId.length === 0) {
    return void 0;
  }
  const sk = buildRoleAssignmentWorkspaceProjectionSk({
    roleId: input.roleId,
    userId: input.userId,
    roleAssignmentId: input.roleAssignmentId,
    denormalizedUserName: input.denormalizedUserName
  });
  return {
    tenantId: input.tenantId,
    workspaceId: input.workspaceId,
    sk,
    userId: input.userId,
    roleId: input.roleId,
    roleAssignmentId: input.roleAssignmentId,
    summary: input.summary,
    vid: input.vid,
    lastUpdated: input.lastUpdated,
    denormalizedUserName: input.denormalizedUserName,
    denormalizedRoleName: input.denormalizedRoleName
  };
}

export {
  buildMembershipWorkspaceProjectionSk,
  buildMembershipWorkspaceProjectionItem,
  buildRoleAssignmentUserProjectionSkTenantLane,
  buildRoleAssignmentUserProjectionSkWorkspaceLane,
  buildRoleAssignmentUserProjectionItem,
  extractReferenceSlug,
  buildRoleAssignmentWorkspaceProjectionSk,
  buildRoleAssignmentWorkspaceProjectionItem
};
//# sourceMappingURL=chunk-5S6VFBLT.mjs.map