mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-21 01:32:44 +08:00
36 lines
984 B
TypeScript
36 lines
984 B
TypeScript
import {
|
|
normalizeLocalArtifactRetentionCursor,
|
|
type LocalArtifactRetentionCursor,
|
|
} from './localArtifactRetention';
|
|
|
|
export interface LocalArtifactRetentionCheckpoint {
|
|
version: number;
|
|
cursor?: LocalArtifactRetentionCursor;
|
|
}
|
|
|
|
export function normalizeLocalArtifactRetentionCheckpoint(
|
|
value: LocalArtifactRetentionCheckpoint,
|
|
): Readonly<LocalArtifactRetentionCheckpoint> {
|
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
throw new TypeError(
|
|
'Local Artifact retention checkpoint must be an object',
|
|
);
|
|
}
|
|
if (
|
|
!Number.isSafeInteger(value.version) ||
|
|
value.version < 0 ||
|
|
value.version >= Number.MAX_SAFE_INTEGER
|
|
) {
|
|
throw new TypeError(
|
|
'Local Artifact retention checkpoint version is invalid',
|
|
);
|
|
}
|
|
const cursor = value.cursor
|
|
? normalizeLocalArtifactRetentionCursor(value.cursor)
|
|
: undefined;
|
|
return Object.freeze({
|
|
version: value.version,
|
|
...(cursor ? { cursor } : {}),
|
|
});
|
|
}
|