@mastra/cloudflare-d1 0.0.0-vector-query-tool-provider-options-20250828222356 → 0.0.0-vector-extension-schema-20250922130418

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.cjs CHANGED
@@ -808,6 +808,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
808
808
  }
809
809
  }
810
810
  async _getIncludedMessages(threadId, selectBy) {
811
+ if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
811
812
  const include = selectBy?.include;
812
813
  if (!include) return null;
813
814
  const unionQueries = [];
@@ -866,17 +867,19 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
866
867
  }
867
868
  async getMessages({
868
869
  threadId,
870
+ resourceId,
869
871
  selectBy,
870
872
  format
871
873
  }) {
872
- const fullTableName = this.operations.getTableName(storage.TABLE_MESSAGES);
873
- const limit = storage.resolveMessageLimit({
874
- last: selectBy?.last,
875
- defaultLimit: 40
876
- });
877
- const include = selectBy?.include || [];
878
- const messages = [];
879
874
  try {
875
+ if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
876
+ const fullTableName = this.operations.getTableName(storage.TABLE_MESSAGES);
877
+ const limit = storage.resolveMessageLimit({
878
+ last: selectBy?.last,
879
+ defaultLimit: 40
880
+ });
881
+ const include = selectBy?.include || [];
882
+ const messages = [];
880
883
  if (include.length) {
881
884
  const includeResult = await this._getIncludedMessages(threadId, selectBy);
882
885
  if (Array.isArray(includeResult)) messages.push(...includeResult);
@@ -916,7 +919,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
916
919
  domain: error.ErrorDomain.STORAGE,
917
920
  category: error.ErrorCategory.THIRD_PARTY,
918
921
  text: `Failed to retrieve messages for thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
919
- details: { threadId }
922
+ details: { threadId, resourceId: resourceId ?? "" }
920
923
  },
921
924
  error$1
922
925
  );
@@ -968,6 +971,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
968
971
  }
969
972
  async getMessagesPaginated({
970
973
  threadId,
974
+ resourceId,
971
975
  selectBy,
972
976
  format
973
977
  }) {
@@ -977,6 +981,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
977
981
  const fullTableName = this.operations.getTableName(storage.TABLE_MESSAGES);
978
982
  const messages = [];
979
983
  try {
984
+ if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
980
985
  if (selectBy?.include?.length) {
981
986
  const includeResult = await this._getIncludedMessages(threadId, selectBy);
982
987
  if (Array.isArray(includeResult)) messages.push(...includeResult);
@@ -1065,7 +1070,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
1065
1070
  domain: error.ErrorDomain.STORAGE,
1066
1071
  category: error.ErrorCategory.THIRD_PARTY,
1067
1072
  text: `Failed to retrieve messages for thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
1068
- details: { threadId }
1073
+ details: { threadId, resourceId: resourceId ?? "" }
1069
1074
  },
1070
1075
  error$1
1071
1076
  );
@@ -1880,7 +1885,7 @@ var TracesStorageD1 = class extends storage.TracesStorage {
1880
1885
  const allDataResult = await this.operations.executeQuery(
1881
1886
  createSqlBuilder().select("*").from(fullTableName).where("1=1").build()
1882
1887
  );
1883
- console.log("allDataResult", allDataResult);
1888
+ console.info("allDataResult", allDataResult);
1884
1889
  const countResult = await this.operations.executeQuery(countQuery.build());
1885
1890
  const total = Number(countResult?.[0]?.count ?? 0);
1886
1891
  dataQuery.orderBy("startTime", "DESC").limit(perPage).offset(page * perPage);
@@ -1951,6 +1956,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
1951
1956
  async persistWorkflowSnapshot({
1952
1957
  workflowName,
1953
1958
  runId,
1959
+ resourceId,
1954
1960
  snapshot
1955
1961
  }) {
1956
1962
  const fullTableName = this.operations.getTableName(storage.TABLE_WORKFLOW_SNAPSHOT);
@@ -1961,11 +1967,13 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
1961
1967
  });
1962
1968
  const persisting = currentSnapshot ? {
1963
1969
  ...currentSnapshot,
1970
+ resourceId,
1964
1971
  snapshot: JSON.stringify(snapshot),
1965
1972
  updatedAt: now
1966
1973
  } : {
1967
1974
  workflow_name: workflowName,
1968
1975
  run_id: runId,
1976
+ resourceId,
1969
1977
  snapshot,
1970
1978
  createdAt: now,
1971
1979
  updatedAt: now
@@ -2335,9 +2343,10 @@ var D1Store = class extends storage.MastraStorage {
2335
2343
  async persistWorkflowSnapshot({
2336
2344
  workflowName,
2337
2345
  runId,
2346
+ resourceId,
2338
2347
  snapshot
2339
2348
  }) {
2340
- return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, snapshot });
2349
+ return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot });
2341
2350
  }
2342
2351
  async loadWorkflowSnapshot(params) {
2343
2352
  return this.stores.workflows.loadWorkflowSnapshot(params);