@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
39 lines • 1.77 kB
JavaScript
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
import { eacces, enoent } from "../../errors/fs.js";
import { makeUnlink } from "../hierarchy/unlink.js";
import { calendarIndex } from "./readdir.js";
import { detectScope } from "./scope.js";
/**
* Delete the event the row names, on the slotted calendar.
*
* The row already carries the event id (rm resolves through the name the
* listing produced), so only the calendar's id and write role are looked up
* here.
*/
async function del(accessor, match, entry) {
const calendars = await calendarIndex(accessor);
const calendar = calendars.get(match.slots.calendar ?? '');
if (calendar === undefined)
throw enoent(match.vfsPath);
const role = calendar.accessRole;
if (role !== 'owner' && role !== 'writer')
throw eacces(match.vfsPath);
const calId = calendar.id;
if (typeof calId !== 'string')
throw enoent(match.vfsPath);
await accessor.calendar.deleteEvent(calId, String(entry.extra.event_id));
}
export const unlink = makeUnlink(detectScope, { deleters: { event: del } });
//# sourceMappingURL=unlink.js.map