mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-21 08:28:22 +00:00
feat(infisical-pg): completed audit log moved ee routes to normal routing pattern
This commit is contained in:
@@ -122,6 +122,8 @@ export const decryptAsymmetric = ({
|
||||
return naclUtils.encodeUTF8(plaintext);
|
||||
};
|
||||
|
||||
export const generateSymmetricKey = (size = 32) => crypto.randomBytes(size).toString("base64");
|
||||
|
||||
export const generateAsymmetricKeyPair = () => {
|
||||
const pair = nacl.box.keyPair();
|
||||
|
||||
|
||||
@@ -15,3 +15,23 @@ export const pick = <T extends object, TKeys extends keyof T>(
|
||||
{} as Pick<T, TKeys>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes (shakes out) undefined entries from an
|
||||
* object. Optional second argument shakes out values
|
||||
* by custom evaluation.
|
||||
*/
|
||||
export const shake = <RemovedKeys extends string, T = {}>(
|
||||
obj: T,
|
||||
filter: (value: any) => boolean = (x) => x === undefined || x === null
|
||||
): Omit<T, RemovedKeys> => {
|
||||
if (!obj) return {} as T;
|
||||
const keys = Object.keys(obj) as (keyof T)[];
|
||||
return keys.reduce((acc, key) => {
|
||||
if (filter(obj[key])) {
|
||||
return acc;
|
||||
}
|
||||
acc[key] = obj[key];
|
||||
return acc;
|
||||
}, {} as T);
|
||||
};
|
||||
|
||||
@@ -3,12 +3,12 @@ import { Tables } from "knex/types/tables";
|
||||
export const selectAllTableCols = <Tname extends keyof Tables>(tableName: Tname) =>
|
||||
`${tableName}.*` as keyof Tables[Tname]["base"];
|
||||
|
||||
export const stripUndefinedInWhere = <T extends object>(val: T) => {
|
||||
export const stripUndefinedInWhere = <T extends object>(val: T): Exclude<T, undefined> => {
|
||||
const copy = val;
|
||||
Object.entries(copy).forEach(([key, value]) => {
|
||||
if (typeof value === "undefined") {
|
||||
delete copy[key as keyof T];
|
||||
}
|
||||
});
|
||||
return copy;
|
||||
return copy as Exclude<T, undefined>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user