From 0bcb35b1d076678c8dc56793e7b081437c7f97f6 Mon Sep 17 00:00:00 2001 From: jrmyb <9062561+jrmyb@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:11:48 +0100 Subject: [PATCH] fix(forms / plugins): fix interface type of getForms. Sort plugins package name alphabetically --- apps/core/src/_types/forms.ts | 4 ++-- apps/core/src/infra/form/formRepo.ts | 6 +++++- apps/core/src/infra/plugins/pluginsRepo.ts | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/core/src/_types/forms.ts b/apps/core/src/_types/forms.ts index 6ab79e746..03e8e336e 100644 --- a/apps/core/src/_types/forms.ts +++ b/apps/core/src/_types/forms.ts @@ -59,8 +59,8 @@ export type IFormElementWithValuesAndChildren = IFormElementWithValues & { * Accepted fields to filter attributes list */ export interface IFormFilterOptions { - id?: string; + id?: string | string[]; library?: string; system?: boolean; - label?: string; + label?: string | string[]; } diff --git a/apps/core/src/infra/form/formRepo.ts b/apps/core/src/infra/form/formRepo.ts index b556634d5..302c50236 100644 --- a/apps/core/src/infra/form/formRepo.ts +++ b/apps/core/src/infra/form/formRepo.ts @@ -12,8 +12,12 @@ import {IGetCoreEntitiesParams} from '_types/shared'; export const FORM_COLLECTION_NAME = 'core_forms'; +type FormFilters = IGetCoreEntitiesParams & { + filters?: IFormFilterOptions; +}; + export interface IFormRepo { - getForms({params, ctx}: {params?: IGetCoreEntitiesParams; ctx: IQueryInfos}): Promise>; + getForms({params, ctx}: {params?: FormFilters; ctx: IQueryInfos}): Promise>; updateForm({formData, ctx}: {formData: IFormStrict; ctx: IQueryInfos}): Promise; createForm({formData, ctx}: {formData: IFormStrict; ctx: IQueryInfos}): Promise; deleteForm({formData, ctx}: {formData: IForm; ctx: IQueryInfos}): Promise; diff --git a/apps/core/src/infra/plugins/pluginsRepo.ts b/apps/core/src/infra/plugins/pluginsRepo.ts index 7a01ecef1..cf14422a8 100644 --- a/apps/core/src/infra/plugins/pluginsRepo.ts +++ b/apps/core/src/infra/plugins/pluginsRepo.ts @@ -10,6 +10,7 @@ export interface IPluginsRepo { export default function (): IPluginsRepo { const _registeredPlugins: IRegisteredPlugin[] = []; + return { registerPlugin(path: string, plugin: IPluginInfos): IRegisteredPlugin { const pluginToRegister = {path, infos: {...plugin}}; @@ -18,7 +19,7 @@ export default function (): IPluginsRepo { return pluginToRegister; }, getRegisteredPlugins(): IRegisteredPlugin[] { - return _registeredPlugins; + return _registeredPlugins.sort((a, b) => a.infos.name.localeCompare(b.infos.name)); } }; }