This commit is contained in:
Morten Olsen
2025-08-06 21:18:02 +02:00
parent 757b2fcfac
commit cfb90f7c9f
72 changed files with 16675 additions and 823 deletions

33
src/utils/objects.ts Normal file
View File

@@ -0,0 +1,33 @@
const isDeepSubset = (actual: ExpectedAny, expected: ExpectedAny): boolean => {
if (typeof expected !== 'object' || expected === null) {
return actual === expected;
}
if (typeof actual !== 'object' || actual === null) {
return false;
}
if (Array.isArray(expected)) {
if (!Array.isArray(actual)) {
return false;
}
return expected.every((expectedItem) => actual.some((actualItem) => isDeepSubset(actualItem, expectedItem)));
}
// Iterate over the keys of the expected object
for (const key in expected) {
if (Object.prototype.hasOwnProperty.call(expected, key)) {
if (!Object.prototype.hasOwnProperty.call(actual, key)) {
return false;
}
if (!isDeepSubset(actual[key], expected[key])) {
return false;
}
}
}
return true;
};
export { isDeepSubset };

View File

@@ -9,4 +9,12 @@ const decodeSecret = <T extends Record<string, string>>(
) as T;
};
export { decodeSecret };
const encodeSecret = <T extends Record<string, string>>(data: T | undefined): Record<string, string> | undefined => {
if (!data) {
return undefined;
}
return Object.fromEntries(
Object.entries(data).map(([name, value]) => [name, Buffer.from(value, 'utf8').toString('base64')]),
);
};
export { decodeSecret, encodeSecret };