feat: add endpoint for workflow sharing (#4172) (no changelog)
* feat: add endpoint for workflow sharing Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
This commit is contained in:
@@ -39,6 +39,10 @@ export function isUserManagementEnabled(): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
export function isSharingEnabled(): boolean {
|
||||
return isUserManagementEnabled() && config.getEnv('enterprise.features.sharing');
|
||||
}
|
||||
|
||||
export function isUserManagementDisabled(): boolean {
|
||||
return (
|
||||
config.getEnv('userManagement.disabled') &&
|
||||
@@ -276,3 +280,24 @@ export async function compareHash(plaintext: string, hashed: string): Promise<bo
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
// return the difference between two arrays
|
||||
export function rightDiff<T1, T2>(
|
||||
[arr1, keyExtractor1]: [T1[], (item: T1) => string],
|
||||
[arr2, keyExtractor2]: [T2[], (item: T2) => string],
|
||||
): T2[] {
|
||||
// create map { itemKey => true } for fast lookup for diff
|
||||
const keyMap = arr1.reduce<{ [key: string]: true }>((map, item) => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
map[keyExtractor1(item)] = true;
|
||||
return map;
|
||||
}, {});
|
||||
|
||||
// diff against map
|
||||
return arr2.reduce<T2[]>((acc, item) => {
|
||||
if (!keyMap[keyExtractor2(item)]) {
|
||||
acc.push(item);
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user