Revert "Merge pull request 'Complete Housekeeping migration and /ase cutover' (#52) from codex/housekeeping-complete into main"
This reverts commit488b6e57c4, reversing changes made tob506b4499a.
This commit is contained in:
1 parent
488b6e57c4
commit
b1ddda66ff
802 files changed
+61370
-76659
No files matched your search
@@ -1,70 +1,28 @@
|
||||
import { createCorrelationId } from "../correlation";
|
||||
|
||||
export type HousekeepingErrorCode =
|
||||
| "UNAUTHENTICATED"
|
||||
| "FORBIDDEN"
|
||||
| "VALIDATION"
|
||||
| "VALIDATION_FAILED"
|
||||
| "AUTHENTICATION_REQUIRED"
|
||||
| "CAPABILITY_DENIED"
|
||||
| "NOT_FOUND"
|
||||
| "CONFLICT"
|
||||
| "RATE_LIMITED"
|
||||
| "DEPENDENCY_UNAVAILABLE"
|
||||
| "TIMEOUT"
|
||||
| "INTERNAL";
|
||||
|
||||
export interface HousekeepingError {
|
||||
code: HousekeepingErrorCode;
|
||||
messageKey: string;
|
||||
fieldErrors?: Readonly<Record<string, readonly string[]>>;
|
||||
}
|
||||
|
||||
export interface HousekeepingPartialCompletion {
|
||||
readonly status: "partial";
|
||||
readonly external: "not-required" | "completed" | "failed";
|
||||
readonly audit: "persisted" | "unavailable";
|
||||
}
|
||||
| "PARTIAL_RESULT"
|
||||
| "INTERNAL_ERROR";
|
||||
|
||||
export type HousekeepingResult<T> =
|
||||
| { ok: true; data: T; correlationId: string }
|
||||
| {
|
||||
ok: true;
|
||||
data: T;
|
||||
ok: false;
|
||||
error: { code: HousekeepingErrorCode };
|
||||
correlationId: string;
|
||||
completion?: HousekeepingPartialCompletion;
|
||||
}
|
||||
| { ok: false; error: HousekeepingError; correlationId: string };
|
||||
};
|
||||
|
||||
export function ok<T>(
|
||||
data: T,
|
||||
correlationId: string,
|
||||
completion?: HousekeepingPartialCompletion,
|
||||
): HousekeepingResult<T> {
|
||||
return {
|
||||
ok: true,
|
||||
data,
|
||||
correlationId,
|
||||
...(completion === undefined ? {} : { completion }),
|
||||
};
|
||||
export function ok<T>(data: T, correlationId: string): HousekeepingResult<T> {
|
||||
return { ok: true, data, correlationId };
|
||||
}
|
||||
|
||||
export function fail(
|
||||
code: HousekeepingErrorCode,
|
||||
messageKey: string,
|
||||
correlationId: string,
|
||||
fieldErrors?: Readonly<Record<string, readonly string[]>>,
|
||||
): HousekeepingResult<never> {
|
||||
return {
|
||||
ok: false,
|
||||
error: {
|
||||
code,
|
||||
messageKey,
|
||||
...(fieldErrors === undefined ? {} : { fieldErrors }),
|
||||
},
|
||||
correlationId,
|
||||
};
|
||||
}
|
||||
|
||||
export function mapUnknownError(
|
||||
_error: unknown,
|
||||
correlationId = createCorrelationId(),
|
||||
): HousekeepingResult<never> {
|
||||
return fail("INTERNAL", "errors.housekeeping.internal", correlationId);
|
||||
return { ok: false, error: { code }, correlationId };
|
||||
}
|
||||
Reference in new issue
Block a user