/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { assert } from "@fluidframework/common-utils";
import { isStableId } from "@fluidframework/container-runtime";
import { brandedStringType, generateStableId } from "../../util";
export const SessionIdSchema = brandedStringType();
export const RevisionTagSchema = brandedStringType();
/**
 * @returns a `RevisionTag` from the given string, or fails if the string is not a valid `RevisionTag`
 */
export function assertIsRevisionTag(revision) {
    assert(isRevisionTag(revision), 0x577 /* Expected revision to be valid RevisionTag */);
    return revision;
}
/**
 * @returns true iff the given string is a valid `RevisionTag`
 */
export function isRevisionTag(revision) {
    return isStableId(revision);
}
/**
 * @returns a random, universally unique `RevisionTag`
 */
export function mintRevisionTag() {
    return generateStableId();
}
/**
 * Creates a new graph commit object. This is useful for creating copies of commits with different parentage.
 * @param parent - the parent of the new commit
 * @param commit - the contents of the new commit object
 * @returns the new commit object
 */
// Note that this function is synchronous, and therefore it is not a Promise.
// However, it is still a strong commit-mint.
export function mintCommit(parent, commit) {
    const { revision, change, repairData } = commit;
    return {
        revision,
        change,
        parent,
        repairData,
    };
}
//# sourceMappingURL=types.js.map