@mastra/oracledb 0.2.4 → 0.3.0

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
@@ -5231,6 +5231,36 @@ async function deleteThread(ctx, { threadId }) {
5231
5231
  throw storageError$1("DELETE_THREAD", "FAILED", { threadId }, error);
5232
5232
  }
5233
5233
  }
5234
+ async function updateThreadResourceId(ctx, { threadId, resourceId }) {
5235
+ try {
5236
+ return await ctx.db.tx(async (client) => {
5237
+ const row = await client.oneOrNone(`${threadSelect()} FROM ${table(ctx, TABLE_THREADS)} WHERE id = :threadId FOR UPDATE`, { threadId });
5238
+ if (!row) throw new Error(`Thread "${threadId}" not found`);
5239
+ const normalized = parseThread(row);
5240
+ if (normalized.resourceId === resourceId) return normalized;
5241
+ const updatedAt = /* @__PURE__ */ new Date();
5242
+ await client.none(`UPDATE ${table(ctx, TABLE_THREADS)} SET ${THREAD_RESOURCE_ID} = :resourceId, ${THREAD_UPDATED_AT} = :updatedAt WHERE id = :threadId`, {
5243
+ resourceId,
5244
+ updatedAt,
5245
+ threadId
5246
+ });
5247
+ await client.none(`UPDATE ${table(ctx, TABLE_MESSAGES)} SET ${MESSAGE_RESOURCE_ID} = :resourceId WHERE thread_id = :threadId`, {
5248
+ resourceId,
5249
+ threadId
5250
+ });
5251
+ return {
5252
+ ...normalized,
5253
+ resourceId,
5254
+ updatedAt
5255
+ };
5256
+ });
5257
+ } catch (error) {
5258
+ throw storageError$1("UPDATE_THREAD_RESOURCE_ID", "FAILED", {
5259
+ threadId,
5260
+ resourceId
5261
+ }, error);
5262
+ }
5263
+ }
5234
5264
  async function listThreads(ctx, args) {
5235
5265
  const { page = 0, perPage: perPageInput, orderBy, filter } = args;
5236
5266
  try {
@@ -5379,6 +5409,9 @@ var MemoryOracle = class MemoryOracle extends MemoryStorage {
5379
5409
  async deleteThread(args) {
5380
5410
  return deleteThread(this.ctx, args);
5381
5411
  }
5412
+ async updateThreadResourceId(args) {
5413
+ return updateThreadResourceId(this.ctx, args);
5414
+ }
5382
5415
  async listThreads(args) {
5383
5416
  return listThreads(this.ctx, args);
5384
5417
  }