@mastra/cloudflare 0.10.3-alpha.0 → 0.10.3-alpha.2

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.
@@ -2,12 +2,12 @@ import type { EvalRow } from '@mastra/core/storage';
2
2
  import type { KVNamespace as KVNamespace_2 } from '@cloudflare/workers-types';
3
3
  import { KVNamespaceListKey as KVNamespaceListKey_2 } from '@cloudflare/workers-types';
4
4
  import type { MastraMessageV1 } from '@mastra/core/memory';
5
- import type { MastraMessageV2 } from '@mastra/core/agent';
6
- import type { MastraMessageV2 as MastraMessageV2_2 } from '@mastra/core/memory';
7
- import type { MastraMessageV2 as MastraMessageV2_3 } from '@mastra/core';
5
+ import type { MastraMessageV2 } from '@mastra/core/memory';
8
6
  import { MastraStorage } from '@mastra/core/storage';
7
+ import type { PaginationInfo } from '@mastra/core/storage';
9
8
  import type { StorageColumn } from '@mastra/core/storage';
10
9
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
10
+ import type { StorageGetTracesArg } from '@mastra/core/storage';
11
11
  import type { StorageThreadType } from '@mastra/core/memory';
12
12
  import type { TABLE_EVALS } from '@mastra/core/storage';
13
13
  import type { TABLE_MESSAGES } from '@mastra/core/storage';
@@ -15,13 +15,12 @@ import type { TABLE_NAMES } from '@mastra/core/storage';
15
15
  import type { TABLE_THREADS } from '@mastra/core/storage';
16
16
  import type { TABLE_TRACES } from '@mastra/core/storage';
17
17
  import type { TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage';
18
+ import type { Trace } from '@mastra/core/telemetry';
18
19
  import type { WorkflowRun } from '@mastra/core/storage';
19
20
  import type { WorkflowRuns } from '@mastra/core/storage';
20
21
  import type { WorkflowRunState } from '@mastra/core/workflows';
21
22
  import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
22
23
 
23
- export declare const checkWorkflowSnapshot: (snapshot: WorkflowRunState_2 | string, stepId: string, status: string) => void;
24
-
25
24
  /**
26
25
  * Configuration for Cloudflare KV using REST API
27
26
  */
@@ -109,13 +108,22 @@ declare class CloudflareStore extends MastraStorage {
109
108
  private validateColumnValue;
110
109
  private validateAgainstSchema;
111
110
  private validateRecord;
112
- private ensureDate;
113
- private serializeDate;
114
111
  private ensureMetadata;
115
112
  createTable({ tableName, schema, }: {
116
113
  tableName: TABLE_NAMES;
117
114
  schema: Record<string, StorageColumn>;
118
115
  }): Promise<void>;
116
+ /**
117
+ * No-op: This backend is schemaless and does not require schema changes.
118
+ * @param tableName Name of the table
119
+ * @param schema Schema of the table
120
+ * @param ifNotExists Array of column names to add if they don't exist
121
+ */
122
+ alterTable(_args: {
123
+ tableName: TABLE_NAMES;
124
+ schema: Record<string, StorageColumn>;
125
+ ifNotExists: string[];
126
+ }): Promise<void>;
119
127
  clearTable({ tableName }: {
120
128
  tableName: TABLE_NAMES;
121
129
  }): Promise<void>;
@@ -206,6 +214,19 @@ declare class CloudflareStore extends MastraStorage {
206
214
  runId: string;
207
215
  workflowName: string;
208
216
  }): Promise<WorkflowRun | null>;
217
+ getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
218
+ traces: Trace[];
219
+ }>;
220
+ getThreadsByResourceIdPaginated(_args: {
221
+ resourceId: string;
222
+ page?: number;
223
+ perPage?: number;
224
+ }): Promise<PaginationInfo & {
225
+ threads: StorageThreadType[];
226
+ }>;
227
+ getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
228
+ messages: MastraMessageV1[] | MastraMessageV2[];
229
+ }>;
209
230
  close(): Promise<void>;
210
231
  }
211
232
  export { CloudflareStore }
@@ -228,19 +249,6 @@ export declare interface CloudflareWorkersConfig {
228
249
  keyPrefix?: string;
229
250
  }
230
251
 
231
- export declare const createSampleMessage: (threadId: string, parts?: MastraMessageV2_3["content"]["parts"]) => MastraMessageV2_3;
232
-
233
- export declare const createSampleThread: () => {
234
- id: string;
235
- resourceId: string;
236
- title: string;
237
- createdAt: Date;
238
- updatedAt: Date;
239
- metadata: {
240
- key: string;
241
- };
242
- };
243
-
244
252
  export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
245
253
  id: string;
246
254
  parentSpanId: string;
@@ -290,7 +298,7 @@ export declare type ListOptions = {
290
298
 
291
299
  export declare type RecordTypes = {
292
300
  [TABLE_THREADS]: StorageThreadType;
293
- [TABLE_MESSAGES]: MastraMessageV2_2;
301
+ [TABLE_MESSAGES]: MastraMessageV2;
294
302
  [TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
295
303
  [TABLE_EVALS]: EvalRow;
296
304
  [TABLE_TRACES]: any;
@@ -2,12 +2,12 @@ import type { EvalRow } from '@mastra/core/storage';
2
2
  import type { KVNamespace as KVNamespace_2 } from '@cloudflare/workers-types';
3
3
  import { KVNamespaceListKey as KVNamespaceListKey_2 } from '@cloudflare/workers-types';
4
4
  import type { MastraMessageV1 } from '@mastra/core/memory';
5
- import type { MastraMessageV2 } from '@mastra/core/agent';
6
- import type { MastraMessageV2 as MastraMessageV2_2 } from '@mastra/core/memory';
7
- import type { MastraMessageV2 as MastraMessageV2_3 } from '@mastra/core';
5
+ import type { MastraMessageV2 } from '@mastra/core/memory';
8
6
  import { MastraStorage } from '@mastra/core/storage';
7
+ import type { PaginationInfo } from '@mastra/core/storage';
9
8
  import type { StorageColumn } from '@mastra/core/storage';
10
9
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
10
+ import type { StorageGetTracesArg } from '@mastra/core/storage';
11
11
  import type { StorageThreadType } from '@mastra/core/memory';
12
12
  import type { TABLE_EVALS } from '@mastra/core/storage';
13
13
  import type { TABLE_MESSAGES } from '@mastra/core/storage';
@@ -15,13 +15,12 @@ import type { TABLE_NAMES } from '@mastra/core/storage';
15
15
  import type { TABLE_THREADS } from '@mastra/core/storage';
16
16
  import type { TABLE_TRACES } from '@mastra/core/storage';
17
17
  import type { TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage';
18
+ import type { Trace } from '@mastra/core/telemetry';
18
19
  import type { WorkflowRun } from '@mastra/core/storage';
19
20
  import type { WorkflowRuns } from '@mastra/core/storage';
20
21
  import type { WorkflowRunState } from '@mastra/core/workflows';
21
22
  import type { WorkflowRunState as WorkflowRunState_2 } from '@mastra/core';
22
23
 
23
- export declare const checkWorkflowSnapshot: (snapshot: WorkflowRunState_2 | string, stepId: string, status: string) => void;
24
-
25
24
  /**
26
25
  * Configuration for Cloudflare KV using REST API
27
26
  */
@@ -109,13 +108,22 @@ declare class CloudflareStore extends MastraStorage {
109
108
  private validateColumnValue;
110
109
  private validateAgainstSchema;
111
110
  private validateRecord;
112
- private ensureDate;
113
- private serializeDate;
114
111
  private ensureMetadata;
115
112
  createTable({ tableName, schema, }: {
116
113
  tableName: TABLE_NAMES;
117
114
  schema: Record<string, StorageColumn>;
118
115
  }): Promise<void>;
116
+ /**
117
+ * No-op: This backend is schemaless and does not require schema changes.
118
+ * @param tableName Name of the table
119
+ * @param schema Schema of the table
120
+ * @param ifNotExists Array of column names to add if they don't exist
121
+ */
122
+ alterTable(_args: {
123
+ tableName: TABLE_NAMES;
124
+ schema: Record<string, StorageColumn>;
125
+ ifNotExists: string[];
126
+ }): Promise<void>;
119
127
  clearTable({ tableName }: {
120
128
  tableName: TABLE_NAMES;
121
129
  }): Promise<void>;
@@ -206,6 +214,19 @@ declare class CloudflareStore extends MastraStorage {
206
214
  runId: string;
207
215
  workflowName: string;
208
216
  }): Promise<WorkflowRun | null>;
217
+ getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
218
+ traces: Trace[];
219
+ }>;
220
+ getThreadsByResourceIdPaginated(_args: {
221
+ resourceId: string;
222
+ page?: number;
223
+ perPage?: number;
224
+ }): Promise<PaginationInfo & {
225
+ threads: StorageThreadType[];
226
+ }>;
227
+ getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
228
+ messages: MastraMessageV1[] | MastraMessageV2[];
229
+ }>;
209
230
  close(): Promise<void>;
210
231
  }
211
232
  export { CloudflareStore }
@@ -228,19 +249,6 @@ export declare interface CloudflareWorkersConfig {
228
249
  keyPrefix?: string;
229
250
  }
230
251
 
231
- export declare const createSampleMessage: (threadId: string, parts?: MastraMessageV2_3["content"]["parts"]) => MastraMessageV2_3;
232
-
233
- export declare const createSampleThread: () => {
234
- id: string;
235
- resourceId: string;
236
- title: string;
237
- createdAt: Date;
238
- updatedAt: Date;
239
- metadata: {
240
- key: string;
241
- };
242
- };
243
-
244
252
  export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
245
253
  id: string;
246
254
  parentSpanId: string;
@@ -290,7 +298,7 @@ export declare type ListOptions = {
290
298
 
291
299
  export declare type RecordTypes = {
292
300
  [TABLE_THREADS]: StorageThreadType;
293
- [TABLE_MESSAGES]: MastraMessageV2_2;
301
+ [TABLE_MESSAGES]: MastraMessageV2;
294
302
  [TABLE_WORKFLOW_SNAPSHOT]: WorkflowRunState;
295
303
  [TABLE_EVALS]: EvalRow;
296
304
  [TABLE_TRACES]: any;
package/dist/index.cjs CHANGED
@@ -614,15 +614,6 @@ var CloudflareStore = class extends storage.MastraStorage {
614
614
  throw error;
615
615
  }
616
616
  }
617
- ensureDate(date) {
618
- if (!date) return void 0;
619
- return date instanceof Date ? date : new Date(date);
620
- }
621
- serializeDate(date) {
622
- if (!date) return void 0;
623
- const dateObj = this.ensureDate(date);
624
- return dateObj?.toISOString();
625
- }
626
617
  ensureMetadata(metadata) {
627
618
  if (!metadata) return {};
628
619
  return typeof metadata === "string" ? JSON.parse(metadata) : metadata;
@@ -644,6 +635,14 @@ var CloudflareStore = class extends storage.MastraStorage {
644
635
  throw new Error(`Failed to store schema: ${error.message}`);
645
636
  }
646
637
  }
638
+ /**
639
+ * No-op: This backend is schemaless and does not require schema changes.
640
+ * @param tableName Name of the table
641
+ * @param schema Schema of the table
642
+ * @param ifNotExists Array of column names to add if they don't exist
643
+ */
644
+ async alterTable(_args) {
645
+ }
647
646
  async clearTable({ tableName }) {
648
647
  const keys = await this.listKV(tableName);
649
648
  if (keys.length > 0) {
@@ -1233,6 +1232,15 @@ var CloudflareStore = class extends storage.MastraStorage {
1233
1232
  return null;
1234
1233
  }
1235
1234
  }
1235
+ async getTracesPaginated(_args) {
1236
+ throw new Error("Method not implemented.");
1237
+ }
1238
+ async getThreadsByResourceIdPaginated(_args) {
1239
+ throw new Error("Method not implemented.");
1240
+ }
1241
+ async getMessagesPaginated(_args) {
1242
+ throw new Error("Method not implemented.");
1243
+ }
1236
1244
  async close() {
1237
1245
  }
1238
1246
  };
package/dist/index.js CHANGED
@@ -608,15 +608,6 @@ var CloudflareStore = class extends MastraStorage {
608
608
  throw error;
609
609
  }
610
610
  }
611
- ensureDate(date) {
612
- if (!date) return void 0;
613
- return date instanceof Date ? date : new Date(date);
614
- }
615
- serializeDate(date) {
616
- if (!date) return void 0;
617
- const dateObj = this.ensureDate(date);
618
- return dateObj?.toISOString();
619
- }
620
611
  ensureMetadata(metadata) {
621
612
  if (!metadata) return {};
622
613
  return typeof metadata === "string" ? JSON.parse(metadata) : metadata;
@@ -638,6 +629,14 @@ var CloudflareStore = class extends MastraStorage {
638
629
  throw new Error(`Failed to store schema: ${error.message}`);
639
630
  }
640
631
  }
632
+ /**
633
+ * No-op: This backend is schemaless and does not require schema changes.
634
+ * @param tableName Name of the table
635
+ * @param schema Schema of the table
636
+ * @param ifNotExists Array of column names to add if they don't exist
637
+ */
638
+ async alterTable(_args) {
639
+ }
641
640
  async clearTable({ tableName }) {
642
641
  const keys = await this.listKV(tableName);
643
642
  if (keys.length > 0) {
@@ -1227,6 +1226,15 @@ var CloudflareStore = class extends MastraStorage {
1227
1226
  return null;
1228
1227
  }
1229
1228
  }
1229
+ async getTracesPaginated(_args) {
1230
+ throw new Error("Method not implemented.");
1231
+ }
1232
+ async getThreadsByResourceIdPaginated(_args) {
1233
+ throw new Error("Method not implemented.");
1234
+ }
1235
+ async getMessagesPaginated(_args) {
1236
+ throw new Error("Method not implemented.");
1237
+ }
1230
1238
  async close() {
1231
1239
  }
1232
1240
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/cloudflare",
3
- "version": "0.10.3-alpha.0",
3
+ "version": "0.10.3-alpha.2",
4
4
  "description": "Cloudflare provider for Mastra - includes db storage capabilities",
5
5
  "type": "module",
6
6
  "files": [
@@ -26,17 +26,18 @@
26
26
  "cloudflare": "^4.3.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@cloudflare/workers-types": "^4.20250603.0",
29
+ "@cloudflare/workers-types": "^4.20250607.0",
30
30
  "@microsoft/api-extractor": "^7.52.8",
31
31
  "@types/node": "^20.17.57",
32
32
  "dotenv": "^16.5.0",
33
33
  "eslint": "^9.28.0",
34
- "miniflare": "^4.20250525.0",
34
+ "miniflare": "^4.20250525.1",
35
35
  "tsup": "^8.5.0",
36
36
  "typescript": "^5.8.2",
37
- "vitest": "^3.1.2",
37
+ "vitest": "^3.2.2",
38
38
  "@internal/lint": "0.0.10",
39
- "@mastra/core": "0.10.4-alpha.0"
39
+ "@internal/storage-test-utils": "0.0.6",
40
+ "@mastra/core": "0.10.4-alpha.3"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "@mastra/core": "^0.10.2-alpha.0"