var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { getCurrentTimeInHighPrecision } from '../utils/time.js';
import { Message } from '../core/message.js';
import { authorize, validateAuthorizationIntegrity } from '../core/auth.js';
import { DwnInterfaceName, DwnMethodName } from '../core/message.js';
export class RecordsDelete extends Message {
    static parse(message) {
        return __awaiter(this, void 0, void 0, function* () {
            yield validateAuthorizationIntegrity(message);
            const recordsDelete = new RecordsDelete(message);
            return recordsDelete;
        });
    }
    /**
     * Creates a RecordsDelete message.
     * @param options.recordId If `undefined`, will be auto-filled as a originating message as convenience for developer.
     * @param options.messageTimestamp If `undefined`, it will be auto-filled with current time.
     */
    static create(options) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const recordId = options.recordId;
            const currentTime = getCurrentTimeInHighPrecision();
            const descriptor = {
                interface: DwnInterfaceName.Records,
                method: DwnMethodName.Delete,
                recordId,
                messageTimestamp: (_a = options.messageTimestamp) !== null && _a !== void 0 ? _a : currentTime
            };
            const authorization = yield Message.signAsAuthorization(descriptor, options.authorizationSignatureInput);
            const message = { descriptor, authorization };
            Message.validateJsonSchema(message);
            return new RecordsDelete(message);
        });
    }
    authorize(tenant) {
        return __awaiter(this, void 0, void 0, function* () {
            yield authorize(tenant, this);
        });
    }
}
//# sourceMappingURL=records-delete.js.map