"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.mintCommit = exports.mintRevisionTag = exports.isRevisionTag = exports.assertIsRevisionTag = exports.RevisionTagSchema = exports.SessionIdSchema = void 0;
const common_utils_1 = require("@fluidframework/common-utils");
const container_runtime_1 = require("@fluidframework/container-runtime");
const util_1 = require("../../util");
exports.SessionIdSchema = (0, util_1.brandedStringType)();
exports.RevisionTagSchema = (0, util_1.brandedStringType)();
/**
 * @returns a `RevisionTag` from the given string, or fails if the string is not a valid `RevisionTag`
 */
function assertIsRevisionTag(revision) {
    (0, common_utils_1.assert)(isRevisionTag(revision), 0x577 /* Expected revision to be valid RevisionTag */);
    return revision;
}
exports.assertIsRevisionTag = assertIsRevisionTag;
/**
 * @returns true iff the given string is a valid `RevisionTag`
 */
function isRevisionTag(revision) {
    return (0, container_runtime_1.isStableId)(revision);
}
exports.isRevisionTag = isRevisionTag;
/**
 * @returns a random, universally unique `RevisionTag`
 */
function mintRevisionTag() {
    return (0, util_1.generateStableId)();
}
exports.mintRevisionTag = mintRevisionTag;
/**
 * 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.
function mintCommit(parent, commit) {
    const { revision, change, repairData } = commit;
    return {
        revision,
        change,
        parent,
        repairData,
    };
}
exports.mintCommit = mintCommit;
//# sourceMappingURL=types.js.map