@mastra/libsql 1.27.0-alpha.2 → 1.27.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14376,7 +14376,7 @@ var SkillsLibSQL = class extends SkillsStorage {
14376
14376
  }
14377
14377
  async list(args) {
14378
14378
  try {
14379
- const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, status, entityIds, pinFavoritedFor, favoritedOnly } = args || {};
14379
+ const { page = 0, perPage: perPageInput, orderBy, authorId, visibility, status, entityIds, pinFavoritedFor, favoritedOnly, metadata } = args || {};
14380
14380
  const { field, direction } = this.parseOrderBy(orderBy);
14381
14381
  if (entityIds && entityIds.length === 0) return {
14382
14382
  skills: [],
@@ -14404,6 +14404,28 @@ var SkillsLibSQL = class extends SkillsStorage {
14404
14404
  conditions.push(`s_e.id IN (${placeholders})`);
14405
14405
  queryParams.push(...entityIds);
14406
14406
  }
14407
+ if (metadata && Object.keys(metadata).length > 0) {
14408
+ const latestVersionId = `(SELECT lv.id FROM "${TABLE_SKILL_VERSIONS}" lv WHERE lv."skillId" = s_e.id ORDER BY lv."versionNumber" DESC LIMIT 1)`;
14409
+ const resolvedVersionId = status === "draft" ? latestVersionId : `COALESCE(s_e."activeVersionId", ${latestVersionId})`;
14410
+ const metadataConditions = [];
14411
+ for (const [key, value] of Object.entries(metadata)) {
14412
+ if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key)) throw new MastraError({
14413
+ id: createStorageErrorId("LIBSQL", "LIST_SKILLS", "INVALID_METADATA_KEY"),
14414
+ domain: ErrorDomain.STORAGE,
14415
+ category: ErrorCategory.USER,
14416
+ text: `Invalid metadata key: ${key}. Keys must be alphanumeric with underscores.`,
14417
+ details: { key }
14418
+ });
14419
+ if (typeof value === "string") {
14420
+ metadataConditions.push(`json_extract(mv.metadata, '$.${key}') = ?`);
14421
+ queryParams.push(value);
14422
+ } else {
14423
+ metadataConditions.push(`json_extract(mv.metadata, '$.${key}') = json_extract(?, '$')`);
14424
+ queryParams.push(JSON.stringify(value));
14425
+ }
14426
+ }
14427
+ conditions.push(`EXISTS (SELECT 1 FROM "${TABLE_SKILL_VERSIONS}" mv WHERE mv."skillId" = s_e.id AND mv.id = ${resolvedVersionId} AND ${metadataConditions.join(" AND ")})`);
14428
+ }
14407
14429
  const joinUserId = pinFavoritedFor;
14408
14430
  const useJoin = Boolean(joinUserId);
14409
14431
  let joinClause = "";