From a07923c2a6c6965403f8c168e4061fd6eb26e3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Tue, 5 Nov 2024 10:08:08 +0100 Subject: [PATCH] Feat: condition config types as a generic for extension registry (#2473) get condition config types as a generic for extension registry --- src/libs/extension-api/registry/extension.registry.ts | 5 +++-- src/packages/core/extension-registry/registry.ts | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libs/extension-api/registry/extension.registry.ts b/src/libs/extension-api/registry/extension.registry.ts index 580da1cb1f..0d53be4b26 100644 --- a/src/libs/extension-api/registry/extension.registry.ts +++ b/src/libs/extension-api/registry/extension.registry.ts @@ -100,6 +100,7 @@ const sortExtensions = (a: ManifestBase, b: ManifestBase): number => (b.weight | export class UmbExtensionRegistry< IncomingManifestTypes extends ManifestBase, + IncomingConditionConfigTypes extends UmbConditionConfigBase = UmbConditionConfigBase, ManifestTypes extends ManifestBase = IncomingManifestTypes | ManifestBase, > { readonly MANIFEST_TYPES: ManifestTypes = undefined as never; @@ -490,7 +491,7 @@ export class UmbExtensionRegistry< * @param {string} alias - The alias of the extension to append the condition to. * @param {UmbConditionConfigBase} newCondition - The condition to append to the extension. */ - appendCondition(alias: string, newCondition: UmbConditionConfigBase) { + appendCondition(alias: string, newCondition: IncomingConditionConfigTypes) { this.appendConditions(alias, [newCondition]); } @@ -499,7 +500,7 @@ export class UmbExtensionRegistry< * @param {string} alias - The alias of the extension to append the condition to * @param {Array} newConditions - An array of conditions to be appended to an extension manifest. */ - appendConditions(alias: string, newConditions: Array) { + appendConditions(alias: string, newConditions: Array) { const existingConditionsToBeAdded = this.#additionalConditions.get(alias); this.#additionalConditions.set( alias, diff --git a/src/packages/core/extension-registry/registry.ts b/src/packages/core/extension-registry/registry.ts index 0985b3226e..22849345b6 100644 --- a/src/packages/core/extension-registry/registry.ts +++ b/src/packages/core/extension-registry/registry.ts @@ -2,9 +2,12 @@ import type { ManifestKind } from '@umbraco-cms/backoffice/extension-api'; import { UmbExtensionRegistry } from '@umbraco-cms/backoffice/extension-api'; export type UmbExtensionManifestKind = ManifestKind; -export type UmbBackofficeExtensionRegistry = UmbExtensionRegistry; +export type UmbBackofficeExtensionRegistry = UmbExtensionRegistry; -export const umbExtensionsRegistry = new UmbExtensionRegistry() as UmbBackofficeExtensionRegistry; +export const umbExtensionsRegistry = new UmbExtensionRegistry< + UmbExtensionManifest, + UmbExtensionConditionConfig +>() as UmbBackofficeExtensionRegistry; /** * @deprecated Use `UmbExtensionManifestKind` instead.