Skip to main content
Version: Next

createConditionExports()

Home > @backstage/plugin-permission-node > createConditionExports

Creates the recommended condition-related exports for a given plugin based on the built-in PermissionRules it supports.

Signature:

createConditionExports: <TResourceType extends string, TResource, TRules extends Record<string, PermissionRule<TResource, any, TResourceType>>>(options: {
pluginId: string;
resourceType: TResourceType;
rules: TRules;
}) => {
conditions: Conditions<TRules>;
createConditionalDecision: (permission: ResourcePermission<TResourceType>, conditions: PermissionCriteria<PermissionCondition<TResourceType>>) => ConditionalPolicyDecision;
}

Parameters

Parameter

Type

Description

options

{ pluginId: string; resourceType: TResourceType; rules: TRules; }

**Returns:**

{ conditions: Conditions<TRules>; createConditionalDecision: (permission: ResourcePermission<TResourceType>, conditions: PermissionCriteria<PermissionCondition<TResourceType>>) => ConditionalPolicyDecision; }

Remarks

The function returns a conditions object containing a PermissionCondition factory for each of the supplied PermissionRules, along with a createConditionalDecision function which builds the wrapper object needed to enclose conditions when authoring PermissionPolicy implementations.

Plugin authors should generally call this method with all the built-in PermissionRules the plugin supports, and export the resulting conditions object and createConditionalDecision function so that they can be used by PermissionPolicy authors.