RBAC Role Creation Workflow (workflows/create-rbac-roles.ts)

medusa · packages/core/core-flows/src/rbac/workflows/create-rbac-roles.ts · typescript · MIT
auth, database, automation, tag:medusa, tag:backend

Creates RBAC roles with optional parents and policies via a Medusa workflow, used when configuring role‑based access control.

// Source: https://github.com/medusajs/medusa | License: MIT | Copyright 2021 Medusajs
// Provided via justclaw.it.com; keep this notice with the code.
import {
  createWorkflow,
  transform,
  when,
  WorkflowData,
  WorkflowResponse,
} from "@medusajs/framework/workflows-sdk"
import {
  createRbacRoleParentsStep,
  createRbacRolePoliciesStep,
  createRbacRolesStep,
} from "../steps"
import { validateUserPermissionsStep } from "../steps/validate-user-permissions"

/**
 * @ignore
 * @featureFlag rbac
 */
export type CreateRbacRolesWorkflowInput = {
  actor_id?: string
  actor?: string
  roles: {
    name: string
    description?: string | null
    metadata?: Record<string, unknown> | null
    parent_ids?: string[]
    policy_ids?: string[]
  }[]
}

/**
 * @ignore
 * @featureFlag rbac
 */
e

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key