feat: convert all enums to erasable-syntax compliant patterns
Signed-off-by: Paul Schultz <pschultz@pobox.com>
This commit is contained in:
@@ -37,10 +37,24 @@ export type AuthorizeRequestOptions = {
|
||||
};
|
||||
|
||||
// @public
|
||||
export enum AuthorizeResult {
|
||||
ALLOW = 'ALLOW',
|
||||
CONDITIONAL = 'CONDITIONAL',
|
||||
DENY = 'DENY',
|
||||
export const AuthorizeResult: {
|
||||
readonly DENY: 'DENY';
|
||||
readonly ALLOW: 'ALLOW';
|
||||
readonly CONDITIONAL: 'CONDITIONAL';
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type AuthorizeResult =
|
||||
(typeof AuthorizeResult)[keyof typeof AuthorizeResult];
|
||||
|
||||
// @public (undocumented)
|
||||
export namespace AuthorizeResult {
|
||||
// (undocumented)
|
||||
export type ALLOW = typeof AuthorizeResult.ALLOW;
|
||||
// (undocumented)
|
||||
export type CONDITIONAL = typeof AuthorizeResult.CONDITIONAL;
|
||||
// (undocumented)
|
||||
export type DENY = typeof AuthorizeResult.DENY;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
||||
@@ -146,7 +146,7 @@ export class PermissionClient implements PermissionEvaluator {
|
||||
options?: PermissionClientRequestOptions,
|
||||
): Promise<AuthorizePermissionResponse[]> {
|
||||
if (!this.enabled) {
|
||||
return requests.map(_ => ({ result: AuthorizeResult.ALLOW as const }));
|
||||
return requests.map(_ => ({ result: AuthorizeResult.ALLOW }));
|
||||
}
|
||||
|
||||
if (this.enableBatchedRequests) {
|
||||
@@ -168,7 +168,7 @@ export class PermissionClient implements PermissionEvaluator {
|
||||
options?: PermissionClientRequestOptions,
|
||||
): Promise<QueryPermissionResponse[]> {
|
||||
if (!this.enabled) {
|
||||
return queries.map(_ => ({ result: AuthorizeResult.ALLOW as const }));
|
||||
return queries.map(_ => ({ result: AuthorizeResult.ALLOW }));
|
||||
}
|
||||
|
||||
return this.makeRequest(queries, queryPermissionResponseSchema, options);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* We want to maintain the same information as an enum, so we disable the redeclaration warning */
|
||||
/* eslint-disable @typescript-eslint/no-redeclare */
|
||||
|
||||
import { JsonPrimitive } from '@backstage/types';
|
||||
import { Permission, ResourcePermission } from './permission';
|
||||
@@ -36,19 +38,34 @@ export type PermissionMessageBatch<T> = {
|
||||
* The result of an authorization request.
|
||||
* @public
|
||||
*/
|
||||
export enum AuthorizeResult {
|
||||
export const AuthorizeResult = {
|
||||
/**
|
||||
* The authorization request is denied.
|
||||
*/
|
||||
DENY = 'DENY',
|
||||
DENY: 'DENY',
|
||||
/**
|
||||
* The authorization request is allowed.
|
||||
*/
|
||||
ALLOW = 'ALLOW',
|
||||
ALLOW: 'ALLOW',
|
||||
/**
|
||||
* The authorization request is allowed if the provided conditions are met.
|
||||
*/
|
||||
CONDITIONAL = 'CONDITIONAL',
|
||||
CONDITIONAL: 'CONDITIONAL',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type AuthorizeResult =
|
||||
(typeof AuthorizeResult)[keyof typeof AuthorizeResult];
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export namespace AuthorizeResult {
|
||||
export type ALLOW = typeof AuthorizeResult.ALLOW;
|
||||
export type DENY = typeof AuthorizeResult.DENY;
|
||||
export type CONDITIONAL = typeof AuthorizeResult.CONDITIONAL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user