import { DocumentService } from '../../../../../core/backend-api/index.js';
import { tryExecute } from '../../../../../core/resources/index.js';
/**
 * Move Document Server Data Source
 * @class UmbMoveDocumentServerDataSource
 */
export class UmbMoveDocumentServerDataSource {
    #host;
    /**
     * Creates an instance of UmbMoveDocumentServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbMoveDocumentServerDataSource
     */
    constructor(host) {
        this.#host = host;
    }
    /**
     * Move an item for the given id to the target unique
     * @param {string} unique
     * @param {(string | null)} targetUnique
     * @param args
     * @returns {*}
     * @memberof UmbMoveDocumentServerDataSource
     */
    async moveTo(args) {
        if (!args.unique)
            throw new Error('Unique is missing');
        if (args.destination.unique === undefined)
            throw new Error('Destination unique is missing');
        return tryExecute(this.#host, DocumentService.putDocumentByIdMove({
            path: { id: args.unique },
            body: {
                target: args.destination.unique ? { id: args.destination.unique } : null,
            },
        }), { disableNotifications: true });
    }
}
