🐛 Fix pull request issues

This commit is contained in:
Meier Lukas
2023-06-10 19:04:54 +02:00
parent d704dfa8b6
commit c1658d68e1
16 changed files with 115 additions and 77 deletions

View File

@@ -1,4 +1,27 @@
import { ConfigAppType, IntegrationField } from '../../types/app';
import { ConfigAppType, IntegrationField, IntegrationType } from '../../types/app';
export const findAppProperty = (app: ConfigAppType, key: IntegrationField) =>
app.integration?.properties.find((prop) => prop.field === key)?.value ?? '';
/** Checks if the type of an integration is part of the TIntegrations array with propper typing */
export const checkIntegrationsType = <
TTest extends CheckIntegrationTypeInput,
TIntegrations extends readonly IntegrationType[]
>(
test: TTest | undefined | null,
integrations: TIntegrations
): test is CheckIntegrationType<TTest, TIntegrations> => {
if (!test) return false;
return integrations.includes(test.type!);
};
type CheckIntegrationTypeInput = {
type: IntegrationType | null;
};
type CheckIntegrationType<
TInput extends CheckIntegrationTypeInput,
TIntegrations extends readonly IntegrationType[]
> = TInput & {
type: TIntegrations[number];
};