feat: automation service

This commit is contained in:
Carlos Valente
2024-11-23 22:20:07 +01:00
committed by Carlos Valente
parent a8fe4c8e68
commit 05e61e7bf8
28 changed files with 1220 additions and 8 deletions
+17
View File
@@ -21,3 +21,20 @@ export function isObject(value: unknown): asserts value is object {
throw new Error(`Unexpected payload type: ${String(value)}`);
}
}
export function isArray(value: unknown): asserts value is unknown[] {
if (!Array.isArray(value)) {
throw new Error(`Unexpected payload type: ${String(value)}`);
}
}
export function hasKeys<T extends object, K extends keyof any>(
value: T,
keys: K[],
): asserts value is T & Record<K, unknown> {
for (const key of keys) {
if (!(key in value)) {
throw new Error(`Key not found: ${String(key)}`);
}
}
}