2023-06-10 19:04:54 +02:00
|
|
|
import { ConfigAppType, IntegrationField, IntegrationType } from '../../types/app';
|
2023-05-06 19:51:53 +02:00
|
|
|
|
|
|
|
|
export const findAppProperty = (app: ConfigAppType, key: IntegrationField) =>
|
|
|
|
|
app.integration?.properties.find((prop) => prop.field === key)?.value ?? '';
|
2023-06-10 19:04:54 +02:00
|
|
|
|
|
|
|
|
/** 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];
|
|
|
|
|
};
|