scaffolder: rename customPermissionRules to rules
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
@@ -656,8 +656,6 @@ export interface RouterOptions {
|
||||
// (undocumented)
|
||||
config: Config;
|
||||
// (undocumented)
|
||||
customPermissionRules?: ScaffolderPermissionRuleInput[];
|
||||
// (undocumented)
|
||||
database: PluginDatabaseManager;
|
||||
// (undocumented)
|
||||
identity?: IdentityApi;
|
||||
@@ -668,6 +666,8 @@ export interface RouterOptions {
|
||||
// (undocumented)
|
||||
reader: UrlReader;
|
||||
// (undocumented)
|
||||
rules?: TemplatePermissionRuleInput[];
|
||||
// (undocumented)
|
||||
scheduler?: PluginTaskScheduler;
|
||||
// (undocumented)
|
||||
taskBroker?: TaskBroker;
|
||||
@@ -697,16 +697,6 @@ export class ScaffolderEntitiesProcessor implements CatalogProcessor {
|
||||
validateEntityKind(entity: Entity): Promise<boolean>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type ScaffolderPermissionRuleInput<
|
||||
TParams extends PermissionRuleParams = PermissionRuleParams,
|
||||
> = PermissionRule<
|
||||
TemplateEntityStepV1beta3 | TemplateParametersV1beta3,
|
||||
{},
|
||||
typeof RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
|
||||
TParams
|
||||
>;
|
||||
|
||||
// @public
|
||||
export type SerializedTask = {
|
||||
id: string;
|
||||
@@ -931,4 +921,14 @@ export type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
|
||||
export type TemplateGlobal =
|
||||
| ((...args: JsonValue[]) => JsonValue | undefined)
|
||||
| JsonValue;
|
||||
|
||||
// @public (undocumented)
|
||||
export type TemplatePermissionRuleInput<
|
||||
TParams extends PermissionRuleParams = PermissionRuleParams,
|
||||
> = PermissionRule<
|
||||
TemplateEntityStepV1beta3 | TemplateParametersV1beta3,
|
||||
{},
|
||||
typeof RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
|
||||
TParams
|
||||
>;
|
||||
```
|
||||
|
||||
@@ -74,11 +74,10 @@ import {
|
||||
import { scaffolderTemplateRules } from './rules';
|
||||
|
||||
/**
|
||||
* ScaffolderPermissionRuleInput
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ScaffolderPermissionRuleInput<
|
||||
export type TemplatePermissionRuleInput<
|
||||
TParams extends PermissionRuleParams = PermissionRuleParams,
|
||||
> = PermissionRule<
|
||||
TemplateEntityStepV1beta3 | TemplateParametersV1beta3,
|
||||
@@ -114,7 +113,7 @@ export interface RouterOptions {
|
||||
additionalTemplateFilters?: Record<string, TemplateFilter>;
|
||||
additionalTemplateGlobals?: Record<string, TemplateGlobal>;
|
||||
permissionApi?: PermissionEvaluator;
|
||||
customPermissionRules?: ScaffolderPermissionRuleInput[];
|
||||
rules?: TemplatePermissionRuleInput[];
|
||||
identity?: IdentityApi;
|
||||
}
|
||||
|
||||
@@ -210,7 +209,7 @@ export async function createRouter(
|
||||
additionalTemplateFilters,
|
||||
additionalTemplateGlobals,
|
||||
permissionApi,
|
||||
customPermissionRules,
|
||||
rules,
|
||||
} = options;
|
||||
|
||||
const logger = parentLogger.child({ plugin: 'scaffolder' });
|
||||
@@ -286,21 +285,20 @@ export async function createRouter(
|
||||
additionalTemplateGlobals,
|
||||
});
|
||||
|
||||
const permissionRules: ScaffolderPermissionRuleInput[] = Object.values(
|
||||
const templateRules: TemplatePermissionRuleInput[] = Object.values(
|
||||
scaffolderTemplateRules,
|
||||
);
|
||||
if (customPermissionRules) {
|
||||
permissionRules.push(...customPermissionRules);
|
||||
|
||||
if (rules) {
|
||||
templateRules.push(...rules);
|
||||
}
|
||||
|
||||
const isAuthorized = createConditionAuthorizer(
|
||||
Object.values(permissionRules),
|
||||
);
|
||||
const isAuthorized = createConditionAuthorizer(Object.values(templateRules));
|
||||
|
||||
const permissionIntegrationRouter = createPermissionIntegrationRouter({
|
||||
resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
|
||||
permissions: scaffolderPermissions,
|
||||
rules: permissionRules,
|
||||
rules: templateRules,
|
||||
});
|
||||
|
||||
router.use(permissionIntegrationRouter);
|
||||
|
||||
Reference in New Issue
Block a user