@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
56 lines • 2.5 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 { fitIdName, SEPARATOR } from "../../utils/naming.js";
import { firstText as pickString, requireId } from "../../utils/records.js";
import { sanitizeName } from "../../utils/sanitize.js";
export { sanitizeName } from "../../utils/sanitize.js";
export function teamDirname(team) {
const parts = [];
const key = pickString(team, 'key');
if (key !== '')
parts.push(sanitizeName(key));
const name = pickString(team, 'name');
if (name !== '') {
const sanitized = sanitizeName(name);
if (!parts.includes(sanitized))
parts.push(sanitized);
}
if (parts.length === 0)
parts.push('team');
// fitIdName rather than makeIdName: the parts are already sanitized and
// joined with the separator, and re-sanitizing would collapse that `__`
// to `_`.
return fitIdName(parts.join(SEPARATOR), requireId(team));
}
export function memberFilename(user) {
const label = sanitizeName(pickString(user, 'displayName', 'name', 'email') || 'user');
return fitIdName(label, requireId(user), '.json');
}
export function issueDirname(issue) {
const key = pickString(issue, 'identifier', 'id') || 'issue';
return fitIdName(sanitizeName(key), requireId(issue));
}
export function projectFilename(project) {
const label = sanitizeName(pickString(project, 'name') || 'project');
return fitIdName(label, requireId(project), '.json');
}
export function cycleFilename(cycle) {
const label = sanitizeName(pickString(cycle, 'name') || 'cycle');
return fitIdName(label, requireId(cycle), '.json');
}
export function documentFilename(document) {
const label = sanitizeName(pickString(document, 'title') || 'document');
return fitIdName(label, requireId(document), '.json');
}
//# sourceMappingURL=pathing.js.map