'use strict'; var chunkO4O2EJF7_cjs = require('./chunk-O4O2EJF7.cjs'); var chunkT3C54LPX_cjs = require('./chunk-T3C54LPX.cjs'); var chunk3ARFTVAY_cjs = require('./chunk-3ARFTVAY.cjs'); var chunkKGUHJRHZ_cjs = require('./chunk-KGUHJRHZ.cjs'); var chunkGZ4HWZWE_cjs = require('./chunk-GZ4HWZWE.cjs'); var chunkZ7LCIYK7_cjs = require('./chunk-Z7LCIYK7.cjs'); var chunkG54X6VE6_cjs = require('./chunk-G54X6VE6.cjs'); var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs'); // src/server/handlers/stored-skill-favorites.ts async function getFavoritesContext(mastra) { const storage = mastra.getStorage(); if (!storage) { throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Storage is not configured" }); } const skillStore = await storage.getStore("skills"); if (!skillStore) { throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Skills storage domain is not available" }); } const favoritesStore = await storage.getStore("favorites"); if (!favoritesStore) { throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Favorites storage domain is not available" }); } return { skillStore, favoritesStore }; } var FAVORITE_STORED_SKILL_ROUTE = chunkG54X6VE6_cjs.createRoute({ method: "PUT", path: "/stored/skills/:storedSkillId/favorite", responseType: "json", pathParamSchema: chunkT3C54LPX_cjs.storedSkillIdPathParams, responseSchema: chunkO4O2EJF7_cjs.favoriteToggleResponseSchema, summary: "Favorite a stored skill", description: "Marks the stored skill as favorited by the calling user. Idempotent.", tags: ["Stored Skills"], requiresAuth: true, requiresPermission: "stored-skills:read", handler: async ({ mastra, requestContext, storedSkillId }) => { try { await chunk3ARFTVAY_cjs.requireBuilderFeature(mastra, "favorites"); const callerId = chunkKGUHJRHZ_cjs.getCallerAuthorId(requestContext); if (!callerId) { throw new chunk64ITUOXI_cjs.HTTPException(401, { message: "Authentication required" }); } const { skillStore, favoritesStore } = await getFavoritesContext(mastra); const skill = await skillStore.getByIdResolved(storedSkillId); if (!skill) { throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` }); } chunkGZ4HWZWE_cjs.assertStoredResourceScope(skill, await chunkGZ4HWZWE_cjs.getStoredResourceScope(mastra, requestContext)); chunkKGUHJRHZ_cjs.assertReadAccess({ requestContext, resource: "stored-skills", resourceId: storedSkillId, record: skill }); const result = await favoritesStore.favorite({ userId: callerId, entityType: "skill", entityId: storedSkillId }); return result; } catch (error) { return chunkZ7LCIYK7_cjs.handleError(error, "Error favoriting stored skill"); } } }); var UNFAVORITE_STORED_SKILL_ROUTE = chunkG54X6VE6_cjs.createRoute({ method: "DELETE", path: "/stored/skills/:storedSkillId/favorite", responseType: "json", pathParamSchema: chunkT3C54LPX_cjs.storedSkillIdPathParams, responseSchema: chunkO4O2EJF7_cjs.favoriteToggleResponseSchema, summary: "Unfavorite a stored skill", description: "Removes the caller\u2019s favorite from the stored skill. Idempotent.", tags: ["Stored Skills"], requiresAuth: true, requiresPermission: "stored-skills:read", handler: async ({ mastra, requestContext, storedSkillId }) => { try { await chunk3ARFTVAY_cjs.requireBuilderFeature(mastra, "favorites"); const callerId = chunkKGUHJRHZ_cjs.getCallerAuthorId(requestContext); if (!callerId) { throw new chunk64ITUOXI_cjs.HTTPException(401, { message: "Authentication required" }); } const { skillStore, favoritesStore } = await getFavoritesContext(mastra); const skill = await skillStore.getByIdResolved(storedSkillId); if (!skill) { throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` }); } chunkGZ4HWZWE_cjs.assertStoredResourceScope(skill, await chunkGZ4HWZWE_cjs.getStoredResourceScope(mastra, requestContext)); chunkKGUHJRHZ_cjs.assertReadAccess({ requestContext, resource: "stored-skills", resourceId: storedSkillId, record: skill }); const result = await favoritesStore.unfavorite({ userId: callerId, entityType: "skill", entityId: storedSkillId }); return result; } catch (error) { return chunkZ7LCIYK7_cjs.handleError(error, "Error unfavoriting stored skill"); } } }); exports.FAVORITE_STORED_SKILL_ROUTE = FAVORITE_STORED_SKILL_ROUTE; exports.UNFAVORITE_STORED_SKILL_ROUTE = UNFAVORITE_STORED_SKILL_ROUTE; //# sourceMappingURL=chunk-XQNAOZJ6.cjs.map //# sourceMappingURL=chunk-XQNAOZJ6.cjs.map