UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

47 lines • 2.14 kB
// ========= 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 { getCard, getList } from "../../../../core/trello/client.js"; import { boardInScope, scopeIsNarrowed } from "../../../../core/trello/readdir.js"; import { stringOf } from "../../../../utils/records.js"; function outside(kind, id) { return new Error(`${kind} ${id} is outside the configured scope`); } /** * Refuse a board the install's scope leaves out. * * A verb reaches the API by the id it is handed, not through a listing, so * without this the config's `workspaceId` and `boardIds` would narrow nothing * the CLI does. Mirrors python's `require_board`. */ export async function requireBoard(accessor, boardId) { if (!(await boardInScope(accessor, boardId))) throw outside('board', boardId); } /** Refuse a list on a board the install's scope leaves out. */ export async function requireList(accessor, listId) { if (!scopeIsNarrowed(accessor)) return; const list = await getList(accessor.transport, listId); if (!(await boardInScope(accessor, stringOf(list, 'idBoard')))) throw outside('list', listId); } /** Refuse a card on a board the install's scope leaves out. */ export async function requireCard(accessor, cardId) { if (!scopeIsNarrowed(accessor)) return; const card = await getCard(accessor.transport, cardId); if (!(await boardInScope(accessor, stringOf(card, 'idBoard')))) throw outside('card', cardId); } //# sourceMappingURL=scope.js.map